/* FolkReel — Warm archival studio paper for browsing & direction, calm cinema dark for the Interview Room. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --serif: "Iowan Old Style", "Charter", "Source Serif 4", Georgia, Cambria, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f7f4ee;
  --panel: #fffdf9;
  --panel2: #efeae0;
  --side: var(--panel2);
  --ink: #1b191c;
  --muted: #676168;
  --line: rgba(34, 26, 22, 0.11);
  --line-strong: rgba(34, 26, 22, 0.2);
  --accent: #c85528;
  --accent-ink: #ffffff;
  --accent-soft: rgba(200, 85, 40, 0.11);
  --ok: #1e824c;
  --ok-soft: rgba(30, 130, 76, 0.12);
  --warn: #b26200;
  --danger: #c6322f;
  --hover: rgba(34, 26, 22, 0.055);
  --shadow: 0 12px 38px rgba(24, 16, 12, 0.14);
  --head: 54px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131114;
    --panel: #1b181c;
    --panel2: #252126;
    --ink: #f3efe9;
    --muted: #a1999e;
    --line: rgba(255, 245, 235, 0.1);
    --line-strong: rgba(255, 245, 235, 0.18);
    --accent: #eb7342;
    --accent-ink: #1c0d07;
    --accent-soft: rgba(235, 115, 66, 0.15);
    --ok: #46c281;
    --ok-soft: rgba(70, 194, 129, 0.15);
    --warn: #f0a846;
    --danger: #ff6e68;
    --hover: rgba(255, 245, 235, 0.06);
    --shadow: 0 14px 44px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #131114;
  --panel: #1b181c;
  --panel2: #252126;
  --ink: #f3efe9;
  --muted: #a1999e;
  --line: rgba(255, 245, 235, 0.1);
  --line-strong: rgba(255, 245, 235, 0.18);
  --accent: #eb7342;
  --accent-ink: #1c0d07;
  --accent-soft: rgba(235, 115, 66, 0.15);
  --ok: #46c281;
  --ok-soft: rgba(70, 194, 129, 0.15);
  --warn: #f0a846;
  --danger: #ff6e68;
  --hover: rgba(255, 245, 235, 0.06);
  --shadow: 0 14px 44px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.in-room { overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.icon { flex: none; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------------------------------------
   Primitives */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s, filter 0.15s;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.48; cursor: default; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.07); }
.btn.small { min-height: 32px; padding: 5px 11px; font-size: 13px; border-radius: 9px; }
.btn.big { min-height: 48px; padding: 12px 22px; font-size: 15.5px; border-radius: 14px; }
.btn.wide { width: 100%; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--danger); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  flex: none;
}
.icon-btn:hover:not(:disabled) { background: var(--hover); }
.icon-btn.tiny { width: 30px; height: 30px; border-radius: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  font-size: 12.5px;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }

.chip-s {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--panel2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}
.chip-s.ok { background: var(--ok-soft); color: var(--ok); }
.chip-s.warm { background: var(--accent-soft); color: var(--accent); }
.chip-s.rec { background: rgba(198, 50, 47, 0.14); color: var(--danger); }

.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.28; } }

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
.spinner.small { width: 14px; height: 14px; }
.spinner.tiny { width: 11px; height: 11px; border-width: 1.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 48px 16px; color: var(--muted); }
.notice { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 11px; background: var(--panel2); font-size: 13.5px; }
.notice.error { background: rgba(198, 50, 47, 0.11); color: var(--danger); }
.callout { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 11px 13px; border-radius: 12px; background: var(--accent-soft); font-size: 13px; }

