:root {
  --paper: #fbf6ee;
  --paper-deep: #f3eadb;
  --card: #fffdf9;
  --ink: #2b2420;
  --ink-soft: #6b5e55;
  --line: #e6dccb;
  --accent: #b84d2a;
  --accent-deep: #9c3f21;
  --accent-soft: #fbe3d6;
  --sage: #6f8f72;
  --sage-soft: #e3ece1;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.06), 0 8px 24px rgba(60, 40, 20, 0.07);
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); }
[hidden] { display: none !important; }

h1, h2, h3, .brand, .chat-title { font-family: "Fraunces", Georgia, serif; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 12px 20px;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, box-shadow 0.15s;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(184, 77, 42, 0.3); }
.btn.primary:hover:not(:disabled) { background: var(--accent-deep); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--paper-deep); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn.block { width: 100%; }
.link-btn { font: inherit; background: none; border: none; color: var(--ink-soft); text-decoration: underline; cursor: pointer; padding: 6px; font-size: 0.85rem; }

/* ---------- Welcome ---------- */
#welcome { min-height: 100%; display: grid; place-items: center; padding: 48px 16px; }
.welcome-inner { max-width: 620px; width: 100%; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.78rem; font-weight: 600; color: var(--accent); margin: 0 0 12px; }
#welcome h1 { font-size: clamp(2.4rem, 7vw, 3.8rem); line-height: 1.05; margin: 0 0 18px; font-weight: 600; }
#welcome h1 em { color: var(--accent); font-weight: 400; }
.lede { font-size: 1.12rem; line-height: 1.6; color: var(--ink-soft); margin: 0 0 28px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card label, .card p { display: block; font-weight: 500; margin: 0 0 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row input { flex: 1 1 200px; }
input[type="text"], input[type="password"] {
  font: inherit; font-size: 1.05rem; padding: 12px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); outline: none;
}
input[type="text"]:focus, input[type="password"]:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.how { list-style: none; padding: 0; margin: 24px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; color: var(--ink-soft); font-size: 0.95rem; }
.how li { display: flex; gap: 10px; align-items: center; }
.how span:first-child { font-size: 1.3rem; }

/* ---------- Interview layout ---------- */
#interview { display: grid; grid-template-columns: 290px 1fr; height: 100vh; height: 100dvh; }
.sidebar { background: var(--paper-deep); border-right: 1px solid var(--line); padding: 24px 20px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.brand { font-size: 1.35rem; font-weight: 700; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.mobile-only { display: none; }
.progress-head { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
.progress-bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
#progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #e9925f); border-radius: 99px; transition: width 0.6s cubic-bezier(.2,.8,.2,1); }
.chapters { list-style: none; padding: 0; margin: 4px 0 8px; display: flex; flex-direction: column; gap: 2px; }
.chapters li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; font-size: 0.93rem; color: var(--ink-soft); transition: background 0.2s; }
.chapters .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 0.7rem; flex: none; background: var(--card); }
.chapters li.done { color: var(--ink); }
.chapters li.done .dot { background: var(--sage); border-color: var(--sage); color: #fff; }
.chapters li.current { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.chapters li.current .dot { border-color: var(--accent); }
.chapters li.current:not(.done) .dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.hint { font-size: 0.8rem; color: var(--ink-soft); margin: -4px 0 0; text-align: center; }
#new-story-btn { margin-top: auto; align-self: center; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--line); background: var(--paper); }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-family: "Fraunces", serif; font-weight: 700; font-size: 1.2rem; flex: none; }
.chat-title { font-weight: 600; font-size: 1.1rem; }
.chat-sub { font-size: 0.82rem; color: var(--ink-soft); }
.mobile-progress { display: none; margin-left: auto; font-size: 0.82rem; font-weight: 600; background: var(--accent-soft); color: var(--accent-deep); padding: 4px 10px; border-radius: 99px; }

.messages { flex: 1; overflow-y: auto; padding: 28px 24px 12px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.msg { max-width: min(640px, 85%); padding: 13px 17px; border-radius: 20px; line-height: 1.55; font-size: 1rem; white-space: pre-wrap; overflow-wrap: anywhere; animation: rise 0.25s ease-out; }
.msg.penny { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 6px; align-self: flex-start; box-shadow: var(--shadow); }
.msg.user { background: var(--accent); color: #fff; border-bottom-right-radius: 6px; align-self: flex-end; }
.msg.notice { align-self: center; background: var(--sage-soft); color: #3f5b42; font-size: 0.88rem; border-radius: 12px; max-width: 90%; text-align: center; }
.msg.error { align-self: center; background: #fbe4e1; color: #8a2e22; font-size: 0.88rem; border-radius: 12px; max-width: 90%; text-align: center; }
.msg.error .retry-btn { margin-left: 6px; border: 1px solid #c9776c; background: #fff; color: #8a2e22; border-radius: 999px; padding: 3px 10px; font: inherit; font-weight: 600; cursor: pointer; }
.msg.error .retry-btn:hover { background: #fff5f3; }
.typing { display: inline-flex; gap: 5px; padding: 4px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-soft); opacity: 0.5; animation: bounce 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }

.composer { display: flex; gap: 10px; align-items: flex-end; padding: 14px 24px 20px; border-top: 1px solid var(--line); background: var(--paper); }
textarea {
  flex: 1; font: inherit; font-size: 1rem; line-height: 1.45; resize: none; max-height: 180px; overflow-y: hidden;
  padding: 12px 18px; border-radius: 24px; border: 1px solid var(--line); background: var(--card); color: var(--ink); outline: none;
}
.send, .mic { width: 48px; height: 48px; padding: 0; font-size: 1.1rem; flex: none; }
.mic { background: var(--card); }
.mic.recording { background: #e0483a; border-color: #e0483a; animation: pulse 1.2s infinite; }
.mic.busy { opacity: 0.6; cursor: progress; }
.voice-toggle { margin-left: auto; font: inherit; font-size: 0.85rem; font-weight: 600; border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); border-radius: 99px; padding: 7px 14px; cursor: pointer; }
.voice-toggle[aria-pressed="true"] { background: var(--sage-soft); border-color: var(--sage); color: #3f5b42; }
.speech-status { align-self: center; margin: 0 16px 8px; font-size: 0.82rem; color: var(--ink-soft); background: var(--paper-deep); border: 1px solid var(--line); padding: 5px 12px; border-radius: 99px; }

/* ---------- Book ---------- */
#book { min-height: 100%; background: var(--paper-deep); padding-bottom: 64px; }
.book-toolbar { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 24px; background: rgba(243, 234, 219, 0.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.spacer { flex: 1; }
.book-status { max-width: 760px; margin: 20px auto 0; padding: 0 16px; color: var(--ink-soft); font-style: italic; text-align: center; }
.book-page {
  max-width: 760px; margin: 28px auto 0; background: var(--card); padding: clamp(28px, 7vw, 80px);
  box-shadow: 0 2px 4px rgba(60,40,20,.06), 0 20px 50px rgba(60,40,20,.12); border-radius: 4px;
  font-family: "Literata", Georgia, serif; font-size: 1.08rem; line-height: 1.8;
}
.book-page:empty { display: none; }
.book-page h1 { font-size: clamp(2rem, 6vw, 3rem); text-align: center; line-height: 1.15; margin: 0.4em 0 0.2em; }
.book-page h1 + p { text-align: center; color: var(--ink-soft); margin-bottom: 3em; }
.book-page h2 { font-size: 1.6rem; margin: 2.6em 0 1em; text-align: center; font-weight: 600; }
.book-page h2::before { content: "❦"; display: block; color: var(--accent); font-size: 1.1rem; margin-bottom: 0.6em; }
.book-page p { margin: 0 0 1.1em; text-indent: 1.5em; }
.book-page h2 + p, .book-page h1 + p { text-indent: 0; }
.book-page h2 + p { display: flow-root; } /* keeps the drop cap from spilling into the next paragraph */
.book-page h2 + p::first-letter { font-family: "Fraunces", serif; font-size: 3.4em; float: left; line-height: 0.85; padding: 0.06em 0.08em 0 0; color: var(--accent); }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 99px; font-weight: 500; box-shadow: var(--shadow); z-index: 10; animation: pop 0.35s cubic-bezier(.2,1.4,.4,1); max-width: calc(100% - 32px); text-align: center; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); opacity: 0.9; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 12px) scale(0.9); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  #interview { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.open { display: flex; position: fixed; inset: 0; z-index: 5; }
  .mobile-progress { display: block; cursor: pointer; margin-left: 0; }
  .voice-toggle { padding: 6px 10px; white-space: nowrap; font-size: 0.8rem; }
  .chat-head { gap: 8px; }
  .chat-head > div:nth-child(2) { min-width: 0; }
  .chat-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mobile-only { display: inline-block; text-decoration: none; font-size: 1.2rem; }
  .chat-head, .messages, .composer { padding-left: 16px; padding-right: 16px; }
  .msg { max-width: 90%; }
  .book-toolbar { padding: 12px 16px; }
  .book-page { margin: 16px 12px 0; }
}

@media print {
  body, #book { background: #fff; }
  .book-toolbar, .book-status, .toast { display: none !important; }
  .book-page { box-shadow: none; margin: 0; padding: 0; max-width: none; }
  .book-page h2 { page-break-before: always; }
}

/* ---------- Voice mode ---------- */
.start-actions { margin-top: 12px; }
.talk-btn { margin-left: auto; padding: 8px 16px; font-size: 0.9rem; }
.voice-toggle { margin-left: 0; }
.voice-mode {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column;
  background: radial-gradient(ellipse at 50% 40%, var(--card) 0%, var(--paper) 55%, var(--paper-deep) 100%);
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
}
.vm-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; max-width: 760px; width: 100%; margin: 0 auto; }
.vm-title { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.2rem; }
.vm-patience { font-size: 0.85rem; color: var(--ink-soft); display: flex; align-items: center; gap: 8px; }
.vm-patience select { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 6px 10px; }
.vm-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; text-align: center; min-height: 0; }
.vm-orb { --level: 0; position: relative; width: min(56vw, 240px); aspect-ratio: 1; border: none; background: none; padding: 0; cursor: pointer; border-radius: 50%; }
.vm-core {
  position: absolute; inset: 12%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f3b293, var(--accent) 60%, var(--accent-deep));
  box-shadow: 0 18px 50px rgba(184, 77, 42, 0.35);
  transform: scale(calc(0.9 + var(--level) * 0.3)); transition: transform 0.08s linear, background 0.4s, box-shadow 0.4s;
}
.vm-ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.vm-ring circle { fill: none; stroke-width: 3; }
.vm-ring-track { stroke: var(--line); }
.vm-ring-fill { stroke: var(--sage); stroke-linecap: round; stroke-dasharray: 352; stroke-dashoffset: 352; transition: stroke-dashoffset 0.15s linear; }
.vm-state { font-size: 1.15rem; font-weight: 600; margin: 0; min-height: 1.5em; }
.vm-caption { max-width: 620px; margin: 0; font-size: 1.05rem; line-height: 1.6; color: var(--ink-soft); max-height: 30vh; overflow-y: auto; }
.vm-caption[data-who="you"] { font-style: italic; }
.vm-caption[data-who="you"]::before { content: attr(data-prefix); font-style: normal; font-weight: 600; }
.vm-controls { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

.voice-mode[data-state="listening"] .vm-core { background: radial-gradient(circle at 35% 30%, #cfe0cc, var(--sage) 65%, #557259); box-shadow: 0 18px 50px rgba(111, 143, 114, 0.35); animation: breathe 4s ease-in-out infinite; }
.voice-mode[data-state="hearing"] .vm-core { background: radial-gradient(circle at 35% 30%, #cfe0cc, var(--sage) 65%, #557259); box-shadow: 0 18px 50px rgba(111, 143, 114, 0.45); }
.voice-mode[data-state="transcribing"] .vm-core,
.voice-mode[data-state="thinking"] .vm-core { animation: think 1.4s ease-in-out infinite; }
.voice-mode[data-state="speaking"] .vm-core { animation: talk 0.9s ease-in-out infinite; }
.voice-mode[data-state="paused"] .vm-core,
.voice-mode[data-state="loading"] .vm-core,
.voice-mode[data-state="off"] .vm-core { background: radial-gradient(circle at 35% 30%, #fff, var(--line) 70%); box-shadow: none; }
.voice-mode[data-state="loading"] .vm-core { animation: breathe 1.6s ease-in-out infinite; }

@keyframes breathe { 0%, 100% { transform: scale(calc(0.9 + var(--level) * 0.3)); } 50% { transform: scale(calc(0.96 + var(--level) * 0.3)); } }
@keyframes think { 0%, 100% { transform: scale(0.86); opacity: 0.85; } 50% { transform: scale(0.92); opacity: 1; } }
@keyframes talk { 0%, 100% { transform: scale(0.92); } 30% { transform: scale(1.02); } 60% { transform: scale(0.96); } }
@media (prefers-reduced-motion: reduce) { .vm-core { animation: none !important; } }

/* ---------- Privacy ---------- */
.card .fine, .fine { font-size: 0.85rem; font-weight: 400; color: var(--ink-soft); margin: 10px 0 0; line-height: 1.5; }
.card .pass-label { margin-top: 16px; }
.row + .row { margin-top: 10px; }
.form-error { color: #8a2e22; background: #fbe4e1; border-radius: 10px; padding: 8px 12px; font-size: 0.88rem; margin: 10px 0 0; }
.privacy-link { display: block; margin: 4px auto 0; font-size: 0.92rem; }
.privacy-side { font-size: 0.85rem; text-decoration: none; color: var(--sage); font-weight: 600; margin-top: auto; }
.privacy-side + #new-story-btn { margin-top: 0; }
.privacy-dialog { max-width: 560px; width: calc(100% - 32px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); padding: 28px; box-shadow: var(--shadow); }
.privacy-dialog::backdrop { background: rgba(43, 36, 32, 0.45); }
.privacy-dialog h2 { margin: 0 0 16px; font-size: 1.4rem; }
.privacy-list { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-direction: column; gap: 14px; line-height: 1.5; font-size: 0.95rem; }
.privacy-list li { display: flex; gap: 12px; }
.privacy-list span { font-size: 1.2rem; flex: none; }
.privacy-dialog form { text-align: right; }

/* ---------- Language switch ---------- */
.welcome-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.welcome-top .eyebrow { margin: 0; }
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; background: var(--card); padding: 3px; gap: 2px; }
.lang-switch button { font: inherit; font-size: 0.82rem; font-weight: 600; border: none; background: none; color: var(--ink-soft); padding: 5px 12px; border-radius: 99px; cursor: pointer; }
.lang-switch button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.lang-switch-side { align-self: center; margin-top: 4px; }
.voice-pick { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 0.85rem; color: var(--ink-soft); }
.voice-pick select { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 5px 10px; }

/* ---------- Your story (public/story/) ---------- */
#interview { grid-template-columns: 290px minmax(0, 1fr) minmax(380px, 40%); }
.story-btn { display: none; padding: 8px 14px; font-size: 0.9rem; }
.story-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-left: 1px solid var(--line); background: var(--paper-deep); }
.story-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.story-panel-head h2 { margin: 0; font-size: 1.2rem; }
.story-close { display: none; font-size: 1.2rem; text-decoration: none; }
.story-root { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px 16px 16px; }
.story-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.story-tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; background: var(--card); padding: 3px; gap: 2px; }
.story-tabs button { font: inherit; font-size: 0.85rem; font-weight: 600; border: none; background: none; color: var(--ink-soft); padding: 6px 12px; border-radius: 99px; cursor: pointer; white-space: nowrap; }
.story-tabs button[aria-selected="true"] { background: var(--accent); color: #fff; }
.story-status { font-size: 0.8rem; color: var(--ink-soft); }
.story-summary { margin: 10px 2px 0; font-size: 0.9rem; line-height: 1.5; color: var(--ink-soft); }
.story-views { position: relative; flex: 1; min-height: 260px; margin-top: 10px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.story-view { position: absolute; inset: 0; }
.story-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 24px; text-align: center; color: var(--ink-soft); font-size: 0.95rem; line-height: 1.5; }

.story-ideas { overflow: auto; padding: 8px 4px; }
.story-ideas svg { display: block; }
.story-ideas .link { fill: none; stroke-width: 1.6; stroke-opacity: 0.55; }
.story-ideas .link.untold { stroke-dasharray: 3 4; stroke-opacity: 0.35; }
.story-ideas .node text { font: 600 12.5px "DM Sans", sans-serif; fill: var(--ink); }
.story-ideas .node.depth-0 text { font: 700 14px "Fraunces", serif; }
.story-ideas .node.untold { opacity: 0.55; }
.story-ideas .node.untold rect { stroke-dasharray: 3 3; }
.story-ideas .node[tabindex] { cursor: default; outline: none; }
.story-ideas .node[tabindex]:focus-visible rect { stroke-width: 2.5; }
.story-ideas .node.enter { animation: story-pop 0.6s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes story-pop { from { opacity: 0; } }

.story-panel .tooltip { position: absolute; pointer-events: none; max-width: 260px; background: var(--ink); color: #fff; border-radius: 8px; padding: 10px 12px; font-size: 0.85rem; line-height: 1.45; box-shadow: var(--shadow); z-index: 3; }
.story-panel .tooltip strong { display: block; font-size: 0.92rem; }

/* Timeline and world map, from Debate_2_Graphics */
.tl-scroll { position: absolute; inset: 0; overflow-x: auto; overflow-y: hidden; }
.tl-inner { position: relative; height: 100%; }
.tl-track { position: absolute; height: 8px; margin-top: -4px; border-radius: 99px; transition: width 0.6s ease, left 0.6s ease; }
.tl-event { position: absolute; width: 0; height: 0; outline: none; transition: left 0.6s ease, top 0.3s; }
.tl-dot { position: absolute; left: -8px; top: -8px; width: 16px; height: 16px; border-radius: 50%; background: var(--card); border: 3px solid var(--c); z-index: 1; }
.tl-stem { position: absolute; left: -1px; width: 2px; height: var(--stem); background: var(--c); opacity: 0.55; }
.tl-event.up .tl-stem { bottom: 8px; }
.tl-event.down .tl-stem { top: 8px; }
.tl-card { position: absolute; left: 0; width: 168px; transform: translateX(-50%); border-radius: 8px; background: var(--tint); box-shadow: 0 2px 8px rgba(60, 40, 20, 0.1); overflow: hidden; transition: box-shadow 0.2s; }
.tl-event.up .tl-card { bottom: calc(8px + var(--stem)); }
.tl-event.down .tl-card { top: calc(8px + var(--stem)); }
.tl-card h3 { margin: 0; padding: 7px 10px; background: var(--head); color: #fff; font: 600 0.82rem/1.25 "DM Sans", sans-serif; text-align: center; text-wrap: balance; }
.tl-card p { margin: 0; padding: 8px 12px 10px; font-size: 0.76rem; line-height: 1.4; color: var(--ink); text-align: center; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.timeline.compact .tl-card p { -webkit-line-clamp: 2; line-clamp: 2; padding: 6px 10px 8px; }
.timeline.compact .tl-card h3 { padding: 6px 10px; }
.tl-when { position: absolute; left: 0; transform: translateX(-50%); white-space: nowrap; font: 700 0.78rem "DM Sans", sans-serif; color: var(--ink); }
.tl-event.up .tl-when { top: 14px; }
.tl-event.down .tl-when { bottom: 14px; }
.tl-event:hover .tl-card, .tl-event:focus-visible .tl-card { box-shadow: 0 6px 18px rgba(60, 40, 20, 0.18); }
.tl-event.enter .tl-card { animation: tl-card-in 0.7s ease; }
.tl-event.enter .tl-dot, .tl-event.enter .tl-stem, .tl-event.enter .tl-when { animation: tl-fade-in 0.5s ease-out; }
@keyframes tl-card-in { from { opacity: 0; transform: translateX(-50%) scale(0.92); } }
@keyframes tl-fade-in { from { opacity: 0; } }
.tl-today { position: absolute; width: 0; height: 0; z-index: 2; }
.tl-today span { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); padding: 2px 8px; border-radius: 99px; background: var(--ink); color: #fff; font: 600 0.7rem "DM Sans", sans-serif; white-space: nowrap; box-shadow: 0 0 0 3px var(--card); }
.geomap svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.geomap .sphere { fill: #eef2f0; }
.geomap .land path { fill: #e6dccb; stroke: var(--card); stroke-width: 0.6; }
.geomap .land path.named { fill: #d4c3a6; }
.geomap .route path { fill: none; stroke: var(--ink-soft); stroke-width: 1.5; stroke-dasharray: 4 5; stroke-opacity: 0.7; }
.geomap .pin { cursor: default; outline: none; }
.geomap .pin circle { stroke: var(--card); stroke-width: 2; }
.geomap .pin text { font: 600 12px "DM Sans", sans-serif; fill: var(--ink); paint-order: stroke; stroke: rgba(238, 242, 240, 0.95); stroke-width: 4px; stroke-linejoin: round; }
.geomap .pin:focus-visible circle { stroke: var(--ink); }

/* Added while the storyteller is still talking: faint until their turn is done. */
.story-ideas .node.tentative, .geomap .pin.tentative, .tl-event.tentative { opacity: 0.5; }
.story-ideas .node, .geomap .pin { transition: opacity 0.4s; }
.tl-event { transition: left 0.6s ease, top 0.3s, opacity 0.4s; }

/* Narrower screens: the story slides over the chat from the "Your story" button. */
@media (max-width: 1200px) {
  #interview { grid-template-columns: 290px minmax(0, 1fr); }
  .story-btn { display: inline-block; margin-left: auto; }
  .story-btn + .talk-btn { margin-left: 0; }
  .story-panel { display: none; }
  .story-panel.open { display: flex; position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); z-index: 15; box-shadow: -12px 0 40px rgba(60, 40, 20, 0.18); }
  .story-close { display: inline-block; }
}
@media (max-width: 820px) {
  #interview { grid-template-columns: 1fr; }
  .story-btn { padding: 6px 10px; font-size: 0.8rem; }
}

/* ---------- Talk screen: the story around the talk button ---------- */
.voice-mode { padding: 14px 18px calc(16px + env(safe-area-inset-bottom)); }
.voice-mode .vm-top { max-width: none; }
.vm-settings { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.vm-chat { padding: 7px 14px; font-size: 0.88rem; }
.vm-board {
  flex: 1; min-height: 0; margin-top: 12px; display: grid; gap: 14px;
  grid-template-columns: minmax(0, 1fr) clamp(250px, 24vw, 320px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas: "chapters center ideas" "map center timeline";
}
.vm-q[data-slot="ideas"] { grid-area: ideas; }
.vm-q[data-slot="timeline"] { grid-area: timeline; }
.vm-q[data-slot="map"] { grid-area: map; }
.vm-q[data-slot="chapters"] { grid-area: chapters; }
.voice-mode .vm-center { grid-area: center; flex: none; min-height: 0; justify-content: center; gap: 14px; }
.voice-mode .vm-orb { width: clamp(140px, 15vw, 200px); }
.voice-mode .vm-state { font-size: 1.02rem; }
.voice-mode .vm-caption { max-height: 24vh; font-size: 0.95rem; }
.voice-mode .vm-controls { flex-direction: column; align-items: stretch; width: 100%; max-width: 240px; }

.vm-q { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.vm-q .sb-title { margin: 0; padding: 10px 14px 4px; font: 600 0.88rem "DM Sans", sans-serif; color: var(--ink-soft); }
.vm-q .sb-body { position: relative; flex: 1; min-height: 0; }
.vm-q .sb-empty { margin: auto; padding: 12px 22px 22px; text-align: center; color: var(--ink-soft); font-size: 0.86rem; line-height: 1.45; }
.vm-q .story-ideas { position: absolute; inset: 0; overflow: auto; padding: 4px; }
.vm-q .story-ideas .tooltip, .vm-q .tooltip { position: absolute; pointer-events: none; max-width: 240px; background: var(--ink); color: #fff; border-radius: 8px; padding: 9px 11px; font-size: 0.82rem; line-height: 1.4; z-index: 3; }
.vm-q .tooltip strong { display: block; }

.story-chapters { position: absolute; inset: 0; overflow: auto; padding: 2px 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.sc-head { margin: 0; font-size: 0.85rem; color: var(--ink-soft); }
.sc-bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; flex: none; }
.sc-bar div { height: 100%; background: linear-gradient(90deg, var(--accent), #e9925f); border-radius: 99px; transition: width 0.6s ease; }
.sc-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.sc-list li { display: flex; align-items: center; gap: 7px; padding: 4px 6px; border-radius: 8px; font-size: 0.84rem; color: var(--ink-soft); min-width: 0; }
.sc-dot { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2px solid var(--c); display: grid; place-items: center; font-size: 0.6rem; color: #fff; }
.sc-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-items { font-size: 0.75rem; font-weight: 600; color: var(--c); white-space: nowrap; }
.sc-list li.done { color: var(--ink); }
.sc-list li.done .sc-dot { background: var(--c); }
.sc-list li.current { background: var(--paper-deep); color: var(--ink); font-weight: 600; }
.sc-write { margin-top: auto; flex: none; }
.sc-hint { margin: -2px 0 0; font-size: 0.78rem; color: var(--ink-soft); text-align: center; }

@media (max-width: 900px) {
  .voice-mode { overflow-y: auto; }
  .vm-board { flex: none; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto 300px 300px; grid-template-areas: "center center" "chapters ideas" "map timeline"; }
  .voice-mode .vm-orb { width: 150px; }
  .voice-mode .vm-controls { flex-direction: row; max-width: none; justify-content: center; }
}
@media (max-width: 560px) {
  .vm-board { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 300px 280px 280px 280px; grid-template-areas: "center" "chapters" "ideas" "timeline" "map"; }
}

/* ---------- Depth for the story graphics ---------- */
:root {
  /* Layered, warm-tinted shadows: a tight contact shadow plus wider, softer ambient ones. */
  --shadow-panel: 0 1px 1px rgba(60, 40, 20, 0.04), 0 2px 4px rgba(60, 40, 20, 0.05), 0 8px 18px rgba(60, 40, 20, 0.07), 0 22px 44px rgba(60, 40, 20, 0.08);
  --shadow-panel-hover: 0 1px 1px rgba(60, 40, 20, 0.05), 0 4px 8px rgba(60, 40, 20, 0.06), 0 14px 28px rgba(60, 40, 20, 0.09), 0 32px 60px rgba(60, 40, 20, 0.10);
  --shadow-chip: drop-shadow(0 1px 1px rgba(60, 40, 20, 0.16)) drop-shadow(0 3px 6px rgba(60, 40, 20, 0.10));
  --highlight: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

/* Panels: lifted cards with a fine top highlight. */
.vm-q, .story-views { box-shadow: var(--shadow-panel), var(--highlight); border-color: rgba(230, 220, 203, 0.8); transition: box-shadow 0.3s ease, transform 0.3s ease; }
.vm-q:hover { box-shadow: var(--shadow-panel-hover), var(--highlight); transform: translateY(-1px); }
.vm-q .sb-title { text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8); }

/* Ideas: chips that sit on the page; the center and told chapters stand out most. */
.story-ideas .node rect { filter: var(--shadow-chip); }
.story-ideas .node.depth-0 rect, .story-ideas .node.depth-1:not(.untold) rect { filter: drop-shadow(0 1px 1px rgba(60, 40, 20, 0.22)) drop-shadow(0 4px 10px rgba(60, 40, 20, 0.18)); }
.story-ideas .node.untold rect { filter: none; }
.story-ideas .link { filter: drop-shadow(0 1px 1px rgba(60, 40, 20, 0.08)); }

/* Timeline: cards, stems and the line itself cast soft shadows. */
.tl-card { box-shadow: 0 1px 2px rgba(60, 40, 20, 0.08), 0 4px 10px rgba(60, 40, 20, 0.10), 0 12px 24px rgba(60, 40, 20, 0.08); }
.tl-event:hover .tl-card, .tl-event:focus-visible .tl-card { box-shadow: 0 2px 4px rgba(60, 40, 20, 0.10), 0 10px 20px rgba(60, 40, 20, 0.14), 0 24px 44px rgba(60, 40, 20, 0.12); }
.tl-card h3 { text-shadow: 0 1px 1px rgba(0, 0, 0, 0.18); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.08); }
.tl-track { box-shadow: 0 2px 6px rgba(60, 40, 20, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.tl-dot { box-shadow: 0 1px 2px rgba(60, 40, 20, 0.2), 0 3px 8px rgba(60, 40, 20, 0.14); }
.tl-when { text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9); }

/* Map: raised land and pins that float above it. */
.geomap .land { filter: drop-shadow(0 1px 1px rgba(60, 40, 20, 0.12)) drop-shadow(0 4px 8px rgba(60, 40, 20, 0.08)); }
.geomap .pin circle { filter: drop-shadow(0 1px 1px rgba(60, 40, 20, 0.3)) drop-shadow(0 3px 6px rgba(60, 40, 20, 0.2)); }
.geomap .route path { filter: drop-shadow(0 1px 1px rgba(60, 40, 20, 0.12)); }

/* Chapters: a recessed progress track with a glossy fill, and lifted check marks. */
.sc-bar { box-shadow: inset 0 1px 2px rgba(60, 40, 20, 0.18); }
.sc-bar div { box-shadow: 0 1px 3px rgba(184, 77, 42, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.sc-list li.done .sc-dot { box-shadow: 0 1px 2px rgba(60, 40, 20, 0.25), 0 2px 6px rgba(60, 40, 20, 0.12); }
.sc-list li.current { box-shadow: 0 1px 2px rgba(60, 40, 20, 0.08), 0 4px 10px rgba(60, 40, 20, 0.08), var(--highlight); background: var(--card); }
.sc-write:not(:disabled) { box-shadow: 0 2px 4px rgba(184, 77, 42, 0.25), 0 8px 20px rgba(184, 77, 42, 0.28); }

/* The chat's story tabs get the same depth. */
.story-tabs { box-shadow: 0 1px 2px rgba(60, 40, 20, 0.06), 0 4px 10px rgba(60, 40, 20, 0.06), var(--highlight); }
.story-tabs button[aria-selected="true"] { box-shadow: 0 1px 2px rgba(184, 77, 42, 0.3), 0 3px 8px rgba(184, 77, 42, 0.25); }

/* ---------- Talk screen polish ---------- */

/* A warm, softly lit backdrop with a faint paper grain. */
.voice-mode {
  background:
    radial-gradient(1100px 650px at 50% 46%, rgba(255, 253, 249, 0.95), transparent 62%),
    radial-gradient(900px 620px at 0% 0%, rgba(233, 146, 95, 0.17), transparent 60%),
    radial-gradient(900px 700px at 100% 100%, rgba(111, 143, 114, 0.17), transparent 60%),
    linear-gradient(180deg, #fbf6ee, #f1e6d4);
}
.voice-mode::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.55;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.24 0 0 0 0 0.16 0 0 0 0 0.08 0 0 0 0.09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
.voice-mode > * { position: relative; z-index: 1; }
.voice-mode .vm-title { font-size: 1.4rem; letter-spacing: 0.005em; }
.voice-mode .vm-patience select, .voice-mode .vm-chat { background: rgba(255, 253, 249, 0.85); box-shadow: 0 1px 2px rgba(60, 40, 20, 0.06), 0 4px 12px rgba(60, 40, 20, 0.06), inset 0 1px 0 #fff; }

/* Panels: frosted cards with a serif title over a fine accent rule. */
.vm-q {
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  background: linear-gradient(180deg, rgba(255, 253, 249, 0.94), rgba(255, 250, 243, 0.84));
  backdrop-filter: blur(10px) saturate(1.08);
  box-shadow: 0 0 0 1px rgba(214, 198, 172, 0.45), var(--shadow-panel), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}
.vm-q:hover { box-shadow: 0 0 0 1px rgba(214, 198, 172, 0.55), var(--shadow-panel-hover), inset 0 1px 0 rgba(255, 255, 255, 0.95); }
.vm-q .sb-title {
  display: flex; align-items: center; gap: 8px; margin: 0 18px; padding: 14px 0 9px;
  font: 600 1.05rem "Fraunces", serif; color: var(--ink); text-shadow: none;
  background: linear-gradient(90deg, rgba(184, 77, 42, 0.38), rgba(184, 77, 42, 0.08) 55%, transparent) bottom left / 100% 1px no-repeat;
}
.sb-count {
  font: 700 0.7rem "DM Sans", sans-serif; color: #fff; padding: 2px 8px; border-radius: 99px;
  background: linear-gradient(180deg, #d4683f, #a8441f);
  box-shadow: 0 1px 2px rgba(168, 68, 31, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.vm-q .sb-empty { font-style: italic; }

/* Ideas: fuller, smoother branches. */
.story-ideas .link { stroke-width: 2.4; stroke-opacity: 0.45; stroke-linecap: round; }
.story-ideas .link.untold { stroke-width: 1.4; }
.story-ideas .node.depth-0 text { font: 700 15px "Fraunces", serif; }
.story-ideas .node.depth-1 text { letter-spacing: 0.01em; }

/* Timeline: glossy headers on cream cards, a lit line, pearl dots. */
.tl-card { border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.85); background: linear-gradient(180deg, #fffdf9, var(--tint)); }
.tl-card h3 { background: linear-gradient(180deg, color-mix(in srgb, var(--head) 76%, #ffffff), var(--head) 70%); }
.tl-track { height: 10px; margin-top: -5px; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.75), 0 3px 12px rgba(60, 40, 20, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.4); }
.tl-dot { width: 18px; height: 18px; left: -9px; top: -9px; background: radial-gradient(circle at 35% 30%, #ffffff, #f3eadb); }

/* Map: a softly lit ocean, parchment land, glowing pins. */
.geomap { background: radial-gradient(ellipse at 45% 40%, #f7faf9 0%, #e8efec 55%, #d6e1dd 100%); }
.geomap .sphere { fill: transparent; }
.geomap .land path { fill: #f1e8d8; stroke: #fffdf9; stroke-width: 0.7; }
.geomap .land path.named { fill: #dfc8a2; }
.geomap .pin circle { stroke: #ffffff; stroke-width: 2.5; filter: drop-shadow(0 0 5px rgba(184, 77, 42, 0.45)) drop-shadow(0 2px 3px rgba(60, 40, 20, 0.35)); }
.geomap .pin text { font: 600 12.5px "DM Sans", sans-serif; }

/* Chapters: tiles with a colored edge and a shiny progress bar. */
.story-chapters { gap: 10px; padding-top: 8px; }
.sc-head { font: italic 0.92rem "Fraunces", serif; color: var(--ink-soft); }
.sc-bar { height: 10px; }
.sc-bar div { position: relative; background: linear-gradient(90deg, #c9572f, #e9925f 60%, #f2b48a); }
.sc-bar div::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent 60%); }
.sc-list { gap: 6px 10px; }
.sc-list li { padding: 6px 9px; background: rgba(255, 255, 255, 0.55); border: 1px solid rgba(230, 220, 203, 0.65); border-left: 3px solid var(--c); box-shadow: 0 1px 2px rgba(60, 40, 20, 0.04); }
.sc-list li.done { background: linear-gradient(90deg, color-mix(in srgb, var(--c) 10%, #ffffff), rgba(255, 255, 255, 0.7)); }
.sc-list li.current { background: #ffffff; border-color: rgba(230, 220, 203, 0.9); border-left-color: var(--c); }

/* Center: a halo behind the talk button and a frosted caption. */
.voice-mode .vm-orb { isolation: isolate; }
.voice-mode .vm-orb::before {
  content: ""; position: absolute; inset: -24%; border-radius: 50%; z-index: -1; filter: blur(6px);
  background: radial-gradient(circle, rgba(233, 146, 95, 0.32), rgba(233, 146, 95, 0.08) 45%, transparent 68%);
  transition: background 0.4s;
}
.voice-mode[data-state="listening"] .vm-orb::before, .voice-mode[data-state="hearing"] .vm-orb::before {
  background: radial-gradient(circle, rgba(111, 143, 114, 0.34), rgba(111, 143, 114, 0.08) 45%, transparent 68%);
}
/* Penny the robot (face.js) in the talk button: a glossy cream head with a
   dark screen face. Her eyes, mouth and antenna bulb glow in the state's
   color: mint while she listens, warm white while she thinks or talks, dim
   while paused. */
.voice-mode[data-state] .vm-core {
  --glow: #fff1df;
  --disc: #e9a988;
  overflow: visible; animation: none !important;
  /* A soft disc behind her, tinted by the state, so the button still reads as one. */
  background: radial-gradient(circle at 50% 32%, #fffdf9, color-mix(in srgb, var(--disc) 26%, #fffdf9) 58%, color-mix(in srgb, var(--disc) 48%, #f3eadb));
  box-shadow: inset 0 2px 5px rgba(255, 255, 255, 0.9), inset 0 -12px 26px color-mix(in srgb, var(--disc) 30%, transparent), 0 14px 34px rgba(60, 40, 20, 0.16);
  transform: scale(calc(0.98 + var(--level) * 0.04));
  transition: transform 0.12s linear, background 0.4s, box-shadow 0.4s;
}
.voice-mode[data-state="listening"] .vm-core, .voice-mode[data-state="hearing"] .vm-core, .voice-mode[data-state="transcribing"] .vm-core { --glow: #8ff5dc; --disc: var(--sage); }
.voice-mode[data-state="paused"] .vm-core, .voice-mode[data-state="loading"] .vm-core, .voice-mode[data-state="off"] .vm-core { --glow: #9aa7ad; --disc: #c9bba6; }
/* The patience circle: thick and glowing, around her. */
.voice-mode .vm-ring { z-index: 2; pointer-events: none; }
.voice-mode .vm-ring circle { stroke-width: 5; }
.voice-mode .vm-ring-track { stroke: rgba(111, 143, 114, 0.18); }
.voice-mode .vm-ring-fill { stroke: #5f8f68; filter: drop-shadow(0 0 3px rgba(95, 143, 104, 0.75)); }
.penny-face {
  position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible;
  color: var(--glow); transition: color 0.5s;
  filter: drop-shadow(0 6px 10px rgba(60, 40, 20, 0.16)) drop-shadow(0 1px 2px rgba(60, 40, 20, 0.12));
}
.penny-face .pf-shell, .penny-face .pf-hand { stroke: rgba(150, 120, 95, 0.35); stroke-width: 0.5; }
.penny-face .pf-ear { stroke: #8a3519; stroke-width: 0.6; }
.penny-face .pf-stem { stroke: #c9b29c; stroke-width: 2; stroke-linecap: round; }
.penny-face .pf-bulb { fill: var(--glow); }
.penny-face .pf-blush { fill: #f2849a; opacity: 0.75; }
.penny-face .pf-screen { stroke: #0b0c0e; stroke-width: 1; }
.penny-face .pf-gloss { fill: none; stroke: rgba(255, 255, 255, 0.16); stroke-width: 2.6; stroke-linecap: round; }
.penny-face .pf-shadow { fill: rgba(60, 40, 20, 0.35); }
.penny-face .pf-glow { opacity: 0.96; }
.voice-mode[data-state="paused"] .pf-glow, .voice-mode[data-state="loading"] .pf-glow { opacity: 0.6; }

.voice-mode .vm-caption:not(:empty) {
  padding: 12px 16px; border-radius: 16px; color: var(--ink);
  background: rgba(255, 253, 249, 0.72); border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 1px 2px rgba(60, 40, 20, 0.05), 0 8px 22px rgba(60, 40, 20, 0.08), inset 0 1px 0 #fff;
  backdrop-filter: blur(8px);
}
.voice-mode .vm-controls .btn.ghost { background: rgba(255, 253, 249, 0.85); box-shadow: 0 1px 2px rgba(60, 40, 20, 0.06), 0 6px 16px rgba(60, 40, 20, 0.08), inset 0 1px 0 #fff; }
