/* InteractIQ Player (web). Mirrors the desktop layout and themes (player_app/ui/themes.py). */
:root, [data-theme="dark"] {
  --window: #111318; --surface: #15181e; --surface-alt: #1b1f27; --avatar-bg: #0e1117;
  --button: #202631; --button-hover: #2a3140; --button-pressed: #171b22;
  --disabled-bg: #181b21; --disabled-text: #737a86;
  --border: #353c49; --border-soft: #2e3440; --input-border: #343a46;
  --accent: #6c8cff; --selection: #29344b;
  --text: #e7e9ee; --text-strong: #f4f5f7; --text-label: #cdd2dc; --text-muted: #9aa3b2; --text-status: #aeb8ca;
  --groove: #343a45; --handle: #dce2ff; --progress-bg: #1a1e25;
  --ok: #5cc98b; --warn: #e3b341; --error: #f07167;
  /* Yuvi's board: a chalkboard */
  --board-bg: #1f2b24; --board-edge: #4b3a2a; --board-ink: #f3f0e6; --board-ink-soft: #c9d3cc;
  --board-mark: #ffd166; --board-s0: #8ecae6; --board-s1: #ffb4a2; --board-s2: #b5e48c; --board-paper: #ffffff;
  color-scheme: dark;
}
[data-theme="light"] {
  --window: #f4f6fa; --surface: #ffffff; --surface-alt: #ffffff; --avatar-bg: #eef1f7;
  --button: #e8ecf3; --button-hover: #dce2ec; --button-pressed: #cfd6e2;
  --disabled-bg: #eef0f4; --disabled-text: #9aa1ad;
  --border: #c9d0dc; --border-soft: #d8dde6; --input-border: #c3cad6;
  --accent: #3c5ee6; --selection: #dce5ff;
  --text: #1d2330; --text-strong: #111622; --text-label: #323a48; --text-muted: #5b6577; --text-status: #4a5466;
  --groove: #c9d0dc; --handle: #3c5ee6; --progress-bg: #e8ecf3;
  --ok: #2e8b57; --warn: #9a6b00; --error: #c0392b;
  /* Yuvi's board: a whiteboard */
  --board-bg: #fbfbf8; --board-edge: #c7ccd6; --board-ink: #1f3a68; --board-ink-soft: #4a5a75;
  --board-mark: #d1495b; --board-s0: #2a6fdb; --board-s1: #d1495b; --board-s2: #2e8b57; --board-paper: #ffffff;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--window); color: var(--text);
  --ui-font-size: 15px;
  font: var(--ui-font-size)/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", "Noto Sans Devanagari", "Noto Sans Bengali", sans-serif;
}
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: inherit; } .muted { color: var(--text-muted); }
.spacer, .grow { flex: 1; min-width: 0; }

/* Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px;
  padding: 6px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--button);
  color: var(--text); font: inherit; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover:not(:disabled) { background: var(--button-hover); color: var(--text-strong); }
.btn:active:not(:disabled) { background: var(--button-pressed); }
.btn:disabled { background: var(--disabled-bg); color: var(--disabled-text); cursor: not-allowed; border-color: var(--border-soft); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.active { border-color: var(--accent); color: var(--accent); }
/* While Yuvi is taking in your words: a clear blue pulse on the voice button. */
.btn.recording { background: var(--accent); border-color: var(--accent); color: #fff; animation: listening 1.2s ease-in-out infinite; }
@keyframes listening { 0%, 100% { box-shadow: 0 0 0 0 rgba(108, 140, 255, .55); } 50% { box-shadow: 0 0 0 7px rgba(108, 140, 255, 0); } }
@media (prefers-reduced-motion: reduce) { .btn.recording { animation: none; } }
.btn.wide { width: 100%; }
.icon-btn { border: 0; background: transparent; color: var(--text-muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 2px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--button-hover); color: var(--text-strong); }
.input, .select {
  background: var(--surface-alt); color: var(--text); border: 1px solid var(--input-border); border-radius: 8px;
  padding: 7px 12px; font: inherit; min-height: 34px;
}
.select { padding: 4px 10px; background: var(--window); border-color: var(--border-soft); min-width: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.input:focus { border-color: var(--accent); outline: none; }
input[type="range"] { accent-color: var(--handle); }
label.btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Sign-in / notice cards */
.center-card { max-width: 440px; margin: 10vh auto 0; padding: 28px; text-align: center; background: var(--surface);
  border: 1px solid var(--border-soft); border-radius: 14px; }
.card-avatar { width: 140px; height: 140px; object-fit: contain; }
.center-card h1 { font-size: 1.4rem; margin: 8px 0; }
.spinner { width: 26px; height: 26px; margin: 14px auto 0; border-radius: 50%; border: 3px solid var(--border);
  border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* Player layout: toolbar + three columns (as the desktop main window) */
.player { height: 100vh; display: flex; flex-direction: column; }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
/* Like the desktop splitters: drag the borders, collapse a side, or focus the viewer. */
.columns { flex: 1; min-height: 0; display: grid;
  grid-template-columns: var(--left-width, 300px) 9px minmax(320px, 1fr) 9px var(--right-width, 37%); }
.column { min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; padding: 6px 10px 10px; overflow: hidden; }
.columns.left-collapsed .left, .columns.right-collapsed .right { visibility: hidden; padding: 0; }
.splitter { position: relative; cursor: col-resize; touch-action: none; }
.splitter::after { content: ""; position: absolute; inset: 0 3px; background: var(--border-soft); border-radius: 2px; }
.splitter:hover::after, .splitter:focus-visible::after, .splitter.dragging::after { background: var(--accent); }
.splitter:focus-visible { outline: none; }
.columns.dragging { user-select: none; }
.columns.dragging iframe, .columns.dragging video { pointer-events: none; } /* keep dragging over the viewer smooth */
.btn[aria-pressed="false"] { opacity: .75; }
.section-title { font-weight: 700; font-size: var(--ui-font-size); margin: 0; color: var(--text-strong); }

/* My Media */
.media-list { flex: 1; min-height: 120px; overflow-y: auto; margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: 8px; }
.media-list li { padding: 8px 12px; margin: 2px 0; border: 1px solid transparent; border-radius: 8px; cursor: pointer;
  display: grid; gap: 1px; line-height: 1.35; }
.media-list li:hover { background: var(--surface-alt); }
.media-list li[aria-selected="true"] { background: var(--selection); border-color: var(--accent); }
.media-list .name, .media-list .state { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-list .state { color: var(--text); white-space: pre; }
.media-list .state.error { color: var(--error); }
.ingestion { position: relative; height: 26px; border: 1px solid var(--border); border-radius: 6px; background: var(--progress-bg); overflow: hidden; text-align: center; }
.ingestion-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--selection); transition: width .3s; }
.ingestion span { position: relative; line-height: 24px; }
#upload-progress progress { width: 100%; }

/* Centre: stage, Yuvi card, viewer, playback */
.center { padding-top: 10px; }
.stage { flex: 1; min-height: 0; position: relative; display: flex; }
.yuvi-card, .viewer { flex: 1; min-height: 0; background: var(--avatar-bg); border: 1px solid var(--border-soft); border-radius: 14px; }
.yuvi-card { display: flex; flex-direction: column; align-items: center; padding: 12px 16px; }
.yuvi-head { align-self: stretch; display: flex; justify-content: space-between; align-items: center; }
.yuvi-figure { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; width: 100%; }
.yuvi-figure img, .yuvi-figure video { max-width: 100%; max-height: 100%; object-fit: contain; }
.yuvi-state { font-weight: 700; font-size: 17px; color: var(--text-strong); }
.yuvi-message { font-size: 13px; color: var(--text-muted); text-align: center; }
.viewer { overflow: auto; display: flex; }
.viewer video { width: 100%; height: 100%; background: #000; border-radius: 14px; }
.viewer audio { margin: auto; width: 90%; }
.viewer iframe { flex: 1; border: 0; border-radius: 14px; background: #fff; }
.viewer .text-view { padding: 16px; width: 100%; }
.segment { white-space: pre-wrap; padding: 8px 10px; border-radius: 6px; }
.segment + .segment { border-top: 1px solid var(--border-soft); }
.segment.highlight { background: var(--selection); }
.preparing { margin: auto; text-align: center; color: var(--text-muted); }
.stage-actions { display: flex; justify-content: flex-end; gap: 8px; }
.board-shortcuts { display: flex; flex-wrap: wrap; gap: 6px; margin-right: auto; }
.board-shortcut { border-color: var(--accent); color: var(--accent); }
.hint { text-align: center; margin: 4px 0; color: var(--text-label); }
.seek-row, .controls { display: flex; align-items: center; gap: 8px; }
.controls, .stage-actions { flex-wrap: wrap; row-gap: 6px; }
.seek-row input { flex: 1; }
.time { font-variant-numeric: tabular-nums; min-width: 44px; }
.controls #volume { width: 110px; }

/* Right column groups */
.right { overflow-y: auto; }
.group { border-bottom: 1px solid var(--border-soft); padding-bottom: 8px; display: flex; flex-direction: column; gap: 8px; }
.group > summary { cursor: pointer; font-weight: 700; font-size: var(--ui-font-size); color: var(--text-strong); padding: 8px 0 4px; list-style: none;
  display: flex; align-items: center; gap: 8px; }
.group > summary::-webkit-details-marker { display: none; }
.group > summary::before { content: "⌄"; font-size: 22px; line-height: 10px; margin-top: -8px; color: var(--text-strong); width: 16px; }
.group:not([open]) > summary::before { content: "›"; margin-top: 0; }
.group[open] { display: flex; }
.question { resize: vertical; min-height: 52px; width: 100%; }
.form-row, .button-row { display: flex; align-items: center; gap: 8px; }
.form-row label { min-width: 120px; white-space: nowrap; color: var(--text); }
.form-row .select.grow { min-width: 0; }
/* Conversation row: one-line label that shortens with "…"; buttons wrap below if space runs out. */
.conversation-row { flex-wrap: wrap; row-gap: 6px; }
.conversation-row #conversation-label { flex: 1 1 160px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-row .row-buttons { display: flex; gap: 8px; flex: 0 0 auto; margin-left: auto; }
.button-row.end { justify-content: flex-end; margin-top: 12px; }
.status { margin: 2px 6px; color: var(--text-status); white-space: pre-wrap; }
.turns { height: clamp(170px, 30vh, 520px); min-height: 120px; max-height: 80vh; resize: vertical; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 8px; padding: 6px; }
.turn { border-bottom: 1px solid var(--border-soft); }
.turn > summary { cursor: pointer; padding: 8px 6px; font-weight: 600; color: var(--text); }
.turn .answer { padding: 4px 10px 10px; color: var(--text); overflow-wrap: anywhere; }
.turn .answer p { margin: 0 0 6px; }
.turn .answer ul, .turn .answer ol { margin: 2px 0 8px; padding-left: 22px; }
.turn .answer li { margin: 2px 0; }
.turn .answer .md-heading { font-weight: 700; color: var(--text-strong); margin: 6px 0 4px; }
.turn .answer code { padding: 0 4px; border-radius: 4px; background: var(--surface-alt); border: 1px solid var(--border-soft); }
.board-chip { font: inherit; font-size: 0.92em; margin: 2px 0; padding: 1px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--accent); background: transparent; color: var(--accent); }
.board-chip:hover { background: var(--selection); }
.turn .meta { display: block; font-size: inherit; color: var(--text-muted); margin-top: 6px; }
.empty { color: var(--text-muted); padding: 8px; }
.sources { list-style: none; margin: 0; padding: 4px; height: 150px; min-height: 60px; max-height: 60vh; resize: vertical; overflow-y: auto; background: var(--surface);
  border: 1px solid var(--border-soft); border-radius: 8px; min-height: 60px; }
.sources li { padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.sources li:hover { background: var(--surface-alt); }
.sources .excerpt { display: block; font-size: inherit; color: var(--text-muted); }

/* Dialogs */
.dialog { width: min(680px, 94vw); max-height: 86vh; overflow: auto; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.wide-dialog { width: min(980px, 96vw); }
.dialog::backdrop { background: rgba(0, 0, 0, .55); }
.plan-badge { font-size: 0.92em; padding: 4px 12px; }
.plan-badge.ended { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.plan-badge.plus { border-color: var(--ok); color: var(--ok); }
.plan-state { font-weight: 600; margin: 0 0 10px; }
.plan-offer { border: 1px solid var(--border-soft); border-radius: 12px; padding: 14px 16px; background: var(--surface-alt); }
.plan-price { display: flex; align-items: baseline; gap: 8px; }
.plan-price span:first-child { font-size: 1.8rem; font-weight: 700; color: var(--text-strong); }
.plan-includes { margin: 10px 0; padding-left: 20px; }
.plan-includes li { margin: 3px 0; }
.small-print { font-size: 0.9em; margin: 6px 0 0; }
.plan-test { margin: 8px 0 0; color: var(--warn); font-weight: 600; }
.dialog h2 { margin: 0 0 12px; font-size: 1.2rem; }
.small-title { font-size: var(--ui-font-size); margin: 16px 0 6px; }
.quiz-q { border: 1px solid var(--border-soft); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.quiz-q legend { font-weight: 600; padding: 0 4px; }
.quiz-q label { display: block; padding: 4px 0; cursor: pointer; }
.quiz-q .correct { color: var(--ok); } .quiz-q .wrong { color: var(--error); }
.quiz-q .explanation { font-size: inherit; color: var(--text-muted); margin-top: 6px; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border-soft); }
.audit details { border-bottom: 1px solid var(--border-soft); padding: 6px 0; }
.audit pre { white-space: pre-wrap; font-size: 12px; background: var(--surface-alt); padding: 8px; border-radius: 6px; max-height: 300px; overflow: auto; }

/* Smaller screens */
@media (max-width: 1150px) {
  /* Narrow windows stack the panels; the side toggles still hide them. */
  .columns { display: flex; flex-direction: column; }
  .splitter { display: none; }
  .columns.left-collapsed .left, .columns.right-collapsed .right { display: none; }
  .column + .column { border-top: 3px solid var(--border-soft); }
  .player { height: auto; min-height: 100vh; } .stage { min-height: 60vh; }
  .toolbar { flex-wrap: wrap; } .media-list { max-height: 240px; } .controls { flex-wrap: wrap; }
}
@media (max-width: 760px) { #user { display: none; } }

/* ------------------------------------------------------------------ Yuvi's teaching board */
@font-face { font-family: "Kalam"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/web/vendor/fonts/kalam-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Kalam"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/web/vendor/fonts/kalam-latin-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Kalam"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/web/vendor/fonts/kalam-devanagari-400.woff2") format("woff2");
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09; }

.board { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
  background: var(--board-bg); color: var(--board-ink); border: 6px solid var(--board-edge); border-radius: 14px;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.18); }
.board-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px dashed var(--board-ink-soft);
  background: color-mix(in srgb, var(--board-bg) 85%, #000 15%); }
.board-head .section-title { color: var(--board-ink); }
.board-head .icon-btn { color: var(--board-ink-soft); }
.board-who { display: flex; flex-direction: column; line-height: 1.2; }
.board-state { font-size: 12px; color: var(--board-ink-soft); }
.board-yuvi { width: 40px; height: 40px; object-fit: contain; border-radius: 50%; background: var(--avatar-bg); }
.board-yuvi.speaking { animation: board-talk 0.9s ease-in-out infinite; box-shadow: 0 0 0 3px var(--board-mark); }
@keyframes board-talk { 50% { transform: scale(1.06); } }
.board-surface { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 26px 40px;
  font-family: "Kalam", "Noto Sans Devanagari", "Noto Sans", "Comic Sans MS", cursive; font-size: 21px; line-height: 1.45; }
.board-question { margin: 0 0 6px; font-size: 15px; color: var(--board-ink-soft); font-family: inherit; }
.board-title { margin: 4px 0 10px; font-size: 30px; font-weight: 700; color: var(--board-ink);
  text-decoration: underline wavy var(--board-mark); text-underline-offset: 8px; text-decoration-thickness: 2px; }
.board-heading { margin: 16px 0 6px; font-size: 24px; font-weight: 700; color: var(--board-mark); }
.board-note { margin: 4px 0; padding-left: 28px; position: relative; }
.board-note::before { content: "➜"; position: absolute; left: 0; color: var(--board-mark); }
.board-visual { margin: 14px 0; padding: 10px; border-radius: 10px; text-align: center;
  border: 2px dashed color-mix(in srgb, var(--board-ink-soft) 60%, transparent); }
.board-visual svg { max-width: 100%; height: auto; }
.board-diagram svg { width: 100%; max-height: 75vh; } /* readable labels first; the board scrolls */
.board-math { font-size: 1.35em; overflow-x: auto; color: var(--board-ink); }
.board-math .katex-display { margin: 0.4em 0; }
.board-chart-svg { width: 100%; max-width: 720px; }
.board-chart-svg text { fill: var(--board-ink); font-family: "Kalam", "Noto Sans", cursive; }
.board-chart-svg .chart-title { font-size: 20px; font-weight: 700; }
.board-chart-svg .chart-tick { font-size: 13px; }
.board-chart-svg .chart-axis-label { font-size: 15px; fill: var(--board-ink-soft); }
.board-chart-svg .chart-axes line { stroke: var(--board-ink); stroke-width: 2; }
.board-chart-svg .chart-series path { stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.board-chart-svg .s0 { stroke: var(--board-s0); fill: var(--board-s0); }
.board-chart-svg .s1 { stroke: var(--board-s1); fill: var(--board-s1); }
.board-chart-svg .s2 { stroke: var(--board-s2); fill: var(--board-s2); }
.board-chart-svg .chart-series path { fill: none; }
.board-figure img { max-width: 100%; max-height: 58vh; border-radius: 8px; background: var(--board-paper);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25); }
.board-figure figcaption { margin-top: 8px; font-size: 16px; color: var(--board-ink-soft); }
.board-figure figcaption strong { color: var(--board-ink); }
.board-figure-open { margin-left: 10px; font: inherit; font-size: 14px; background: transparent; color: var(--board-mark);
  border: 1px solid var(--board-mark); border-radius: 999px; padding: 1px 10px; cursor: pointer; }
.board-figure-loading { padding: 28px; color: var(--board-ink-soft); font-style: italic; }
.board:fullscreen { border-radius: 0; border-width: 10px; }
.board:fullscreen .board-surface { font-size: 26px; padding: 26px 8vw 60px; }
@media (prefers-reduced-motion: reduce) { .board-yuvi.speaking { animation: none; } }
@media (max-width: 700px) {
  .board-surface { padding: 12px 14px 28px; font-size: 18px; }
  .board-title { font-size: 24px; }
  .board-head .btn { padding: 4px 8px; }
}
@media print {
  /* "Save PDF" prints only the board, on white paper. */
  body * { visibility: hidden !important; }
  #board, #board * { visibility: visible !important; }
  #board { position: absolute; inset: 0; border: 0; box-shadow: none; background: #fff; color: #1f3a68; }
  #board .board-head { display: none; }
  #board .board-surface { overflow: visible; color: #1f3a68; }
}