.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--panel2); }
.seg.dark { background: rgba(255, 255, 255, 0.12); }
.seg-btn { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: inherit; }
.seg-btn.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14); }
.seg.dark .seg-btn { color: rgba(255, 255, 255, 0.78); }
.seg.dark .seg-btn.on { background: rgba(255, 255, 255, 0.94); color: #161214; }

input[type="text"], input[type="url"], input[type="search"], input[type="password"], textarea, select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  font-size: 14.5px;
  outline: none;
}
textarea { resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field { display: flex; flex-direction: column; gap: 5px; width: 100%; }

/* ---------------------------------------------------------------------------------------------
   App Frame */

.app { min-height: 100%; display: flex; flex-direction: column; }
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  height: calc(var(--head) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 14px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 760 19px var(--display);
  letter-spacing: -0.025em;
  text-decoration: none;
}
.brand img { border-radius: 7px; }
.crumb {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  padding-left: 10px;
  border-left: 1px solid var(--line-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.sync { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.sync.offline { color: var(--warn); }
.sync-bar {
  width: 54px;
  height: 5px;
  border-radius: 999px;
  background: var(--line-strong);
  overflow: hidden;
  display: inline-block;
}
.sync-bar-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 0.16s linear;
}
.upload-banner[hidden], .take-upload-track[hidden] { display: none; }
.upload-banner {
  margin-bottom: 14px;
  padding: 12px 15px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.upload-banner-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.upload-banner-title { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; }
.upload-banner-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.upload-banner-fill {
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 0.16s linear;
}
.upload-banner-note { margin: 0; }
.take-upload-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(0, 0, 0, 0.45);
  z-index: 2;
}
.take-upload-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 0.16s linear;
}
@media (max-width: 640px) {
  .sync-bar { width: 34px; }
}
.view { flex: 1; min-height: 0; }

/* ---------------------------------------------------------------------------------------------
   Sign-in Blocker */

.blocker {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}
.signin {
  width: 100%;
  max-width: 420px;
  padding: 32px 28px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.signin img { border-radius: 16px; }
.signin h1 { margin: 2px 0 0; font: 780 28px/1.1 var(--display); letter-spacing: -0.025em; }
.signin-lede { margin: 0; font-size: 15.5px; line-height: 1.55; color: var(--ink); }
.signin .link { margin-top: 2px; }

/* ---------------------------------------------------------------------------------------------
   Projects Home */

.home-empty {
  max-width: 540px;
  margin: 0 auto;
  padding: 56px 20px 80px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.home-eyebrow {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
}
.home-empty h1 {
  margin: 0;
  font: 760 32px/1.15 var(--serif);
  letter-spacing: -0.02em;
}
.home-empty p { margin: 0; line-height: 1.6; }
.onboarding-form {
  width: 100%;
  margin-top: 10px;
  padding: 18px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}
.reassure-note { max-width: 440px; }

.home { max-width: 960px; margin: 0 auto; padding: 24px 18px 80px; }
.home-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.home-head h1 { margin: 0; font: 760 28px/1.1 var(--display); letter-spacing: -0.025em; }
.home-head p { margin: 4px 0 0; }

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: border-color 0.15s, transform 0.12s;
}
.project-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.pc-link { text-decoration: none; display: flex; flex-direction: column; flex: 1; }
.pc-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #211a1b 0%, #2d211d 100%);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.pc-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
}
.pc-film-icon { color: rgba(255, 240, 228, 0.35); }
.pc-runtime {
  position: absolute;
  z-index: 1;
  right: 10px;
  bottom: 10px;
  padding: 2px 8px;
  border-radius: 7px;
  background: rgba(12, 10, 12, 0.78);
  color: #fff;
  font: 600 12px var(--mono);
  font-variant-numeric: tabular-nums;
}
.pc-body { padding: 14px 16px 10px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pc-title { margin: 0; font: 720 18px/1.25 var(--display); letter-spacing: -0.015em; }
.pc-premise { margin: 0; font-size: 13.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pc-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: auto; padding-top: 4px; }
.pc-actions { padding: 0 16px 14px; display: flex; justify-content: flex-end; }

/* ---------------------------------------------------------------------------------------------
   Project Workspace */

body[data-view="project"] .app { min-height: 0; height: var(--app-visible-height, 100dvh); }
body[data-view="project"] .view { display: flex; flex-direction: column; overflow: hidden; }

.workspace { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.workspace.drag-over::after {
  content: "Drop video or audio files to ingest into this project";
  position: absolute;
  inset: 12px;
  z-index: 30;
  border-radius: 18px;
  border: 2px dashed var(--accent);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  display: grid;
  place-items: center;
  font: 700 18px var(--display);
  color: var(--accent);
  pointer-events: none;
}

.ws-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.ws-head-main { flex: 1; min-width: 0; }
.proj-title-in {
  width: 100%;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 2px 6px !important;
  margin-left: -6px;
  border-radius: 8px;
  font: 750 20px/1.2 var(--display) !important;
  letter-spacing: -0.02em;
}
.proj-title-in:hover { background: var(--hover) !important; }
.proj-title-in:focus { background: var(--panel) !important; box-shadow: 0 0 0 2px var(--accent-soft) !important; }
.ws-sub { font-size: 12.5px; color: var(--muted); padding-left: 1px; }
.ws-head-actions { display: flex; align-items: center; gap: 6px; flex: none; }

.ws-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 14px 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.ws-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
}
.ws-tab.on { color: var(--ink); border-bottom-color: var(--accent); }
.tab-badge { padding: 1px 6px; border-radius: 999px; background: var(--panel2); font-size: 11.5px; color: var(--muted); }

.ws-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 390px; }
.ws-main { overflow-y: auto; padding: 18px 20px 64px; display: flex; flex-direction: column; gap: 18px; }
.ws-room-slots { display: flex; flex-direction: column; gap: 18px; }
.ws-doc {
  border-left: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.ws-doc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.ws-doc-head strong { display: block; font-size: 14px; line-height: 1.2; }
.ws-doc-head-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ws-doc-head-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.doc-thread-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 2px 7px 2px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
}
.doc-thread-btn:hover { color: var(--ink); }
.doc-thread-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-thread-count {
  padding: 0 5px;
  border-radius: 999px;
  background: var(--panel2);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  flex: none;
}
.thread-menu { min-width: 250px; max-width: 320px; }
.thread-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.thread-row .menu-item { flex: 1; min-width: 0; }
.thread-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.thread-row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.thread-row-when { font-size: 11px; color: var(--muted); }
.doc-badge, .doc-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font: 760 12.5px var(--serif);
  flex: none;
}
.ws-doc-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

@media (min-width: 1024px) {
  .mobile-only { display: none !important; }
}
@media (max-width: 1023px) {
  .ws-body { grid-template-columns: minmax(0, 1fr); }
  .ws-doc { display: none; border-left: 0; }
  .workspace[data-tab="doc"] .ws-main { display: none; }
  .workspace[data-tab="doc"] .ws-doc { display: flex; }
}
@media (max-width: 640px) {
  .ws-head { padding: 8px 10px; gap: 6px; }
  .proj-title-in { font-size: 17px !important; }
  .ws-main { padding: 14px 12px 60px; }
  .crumb { display: none !important; }
  .hide-mobile { display: none !important; }
  #enter-room-btn { padding: 6px 12px; min-height: 34px; font-size: 13.5px; }
}

/* Panels inside workspace */
.panel-block {
  padding: 16px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.block-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.block-head h2, .block-head h3 { margin: 0; font: 720 16.5px/1.25 var(--display); letter-spacing: -0.015em; }
.block-head p { margin: 2px 0 0; }

.q-list { display: flex; flex-direction: column; gap: 8px; }
.q-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.q-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font: 700 12px var(--mono);
  display: grid;
  place-items: center;
  flex: none;
  margin-top: 1px;
}
.q-main { flex: 1; min-width: 0; }
.q-text { font: 500 16px/1.38 var(--serif); color: var(--ink); }
.q-why { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.q-acts { display: flex; gap: 2px; flex: none; }

.inline-add { display: flex; gap: 8px; align-items: center; }
.inline-add input { flex: 1; min-width: 0; }

.asked-details { border-top: 1px solid var(--line); padding-top: 8px; }
.asked-details summary { cursor: pointer; font-weight: 600; user-select: none; }
.asked-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.asked-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; border-radius: 10px; background: var(--bg); font-size: 13.5px; }
.asked-text { color: var(--muted); flex: 1; min-width: 0; }

.links-list { display: flex; flex-direction: column; gap: 6px; }
.sketch-notes p { margin: 0; line-height: 1.55; }

/* Takes reel */
.reel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.empty-reel {
  grid-column: 1 / -1;
  padding: 28px 18px;
  text-align: center;
  border-radius: 14px;
  border: 1px dashed var(--line-strong);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.empty-reel p { margin: 0; max-width: 400px; }

.take-card {
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.12s;
}
.take-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.take-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #211a1b, #2c211e);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.take-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
}
.take-thumb-ph { color: rgba(255, 240, 228, 0.35); }
.take-mode-badge, .take-len-badge {
  position: absolute;
  z-index: 1;
  bottom: 8px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(12, 10, 12, 0.78);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.take-mode-badge { left: 8px; }
.take-len-badge { right: 8px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.take-card-body { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.take-card-title { font-weight: 700; font-size: 14.5px; line-height: 1.3; }
.take-card-meta { font-size: 12px; color: var(--muted); }
.take-card-snippet {
  margin: 4px 0 0;
  font: 13.5px/1.45 var(--serif);
  color: color-mix(in srgb, var(--ink) 80%, transparent);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.take-card-chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }

/* Context card */
.context-card { padding: 0; }
.context-sum {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 16px;
  cursor: pointer;
  list-style: none;
  font-size: 14px;
}
.context-sum::-webkit-details-marker { display: none; }
.context-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.links-block { display: flex; flex-direction: column; gap: 7px; }
.link-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 10px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 13px;
}
.link-pill a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; color: var(--accent); }

/* Story Sketch */
.sketch-view { display: flex; flex-direction: column; gap: 16px; }
.sketch-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sketch-head h2 { margin: 0; font: 750 22px/1.2 var(--display); }
.sketch-head p { margin: 4px 0 0; }
.sketch-logline {
  margin: 0;
  padding: 16px 20px;
  border-left: 3px solid var(--accent);
  border-radius: 0 14px 14px 0;
  background: var(--panel);
  font: italic 19px/1.45 var(--serif);
}
.acts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.act-card {
  padding: 15px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.act-num { font: 700 11px var(--mono); letter-spacing: 0.1em; color: var(--accent); }
.act-card h3 { margin: 0; font: 700 16px/1.25 var(--display); }
.act-card p { margin: 0; }
.act-beats { margin: 4px 0 0; padding-left: 18px; font-size: 13.5px; display: flex; flex-direction: column; gap: 4px; }
.gaps-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.gaps-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 11px; border-radius: 10px; background: var(--bg); font-size: 14px; }
.moments-list { display: flex; flex-direction: column; gap: 10px; }
.moment-card { padding: 12px 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.moment-card blockquote { margin: 0; font: 15.5px/1.45 var(--serif); }
.moment-card p { margin: 0; }
.moment-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.future-note { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--panel2); font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------------------------------------
   Doc Director Pane */

.doc-thread { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; }
.doc-empty { display: flex; flex-direction: column; gap: 14px; margin: auto 0; }
.doc-hello { display: flex; gap: 11px; align-items: flex-start; }
.doc-hello p { margin: 3px 0 0; }
.starter-list { display: flex; flex-direction: column; gap: 7px; }
.starter-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  text-align: left;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
}
.starter-btn:hover { border-color: var(--accent); background: var(--accent-soft); }

.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; flex-direction: column; gap: 6px; }
.msg.user { align-items: flex-end; }
.msg.user .bubble {
  max-width: 88%;
  padding: 9px 13px;
  border-radius: 14px 14px 4px 14px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 14px;
  white-space: pre-wrap;
}
.msg.assistant { align-items: flex-start; font-size: 14.2px; }
.doc-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.doc-tool.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); background: var(--ok-soft); }
.doc-tool.failed { color: var(--danger); cursor: pointer; list-style: none; }
.doc-tool.failed::-webkit-details-marker { display: none; }
.doc-tool.aborted { color: var(--muted); }
.doc-tool-err { max-width: 100%; }
.tool-err-detail { margin: 6px 0 0; padding: 8px 10px; border-radius: 9px; background: rgba(198, 50, 47, 0.08); color: var(--danger); font: 12px/1.45 var(--mono); white-space: pre-wrap; overflow-x: auto; }
.retry-row { display: flex; justify-content: flex-start; padding-top: 4px; }

