:root {
  --bg: #120c10;
  --bg-2: #1c1318;
  --ink: #f6eee6;
  --ink-2: #c9b9ad;
  --ink-3: #8d7b70;
  --line: rgba(246, 238, 230, .12);
  --beak: #f2d65c;
  --beak-2: #fff3b8;
  --vest: #cdbba2;
  --you: #8fb8ff;
  --live: #6ee7a8;
  --radius: 16px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 80% at 30% 0%, #2a1a1c 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
  min-height: 100dvh;
  overflow-x: hidden;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.bar {
  display: flex; align-items: center; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
}
.bar .back { color: var(--ink-2); text-decoration: none; font-size: 14px; white-space: nowrap; }
.bar .back:hover { color: var(--ink); }
.bar .brand { margin: 0 auto; display: flex; }
.bar .brand { color: var(--ink); text-decoration: none; font-weight: 650; font-size: 14px; letter-spacing: .02em; }
.bar .build-id { font-size: 12px; color: var(--ink-3); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }

.room {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr);
  min-height: 0;
}

.stage { position: relative; min-height: 0; }
#stage { display: block; width: 100%; height: 100%; touch-action: none; }
.truth {
  position: absolute; left: 16px; top: 14px;
  font-size: 12px; letter-spacing: .02em; color: var(--ink-2);
  background: rgba(18, 12, 16, .62); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 999px; backdrop-filter: blur(6px);
}
.truth .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--live); margin-right: 7px; vertical-align: 1px; box-shadow: 0 0 0 3px rgba(110, 231, 168, .18); }
.mood {
  position: absolute; right: 16px; top: 14px; text-align: right;
  background: rgba(18, 12, 16, .62); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px 12px; backdrop-filter: blur(6px);
  transition: border-color .4s;
}
.mood small { display: block; font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; }
.mood b { font-size: 18px; color: var(--beak-2); text-transform: capitalize; }
.mood.changed { border-color: var(--beak); }
.loading {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 10px;
  color: var(--ink-2); background: rgba(18, 12, 16, .5);
}
.loading.done { display: none; }
.loading progress { width: 180px; accent-color: var(--beak); }
.caption {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  width: min(92%, 640px); margin: 0; text-align: center;
  font-size: 17px; line-height: 1.35; color: var(--ink);
  text-shadow: 0 1px 2px rgba(0,0,0,.8), 0 0 18px rgba(0,0,0,.6);
  min-height: 1.35em;
}

.graph {
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
  background: rgba(28, 19, 24, .55);
}
.graph-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--beak); }
.graph h1 { margin: 2px 0 0; font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.graph h1 em { font-style: normal; font-weight: 400; color: var(--ink-3); font-size: 15px; }
.graph-meta { margin: 0; color: var(--ink-3); font-size: 13px; white-space: nowrap; }

.nodes { list-style: none; margin: 0; padding: 16px 18px 24px 34px; overflow-y: auto; flex: 1; position: relative; }
.node {
  position: relative; margin: 0 0 14px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: rgba(18, 12, 16, .7);
  animation: grow .45s cubic-bezier(.2, .8, .2, 1) both;
}
.node::before { /* the node */
  content: ""; position: absolute; left: -22px; top: 15px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--ink-3);
}
.node::after { /* the edge to the next node */
  content: ""; position: absolute; left: -17px; top: 28px; bottom: -16px; width: 2px; background: var(--line);
}
.node:last-child::after { display: none; }
.node .who { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.node p { margin: 4px 0 0; }
.node.you::before { border-color: var(--you); }
.node.you .who { color: var(--you); }
.node.him::before { border-color: var(--beak); background: var(--beak); }
.node.him .who { color: var(--beak); }
.node .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; border-radius: 999px; padding: 2px 9px; border: 1px solid var(--line); color: var(--ink-2); }
.chip.emotion { border-color: rgba(240, 138, 36, .55); color: var(--beak-2); text-transform: capitalize; }
.chip.shift { border-color: rgba(110, 231, 168, .4); color: var(--live); }
.node.thinking p { color: var(--ink-3); }
.node.thinking p::after { content: "…"; animation: blink 1s steps(2) infinite; }
.node.error { border-color: rgba(255, 120, 120, .4); }
.node.seed p { color: var(--ink-2); font-size: 14px; }
@keyframes grow { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes blink { 50% { opacity: 0; } }

.composer {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 16px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: rgba(18, 12, 16, .92);
  position: sticky; bottom: 0; z-index: 2;
}
.composer input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 11px 16px; outline: none;
}
.composer input:focus { border-color: var(--beak); }
.composer button { font: inherit; cursor: pointer; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); background: var(--bg-2); }
.composer .send { padding: 11px 18px; background: var(--beak); border-color: var(--beak); color: #1b0f05; font-weight: 650; }
.composer button:disabled { opacity: .5; cursor: default; }
.composer .mic { position: relative; width: 44px; height: 44px; display: grid; place-items: center; flex: none; overflow: hidden; }
.composer .mic svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; position: relative; z-index: 1; }
.composer .mic i { position: absolute; inset: auto 0 0 0; height: 0; background: rgba(240, 138, 36, .45); transition: height .08s; }
.composer .mic.recording { border-color: var(--beak); color: var(--beak-2); }
.status { margin: 0; padding: 0 16px 6px; min-height: 1.2em; font-size: 12px; color: var(--ink-3); text-align: center; background: rgba(18, 12, 16, .92); }

@media (max-width: 820px) {
  .room { grid-template-columns: 1fr; grid-template-rows: minmax(52dvh, 58dvh) auto; }
  .graph { border-left: 0; border-top: 1px solid var(--line); }
  .nodes { max-height: none; overflow: visible; }
  .caption { font-size: 15px; bottom: 10px; }
  .mood b { font-size: 16px; }

}
