/* A quiet, paper-like look: serif for what people said and what was learned, sans for controls. */
:root {
  --paper: #f5f1ea;
  --sheet: #fbf9f5;
  --card: #ffffff;
  --ink: #1c1a17;
  --ink-2: #4a453e;
  --muted: #8a8277;
  --line: #e6dfd3;
  --line-2: #d9d0c2;
  --accent: #2b5d4f;
  --accent-2: #e3eee9;
  --warm: #b4572e;
  --warm-2: #f6e6dc;
  --danger: #a8392a;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, ui-serif, serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --r: 14px;
  --shadow: 0 1px 2px rgba(40, 30, 20, 0.04), 0 4px 16px rgba(40, 30, 20, 0.05);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--danger); font-size: 14px; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: 0.55; cursor: default; }
input, textarea { font: inherit; color: var(--ink); }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.display { font: 400 clamp(34px, 6vw, 52px)/1.08 var(--serif); letter-spacing: -0.015em; margin: 0; }
.lede { color: var(--ink-2); font-size: 17px; line-height: 1.55; margin: 14px 0 0; max-width: 34em; }
h2 { font: 600 12px/1 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; }
h3 { font: 600 12px/1.3 var(--sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 22px 0 8px; }

/* ---------- start ---------- */
.start { min-height: 100vh; display: grid; place-items: center; padding: 32px 22px; }
.start-inner { width: 100%; max-width: 520px; }
.name-input { display: block; width: 100%; margin: 34px 0 0; padding: 6px 0 10px; border: 0; border-bottom: 1.5px solid var(--line-2); background: transparent; font: 400 30px/1.2 var(--serif); }
.name-input::placeholder { color: #bdb3a5; }
.name-input:focus { outline: none; border-color: var(--accent); }
.returning { margin-top: 14px; padding: 10px 14px; border-radius: 10px; background: var(--accent-2); color: var(--accent); font-size: 14px; }
.link-box { margin-top: 18px; font-size: 14px; color: var(--muted); }
.link-box summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.link-box summary::before { content: '+'; font-size: 16px; line-height: 1; }
.link-box[open] summary::before { content: '–'; }
.link-box summary::-webkit-details-marker { display: none; }
.link-box input { display: block; width: 100%; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.hint { margin: 6px 0 0; font-size: 12.5px; }
.lab { margin-top: 18px; display: grid; gap: 10px; font-size: 13px; }
.lab input, .lab textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.start-actions { display: flex; align-items: center; gap: 18px; margin-top: 34px; flex-wrap: wrap; }
.call-btn { display: inline-flex; align-items: center; gap: 10px; padding: 15px 26px 15px 22px; border: 0; border-radius: 999px; background: var(--ink); color: var(--paper); font-size: 16px; font-weight: 600; box-shadow: var(--shadow); transition: transform 0.12s ease, background 0.2s; }
.call-btn:hover { background: #000; }
.call-btn:active { transform: scale(0.98); }
.call-btn .ico { width: 20px; height: 20px; fill: currentColor; }
.call-btn.connecting .ico { animation: pulse 1s infinite; }
.call-btn.small { padding: 11px 20px; font-size: 14px; }
.text-btn { background: none; border: 0; padding: 4px 0; color: var(--ink-2); font-size: 14px; text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 4px; }
.text-btn:hover { color: var(--ink); text-decoration-color: currentColor; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- call ---------- */
.call { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--paper); }
.who { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.who b { font: 400 20px/1.2 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.actions { display: flex; align-items: center; gap: 8px; }
.pill { padding: 7px 13px; border: 1px solid var(--line-2); border-radius: 999px; background: transparent; font-size: 13px; color: var(--ink-2); }
.pill:hover { background: var(--sheet); }
.pill[aria-pressed='true'] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.nb-toggle { display: none; }
.nb-toggle span { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--accent-2); color: var(--accent); font-size: 11px; font-weight: 700; text-align: center; }
.end-btn { padding: 8px 16px; border: 0; border-radius: 999px; background: var(--danger); color: #fff; font-size: 13px; font-weight: 600; }
.end-btn:hover { filter: brightness(1.08); }
body[data-mode='text'] #mute, body[data-mode='text'] #quiet { display: none; }

.stage { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 420px); }
.convo { min-height: 0; display: flex; flex-direction: column; }

.presence { --lvl: 0; display: flex; align-items: center; gap: 14px; padding: 18px 28px 6px; }
.orb { position: relative; width: 44px; height: 44px; flex: none; }
.orb::before, .orb span { content: ''; position: absolute; inset: 0; border-radius: 50%; }
.orb::before { background: var(--accent); opacity: 0.14; transform: scale(calc(1 + var(--lvl) * 0.9)); transition: transform 80ms linear; }
.orb span { inset: 10px; background: var(--accent); transition: background 0.3s; }
.presence[data-state='you'] .orb span, .presence[data-state='you'] .orb::before { background: var(--warm); }
.presence[data-state='connecting'] .orb span, .presence[data-state='thinking'] .orb span { animation: pulse 1.1s infinite; }
.presence[data-state='ended'] .orb span, .presence[data-state='ended'] .orb::before { background: var(--line-2); }
.presence-text { font-size: 13px; letter-spacing: 0.04em; color: var(--muted); }
body[data-mode='text'] .presence { padding-top: 14px; }
body[data-mode='text'] .orb { width: 28px; height: 28px; }
body[data-mode='text'] .orb span { inset: 7px; }

.transcript { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 28px 20px; display: flex; flex-direction: column; gap: 18px; scroll-behavior: smooth; }
.line { max-width: 44em; }
.line .speaker { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.line .text { display: block; font: 400 19px/1.5 var(--serif); white-space: pre-wrap; }
.line.agent .speaker { color: var(--accent); }
.line.person .text { color: var(--ink-2); }
.line.partial .text::after { content: ' ▍'; color: var(--warm); animation: pulse 1s infinite; }
.line.error .text { color: var(--danger); font: 14px/1.5 var(--sans); }
.composer { display: flex; gap: 8px; margin: 0 28px 20px; padding: 6px 6px 6px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); box-shadow: var(--shadow); }
.composer input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 15px; }
.composer input:focus { outline: none; }
.composer button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--ink); display: grid; place-items: center; }
.composer button svg { width: 17px; height: 17px; fill: var(--paper); }
body[data-mode='voice'] .composer { opacity: 0.75; box-shadow: none; }
body[data-mode='voice'] .composer:focus-within { opacity: 1; }

/* ---------- notebook ---------- */
.notebook { min-height: 0; overflow-y: auto; padding: 22px 22px 40px; background: var(--sheet); border-left: 1px solid var(--line); }
.nb-head { display: flex; align-items: baseline; justify-content: space-between; }
.nb-head h2 { margin: 0; }
.nb-state { font-size: 12px; color: var(--warm); animation: pulse 1.2s infinite; }
.who-line { margin: 12px 0 16px; font: italic 400 16px/1.45 var(--serif); color: var(--ink-2); }
.who-line:empty { display: none; }
.bg-box { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
.bg-box summary { cursor: pointer; }
.bg-box p { margin: 6px 0 0; line-height: 1.5; }
.nb { display: flex; flex-direction: column; gap: 6px; }
.nb-empty { margin: 18px 0; color: var(--muted); font: italic 15px/1.5 var(--serif); }
.nb details > summary { list-style: none; cursor: pointer; }
.nb details > summary::-webkit-details-marker { display: none; }
.nb-dir { margin-top: 8px; }
.nb-dir > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; padding: 4px 0; }
.nb-dir > summary::before { content: ''; width: 5px; height: 5px; margin: 0 3px 2px 1px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform 0.15s; align-self: center; }
.nb-dir[open] > summary::before { transform: rotate(45deg); }
.nb-dirname { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.nb-count { margin-left: auto; font-size: 11px; color: var(--muted); }
.nb-desc { flex-basis: 100%; padding-left: 18px; font-size: 12.5px; color: var(--muted); line-height: 1.4; margin-top: 2px; }
.nb-children { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 4px 5px; padding-left: 12px; border-left: 1px solid var(--line); }
.nb-note { background: var(--card); border: 1px solid var(--line); border-radius: 10px; transition: border-color 0.3s, box-shadow 0.3s; }
.nb-note > summary { padding: 10px 12px; }
.nb-title { font: 600 15px/1.3 var(--serif); }
.nb-sum { display: block; margin-top: 2px; font-size: 13px; line-height: 1.4; color: var(--muted); }
.nb-note[open] .nb-sum { display: none; }
.nb-body { padding: 0 14px 12px; font: 15px/1.5 var(--serif); color: var(--ink-2); }
.nb-body p { margin: 0 0 6px; }
.nb-body ul { margin: 0; padding-left: 18px; }
.nb-body li { margin: 3px 0; }
.nb-body q { font-style: italic; color: var(--ink); }
.nb-body q::before { content: '“'; } .nb-body q::after { content: '”'; }
.nb-badge { margin-left: 8px; padding: 1px 7px; border-radius: 6px; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; vertical-align: 2px; }
.nb-note.is-add { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-2); animation: rise 0.4s ease-out; }
.nb-note.is-add .nb-badge { background: var(--accent); color: #fff; }
.nb-note.is-edit { border-color: #d9b49f; box-shadow: 0 0 0 3px var(--warm-2); }
.nb-note.is-edit .nb-badge { background: var(--warm-2); color: var(--warm); }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }
.open-box { margin-top: 22px; padding-top: 4px; border-top: 1px dashed var(--line-2); }
.open-box ul { margin: 0; padding-left: 18px; font-size: 14px; color: var(--ink-2); }
.open-box li { margin: 4px 0; }

/* ---------- after ---------- */
.after { min-height: 100vh; padding: 56px 22px 80px; }
.after-inner { max-width: 1040px; margin: 0 auto; }
.after .lede { font: italic 400 19px/1.5 var(--serif); }
.after-actions { display: flex; align-items: center; gap: 20px; margin: 26px 0 40px; flex-wrap: wrap; }
.after-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 40px; align-items: start; }
.headline { font: 400 18px/1.5 var(--serif); margin: 0 0 18px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats div { padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.stats b { display: block; font: 400 28px/1.1 var(--serif); }
.stats span { font-size: 12px; color: var(--muted); }
.report ul { margin: 0; padding-left: 18px; line-height: 1.5; }
.report li { margin: 4px 0; }
.curve { display: flex; align-items: flex-end; gap: 3px; height: 56px; padding-bottom: 1px; border-bottom: 1px solid var(--line-2); }
.curve i { flex: 1; max-width: 16px; min-height: 2px; height: calc(var(--h) * 100%); background: var(--accent); border-radius: 3px 3px 0 0; opacity: 0.85; }
.golden { list-style: none; padding: 0 !important; }
.golden li span { display: inline-block; width: 64px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.golden .yes span { color: var(--accent); } .golden .partial span { color: #a77b14; } .golden .no span { color: var(--danger); }
.review { margin-top: 26px; font-size: 14px; color: var(--ink-2); }
.review summary { cursor: pointer; color: var(--muted); }

/* ---------- people / eval ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: 44px 22px 80px; }
.page .display { font-size: clamp(30px, 5vw, 42px); }
.page .person-name { font-size: 32px; }
.page-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 32px; margin-top: 28px; align-items: start; }
.people-list { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 20px; }
.person-row { text-align: left; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; }
.person-row:hover { background: var(--sheet); }
.person-row.on { background: var(--card); box-shadow: var(--shadow); }
.person-row b { display: block; font: 400 17px/1.3 var(--serif); }
.person-row span { font-size: 12.5px; color: var(--muted); }
.tabs { display: flex; gap: 4px; margin: 18px 0 16px; border-bottom: 1px solid var(--line); }
.tabs button { padding: 8px 12px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-size: 14px; margin-bottom: -1px; }
.tabs button.on { color: var(--ink); border-color: var(--ink); }
.session-head { margin: 22px 0 6px; font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.page .transcript { padding: 0; overflow: visible; }

.eval-table { border-collapse: collapse; width: 100%; margin: 8px 0 28px; font-size: 14px; background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.eval-table th, .eval-table td { border-bottom: 1px solid var(--line); padding: 9px 12px; text-align: left; }
.eval-table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.eval-table td:not(:first-child), .eval-table th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.run { border-top: 1px solid var(--line); padding: 14px 0; }
.run h3 { margin-top: 4px; }
.run details { margin: 6px 0; font-size: 14px; }
.run summary { cursor: pointer; color: var(--ink-2); }
.facts { list-style: none; padding: 0; margin: 8px 0; }
.facts li { padding: 3px 0; line-height: 1.4; }
.mk { display: inline-block; width: 16px; color: var(--accent); }
.tag { display: inline-block; margin-right: 6px; padding: 1px 6px; border-radius: 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; background: var(--line); color: var(--ink-2); }
.tag.new { background: var(--accent); color: #fff; }
.run .transcript { max-height: 560px; overflow-y: auto; margin-top: 8px; padding: 0; gap: 12px; }
.run .line .text { font-size: 15px; }
.sub { color: var(--ink-2); line-height: 1.55; max-width: 52em; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; position: relative; }
  .nb-toggle { display: inline-block; }
  .notebook { position: fixed; left: 0; right: 0; bottom: 0; height: 78dvh; z-index: 5; border-left: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; box-shadow: 0 -10px 40px rgba(40, 30, 20, 0.15); transform: translateY(105%); transition: transform 0.28s ease; }
  body.nb-open .notebook { transform: none; }
  .topbar { padding: 10px 14px; }
  .actions { gap: 6px; }
  .pill { padding: 6px 10px; font-size: 12.5px; }
  .end-btn { padding: 7px 12px; }
  .presence { padding: 14px 18px 4px; }
  .transcript { padding: 8px 18px 16px; }
  .line .text { font-size: 17px; }
  .composer { margin: 0 14px 14px; }
  .after-grid, .page-grid { grid-template-columns: 1fr; }
  .people-list { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .who b { font-size: 17px; }
}