.thinking { width: 100%; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); padding: 6px 10px; font-size: 12.5px; color: var(--muted); }
.thinking summary { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; }

.typing { display: inline-flex; gap: 4px; padding: 8px 10px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: 0.4; animation: dotpulse 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotpulse { 50% { opacity: 1; transform: scale(1.2); } }

.caret { display: inline-block; width: 6px; height: 14px; margin-left: 3px; background: var(--accent); vertical-align: -2px; animation: blink 0.9s steps(1) infinite; }

.md p { margin: 0 0 8px; }
.md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 4px 0 8px; padding-left: 20px; }
.md blockquote { margin: 6px 0; padding: 4px 10px; border-left: 3px solid var(--accent); color: var(--muted); }
.md code { font-family: var(--mono); font-size: 12.5px; padding: 1px 4px; border-radius: 5px; background: var(--panel2); }
.md .code { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 8px 0; }
.md .code-head { display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; background: var(--panel2); font-size: 11.5px; color: var(--muted); }
.md .code pre { margin: 0; padding: 10px; overflow-x: auto; }
.md .copy-code { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 11.5px; }
.md .table { overflow-x: auto; margin: 8px 0; }
.md table { border-collapse: collapse; width: 100%; font-size: 13px; }
.md th, .md td { padding: 6px 8px; border: 1px solid var(--line); text-align: left; }
.md th { background: var(--panel2); font-weight: 600; }
.md .align-center { text-align: center; }
.md .align-right { text-align: right; }

