/* ── Design tokens ──
   Warm, light "notebook" theme: cream page, serif headings, amber
   accent, with dark surfaces reserved for the video card and user
   chat bubbles (matching the Acharya screen design). */
:root {
  --bg-page: #f6f2e9;
  --bg-card: #ffffff;
  --bg-card-alt: #efe9db;
  --border-subtle: #e5ddc9;
  --border-strong: #d8cfb6;

  --bg-dark: #17181c;
  --bg-dark-alt: #1f222a;
  --navy: #1e2a4a;
  --navy-light: #2c3b61;

  --accent: #dc9a3a;
  --accent-hover: #c98a2c;
  --accent-soft: rgba(220, 154, 58, 0.16);
  --accent-text-on: #1a1206;

  --text-heading: #201d16;
  --text-body: #4b473d;
  --text-muted: #8c8676;
  --text-faint: #b3ac99;
  --text-on-dark: #f3efe4;
  --text-on-navy: #ffffff;

  --status-active-bg: #e2f0e4;
  --status-active-text: #2f7a4f;
  --status-inactive-bg: #eae5d8;
  --status-inactive-text: #726c5c;

  --font-serif: "Lora", Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --radius-card: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 2px 10px rgba(40, 32, 15, 0.06);
  --shadow-elevated: 0 10px 32px rgba(40, 32, 15, 0.14);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-body);
  min-height: 100vh;
}

.container {
  max-width: 1500px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
  /* Clip sideways overflow WITHOUT clipping vertically. "overflow-x: hidden"
     silently makes overflow-y auto too, so on a short page (home screen, before
     a lesson) the account menu that hangs below the header was cut off by this
     box and the last rows (Logout) could not be seen. `clip` has no such side
     effect; `hidden` first is only a fallback for very old browsers. */
  overflow-x: hidden;
  overflow-x: clip;
  overflow-y: visible;
}

/* ── Header ── */
header {
  text-align: center;
  margin-bottom: 1rem;
  padding: 1rem 0;
}

/* Brand row: logo mark + ClarifyBro name, on its own line above the burger/welcome row. */
.header-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}
.header-brand .brand-mark {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  min-height: 44px;
}

header h1 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-heading);
  margin: 0;
}

/* Welcome message sits directly next to the burger menu, same line;
   flex:1 pushes the language selector to the right edge. */
#welcomeMsg.welcome-msg {
  flex: 1;
  min-width: 0;
}

header h3 { display: none; }   /* tagline removed to save space */

.user-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}

/* ── Burger trigger button ── */
.user-menu-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--navy);
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-on-navy);
  transition: background 0.2s, transform 0.15s;
}
.user-menu-btn:hover { background: var(--navy-light); }
.user-menu-btn:active { transform: scale(0.95); }
.user-menu-btn.hidden { display: none; }

.user-menu-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: none;
}
.user-menu-btn.has-avatar .user-menu-avatar { display: block; }
.user-menu-btn.has-avatar .user-menu-burger { display: none; }

.user-menu-burger {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.user-menu-burger span {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}

/* ── Dropdown panel ── */
.user-menu-panel {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 1000;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--bg-card);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-elevated);
  animation: userMenuIn 0.14s ease-out;
}
@keyframes userMenuIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.user-menu-panel.hidden { display: none; }

/* Old rules kept as no-ops for compatibility */
.user-info.hidden { display: none; }
.user-photo { display: none; }

.user-details {
  text-align: left;
  flex: 1;
}

.user-name {
  font-weight: 600;
  color: var(--text-heading);
  font-size: 0.98rem;
  margin: 0;
}

.user-email {
  font-size: 0.87rem;
  color: var(--text-muted);
  margin: 0.2rem 0 0;
}

.last-login {
  font-size: 0.77rem;
  color: var(--text-faint);
  margin: 0.15rem 0 0;
  font-style: italic;
}

.logout-btn {
  padding: 0.5rem 1rem;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.93rem;
  font-weight: 500;
  transition: background 0.3s ease;
}

.logout-btn:hover {
  background: #dc2626;
}

.admin-link {
  padding: 0.5rem 1rem;
  background: var(--navy);
  color: var(--text-on-navy);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.93rem;
  font-weight: 500;
  text-decoration: none;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.admin-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.admin-link.hidden {
  display: none;
}

.guest-info {
  display: flex;
  gap: 0.5rem;
}

.guest-info.hidden {
  display: none;
}

.login-link {
  padding: 0.5rem 1.5rem;
  background: var(--accent);
  color: var(--accent-text-on);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.98rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.login-link:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

/* Welcome message — now INLINE beside the app title in the compact header. */
.welcome-msg {
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--status-active-text);
  line-height: 1.25;
}
/* Greeting on top, full student name below (wraps instead of truncating). */
.welcome-msg .welcome-greet,
.welcome-msg .welcome-name {
  display: block;
  overflow-wrap: anywhere;
}
.welcome-msg.hidden { display: none; }

/* Old top-page subtitle is removed for space; keep the rule as a no-op. */
.subtitle { display: none; }

.badge {
  display: inline-block;
  margin-top: 0.4rem;
  padding: 2px 12px;
  font-size: 0.82rem;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  border: 1px solid rgba(220, 154, 58, 0.3);
}

/* ── Input Row ── */
.input-row {
  display: flex;
  gap: 8px;
  max-width: 900px;
  margin: 0 auto 0.6rem;
}

.input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper input {
  width: 100%;
  padding: 10px 44px 10px 16px;
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-heading);
  font-size: 1.03rem;
  outline: none;
  transition: border-color 0.2s;
}

.input-wrapper input::placeholder { color: var(--text-faint); }
.input-wrapper input:focus {
  border-color: var(--accent);
}

.voice-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s;
}

.voice-btn:hover { color: var(--accent-hover); }
.voice-btn.recording { color: #d64545; animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Mic Permission Banner ── */
.mic-permission-banner {
  margin-bottom: 12px;
  padding: 10px 16px;
  background: var(--navy);
  border: 1px solid var(--navy-light);
  border-radius: var(--radius-md);
  animation: slideDown 0.3s ease;
}
.mic-permission-banner.hidden { display: none; }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.mic-banner-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.mic-banner-content span {
  flex: 1;
  color: var(--text-on-dark);
  font-size: 0.93rem;
  min-width: 150px;
}
.mic-permission-btn {
  padding: 6px 16px;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: var(--accent-text-on);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  white-space: nowrap;
}
.mic-permission-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}
.mic-permission-dismiss {
  background: none;
  border: none;
  color: var(--text-on-dark);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  transition: color 0.2s;
}
.mic-permission-dismiss:hover {
  color: var(--text-on-dark);
  opacity: 0.7;
}

/* Groups the image/camera buttons with Generate Answer so all three
   stay on one row even when .input-row stacks the text input above
   them on narrow screens. Sized to content here — width: 100% only
   applies inside the ≤768px stacked layout below, otherwise it eats
   most of .input-row's width at desktop sizes and squeezes the text
   input down to almost nothing. */
.action-btn-row {
  display: flex;
  gap: 8px;
}

