/* OSITA class page. Light by default; dark only when chosen with the DARK MODE switch (data-theme="dark").
   Session sidebar, ink title banner, uppercase tab bar. On phones the sidebar is a drawer and only the panel scrolls. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #f7f7f5;
  --bg-card: #ffffff;
  --bg-subtle: #fafafa;
  --bg-hover: #f0f0f0;
  --text-primary: #111111;
  --text-secondary: #555555;
  --text-muted: #888888;
  --text-faint: #a3a3a3;
  --border-color: #e5e5e5;
  --border-strong: #cccccc;
  --accent: #111111;
  --accent-hover: #2a2a2a;
  --accent-text: #ffffff;
  --ink-bg: #111111;
  --ink-text: #ffffff;
  --ink-muted: #a9a9a9;
  --success: #22a06b;
  --success-bg: #f0faf5;
  --success-border: #c8ebd9;
  --danger-text: #cc3333;
  --danger-bg: #fff5f5;
  --danger-border: #ffcccc;
  --warning-text: #b36800;
  --warning-bg: #fff8ee;
  --warning-border: #ffe0aa;
  --info: #3b82f6;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;
  --shadow-color: rgba(0, 0, 0, 0.08);
  --side-bg: #ffffff;
  --side-line: #e5e5e5;
  --side-hover: #f2f2f2;
  --side-text: #222222;
  --side-muted: #8a8a8a;
  --side-strong: #111111;
  --side-input: #f5f5f5;
  --side-input-border: #e0e0e0;
  --side-btn: #111111;
  --side-btn-hover: #2a2a2a;
  --side-btn-text: #ffffff;
  color-scheme: light;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --side-text: #dddddd; --side-muted: #6f6f6f; --side-strong: #ffffff;
  --side-input: #252525; --side-input-border: #303030;
  --side-btn: #ffffff; --side-btn-hover: #e9e9e9; --side-btn-text: #111111;
  --bg-primary: #1a1a1a; --bg-card: #232323; --bg-subtle: #202020; --bg-hover: #2e2e2e;
  --text-primary: #f5f5f5; --text-secondary: #cfcfcf; --text-muted: #999999; --text-faint: #777777;
  --border-color: #333333; --border-strong: #464646;
  --accent: #f0f0f0; --accent-hover: #d8d8d8; --accent-text: #1a1a1a;
  --success: #4ec78a; --success-bg: #17261c; --success-border: #2d4536;
  --danger-text: #ff8a80; --danger-bg: #2b1a1a; --danger-border: #4a2f2f;
  --warning-text: #e8ab3f; --warning-bg: #2b2416; --warning-border: #4a3f24;
  --info: #6fa8dc; --info-bg: #182530; --info-border: #2d4356;
  --shadow-color: rgba(0, 0, 0, 0.6);
  --side-bg: #141414; --side-line: #262626; --side-hover: #202020;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; color: var(--text-primary); background: var(--bg-primary);
  -webkit-font-smoothing: antialiased; display: flex; overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.mobile-only { display: none !important; }
button, input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 220px; min-width: 220px; height: 100vh; height: 100dvh; background: var(--side-bg);
  border-right: 1px solid var(--side-line); display: flex; flex-direction: column; color: var(--side-text);
}
.logo { padding: 18px 16px 14px; border-bottom: 1px solid var(--side-line); }
.logo-row { display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 28px; height: 28px; border-radius: 7px; background: var(--side-btn); color: var(--side-btn-text); display: grid; place-items: center; }
.logo-name { font-size: 16px; font-weight: 700; letter-spacing: .08em; color: var(--side-strong); }
.close-btn { margin-left: auto; background: none; border: 0; color: var(--side-text); width: 40px; height: 40px;
  border-radius: 8px; display: grid; place-items: center; }
.close-btn:hover { background: var(--side-hover); }
.logo-sub { margin-top: 6px; font-size: 9px; font-weight: 600; letter-spacing: .16em; color: var(--side-muted); }
.search { padding: 12px 12px 4px; }
.search input {
  width: 100%; background: var(--side-input); border: 1px solid var(--side-input-border); border-radius: 7px;
  padding: 7px 10px; color: var(--side-text); font-size: 12px;
}
.search input::placeholder { color: var(--side-muted); }
.join-wrap { padding: 8px 12px 12px; }
.join-btn {
  width: 100%; border: 0; border-radius: 7px; padding: 9px 10px; background: var(--side-btn); color: var(--side-btn-text);
  font-size: 11px; font-weight: 700; letter-spacing: .12em;
}
.join-btn:hover { background: var(--side-btn-hover); }
.section-label { padding: 10px 16px 6px; font-size: 9px; font-weight: 700; letter-spacing: .16em; color: var(--side-muted); }
.session-list { flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #333333 transparent; }
.session-item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 16px; color: inherit; }
.session-item:hover, .session-item.active { background: var(--side-hover); }
.session-item.active { box-shadow: inset 2px 0 0 var(--side-strong); }
.session-name { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--side-text);
  margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--side-muted); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #ff5f57; flex: none; }
.side-empty { padding: 8px 16px; font-size: 12px; color: var(--side-muted); line-height: 1.5; }
.side-footer { border-top: 1px solid var(--side-line); padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; }
.side-footer span { font-size: 9px; font-weight: 700; letter-spacing: .16em; color: var(--side-muted); }
.icon-btn { background: var(--side-input); border: 1px solid var(--side-input-border); color: var(--side-text);
  border-radius: 7px; padding: 5px 9px; font-size: 11px; min-width: 44px; }
.icon-btn[aria-pressed="true"] { background: var(--side-btn); color: var(--side-btn-text); border-color: var(--side-btn); }
.backdrop { display: none; }

/* ---------- main ---------- */
.main { flex: 1; min-width: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.mobile-bar { display: none; }
.details-btn { margin-left: auto; background: none; border: 1px solid #3a3a3a; color: var(--ink-text); border-radius: 7px;
  padding: 6px 10px; font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.details-btn[aria-expanded="true"] { background: var(--ink-text); color: var(--ink-bg); }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

.center { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 24px; overflow-y: auto; }
.card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 10px; padding: 18px; }
.join-card { width: 100%; max-width: 380px; }
.join-card h1 { font-size: 18px; margin-bottom: 6px; }
.join-card p { color: var(--text-muted); font-size: 13px; line-height: 1.5; margin-bottom: 14px; }
.join-form { display: flex; gap: 8px; }
.join-form input {
  flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: .25em; font-weight: 700; font-size: 16px;
  padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg-subtle);
}
.btn { border: 0; border-radius: 8px; padding: 10px 16px; background: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn-line { background: none; color: var(--text-primary); border: 1px solid var(--border-strong); border-radius: 7px;
  padding: 6px 10px; font-size: 11px; font-weight: 700; letter-spacing: .1em; }
.btn-line:hover { background: var(--bg-hover); }
.error { color: var(--danger-text); font-size: 13px; margin-top: 10px; }

.title-card { background: var(--ink-bg); color: var(--ink-text); padding: 20px 28px; flex-shrink: 0; }
.title-row { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.title-row h2 { font-size: 18px; font-weight: 600; }
.title-sub { font-size: 12px; color: var(--ink-muted); letter-spacing: .02em; }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 9px;
  font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.badge-live { background: #2a0606; color: #ff8080; border: 1px solid #4a0000; }
.badge-ended { background: #1f1f1f; color: #9a9a9a; border: 1px solid #333333; }
.badge-proc { background: #2a2106; color: #ffc766; border: 1px solid #4a3a00; }
.proc-dot { width: 7px; height: 7px; border-radius: 50%; background: #ffb340; flex: none; }
.badge-live .dot { width: 6px; height: 6px; border-radius: 50%; background: #ff5f57; }

.tab-bar { display: flex; border-bottom: 1px solid var(--border-color); background: var(--bg-card); padding: 0 24px; flex-shrink: 0; }
.tab { position: relative; background: none; border: 0; padding: 14px 16px; font-size: 12px; font-weight: 600;
  letter-spacing: .1em; color: var(--text-faint); }
.tab:hover { color: var(--text-secondary); }
.tab[aria-selected="true"] { color: var(--text-primary); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px 2px 0 0; }

.layout { flex: 1; display: flex; overflow: hidden; }
.details { width: 230px; flex: none; padding: 20px 0 20px 20px; overflow-y: auto; }
.details .card { display: flex; flex-direction: column; gap: 12px; padding: 14px; }
.card-title { font-size: 9px; font-weight: 700; letter-spacing: .14em; color: var(--text-faint); }
.detail-row { display: flex; gap: 10px; align-items: flex-start; }
.detail-icon { width: 26px; height: 26px; border-radius: 7px; background: var(--bg-hover); color: var(--text-secondary);
  display: grid; place-items: center; flex: none; }
.detail-label { font-size: 9px; font-weight: 700; letter-spacing: .12em; color: var(--text-faint); }
.detail-value { font-size: 13px; color: var(--text-primary); margin-top: 2px; overflow-wrap: anywhere; }
.detail-value.code { font-weight: 700; letter-spacing: .2em; }
.hint { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

.panel { flex: 1; min-width: 0; overflow-y: auto; padding: 20px 28px 28px; }
.panel.chat { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 16px; }
.empty { padding: 28px 0; font-size: 13px; color: var(--text-faint); text-align: center; line-height: 1.6; }

/* transcript */
.line { display: flex; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--border-color); }
.timestamp { flex: none; width: 46px; padding-top: 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em;
  color: var(--text-faint); font-variant-numeric: tabular-nums; }
.line-body { min-width: 0; }
.chips { display: flex; gap: 6px; margin-bottom: 3px; }
.chip { display: inline-block; border-radius: 5px; padding: 1px 7px; font-size: 11px; font-weight: 600;
  background: var(--bg-hover); color: var(--text-secondary); border: 1px solid var(--border-color); }
.chip-you { background: var(--info-bg); color: var(--info); border-color: var(--info-border); letter-spacing: .1em; font-size: 10px; font-weight: 700; }
.line-text { font-size: 16px; line-height: 1.7; color: var(--text-primary); overflow-wrap: anywhere; }
.lowconf { opacity: .5; text-decoration: underline dotted; }
.chip-rev { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); letter-spacing: .1em; font-size: 10px; font-weight: 700; }
details.earlier { margin-top: 4px; font-size: 13px; color: var(--text-muted); }
details.earlier summary { cursor: pointer; font-size: 11px; font-weight: 600; }
.earlier-line { margin: 6px 0 2px; padding-left: 10px; border-left: 2px solid var(--border-strong); line-height: 1.55; }
.end-marker { margin-top: 18px; text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .16em; color: var(--text-faint); }
.typing { display: flex; gap: 5px; justify-content: center; margin-top: 18px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ask */
.messages { flex: 1; overflow-y: auto; padding-bottom: 12px; }
.qa { margin-bottom: 18px; }
.q { display: inline-block; max-width: 85%; background: var(--accent); color: var(--accent-text); padding: 9px 13px;
  border-radius: 12px 12px 3px 12px; font-size: 14px; line-height: 1.5; }
.q-row { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.a { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; padding: 13px 15px; line-height: 1.6; }
.a.warn { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.a.muted { color: var(--text-muted); }
.quote { margin-top: 10px; border-left: 3px solid var(--accent); padding: 6px 12px; background: var(--bg-subtle);
  border-radius: 0 7px 7px 0; font-style: italic; color: var(--text-secondary); }
details.sources { margin-top: 10px; font-size: 12px; color: var(--text-muted); }
details.sources summary { cursor: pointer; font-weight: 700; letter-spacing: .1em; font-size: 10px; }
.source { margin-top: 8px; padding: 8px 10px; background: var(--bg-subtle); border: 1px solid var(--border-color); border-radius: 7px; }
.source-line { font-size: 13px; line-height: 1.55; color: var(--text-secondary); }
.ask-form { display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--border-color); padding-top: 12px; }
.ask-form textarea { flex: 1; min-width: 0; resize: none; border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 10px 12px; background: var(--bg-card); line-height: 1.5; max-height: 140px; }
.small { font-size: 11px; color: var(--text-faint); margin-top: 6px; }
.small.warn-text { color: var(--warning-text); background: var(--warning-bg); border: 1px solid var(--warning-border); padding: 4px 6px; }
.quick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.quick-label { font-size: 9px; font-weight: 700; letter-spacing: .14em; color: var(--text-faint); margin-right: 2px; }
.recap-head { font-size: 9px; font-weight: 700; letter-spacing: .14em; color: var(--text-faint); margin-bottom: 4px; }
.recap-item { padding: 8px 0; border-bottom: 1px solid var(--border-color); }
.recap-item:last-of-type { border-bottom: none; }

/* topics */
.panel h3 { font-size: 9px; font-weight: 700; letter-spacing: .14em; color: var(--text-faint); margin: 4px 0 10px; }
.timeline { list-style: none; margin-bottom: 26px; }
.seg { display: flex; gap: 12px; padding: 9px 12px; border-left: 3px solid var(--accent); background: var(--bg-card);
  border-radius: 0 8px 8px 0; margin-bottom: 5px; border-top: 1px solid var(--border-color); border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color); }
.seg.digression { border-left-color: var(--border-strong); color: var(--text-muted); background: var(--bg-subtle); }
.seg .timestamp { width: 92px; padding-top: 1px; }
.topic-list { list-style: none; margin-bottom: 18px; }
.topic { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-color); }
.topic-name { font-size: 14px; }
.topic-no { font-size: 10px; font-weight: 700; letter-spacing: .12em; color: var(--text-faint); margin-right: 8px; }
.review-item { margin-top: 10px; }
.review-meta { margin-top: 6px; font-size: 11px; color: var(--text-faint); }

/* ---------- phones and small tablets ----------
   The sidebar is a drawer (menu button, close button, tap outside or Esc closes it). The page itself never scrolls:
   the bar, title and tabs stay on top and only the open panel scrolls, so the transcript can follow new lines and the
   ask box stays at the bottom. Session details open with the DETAILS button. */
@media (max-width: 820px) {
  .mobile-only { display: revert !important; }
  .close-btn.mobile-only { display: grid !important; }
  .desktop-only { display: none !important; }

  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; width: min(300px, 85vw); min-width: 0;
    transform: translateX(-100%); transition: transform .22s ease, visibility .22s; visibility: hidden;
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  body.menu-open .sidebar { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  .backdrop { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .4);
    opacity: 0; pointer-events: none; transition: opacity .22s; }
  body.menu-open .backdrop { opacity: 1; pointer-events: auto; }
  .session-item { padding: 12px 16px; }
  .search input { font-size: 16px; padding: 9px 12px; }      /* 16px: iPhones zoom into smaller inputs */
  .join-btn { padding: 12px 10px; }
  .side-footer { padding: 14px 16px; }
  .icon-btn { padding: 8px 12px; }

  .mobile-bar { display: flex; align-items: center; gap: 8px; flex-shrink: 0;
    padding: calc(6px + env(safe-area-inset-top)) 12px 6px; background: var(--bg-card);
    border-bottom: 1px solid var(--border-color); color: var(--text-primary); }
  .menu-btn { background: none; border: 0; color: inherit; width: 40px; height: 40px; border-radius: 8px;
    display: grid; place-items: center; }
  .menu-btn:hover { background: var(--bg-hover); }
  .mobile-bar strong { letter-spacing: .08em; font-size: 15px; }

  .center { padding: 16px; place-items: start center; padding-top: 12vh; }
  .join-form input { font-size: 18px; }

  .title-card { padding: 12px 16px; }
  .title-row { gap: 8px; margin-bottom: 4px; }
  .title-row h2 { font-size: 15px; flex: 1 1 0; min-width: 0; line-height: 1.3; }
  .title-row .badge, .details-btn { flex: none; }
  .details-btn { margin-left: 0; }
  .title-sub { font-size: 11px; }

  .tab-bar { padding: 0; }
  .tab { flex: 1; padding: 13px 4px; font-size: 11px; }

  .layout { flex-direction: column; min-height: 0; }
  .details { display: none; width: auto; padding: 12px 16px 0; flex: none; max-height: 45dvh; }
  .layout.show-details .details { display: block; }
  .details .card { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .details .card-title, .details .hint, .details .btn-line { grid-column: 1 / -1; }

  .panel { flex: 1; min-height: 0; padding: 12px 16px 20px; -webkit-overflow-scrolling: touch; }
  .panel.chat { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .line { gap: 10px; }
  .timestamp { width: 40px; }
  .line-text { font-size: 15px; line-height: 1.6; }
  .q { max-width: 92%; }
  .quick { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 8px; padding: 0 16px; }
  .quick::-webkit-scrollbar { display: none; }
  .quick .btn-line { flex: none; padding: 8px 12px; }
  .ask-form textarea { font-size: 16px; }
  .ask-form .btn { padding: 11px 16px; }
  .seg { gap: 8px; }
  .seg .timestamp { width: 78px; }
  .topic { flex-wrap: wrap; }
}