.doc-foot { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.composer-box { border: 1px solid var(--line-strong); border-radius: 14px; background: var(--bg); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.doc-input { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 2px 0 !important; min-height: 24px; max-height: 160px; resize: none; font-size: 14px !important; }
.composer-bar { display: flex; align-items: center; gap: 8px; }
.send { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.send:disabled { opacity: 0.35; cursor: default; }
.send.stop { background: var(--danger); color: #fff; }

.fenced { padding: 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; margin: auto; }

/* ---------------------------------------------------------------------------------------------
   Take View */

.take-page { max-width: 1120px; margin: 0 auto; padding-bottom: 60px; }
.take-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; padding: 18px 16px; }
@media (max-width: 860px) { .take-layout { grid-template-columns: minmax(0, 1fr); } }

.player-shell { border-radius: 16px; overflow: hidden; background: #0e0d0f; border: 1px solid var(--line); }
.player-shell.audio-only { background: var(--panel); }
.player-shell.audio-only .take-timeline { background: var(--panel2); color: var(--ink); }
.player-shell.audio-only .tl-bar { background: var(--line-strong); }
.player-shell.audio-only .tl-legend { color: var(--muted); }
.take-video { width: 100%; aspect-ratio: 16 / 9; max-height: 62vh; display: block; background: #000; }
.take-audio { width: 100%; display: block; padding: 18px; }
.take-timeline { padding: 10px 14px 6px; background: #161418; color: #ddd; }
.tl-bar { position: relative; height: 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); }
.tl-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 0;
  padding: 0;
  border-radius: 50%;
}
.tl-dot.marker { width: 10px; height: 10px; background: #f4ebe0; }
.tl-dot.flag { width: 8px; height: 14px; border-radius: 3px; background: #eb7342; }
.tl-legend { display: flex; gap: 12px; margin-top: 6px; font-size: 12px; color: rgba(255, 255, 255, 0.65); font-family: var(--mono); }
.player-foot { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--panel); border-top: 1px solid var(--line); }

.take-transcript-col { display: flex; flex-direction: column; gap: 18px; }
.beats-section h3, .flags-section h3, .transcript-section h3 { margin: 0 0 10px; font: 720 16px var(--display); }
.beats-head { align-items: center; margin-bottom: 10px; }
.beats-head h3 { margin: 0; }
.beats-section.empty .beats-head { margin-bottom: 0; }
.beat-reset-btn { color: var(--muted); font-weight: 600; }
.beat-reset-btn:hover:not(:disabled) { color: var(--accent); background: var(--accent-soft); }
.flags-strip { display: flex; flex-wrap: wrap; gap: 7px; }
.flag-chip { border: 0; padding: 5px 10px; }
.flag-chip:hover { filter: brightness(0.95); }
.transcript-empty-card { padding: 16px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.transcript-empty-card p { margin: 0; }
.beats-list { display: flex; flex-direction: column; gap: 6px; }
.beat-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 9px 8px 10px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.beat-row:hover { border-color: var(--line-strong); }
.beat-time {
  border: 0;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 6px;
  font: 600 12px var(--mono);
  flex: none;
  margin-top: 2px;
}
.beat-time:hover { filter: brightness(0.94); }
.beat-body { flex: 1; min-width: 0; cursor: text; display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 8px; padding-top: 1px; }
.beat-q { margin: 0; font: 15px/1.38 var(--serif); color: var(--ink); flex: 1 1 180px; }
.beat-row.is-freeform .beat-q { color: var(--muted); font-style: italic; }
.beat-freeform-tag { font-size: 11px; padding: 1px 7px; flex: none; }
.beat-edit-btn { color: var(--muted); opacity: 0.55; margin-top: -2px; transition: opacity 0.15s, color 0.15s, background 0.15s; }
.beat-row:hover .beat-edit-btn, .beat-edit-btn:focus-visible { opacity: 1; color: var(--ink); }
@media (hover: none) { .beat-edit-btn { opacity: 0.8; } }
.beat-edit-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 11px;
  border-radius: 11px;
  border: 1px solid var(--accent);
  background: var(--panel);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.beat-edit-top { display: flex; align-items: flex-start; gap: 10px; }
.beat-edit { flex: 1; min-width: 0; font: 15px/1.42 var(--serif); min-height: 58px; }
.beat-requeue-opt {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.beat-requeue-opt input { width: auto; margin: 0; accent-color: var(--accent); cursor: pointer; }
.beat-edit-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.beat-edit-secondary { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.pieces-list { display: flex; flex-direction: column; gap: 10px; }
.piece-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); transition: border-color 0.15s, background 0.15s; }
.piece-row.playing { border-color: var(--accent); background: color-mix(in srgb, var(--panel) 88%, var(--accent-soft)); }
.piece-time {
  border: 0;
  background: var(--panel2);
  color: var(--muted);
  padding: 2px 7px;
  border-radius: 6px;
  font: 600 12px var(--mono);
  flex: none;
  margin-top: 2px;
}
.piece-time:hover { color: var(--accent); }
.piece-body { flex: 1; min-width: 0; }
.piece-text { margin: 0; font: 15.5px/1.55 var(--serif); cursor: text; }
.piece-edit-wrap { display: flex; flex-direction: column; gap: 8px; }
.piece-edit { width: 100%; font: 15px/1.5 var(--serif); }
.piece-edit-actions { display: flex; gap: 8px; }

/* ---------------------------------------------------------------------------------------------
   The Interview Room (Full-screen dark cinema stage) */

.room {
  position: fixed;
  inset: 0 0 var(--app-covered-bottom, 0px) 0;
  z-index: 40;
  background: #0d0c0e;
  color: #f6f2eb;
}
.room-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.room-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.25s ease;
}
.room-video.mirrored { transform: scaleX(-1); }
.room-video.hidden-self { opacity: 0; pointer-events: none; }

.room-matte {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, #231c1a 0%, #100e11 72%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.room-halo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(235, 115, 66, 0.16);
  display: grid;
  place-items: center;
  transition: transform 0.08s ease-out;
}
.room-halo-core {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: rgba(235, 115, 66, 0.24);
  border: 1px solid rgba(255, 200, 170, 0.25);
  color: #ffb189;
  display: grid;
  place-items: center;
}
.room-matte-label { margin: 0; font-size: 14px; color: rgba(246, 242, 235, 0.68); }

.room-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(10, 8, 10, 0.34) 0%, rgba(10, 8, 10, 0.04) 26%, rgba(10, 8, 10, 0) 52%, rgba(10, 8, 10, 0.1) 76%, rgba(10, 8, 10, 0.64) 100%);
}
.room-focus-ring {
  position: absolute;
  z-index: 2;
  width: 68px;
  height: 68px;
  margin: -34px 0 0 -34px;
  border-radius: 50%;
  border: 2px solid rgba(255, 220, 175, 0.92);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  animation: focus-reticle 1.15s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.room-focus-ring::after {
  content: "";
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background: rgba(255, 220, 175, 0.85);
}
@keyframes focus-reticle {
  0% { opacity: 0; transform: scale(1.38); }
  18% { opacity: 1; transform: scale(0.96); }
  34% { opacity: 1; transform: scale(1.03); }
  55% { opacity: 0.95; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.96); }
}

.room-top {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 8px;
}
.room-top-left, .room-top-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rec-pill, .room-proj-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(16, 14, 16, 0.72);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 13.5px;
  font-weight: 600;
}
.rec-pill .rec-dot { color: #ff5449; }
.rec-pill.paused .rec-dot { color: #f0a846; animation: none; }
.room-timer { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.rec-paused-tag { font-size: 11.5px; color: #f0a846; text-transform: uppercase; letter-spacing: 0.06em; }
.room-meter { width: 54px; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.16); overflow: hidden; }
.room-meter-fill { display: block; width: 100%; height: 100%; border-radius: 999px; background: #eb7342; transform-origin: left center; transform: scaleX(0.08); }
.room-safe { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: rgba(255, 255, 255, 0.65); }

.room-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(16, 14, 16, 0.68);
  backdrop-filter: blur(12px);
  color: #f6f2eb;
  font-size: 13px;
  font-weight: 600;
}
.room-chip.on { background: rgba(235, 115, 66, 0.25); border-color: rgba(235, 115, 66, 0.6); color: #ffd4be; }
.room-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(16, 14, 16, 0.68);
  backdrop-filter: blur(12px);
  color: #f6f2eb;
  display: grid;
  place-items: center;
}
.room-icon-btn:hover { background: rgba(255, 255, 255, 0.16); }

/* Top-center Eyeline Teleprompter (directly beneath webcam lens!) */
.room-prompter {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: center;
  padding: 4px 16px 0;
}
.prompter-card {
  width: 100%;
  max-width: 680px;
  padding: 12px 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(8, 6, 8, 0.28) 0%, rgba(8, 6, 8, 0.18) 100%);
  border: 1px solid rgba(255, 250, 244, 0.1);
  transition: border-color 0.25s, background 0.25s;
}
.prompter-card.thinking {
  background: linear-gradient(180deg, rgba(8, 6, 8, 0.34) 0%, rgba(8, 6, 8, 0.22) 100%);
  border-color: rgba(235, 115, 66, 0.55);
}
.prompter-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; font-size: 12px; color: rgba(255, 250, 244, 0.86); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9); }
.prompter-tag { font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: #ffb590; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.92); }
.prompter-nav { display: inline-flex; gap: 4px; margin-left: auto; }
.prompter-step {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(10, 8, 10, 0.28);
  color: #fff;
  display: grid;
  place-items: center;
}
.prompter-step:disabled { opacity: 0.3; }
.prompter-mode-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(10, 8, 10, 0.34);
  color: rgba(255, 250, 244, 0.94);
  font-size: 11.5px;
  font-weight: 600;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.prompter-mode-btn:hover { background: rgba(10, 8, 10, 0.56); border-color: rgba(255, 255, 255, 0.4); color: #fff; }
.prompter-mode-btn.on { background: rgba(235, 115, 66, 0.28); border-color: rgba(235, 115, 66, 0.65); color: #ffd4be; }
.prompter-nav + .prompter-mode-btn, .prompter-angle-btn + .prompter-mode-btn { margin-left: 6px; }
.prompter-angle-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(10, 8, 10, 0.32);
  color: rgba(255, 250, 244, 0.94);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}
.prompter-angle-btn:hover { background: rgba(10, 8, 10, 0.52); color: #fff; }
.prompter-angle-btn + .prompter-nav { margin-left: 4px; }
.prompter-q {
  margin: 0;
  font: 500 23px/1.32 var(--serif);
  color: #fffdf9;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.88), 0 1px 3px rgba(0, 0, 0, 0.96);
}
.prompter-why {
  margin: 5px 0 0;
  font-size: 13px;
  color: rgba(255, 250, 244, 0.86);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
}
@media (max-width: 640px) {
  .prompter-q { font-size: 19px; }
  .room-safe { display: none; }
}

.room-error-card {
  max-width: 440px;
  padding: 22px;
  border-radius: 18px;
  background: rgba(28, 22, 24, 0.94);
  border: 1px solid rgba(255, 110, 104, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  margin-top: 60px;
}
.room-error-card p { margin: 0; color: rgba(255, 240, 235, 0.8); font-size: 14px; }

.room-bottom {
  position: relative;
  z-index: 3;
  margin-top: auto;
  padding: 12px 16px calc(22px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.room-reassure {
  margin: 0;
  font-size: 13px;
  color: rgba(246, 242, 235, 0.74);
  text-align: center;
  max-width: 480px;
}
.room-dock {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.room-record-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 58px;
  padding: 0 26px 0 18px;
  border-radius: 999px;
  border: 0;
  background: #e2582c;
  color: #fff;
  font: 700 16.5px var(--display);
  box-shadow: 0 10px 30px rgba(226, 88, 44, 0.45);
  transition: transform 0.12s, filter 0.15s;
}
.room-record-btn:hover { filter: brightness(1.08); }
.room-record-btn:active { transform: scale(0.97); }
.room-rec-circle { width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 4px #e2582c; }

.room-action {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 68px;
  height: 58px;
  padding: 0 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(18, 16, 18, 0.76);
  backdrop-filter: blur(12px);
  color: #f6f2eb;
  font-size: 11.5px;
  font-weight: 600;
}
.room-action:hover:not(:disabled) { background: rgba(255, 255, 255, 0.15); }
.room-action:disabled { opacity: 0.5; }
.room-action.accent { background: rgba(235, 115, 66, 0.28); border-color: rgba(235, 115, 66, 0.7); color: #ffe0cf; }

.room-stop-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 58px;
  padding: 0 22px;
  border-radius: 999px;
  border: 0;
  background: #e2433b;
  color: #fff;
  font: 700 15.5px var(--display);
  box-shadow: 0 8px 24px rgba(226, 67, 59, 0.42);
}
.stop-sq { width: 14px; height: 14px; border-radius: 3px; background: #fff; }

/* ---------------------------------------------------------------------------------------------
   Popovers, Dialogs, Toasts */

.popover {
  position: fixed;
  z-index: 60;
  min-width: 220px;
  max-width: 320px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  padding: 6px;
}
.popover.sheet {
  left: 10px !important;
  right: 10px;
  bottom: calc(var(--app-covered-bottom, 0px) + calc(10px + env(safe-area-inset-bottom))) !important;
  top: auto !important;
  max-width: none;
}
.menu { display: flex; flex-direction: column; gap: 2px; }
.menu-head { padding: 6px 10px 3px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 9px;
  border: 0;
  background: none;
  text-align: left;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
}
.menu-item:hover { background: var(--hover); }
.menu-item.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.menu-item.danger { color: var(--danger); }
.mi-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-note { padding: 8px 10px; margin: 0; }
.model-list { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 6px 0; }
.menu-sub { padding: 6px 6px 2px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.menu-foot { padding: 8px 6px 2px; border-top: 1px solid var(--line); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

dialog.settings, dialog.modal {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  max-width: 520px;
  width: calc(100% - 24px);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(10, 8, 10, 0.52); backdrop-filter: blur(4px); }
.settings-panel, .modal-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; display: flex; flex-direction: column; max-height: 88dvh; }
.settings-head, .modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.settings-head h2, .modal-head h2 { margin: 0; font: 740 18px var(--display); }
.settings-body, .modal-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.import-section { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 13px; background: var(--bg); border: 1px solid var(--line); }
.import-section p { margin: 0; }
.cmd-box { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 8px 7px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line-strong); }
.cmd-box code { font: 600 13px var(--mono); overflow-x: auto; white-space: nowrap; }
.import-status { min-height: 18px; }
.set { display: flex; flex-direction: column; gap: 8px; }
.set h3 { margin: 0; font-size: 13.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.set p { margin: 0; }
.tool-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.tool-row-main { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.adv-keys summary { cursor: pointer; font-size: 13px; color: var(--accent); font-weight: 600; margin-top: 4px; }
.key-rows { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background 0.15s; cursor: pointer; }
.switch-track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }

.toasts {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 24px);
}
body.in-room .toasts {
  bottom: calc(108px + env(safe-area-inset-bottom));
}
.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  border-radius: 12px;
  background: #1d191b;
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.32);
  transition: opacity 0.22s, transform 0.22s;
}
.toast.error { background: #a82825; }
.toast.leaving { opacity: 0; transform: translateY(8px); }

/* How It Works Doc Page */
body.doc-page { overflow: auto; }
.doc { max-width: 720px; margin: 0 auto; padding: 24px 20px 80px; }
.doc-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 32px; }
.doc h1 { font: 760 34px/1.12 var(--serif); margin: 0 0 14px; }
.doc .lede { font-size: 17px; line-height: 1.65; color: var(--muted); }
.doc h2 { font: 730 20px/1.3 var(--display); margin: 30px 0 8px; }
.doc p { line-height: 1.68; }
.doc pre { padding: 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); overflow-x: auto; font-size: 13px; }
.doc footer { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); }