/* ── Main Question Image Upload ── */
.image-btn-group {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.main-image-btn {
  padding: 8px 10px;
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.main-image-btn:hover {
  color: var(--accent-hover);
  border-color: var(--accent);
}
.main-image-btn.has-image {
  color: var(--status-active-text);
  border-color: var(--status-active-text);
}
.main-image-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 900px;
  margin: 0 auto 8px;
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.main-image-preview.hidden {
  display: none;
}
.main-image-preview img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}
.main-image-remove {
  background: none;
  border: none;
  color: #c1503f;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
  transition: color 0.2s;
}
.main-image-remove:hover {
  color: #a13f31;
}

/* ── Image Upload Progress & Success ── */
.image-upload-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.image-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border-subtle);
  border-radius: 2px;
  overflow: hidden;
}
.image-progress-bar.hidden {
  display: none;
}
.image-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.15s ease;
}
.image-success-msg {
  color: var(--status-active-text);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}
.image-success-msg.hidden {
  display: none;
}

.ask-btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-text-on);
  font-weight: 600;
  font-size: 0.98rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.ask-btn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-card); }
.ask-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Language Selector (header) ── */
.lang-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.lang-select {
  padding: 4px 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-heading);
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
  max-width: 88px;
  transition: border-color 0.2s;
}

.lang-select:focus {
  border-color: var(--accent);
}

/* ── Voice Selector Row ── */
.voice-row {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 800px;
  margin: 0 auto 1rem;
  justify-content: center;
}

.voice-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.voice-select {
  padding: 5px 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-heading);
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
  min-width: 0;
  width: 200px;
  max-width: 100%;
  transition: border-color 0.2s;
}

.voice-select:focus {
  border-color: var(--accent);
}

/* ── Status / Progress ── */
.status-section {
  max-width: 800px;
  margin: 0 auto 1rem;
  text-align: center;
  padding: 1rem;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 0.6rem;
}

.spinner.small { width: 22px; height: 22px; border-width: 2px; }

@keyframes spin { to { transform: rotate(360deg); } }

.status-text { color: var(--text-muted); font-size: 0.93rem; }

.progress-bar-track {
  height: 4px;
  background: var(--border-subtle);
  border-radius: 4px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s;
}

.hidden { display: none !important; }

/* ── Content Section: side by side ── */
.content-section {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

/* ── Answer Panel (right) ── */
.answer-panel {
  width: 300px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.answer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.answer-header:hover { background: var(--bg-card-alt); }

.answer-header h3 {
  color: var(--accent-hover);
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.collapse-icon {
  transition: transform 0.3s;
  color: var(--text-muted);
}

.collapse-icon.collapsed { transform: rotate(-90deg); }

.answer-body {
  padding: 0 1rem 0.8rem;
  /* Was overflow:hidden + max-height:800px, which silently cut off the end of
     a long answer plus the quick-check card (last lines unreachable). Only
     the collapsed state clips now. */
  overflow: visible;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
  max-height: 20000px;
  opacity: 1;
}

.answer-body.collapsed {
  overflow: hidden;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

.answer-body p {
  color: var(--text-body);
  line-height: 1.6;
  font-size: 0.98rem;
  text-align: left;
  overflow-wrap: break-word;
}

.speak-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 0.6rem;
  padding: 4px 12px;
  background: none;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s, color 0.2s;
}

.speak-btn:hover { background: var(--bg-card-alt); color: var(--text-heading); }

/* ── Animation Panel (right) ── */
.video-panel {
  flex: 1;
  min-width: 0;
}

/* Primary "ask anytime" CTA below the video — the dominant, hard-to-miss
   way to interrupt with a doubt, rather than a small icon buried in the
   controls row. */
.interrupt-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 12px;
  padding: 14px 20px;
  background: var(--accent);
  color: var(--accent-text-on);
  border: none;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(220, 154, 58, 0.35);
  transition: background 0.2s, transform 0.15s;
}
.interrupt-banner:hover { background: var(--accent-hover); transform: translateY(-1px); }
.interrupt-banner:active { transform: translateY(0); }
.interrupt-banner.recording {
  background: #c1503f;
  box-shadow: 0 6px 18px rgba(193, 80, 63, 0.35);
  animation: pulse 1s infinite;
}

.video-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  color: var(--text-muted);
  font-size: 0.93rem;
}

/* Canvas Container — wraps the canvas for fullscreen. This is the dark
   "video card" floating on the light page. */
.canvas-container {
  position: relative;
  background: var(--bg-dark);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-elevated);
  padding: 10px;
  overflow: hidden;
}

.canvas-container:fullscreen,
.canvas-container:-webkit-full-screen {
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

/* Fullscreen uses a normal (non-overlay) stacked flex layout: the
   canvas/video is the only flex-growing child, so the timeline and
   controls bar below it always get exactly the space their actual
   content needs — never overlapping the video, regardless of how
   many buttons are in the controls row or how they wrap on narrow
   screens. (A fixed-pixel "leave 50px for controls" guess used to
   live here; it broke as soon as the controls bar's real height
   changed, e.g. from adding more buttons.) */
.canvas-container:fullscreen .canvas-wrapper,
.canvas-container:-webkit-full-screen .canvas-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 100vw;
  border-radius: 0;
}

/* The timeline/controls now float over the video itself (see
   .video-controls-overlay below) instead of occupying their own flex
   row below it, so they stay correctly pinned to the bottom of the
   fullscreened video with no extra fullscreen-specific rules needed —
   .video-controls-overlay's own bottom-safe-area padding covers the
   notch/home-indicator case that used to need handling here. */
.canvas-container:fullscreen .video-controls-overlay,
.canvas-container:-webkit-full-screen .video-controls-overlay {
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}

/* Floating exit-fullscreen button — LIVES INSIDE .canvas-container so that
   it remains visible when the browser puts the container into native
   fullscreen (which hides every element outside the fullscreened tree).
   Positioned absolutely within the container; hidden by default; the
   `.canvas-container:fullscreen` selector reveals it when active. */
.fs-exit-btn {
  display: none;
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 2147483647;
  padding: 10px 16px;
  background: rgba(23, 24, 28, 0.85);
  color: var(--text-on-dark);
  border: 1px solid rgba(243, 239, 228, 0.25);
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  align-items: center;
  gap: 6px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  touch-action: manipulation;
}
.fs-exit-btn:hover  { background: rgba(40, 42, 48, 0.95); }
.fs-exit-btn:active { transform: scale(0.96); }

/* Show whenever the canvas container is fullscreen — WebKit + standard. */
.canvas-container:fullscreen .fs-exit-btn,
.canvas-container:-webkit-full-screen .fs-exit-btn,
body.is-fullscreen .fs-exit-btn { display: inline-flex; }

/* .fs-exit-btn (above) is the exit control once in fullscreen, so the
   enter-fullscreen overlay icon steps aside instead of sitting
   underneath/next to it in the same corner. */
.canvas-container:fullscreen #fullscreenBtn,
.canvas-container:-webkit-full-screen #fullscreenBtn,
body.is-fullscreen #fullscreenBtn { display: none; }

