:root {
  --bg: #f6f1e7; --panel: #fffaf1; --ink: #2b2620; --muted: #7b7063; --line: #e4d9c6;
  --accent: #9a6b2f; --adam: #a8612b; --eve: #b04a67; --god: #b08a1e; --serpent: #2f7a6d; --animal: #6f6a5c; --world: #5e6f86;
  --inner: #efe7d8; --major: #7c1f1f;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16140f; --panel: #1f1c16; --ink: #ece4d4; --muted: #9d927f; --line: #342f25;
    --accent: #d7a560; --adam: #e0945a; --eve: #e77e9b; --god: #e2c15a; --serpent: #5fc0ac; --animal: #aaa38f; --world: #93a6c2;
    --inner: #28241c; --major: #ff8f8f;
  }
}
:root[data-theme="dark"] {
  --bg: #16140f; --panel: #1f1c16; --ink: #ece4d4; --muted: #9d927f; --line: #342f25;
  --accent: #d7a560; --adam: #e0945a; --eve: #e77e9b; --god: #e2c15a; --serpent: #5fc0ac; --animal: #aaa38f; --world: #93a6c2;
  --inner: #28241c; --major: #ff8f8f;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.5; }
button, select, input { font: inherit; color: inherit; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.ghost { background: none; border-color: transparent; }
select, input { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; max-width: 100%; }
.muted { color: var(--muted); }

.top { display: flex; align-items: center; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand h1 { font-family: var(--serif); font-weight: 600; font-size: 30px; margin: 0; line-height: 1; letter-spacing: .5px; }
.brand .sub { color: var(--muted); font-size: 12px; }
.brand { display: flex; flex-direction: column; gap: 2px; }
.clock { font-family: var(--serif); font-size: 22px; flex: 1; text-align: center; min-width: 200px; }
.clock small { display: block; font-family: var(--sans); font-size: 12px; color: var(--muted); }
.meta { display: flex; gap: 8px; align-items: center; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); white-space: nowrap; }
.pill.running { border-color: #3d8b5a; color: #3d8b5a; }
.pill.paused, .pill.idle { color: var(--muted); }
.pill.budget-reached, .pill.error, .pill.retrying { border-color: var(--major); color: var(--major); }

.admin { display: flex; gap: 8px; padding: 10px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.zoom { display: flex; gap: 4px; padding: 10px 20px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.zoom button { border-radius: 99px; padding: 5px 16px; }
.zoom button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 0; min-height: calc(100vh - 160px); }
.story { padding: 16px 24px 80px; border-right: 1px solid var(--line); min-width: 0; }
.cast { padding: 16px; }
.cast h2 { font-family: var(--serif); font-weight: 600; font-size: 20px; margin: 0 0 10px; }
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .story { border-right: 0; padding: 12px 16px 40px; }
  .cast { border-top: 1px solid var(--line); }
  .top { padding: 12px 16px; }
  .clock { text-align: left; order: 3; flex-basis: 100%; }
}

.bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; position: sticky; top: 0; background: var(--bg); padding: 8px 0; z-index: 2; }
.bar .title { font-family: var(--serif); font-size: 20px; font-weight: 600; flex: 1; min-width: 160px; }
.bar label { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; }
.chip { font-size: 12px; padding: 2px 10px; border-radius: 99px; border: 1px solid var(--line); cursor: pointer; user-select: none; }
.chip.off { opacity: .35; }

.minute { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-top: 1px dashed var(--line); }
.minute .t { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; padding-top: 2px; }
.line { margin: 2px 0; }
.line .who { font-weight: 600; }
.line.speech .words { font-family: var(--serif); font-size: 18px; font-style: italic; }
.line.world, .line.prologue { color: var(--world); font-family: var(--serif); font-size: 17px; }
.line.prologue { font-style: italic; }
.line.major { color: var(--major); font-weight: 600; font-family: var(--serif); font-size: 19px; }
.line.move, .line.sleep, .line.wake, .line.birth, .line.sound { color: var(--muted); font-size: 14px; }
.inner { background: var(--inner); border-radius: 8px; padding: 6px 10px; margin: 4px 0; font-size: 13.5px; }
.inner .layer { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 6px; }
.inner .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding-top: 2px; }
.emo { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; }
.emo i { display: inline-block; height: 6px; border-radius: 3px; background: currentColor; opacity: .6; }
.c-adam { color: var(--adam); } .c-eve { color: var(--eve); } .c-god { color: var(--god); } .c-serpent { color: var(--serpent); } .c-animal { color: var(--animal); }
.b-adam { border-left: 3px solid var(--adam); } .b-eve { border-left: 3px solid var(--eve); } .b-god { border-left: 3px solid var(--god); } .b-serpent { border-left: 3px solid var(--serpent); } .b-animal { border-left: 3px solid var(--animal); }

.summary { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; margin-bottom: 12px; cursor: pointer; }
.summary:hover { border-color: var(--accent); }
.summary .when { color: var(--muted); font-size: 12px; }
.summary h3 { font-family: var(--serif); font-size: 22px; font-weight: 600; margin: 2px 0 8px; }
.summary .text { font-family: var(--serif); font-size: 18px; line-height: 1.55; white-space: pre-wrap; }
.empty { color: var(--muted); font-family: var(--serif); font-size: 18px; padding: 30px 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.card:hover { border-color: var(--accent); }
.card .name { font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.card .where { font-size: 12px; color: var(--muted); }
.card .thought { font-family: var(--serif); font-size: 16px; font-style: italic; margin-top: 4px; }
.bars { display: grid; grid-template-columns: 58px 1fr; gap: 2px 8px; font-size: 11px; color: var(--muted); margin-top: 6px; }
.bars .track { background: var(--inner); border-radius: 3px; height: 6px; margin-top: 5px; }
.bars .fill { background: var(--accent); height: 100%; border-radius: 3px; }
.cast .animals-h { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 16px 0 6px; }

.drawer { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; justify-content: flex-end; z-index: 10; }
.drawer[hidden] { display: none; }
.drawer-inner { width: min(560px, 100%); height: 100%; overflow-y: auto; background: var(--bg); padding: 20px 22px 60px; position: relative; }
.drawer .close { position: absolute; top: 10px; right: 10px; font-size: 18px; }
.drawer h2 { font-family: var(--serif); font-size: 28px; margin: 0 0 4px; }
.drawer h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 6px; }
.drawer .mem { font-size: 14px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.drawer .mem .when { color: var(--muted); font-size: 11px; }
.drawer .life { font-family: var(--serif); font-size: 17px; white-space: pre-wrap; }
.admin[hidden] { display: none; }