.canvas-wrapper {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  /* Scene layout (SLOT_DEFS in app.js) positions elements by FIXED
     PERCENTAGE bands (top 24%, focus 55%, bottom 82%) — in fullscreen
     the wrapper fills the device's actual (tall/portrait) viewport via
     flex, which is what the layout math is tuned against. This
     non-fullscreen aspect-ratio used to be 16/9 (wide/short): the same
     percentage bands land much closer together in absolute pixels on a
     short canvas, so content that fit fine in fullscreen visibly
     overlapped here (reported: "alignment is messed up ... without
     maximizing"). 4/5 keeps the embedded preview reasonably compact
     while giving noticeably more vertical room — more than double the
     height at the same width vs 16/9 — instead of fighting a
     wide-aspect box the layout was never designed for. */
  aspect-ratio: 4 / 5;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Covers the whole video while a mic-interrupt question is being
   answered (pauseVideoForChat → resumeVideoAfterChat) — otherwise a
   paused video with no other indicator reads as stuck, not deliberate. */
.chat-answering-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(14, 17, 20, 0.72);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.chat-answering-overlay .spinner { margin: 0; }
.chat-answering-overlay p {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-on-dark);
}

/* Predict-before-reveal checkpoint (see runPredictCheckpoint in app.js) —
   shares chat-answering-overlay's positioning/backdrop, adds a question +
   answer row. Reuses .chat-input-wrapper/.chat-voice-btn/.chat-send-btn
   (same look as the chat panel's own input) rather than new styles. */
.predict-checkpoint-overlay {
  padding: 20px;
  gap: 14px;
}
.predict-question-text {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-on-dark);
  text-align: center;
  max-width: 320px;
}
.predict-answer-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}
.predict-answer-row .chat-input-wrapper {
  width: 100%;
}
.predict-answer-row .chat-input-wrapper input {
  background: rgba(255, 255, 255, 0.95);
}
.predict-skip-btn {
  background: none;
  border: none;
  color: rgba(243, 239, 228, 0.7);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
  padding: 2px 6px;
}
.predict-skip-btn:hover { color: var(--text-on-dark); }
.predict-checking-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.predict-checking-row .spinner { margin: 0; }
.predict-checking-row p {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-on-dark);
}

/* Fullscreen overlays the top-right of the video, mirroring the badge. */
.video-overlay-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(23, 24, 28, 0.7);
  border: 1px solid rgba(243, 239, 228, 0.25);
  backdrop-filter: blur(4px);
  color: var(--text-on-dark);
  cursor: pointer;
  transition: background 0.2s;
}
.video-overlay-btn:hover { background: rgba(40, 42, 48, 0.9); }

/* ── Controls overlay — floats over the bottom of the video behind a
   dark scrim, matching the design, instead of sitting in its own row
   below the video. Lives inside .canvas-wrapper so it's positioned
   relative to the video regardless of fullscreen state. ── */
.video-controls-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  /* Was 22px top padding with the scrim starting at 45% — reported as
     covering too much of the actual video. Hugs the bottom edge more
     tightly now, so less of the frame above it is obscured. */
  padding: 10px 10px 8px;
  background: linear-gradient(to bottom, rgba(20, 24, 28, 0), rgba(14, 17, 20, 0.86) 65%, rgba(14, 17, 20, 0.92));
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Tap the video to hide all overlay chrome (badge, fullscreen button,
   timeline, controls) for an unobstructed view; tap again to bring it
   back — see the canvas click handler in app.js. */
.canvas-wrapper.chrome-hidden .video-controls-overlay {
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
}
.canvas-wrapper.chrome-hidden .video-overlay-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.video-overlay-btn {
  transition: opacity 0.2s ease;
}

.timeline-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-label {
  flex: 0 0 auto;
  min-width: 26px;
  font-size: 10.5px;
  color: rgba(243, 239, 228, 0.6);
}
.time-label:last-child { text-align: right; }

/* .timeline is the drag/tap target — padded taller than the visual bar
   (.timeline-track, still 4px) so it's actually hittable on a phone
   screen; touch-action: none stops the browser treating a drag here as
   a page scroll instead of feeding it to our pointer handlers. */
.timeline {
  flex: 1 1 auto;
  padding: 10px 0;
  cursor: pointer;
  position: relative;
  touch-action: none;
}

.timeline-track {
  height: 4px;
  background: rgba(243, 239, 228, 0.22);
  border-radius: 4px;
  overflow: visible;
  position: relative;
  transition: height 0.15s ease;
}

.timeline:hover .timeline-track,
.timeline.dragging .timeline-track {
  height: 8px;
}

.timeline-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.1s linear;
  position: relative;
}

/* Drag handle — invisible until hover/drag, matches standard video
   scrubber affordance so the control reads as draggable. */
.timeline-fill::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.6);
  transform: translateY(-50%) scale(0);
  transition: transform 0.15s ease;
}

.timeline:hover .timeline-fill::after,
.timeline.dragging .timeline-fill::after {
  transform: translateY(-50%) scale(1);
}

/* ── Animation Controls — a row of minimalist circular icon buttons,
   matching the design; Play/Pause stands out as the primary amber
   action among them. ── */
.anim-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
}

.ctrl-icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  border: none;
  background: rgba(243, 239, 228, 0.12);
  color: var(--text-on-dark);
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ctrl-icon-btn:hover {
  background: rgba(243, 239, 228, 0.22);
}

.ctrl-icon-btn.recording-active,
.ctrl-icon-btn.recording {
  background: rgba(214, 69, 69, 0.25);
  color: #ef8080;
  animation: pulse 1s infinite;
}

/* Play/Pause is the primary, most-used control — call it out the way
   the design does, as a bigger solid amber circle among otherwise
   plain translucent icon buttons. */
.ctrl-icon-btn--primary {
  width: 50px;
  height: 50px;
  background: var(--accent);
  color: var(--accent-text-on);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}
.ctrl-icon-btn--primary:hover { background: var(--accent-hover); }

/* Secondary row — scene counter + speed, de-emphasized below the main
   transport controls rather than competing with them for attention. */
.anim-controls-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.scene-label {
  font-size: 0.82rem;
  color: var(--text-on-dark);
  opacity: 0.55;
  font-weight: 500;
}

.speed-label {
  font-size: 0.82rem;
  color: var(--text-on-dark);
  opacity: 0.55;
  display: flex;
  align-items: center;
  gap: 6px;
}

.speed-select {
  padding: 3px 6px;
  border: 1px solid rgba(243, 239, 228, 0.2);
  background: rgba(243, 239, 228, 0.08);
  color: var(--text-on-dark);
  border-radius: 6px;
  font-size: 0.87rem;
  cursor: pointer;
  outline: none;
}

.speed-select:focus { border-color: var(--accent); }

/* ── Error ── */
.error-section {
  max-width: 800px;
  margin: 1rem auto 0;
  padding: 0.8rem 1rem;
  background: rgba(193, 80, 63, 0.1);
  border: 1px solid rgba(193, 80, 63, 0.3);
  border-radius: 10px;
}

.error-section p {
  color: #a13f31;
  font-size: 0.93rem;
}

/* ── Chat Panel (left side) ── */
.chat-panel {
  width: 300px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  max-height: 600px;
  overflow: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.chat-header h3 {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chat-mode-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mode-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.mode-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.mode-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.mode-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border-strong);
  border-radius: 20px;
  transition: background 0.3s;
}

.mode-slider::before {
  content: "";
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s, background 0.3s;
}

.mode-switch input:checked + .mode-slider {
  background: var(--accent);
}

.mode-switch input:checked + .mode-slider::before {
  transform: translateX(16px);
  background: #fff;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 200px;
  background: var(--bg-card-alt);
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

.chat-empty {
  color: var(--text-faint);
  font-size: 0.88rem;
  text-align: center;
  padding: 2rem 1rem;
  font-style: italic;
}

.chat-empty.hidden {
  display: none;
}

.chat-msg {
  max-width: 88%;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--navy);
  color: var(--text-on-navy);
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text-body);
  box-shadow: var(--shadow-card);
  border-bottom-left-radius: 4px;
  position: relative;
  padding-left: 0.85rem;
}

.chat-msg.typing {
  color: var(--text-muted);
  font-style: italic;
}

.chat-msg.typing p {
  animation: pulse 1.2s infinite;
}

.msg-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.msg-badge.video {
  background: rgba(30, 42, 74, 0.1);
  color: var(--navy);
}

.msg-badge.text {
  background: var(--status-active-bg);
  color: var(--status-active-text);
}

/* "Interrupted the video at 1:24" — a small annotation on a user
   bubble that shows when a question was voice-interrupted mid-video. */
.interrupt-note {
  display: block;
  text-align: right;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-hover);
  margin: 0 2px 4px;
}

.chat-input-area {
  padding: 0.6rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-card);
}

/* Quick-action for a follow-up that's really "I still don't get it" —
   forces the adaptive-explanation prompt server-side instead of
   relying on the student to phrase their confusion in words. */
.explain-differently-btn {
  display: block;
  width: 100%;
  margin-bottom: 0.5rem;
  padding: 6px 10px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.explain-differently-btn:hover { background: rgba(220, 154, 58, 0.25); }
.explain-differently-btn.hidden { display: none; }

.chat-input-wrapper {
  display: flex;
  gap: 4px;
  align-items: center;
}

.chat-input-wrapper input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--bg-card-alt);
  color: var(--text-heading);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input-wrapper input::placeholder { color: var(--text-faint); }
.chat-input-wrapper input:focus {
  border-color: var(--accent);
}

.chat-send-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: var(--accent-text-on);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.2s;
}

.chat-send-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ── Chat Voice Button ── */
.chat-voice-btn {
  padding: 5px 6px;
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.chat-voice-btn:hover {
  color: var(--accent-hover);
  border-color: var(--accent);
}
.chat-voice-btn.recording {
  color: #c1503f;
  border-color: #c1503f;
  animation: pulse 1s infinite;
}

/* ── Chat Image Upload ── */
.chat-image-btn {
  padding: 5px 6px;
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.chat-image-btn:hover {
  color: var(--accent-hover);
  border-color: var(--accent);
}
.chat-image-btn.has-image {
  color: var(--status-active-text);
  border-color: var(--status-active-text);
}
.chat-image-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  margin-bottom: 6px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}
.chat-image-preview.hidden {
  display: none;
}
.chat-image-preview img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}
.chat-image-remove {
  background: none;
  border: none;
  color: #c1503f;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.2s;
}
.chat-image-remove:hover {
  color: #a13f31;
}
.chat-msg-image {
  max-width: 100%;
  max-height: 120px;
  border-radius: 8px;
  margin-bottom: 4px;
  display: block;
  border: 1px solid var(--border-subtle);
}

/* ── Responsive: Tablet (≤1024px) ── */
@media (max-width: 1024px) {
  .content-section {
    flex-wrap: wrap;
  }

  .chat-panel {
    width: 240px;
  }

  .video-panel {
    flex: 1;
    min-width: 0;
  }

  .answer-panel {
    width: 100%;
    flex-shrink: 1;
    order: 3;
  }

  header h1 {
    font-size: 1.75rem;
  }

  .user-info {
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
  }

  .user-photo {
    width: 34px;
    height: 34px;
  }
}

/* ── Responsive: Small Tablet / Large Phone (≤768px) ── */
@media (max-width: 768px) {
  .container {
    padding: 0.75rem 0.75rem 1.5rem;
  }

  .header-top {
    gap: 8px;
  }

  header h1 {
    font-size: 1.5rem;
  }

  header h3 {
    font-size: 0.93rem;
  }

  .user-info {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    width: 100%;
  }

  .user-details {
    text-align: center;
    min-width: 0;
  }

  .user-photo {
    width: 36px;
    height: 36px;
  }

  .welcome-msg {
    font-size: 0.98rem;
  }

  .subtitle {
    font-size: 0.9rem;
  }

  .input-row {
    flex-direction: column;
    max-width: 100%;
  }

  .input-wrapper input {
    font-size: 1rem;
  }

  /* Image/camera buttons + Generate Answer share one row below the
     text input, instead of each stacking as its own full-width row. */
  .action-btn-row {
    width: 100%;
  }

  .image-btn-group .main-image-btn {
    padding: 10px 14px;
  }

  .ask-btn {
    flex: 1;
    padding: 12px 20px;
    font-size: 1rem;
  }

  .main-image-preview {
    max-width: 100%;
  }

  .voice-row {
    flex-direction: column;
    gap: 4px;
    max-width: 100%;
  }

  .voice-select {
    width: 100%;
  }

  .content-section {
    flex-direction: column;
  }

  .video-panel {
    width: 100%;
    order: 1;
  }

  .chat-panel {
    width: 100%;
    max-height: 350px;
    order: 2;
  }

  .answer-panel {
    display: block;
    flex: none;
    width: 100%;
    order: 3;
  }

  .status-section {
    max-width: 100%;
  }

  .mic-banner-content {
    gap: 8px;
  }

  .mic-banner-content span {
    min-width: 120px;
  }
}

/* ── Responsive: Mobile Phone (≤480px) ── */
@media (max-width: 480px) {
  .container {
    padding: 0.5rem 0.5rem 1rem;
  }

  header {
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
  }

  header h1 {
    font-size: 1.25rem;
  }

  header h3 {
    font-size: 0.87rem;
  }

  .header-top {
    gap: 6px;
  }

  .user-info {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.4rem;
    padding: 0.5rem;
  }

  .user-photo {
    width: 32px;
    height: 32px;
  }

  .user-name {
    font-size: 0.88rem;
  }

  .user-email {
    font-size: 0.82rem;
  }

  .last-login {
    font-size: 0.72rem;
  }

  .logout-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
  }

  .admin-link {
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
  }

  .login-link {
    padding: 0.4rem 1rem;
    font-size: 0.9rem;
  }

  .welcome-msg {
    font-size: 0.88rem;
  }

  .subtitle {
    font-size: 0.9rem;
  }

  .input-wrapper input {
    padding: 10px 40px 10px 12px;
    font-size: 1.03rem;
  }

  .ask-btn {
    padding: 11px 16px;
    font-size: 0.98rem;
  }

  .voice-label {
    font-size: 0.84rem;
  }

  .voice-select {
    font-size: 0.87rem;
    padding: 5px 8px;
  }

  .chat-panel {
    max-height: 300px;
  }

  .chat-header {
    padding: 0.5rem 0.75rem;
  }

  .chat-header h3 {
    font-size: 0.84rem;
  }

  .chat-messages {
    padding: 0.5rem;
    min-height: 150px;
  }

  .chat-msg {
    font-size: 0.9rem;
    max-width: 90%;
    padding: 0.4rem 0.6rem;
  }

  .chat-input-wrapper input {
    padding: 7px 6px;
    font-size: 0.9rem;
  }

  .chat-empty {
    font-size: 0.87rem;
    padding: 1rem 0.5rem;
  }

  .answer-header {
    padding: 0.5rem 0.75rem;
  }

  .answer-header h3 {
    font-size: 0.84rem;
  }

  .answer-body {
    padding: 0 0.75rem 0.6rem;
  }

  .answer-body p {
    font-size: 0.9rem;
    line-height: 1.5;
  }

  .speak-btn {
    font-size: 0.84rem;
    padding: 3px 10px;
  }

  .anim-controls {
    gap: 10px;
  }

  .ctrl-icon-btn {
    width: 34px;
    height: 34px;
  }

  .ctrl-icon-btn--primary {
    width: 44px;
    height: 44px;
  }

  .scene-label {
    font-size: 0.8rem;
  }

  .speed-label {
    font-size: 0.8rem;
  }

  .speed-select {
    font-size: 0.8rem;
    padding: 2px 4px;
  }

  .mic-permission-banner {
    padding: 8px 12px;
  }

  .mic-banner-content span {
    font-size: 0.9rem;
    min-width: 100px;
  }

  .mic-permission-btn {
    padding: 5px 12px;
    font-size: 0.87rem;
  }

  .status-text {
    font-size: 0.9rem;
  }

  .spinner {
    width: 24px;
    height: 24px;
  }

  .error-section {
    padding: 0.6rem 0.75rem;
  }

  .error-section p {
    font-size: 0.9rem;
  }

  .main-image-preview img {
    width: 44px;
    height: 44px;
  }

  .chat-image-preview img {
    width: 40px;
    height: 40px;
  }
}

/* ── Camera / Gallery Picker Bottom Sheet ── */
.img-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.img-picker-overlay.hidden {
  display: none;
}
.img-picker-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--bg-dark-alt);
  border-radius: 18px 18px 0 0;
  padding: 12px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: sheetSlideUp 0.22s ease;
}
@keyframes sheetSlideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.img-picker-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: rgba(243, 239, 228, 0.06);
  border: 1px solid rgba(243, 239, 228, 0.1);
  border-radius: 12px;
  color: var(--text-on-dark);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.img-picker-btn:hover, .img-picker-btn:active {
  background: rgba(220, 154, 58, 0.18);
}
.img-picker-cancel {
  margin-top: 4px;
  padding: 14px;
  background: none;
  border: none;
  color: var(--text-on-dark);
  opacity: 0.6;
  font-size: 1.03rem;
  cursor: pointer;
  border-radius: 10px;
  transition: opacity 0.15s;
}
.img-picker-cancel:hover { opacity: 1; }

/* .ctrl-icon-btn sets its own display, which beat the generic hidden state */
.ctrl-icon-btn.hidden { display: none !important; }


/* ── Saved videos (Save dialog, Open list, in-app player) ── */
.sv-backdrop { position: fixed; inset: 0; z-index: 10000; background: rgba(15,23,42,0.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sv-modal { width: 100%; max-width: 420px; max-height: 85vh; overflow-y: auto; background: var(--bg-card, #fff); color: var(--text-primary, #1e293b); border-radius: 14px; padding: 16px; box-shadow: 0 20px 50px rgba(0,0,0,0.35); }
.sv-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sv-title { margin: 0; font-size: 1.1rem; }
.sv-x { border: none; background: transparent; font-size: 1.6rem; line-height: 1; cursor: pointer; color: inherit; padding: 0 6px; }
.sv-label { display: block; margin: 12px 0 4px; font-size: 0.85rem; opacity: 0.8; }
.sv-input { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--border-subtle, #cbd5e1); border-radius: 8px; font-size: 1rem; background: #fff; color: #1e293b; margin-bottom: 6px; }
.sv-input.hidden { display: none; }
.sv-error { color: #dc2626; font-size: 0.9rem; margin: 8px 0 0; }
.sv-error.hidden { display: none; }
.sv-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.sv-btn { padding: 10px 18px; border: none; border-radius: 8px; background: #d99a38; color: #1e293b; font-weight: 600; font-size: 0.95rem; cursor: pointer; }
.sv-btn:disabled { opacity: 0.6; cursor: default; }
.sv-btn-secondary { background: #e2e8f0; }
.sv-folder { margin: 14px 0 4px; font-weight: 600; font-size: 0.9rem; opacity: 0.85; }
.sv-row { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--border-subtle, #e2e8f0); }
.sv-row-name { flex: 1; text-align: left; border: none; background: transparent; font-size: 1rem; cursor: pointer; color: inherit; padding: 8px 4px; overflow-wrap: anywhere; }
.sv-mini { border: 1px solid var(--border-subtle, #cbd5e1); background: transparent; border-radius: 6px; padding: 4px 8px; font-size: 0.75rem; cursor: pointer; color: inherit; }
.sv-mini-danger { color: #dc2626; }
.sv-empty { opacity: 0.7; font-size: 0.95rem; }
.sv-toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 10001; background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 0.95rem; box-shadow: 0 6px 20px rgba(0,0,0,0.35); }
.sv-player { position: fixed; inset: 0; z-index: 10000; background: #000; display: flex; flex-direction: column; }
.sv-player-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; color: #fff; }
.sv-player-bar .sv-x { color: #fff; }
.sv-player-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-player video { flex: 1; min-height: 0; width: 100%; background: #000; }


/* ── Animated tutor loader (shown while the answer/lesson is being generated) ── */
.tutor-loader { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 0 auto 0.6rem; }
.tutor-loader svg { overflow: visible; }
.tl-ring { fill: none; stroke: var(--accent, #d99a38); stroke-width: 1.6; opacity: 0.55; }
.tl-core { fill: var(--accent, #d99a38); transform-origin: 60px 60px; animation: tl-pulse 1.4s ease-in-out infinite; }
.tl-e { transform-origin: 60px 60px; }
.tl-e1 { animation: tl-orbit 2.4s linear infinite; }
.tl-e2 { animation: tl-orbit 3.1s linear infinite reverse; }
.tl-e3 { animation: tl-orbit 3.8s linear infinite; }
.tl-orbits { transform-origin: 60px 60px; animation: tl-orbit 14s linear infinite; }
.tl-dots { display: flex; gap: 6px; height: 10px; }
.tl-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent, #d99a38); animation: tl-bounce 1s ease-in-out infinite; }
.tl-dots span:nth-child(2) { animation-delay: 0.15s; }
.tl-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes tl-orbit { to { transform: rotate(360deg); } }
@keyframes tl-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.35); opacity: 0.75; } }
@keyframes tl-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.5; } 40% { transform: translateY(-6px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .tl-e, .tl-orbits { animation-duration: 12s; }
  .tl-dots span { animation: none; opacity: 0.8; }
}


/* Loader over the black animation canvas until scene 1 is drawn */
.canvas-loader { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: radial-gradient(circle at 50% 45%, #1e293b 0%, #0f172a 70%); color: #cbd5e1; pointer-events: none; }
.canvas-loader.hidden { display: none; }
.canvas-loader .tl-ring { stroke: #d99a38; }
.canvas-loader-text { margin: 0; font-size: 0.95rem; opacity: 0.85; }


/* "Generating animation" message over the blank video area: bold and prominent */
.video-loading p { font-weight: 700; font-size: 1.05rem; color: var(--text-primary, #1e293b); text-align: center; margin: 0.4rem 0 0; }
.canvas-loader-text { font-weight: 700; font-size: 1.05rem; color: #f1f5f9; opacity: 1; text-align: center; padding: 0 16px; }

/* AI caution under the answer */
.ai-caution { margin: 10px 0 0; padding: 8px 10px; font-size: 0.82rem; line-height: 1.35; color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; }

/* Question paper screen */
.paper-screen { position: fixed; inset: 0; z-index: 10000; background: var(--bg-page, #f7f4ee); color: var(--text-primary, #1e293b); display: flex; flex-direction: column; }
.paper-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; background: var(--bg-card, #fff); border-bottom: 1px solid var(--border-subtle, #e2e8f0); }
.paper-title { display: flex; flex-direction: column; min-width: 0; }
.paper-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paper-sub { font-size: 0.8rem; opacity: 0.7; }
.paper-list { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.paper-q { text-align: left; border: 1px solid var(--border-subtle, #e2e8f0); background: var(--bg-card, #fff); color: inherit; border-radius: 10px; padding: 10px 12px; cursor: pointer; font: inherit; }
.paper-q:active { background: #fff7e6; }
.paper-q-head { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; align-items: center; }
.paper-q-num { font-weight: 700; color: #b7791f; }
.paper-q-tag { font-size: 0.72rem; padding: 2px 7px; border-radius: 999px; background: #eef2f7; }
.paper-q-warn { background: #fff1f0; color: #b42318; }
.paper-q-text { font-size: 0.95rem; line-height: 1.4; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.paper-foot { padding: 10px 14px; border-top: 1px solid var(--border-subtle, #e2e8f0); background: var(--bg-card, #fff); display: flex; justify-content: center; }


/* Past-paper strip */
.paper-strip { margin: 0 0 10px; padding: 8px 10px; background: var(--bg-card, #fff); border: 1px solid var(--border-subtle, #e2e8f0); border-radius: 12px; }
.paper-strip.hidden { display: none; }
.paper-strip-top { display: flex; align-items: center; gap: 8px; }
.paper-strip-text { flex: 1; font-weight: 600; font-size: 0.92rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paper-strip-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border-subtle, #cbd5e1); background: transparent; cursor: pointer; color: inherit; }
.paper-strip-btn:disabled { opacity: 0.35; cursor: default; }
.paper-strip-all { border: 1px solid var(--border-subtle, #cbd5e1); background: transparent; border-radius: 999px; padding: 6px 10px; font-size: 0.78rem; cursor: pointer; color: inherit; }
.paper-strip-marks { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 0.82rem; }
.paper-mark { border: 1px solid var(--border-subtle, #cbd5e1); background: transparent; border-radius: 999px; padding: 5px 10px; font-size: 0.82rem; cursor: pointer; color: inherit; }
.paper-mark.active { background: #fff1cc; border-color: #d99a38; font-weight: 700; }
.paper-q-correct { background: #dcfce7; color: #166534; }
.paper-q-partial { background: #fef9c3; color: #854d0e; }
.paper-q-wrong { background: #fee2e2; color: #991b1b; }

/* Exam-style solution card */
.solution-card { margin: 0 0 12px; padding: 12px; background: #f8fafc; border: 1px solid #dbe4ee; border-radius: 12px; font-size: 0.95rem; }
.solution-card.hidden { display: none; }
.sol-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sol-steps { margin: 0 0 8px 1.1rem; padding: 0; }
.sol-step { margin-bottom: 8px; }
.sol-step-title { font-weight: 700; }
.sol-step-work { white-space: pre-wrap; overflow-wrap: anywhere; }
.sol-formulas, .sol-tip { font-size: 0.88rem; margin: 6px 0; opacity: 0.9; }
.sol-final { margin-top: 8px; padding: 10px; background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 8px; overflow-wrap: anywhere; }
.sol-label { font-weight: 600; opacity: 0.8; }

/* My progress */
.prog-card { text-align: center; padding: 16px; background: var(--bg-card, #fff); border: 1px solid var(--border-subtle, #e2e8f0); border-radius: 12px; }
.prog-big { font-size: 2.4rem; font-weight: 800; color: #b7791f; }
.prog-sub { font-size: 0.85rem; opacity: 0.75; }
.prog-row { padding: 8px 2px; }
.prog-row-top { display: flex; justify-content: space-between; gap: 8px; font-size: 0.92rem; margin-bottom: 4px; }
.prog-label { overflow-wrap: anywhere; }
.prog-pct { opacity: 0.75; white-space: nowrap; }
.prog-track { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.prog-fill { height: 100%; background: #22c55e; border-radius: 999px; }
.prog-fill.low { background: #ef4444; }


/* PDF reading progress */
.paper-progress { width: 100%; max-width: 380px; background: var(--bg-card, #fff); color: var(--text-primary, #1e293b); border-radius: 14px; padding: 18px; box-shadow: 0 20px 50px rgba(0,0,0,0.35); }
.paper-progress-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 12px; }
.paper-progress-track { height: 12px; }
.paper-progress-fill { transition: width 0.4s ease; background: linear-gradient(90deg, #38bdf8, #d99a38); }
.paper-progress-line { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 0.9rem; }
.paper-progress-pct { font-weight: 700; }
.paper-progress-note { margin-top: 8px; font-size: 0.78rem; opacity: 0.65; }

/* ── Doubt-clearing tools (public/doubt-tools.js) ── */
.check-work-toggle { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; margin-top: 6px; cursor: pointer; flex-basis: 100%; }
.check-work-toggle input { width: auto; margin: 0; }
.confusion-reasons { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; align-items: center; }
.confusion-reasons-title { flex-basis: 100%; font-size: 0.85rem; font-weight: 600; }
.confusion-chip, .doubt-btn { border: 1px solid var(--border-strong, #cbd5e1); background: var(--bg-card, #fff); color: var(--text-primary, #1e293b); border-radius: 999px; padding: 6px 12px; font-size: 0.85rem; cursor: pointer; }
.doubt-btn { border-radius: 8px; background: var(--navy, #1e3a5f); color: var(--text-on-navy, #fff); border-color: transparent; }
.doubt-btn-ghost { background: transparent; color: inherit; border-color: var(--border-strong, #cbd5e1); }
.doubt-btn:disabled { opacity: 0.6; cursor: default; }
.doubt-verify { margin: 0 0 10px; padding: 8px 10px; border-radius: 8px; font-size: 0.85rem; }
.doubt-verify-ok { color: #15803d; background: rgba(34, 197, 94, 0.1); }
.doubt-verify-issue { color: #92400e; background: rgba(245, 158, 11, 0.16); border: 1px solid rgba(245, 158, 11, 0.5); }
.doubt-report { margin-top: 10px; font-size: 0.85rem; }
.doubt-report-btn { background: none; border: none; padding: 0; cursor: pointer; color: inherit; opacity: 0.75; text-decoration: underline; font-size: 0.85rem; }
.doubt-report-form { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.doubt-report-text { flex-basis: 100%; border-radius: 8px; border: 1px solid var(--border-strong, #cbd5e1); padding: 6px 8px; font: inherit; resize: vertical; }
.doubt-report-msg { margin-top: 6px; }
.doubt-check-card { margin-top: 14px; padding: 12px; border-radius: 12px; border: 1px solid var(--border-strong, #cbd5e1); background: var(--bg-card, #fff); }
.doubt-check-title { font-weight: 700; margin-bottom: 6px; }
.doubt-check-q { margin-bottom: 8px; }
.doubt-check-row { display: flex; gap: 6px; flex-wrap: wrap; }
.doubt-check-input { flex: 1; min-width: 140px; border-radius: 8px; border: 1px solid var(--border-strong, #cbd5e1); padding: 6px 10px; font: inherit; }
.doubt-check-hint { margin-top: 6px; font-size: 0.82rem; opacity: 0.7; }
.doubt-check-result { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.doubt-check-good { font-weight: 700; color: #15803d; }
.doubt-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10000; }
.doubt-dialog { width: 100%; max-width: 360px; background: var(--bg-card, #fff); color: var(--text-primary, #1e293b); border-radius: 14px; padding: 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35); display: flex; flex-direction: column; gap: 12px; }
.doubt-dialog-title { font-weight: 700; font-size: 1.05rem; }
.doubt-dialog-note { font-size: 0.85rem; opacity: 0.7; }
.doubt-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; }
.doubt-field select { padding: 8px; border-radius: 8px; border: 1px solid var(--border-strong, #cbd5e1); font: inherit; }
.doubt-dialog-msg { font-size: 0.85rem; min-height: 1em; }

/* ── Account menu (burger dropdown) ──────────────────────────────
   Profile header, then icon rows with 46px touch targets, then a separated
   Logout. Never taller than the screen: it scrolls inside itself instead of
   pushing Logout below the fold. Selectors use two classes so they win over
   the older per-breakpoint .user-info rules above. */
.user-menu-panel.user-info {
  width: min(300px, calc(100vw - 24px));
  min-width: 0;
  max-height: calc(100vh - 150px);
  max-height: calc(100dvh - 150px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  padding: 8px;
  border-radius: 14px;
  text-align: left;
}
.user-menu-panel.user-info.hidden { display: none; }

.user-menu-panel .user-details {
  flex: none;
  min-width: 0;
  text-align: left;
  padding: 10px 12px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}
.user-menu-panel .user-name {
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.user-menu-panel .user-email {
  font-size: 0.85rem;
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}
.user-menu-panel .last-login {
  font-size: 0.75rem;
  margin: 6px 0 0;
  font-style: normal;
}
.user-menu-panel .last-login:empty { display: none; }

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.user-menu-panel .menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  background: transparent;
  color: var(--text-heading);
  border: none;
  border-radius: 10px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transform: none;
  box-shadow: none;
  transition: background 0.15s ease;
}
.user-menu-panel .menu-item:hover,
.user-menu-panel .menu-item:active {
  background: var(--accent-soft);
  transform: none;
  box-shadow: none;
}
.user-menu-panel .menu-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.user-menu-panel .menu-item.hidden { display: none; }

/* Icons: one mask per item, tinted with the text colour. */
.user-menu-panel .menu-item::before {
  content: "";
  flex: none;
  width: 20px;
  height: 20px;
  background-color: currentColor;
  opacity: 0.75;
  -webkit-mask: var(--menu-icon) center / contain no-repeat;
  mask: var(--menu-icon) center / contain no-repeat;
}
#openSavedBtn  { --menu-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpolygon points='10 8 16 12 10 16 10 8'/%3E%3C/svg%3E"); }
#progressBtn   { --menu-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='20' x2='18' y2='10'/%3E%3Cline x1='12' y1='20' x2='12' y2='4'/%3E%3Cline x1='6' y1='20' x2='6' y2='14'/%3E%3C/svg%3E"); }
#profileBtn    { --menu-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E"); }
.menu-list a[href="/pricing"] { --menu-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='1' y='4' width='22' height='16' rx='2'/%3E%3Cline x1='1' y1='10' x2='23' y2='10'/%3E%3C/svg%3E"); }
#adminLink     { --menu-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z'/%3E%3C/svg%3E"); }
#logoutBtn     { --menu-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpolyline points='16 17 21 12 16 7'/%3E%3Cline x1='21' y1='12' x2='9' y2='12'/%3E%3C/svg%3E"); }

/* Logout: same row shape, quiet danger colour instead of a loud red button. */
.user-menu-panel .logout-btn.menu-item {
  background: transparent;
  color: #dc2626;
  font-weight: 600;
}
.user-menu-panel .logout-btn.menu-item:hover,
.user-menu-panel .logout-btn.menu-item:active {
  background: rgba(220, 38, 38, 0.09);
}

/* Free-trial limit: upgrade card shown where the lesson would have appeared */
.upgrade-prompt { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.7rem; padding: 1.8rem 1.2rem; background: var(--bg-card); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.upgrade-prompt h3 { font-size: 1.15rem; color: var(--text-heading); margin: 0; text-wrap: balance; }
.upgrade-prompt p { color: var(--text-body); max-width: 34ch; line-height: 1.5; margin: 0; }
.upgrade-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 1.4rem; border-radius: 12px; background: var(--accent); color: var(--accent-text-on); font-weight: 700; text-decoration: none; }
.upgrade-btn:hover { background: var(--accent-hover); }
.upgrade-later { background: none; border: none; color: var(--text-muted); font: inherit; font-size: 0.9rem; cursor: pointer; padding: 6px 10px; text-decoration: underline; }
.chat-msg.assistant .upgrade-btn { min-height: 40px; font-size: 0.92rem; }

/* My progress: paper picker, segmented bar, per-question chips */
.prog-picker { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--bg-card, #fff); border-bottom: 1px solid var(--border-subtle, #e2e8f0); }
.prog-picker.hidden { display: none; }
.prog-picker-label { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.65; flex: none; }
.prog-picker-name { min-width: 0; overflow-wrap: anywhere; }
.prog-select { flex: 1; min-width: 0; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--border-strong, #cbd5e1); background: var(--bg-card, #fff); color: inherit; font: inherit; }
.prog-when { margin-top: 8px; font-size: 0.8rem; opacity: 0.65; }
.prog-seg { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: #e2e8f0; margin: 14px 0 8px; }
.seg-correct { background: #22c55e; }
.seg-partial { background: #f59e0b; }
.seg-wrong { background: #ef4444; }
.seg-none { background: #cbd5e1; }
.prog-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; font-size: 0.82rem; }
.prog-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.prog-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.prog-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 6px; }
.prog-chip { min-width: 38px; padding: 6px 8px; text-align: center; font-size: 0.8rem; font-weight: 700; border-radius: 8px; color: #fff; }
.prog-chip.correct { background: #22c55e; }
.prog-chip.partial { background: #f59e0b; }
.prog-chip.wrong { background: #ef4444; }
.prog-chip.none { background: #e2e8f0; color: #64748b; font-weight: 600; }
.prog-row-link { cursor: pointer; border-radius: 10px; padding: 8px 8px; }
.prog-row-link:hover, .prog-row-link:focus-visible { background: rgba(220, 154, 58, 0.14); outline: none; }

/* On-request helpers: double-check and quick check */
.doubt-verify-ask { margin-top: 10px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.doubt-verify-note { font-size: 0.82rem; opacity: 0.8; }
.doubt-check-offer { margin-top: 14px; padding: 12px; border-radius: 12px; border: 1px dashed var(--border-strong, #cbd5e1); display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }

/* About ClarifyBro: version dialog opened from the menu */
#aboutBtn { --menu-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='16' x2='12' y2='12'/%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'/%3E%3C/svg%3E"); }
.about-backdrop { position: fixed; inset: 0; z-index: 10000; background: rgba(15,23,42,0.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.about-card { width: 100%; max-width: 340px; max-height: 90vh; overflow-y: auto; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 28px 22px 20px; background: var(--bg-card, #fff); color: var(--text-body, #334155); border-radius: 20px; box-shadow: 0 24px 60px rgba(0,0,0,0.35); }
.about-logo { width: 84px; height: 84px; border-radius: 20px; box-shadow: 0 6px 18px rgba(30,42,74,0.3); }
.about-name { margin: 14px 0 2px; font-size: 1.4rem; color: var(--text-heading, #1e293b); }
.about-tag { margin: 0 0 14px; font-size: 0.85rem; color: var(--text-muted, #64748b); }
.about-version { margin: 0; font-size: 1.6rem; font-weight: 700; color: var(--text-heading, #1e293b); }
.about-build { margin: 2px 0 14px; font-size: 0.95rem; color: var(--text-muted, #64748b); min-height: 1.2em; }
.about-details { width: 100%; border-top: 1px solid var(--border-subtle, #e2e8f0); }
.about-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--border-subtle, #e2e8f0); font-size: 0.9rem; }
.about-row-label { color: var(--text-muted, #64748b); }
.about-row-value { color: var(--text-heading, #1e293b); font-weight: 600; text-align: right; }
.about-status { margin: 12px 0 0; min-height: 1.3em; font-size: 0.88rem; color: var(--text-muted, #64748b); }
.about-status.ok { color: #16a34a; }
.about-status.warn { color: #d97706; }
.about-check { margin-top: 8px; width: 100%; min-height: 46px; border: none; border-radius: 12px; background: var(--accent); color: var(--accent-text-on, #fff); font: inherit; font-weight: 700; cursor: pointer; }
.about-check:disabled { opacity: 0.6; cursor: default; }
.about-close { margin-top: 6px; background: none; border: none; color: var(--text-muted, #64748b); font: inherit; font-size: 0.92rem; padding: 10px 14px; cursor: pointer; }
.about-links { margin: 6px 0 0; font-size: 0.82rem; }
.about-links a { color: var(--accent); text-decoration: none; }

/* Question credits: balance chip under the header, and the low-balance nudge */
.credit-chip { display: inline-flex; align-items: center; gap: 6px; align-self: center; margin: 8px auto 0; padding: 6px 8px 6px 12px; border-radius: 999px; background: var(--accent-soft, #fdf0d5); color: var(--text-heading, #1e293b); font-size: 0.9rem; text-decoration: none; border: 1px solid var(--border-subtle, #e4dccb); }
.credit-chip.hidden { display: none; }
.credit-chip b { font-size: 1rem; font-variant-numeric: tabular-nums; }
.credit-chip-add { margin-left: 4px; padding: 3px 10px; border-radius: 999px; background: var(--accent); color: var(--accent-text-on, #fff); font-weight: 700; font-size: 0.8rem; }
.credit-chip.low { border-color: #d97706; }
.credit-chip.low b { color: #b45309; }
.credit-low { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0 0; padding: 10px 14px; border-radius: 12px; background: #fff7e6; color: #7a4a05; border: 1px solid #f0cf8f; font-size: 0.9rem; }
.credit-low a { flex: none; padding: 6px 14px; border-radius: 999px; background: var(--accent); color: var(--accent-text-on, #fff); font-weight: 700; text-decoration: none; font-size: 0.85rem; }
.credit-low.hidden { display: none; }

/* Feedback: star rating form (menu item, and the one-time prompt on first logout or exit) */
#feedbackBtn { --menu-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/%3E%3C/svg%3E"); }
.fb-backdrop { position: fixed; inset: 0; z-index: 10001; background: rgba(15,23,42,0.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.fb-card { width: 100%; max-width: 360px; max-height: 92vh; overflow-y: auto; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 26px 20px 18px; background: var(--bg-card, #fff); color: var(--text-body, #334155); border-radius: 20px; box-shadow: 0 24px 60px rgba(0,0,0,0.35); }
.fb-title { margin: 0 0 4px; font-size: 1.35rem; color: var(--text-heading, #1e293b); }
.fb-sub { margin: 0 0 14px; font-size: 0.92rem; color: var(--text-muted, #64748b); }
.fb-stars { display: flex; gap: 4px; justify-content: center; }
.fb-star { background: none; border: none; padding: 4px; cursor: pointer; line-height: 0; border-radius: 10px; }
.fb-star svg { fill: none; stroke: #c9ced8; stroke-width: 1.6; stroke-linejoin: round; transition: transform 0.12s ease; }
.fb-star.on svg { fill: #f2b54a; stroke: #d9962a; }
.fb-star:hover svg { transform: scale(1.12); }
.fb-star:focus-visible { outline: 3px solid var(--accent, #6c5ce7); outline-offset: 1px; }
.fb-word { min-height: 1.4em; margin: 6px 0 12px; font-weight: 700; color: var(--text-heading, #1e293b); }
.fb-label { align-self: flex-start; margin-bottom: 6px; font-size: 0.85rem; color: var(--text-muted, #64748b); }
.fb-comment { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--border-subtle, #cbd5e1); border-radius: 12px; font: inherit; font-size: 0.95rem; resize: vertical; background: #fff; color: #1e293b; }
.fb-count { align-self: flex-end; margin: 4px 2px 0; font-size: 0.75rem; color: var(--text-muted, #64748b); }
.fb-msg { min-height: 1.2em; margin: 6px 0 0; font-size: 0.85rem; color: #b91c1c; }
.fb-send { margin-top: 6px; width: 100%; min-height: 46px; border: none; border-radius: 12px; background: var(--accent); color: var(--accent-text-on, #fff); font: inherit; font-weight: 700; cursor: pointer; }
.fb-send:disabled { opacity: 0.5; cursor: default; }
.fb-skip { margin-top: 6px; background: none; border: none; color: var(--text-muted, #64748b); font: inherit; font-size: 0.92rem; padding: 10px 14px; cursor: pointer; }
.fb-done { padding: 14px 0 8px; }
.fb-done-star { font-size: 3rem; line-height: 1; color: #f2b54a; margin-bottom: 6px; }

/* Help & FAQ and Report a problem menu items */
#faqLink { --menu-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M9.1 9a3 3 0 0 1 5.8 1c0 2-3 3-3 3'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E"); }
#reportLink { --menu-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z'/%3E%3Cline x1='4' y1='22' x2='4' y2='15'/%3E%3C/svg%3E"); }

/* Verify your email: the 6-digit code dialog (reuses the feedback dialog look) */
.vf-code { width: 100%; box-sizing: border-box; margin: 4px 0 2px; padding: 12px; text-align: center; font: 700 1.8rem ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.4em; text-indent: 0.4em; border: 2px solid var(--border-subtle, #cbd5e1); border-radius: 14px; background: #fff; color: #1e293b; }
.vf-code:focus { outline: none; border-color: var(--accent, #6c5ce7); }
.vf-resend { margin-top: 4px; background: none; border: none; color: var(--accent, #6c5ce7); font: inherit; font-weight: 600; font-size: 0.92rem; padding: 8px 12px; cursor: pointer; }
.vf-resend:disabled { color: var(--text-muted, #64748b); cursor: default; font-weight: 400; }
.vf-note { margin: 2px 0 0; font-size: 0.8rem; color: var(--text-muted, #64748b); }
