:root {
  --bg: #faf8f4; --panel: #f1ede5; --text: #26231f; --muted: #7a7368;
  --line: #ddd6c8; --accent: #7a4b1e; --accent-text: #fff; --danger: #a33a2a;
  --page: #fffefb;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17150f; --panel: #1f1c15; --text: #e8e3d8; --muted: #9a9384;
    --line: #36322a; --accent: #d9a35f; --accent-text: #17150f; --danger: #e5826f;
    --page: #1b1912;
  }
}
:root[data-theme="dark"] {
  --bg: #17150f; --panel: #1f1c15; --text: #e8e3d8; --muted: #9a9384;
  --line: #36322a; --accent: #d9a35f; --accent-text: #17150f; --danger: #e5826f;
  --page: #1b1912;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, "Segoe UI", system-ui, sans-serif;
  display: flex; flex-direction: column;
}
h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 0.85rem; } .spacer { flex: 1; }

button {
  font: inherit; font-size: 0.9rem; color: var(--text); background: transparent;
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button:focus-visible, input:focus-visible, textarea:focus-visible, li:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.danger { color: var(--danger); }

#topbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  border-bottom: 1px solid var(--line); background: var(--panel);
  transition: opacity .25s;
}
.brand { font-weight: 600; letter-spacing: 0.02em; display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 30px; height: 30px; border-radius: 50%; display: block; }

#layout { flex: 1; display: grid; grid-template-columns: 230px 1fr 300px; min-height: 0; }
#stories-panel, #side-panel { background: var(--panel); padding: 14px; overflow-y: auto; overflow-x: hidden; }
#stories-panel { border-right: 1px solid var(--line); }
#side-panel { border-left: 1px solid var(--line); }
.tab { display: flex; flex-direction: column; gap: 22px; }
.tab[hidden] { display: none; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.panel-head h2 { margin: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

ul { list-style: none; margin: 0; padding: 0; }
#story-list li, #draft-list li {
  padding: 7px 9px; border-radius: 6px; cursor: pointer; border: 1px solid transparent;
}
#story-list li:hover, #draft-list li:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
#story-list li.active, #draft-list li.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
li .sub { display: block; font-size: 0.78rem; color: var(--muted); }

#editor-area { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
#editor-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; width: 100%; max-width: 820px; margin: 0 auto; padding: 20px 24px 0; }
#title-input {
  font: 600 1.6rem Georgia, "Times New Roman", serif; color: var(--text);
  background: transparent; border: none; border-bottom: 1px solid transparent; padding: 6px 0; margin-bottom: 8px;
}
#title-input:hover, #title-input:focus { border-bottom-color: var(--line); outline: none; }
#editor {
  flex: 1; resize: none; width: 100%; border: none; outline: none;
  background: var(--page); color: var(--text);
  font: 1.15rem/1.75 Georgia, "Times New Roman", serif;
  padding: 24px 28px; margin-bottom: 20px; border-radius: 8px;
  box-shadow: 0 0 0 1px var(--line);
}
#empty-state { margin: auto; text-align: center; color: var(--muted); }
#focus-hint { display: none; position: absolute; bottom: 34px; left: 0; right: 0; text-align: center; font-size: 0.8rem; opacity: 0; transition: opacity 1s; }

/* Focus mode: the page and nothing else */
body[data-mode="focus"] #stories-panel,
body[data-mode="focus"] #side-panel,
body[data-mode="focus"] #title-input { display: none; }
body[data-mode="focus"] #layout { grid-template-columns: 1fr; }
body[data-mode="focus"] #editor-wrap { max-width: none; padding: 36px 48px 0; } /* 48px = half an inch each side */
body[data-mode="focus"] #editor { box-shadow: none; background: var(--bg); font-size: 1.25rem; padding: 0; }
body[data-mode="focus"] #focus-hint { display: block; opacity: 0.7; }
body[data-mode="focus"] #focus-hint.faded { opacity: 0; }

dl#stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0; }
dl#stats dt { color: var(--muted); } dl#stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  #layout { grid-template-columns: 1fr; }
  #stories-panel, #side-panel { border: none; border-bottom: 1px solid var(--line); max-height: 30vh; }
}

select { font: inherit; font-size: 0.9rem; width: 100%; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px; }
.row.tight { margin: 0; gap: 6px; flex-wrap: nowrap; } .row.end { justify-content: flex-end; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
dialog { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 20px; width: min(560px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h3 { margin: 0 0 12px; }
dialog label { display: block; margin-bottom: 12px; font-size: 0.9rem; }
dialog label.inline { display: block; margin-bottom: 4px; }
dialog input[type=text], dialog input[type=password], dialog input[type=email], dialog input[type=number], dialog select, dialog textarea { display: block; width: 100%; margin-top: 4px; font: inherit; color: var(--text); background: var(--page); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
dialog input[type=file] { display: block; margin-top: 4px; }
dialog fieldset { border: none; padding: 0; margin: 0 0 12px; }

/* ---- Phase 2: tabs, beats, sprint, progress ---- */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 6px 10px; color: var(--muted); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.check { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
#beat-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; align-items: start; padding: 5px 4px; border-radius: 6px; border: 1px solid transparent; }
#beat-list li.current { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
#beat-list li.done .beat-text { text-decoration: line-through; color: var(--muted); }
#beat-list textarea.beat-text { width: 100%; resize: none; overflow: hidden; font: inherit; font-size: 0.9rem; line-height: 1.35; color: inherit; background: transparent; border: 1px solid transparent; border-radius: 4px; padding: 2px 4px; }
#beat-list textarea.beat-text:focus { border-color: var(--line); background: var(--page); outline: none; }
.beat-tools { display: flex; flex-direction: column; gap: 0; }
.beat-tools button { padding: 0 6px; font-size: 0.8rem; line-height: 1.5; border-color: transparent; color: var(--muted); }
.beat-tools button:hover { color: var(--text); border-color: var(--line); }
.beat-meta { grid-column: 2 / 4; font-size: 0.75rem; color: var(--muted); padding-left: 4px; }
#add-beat-form { margin: 8px 0; } #add-beat-form input { flex: 1; min-width: 0; font: inherit; font-size: 0.9rem; color: var(--text); background: var(--page); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
#reentry-body { font-size: 0.9rem; } #reentry-body .tail { color: var(--muted); font-family: Georgia, serif; font-style: italic; margin: 6px 0; padding-left: 8px; border-left: 2px solid var(--line); }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.statgrid div { text-align: center; } .statgrid dt { color: var(--muted); font-size: 0.75rem; } .statgrid dd { margin: 0; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 90px; padding-top: 6px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; font-size: 0.7rem; color: var(--muted); }
.chart .bar { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.chart .col.today .bar { opacity: 1; }
.meter { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 4px 0 10px; } .meter > div { height: 100%; background: var(--accent); }

#sprint-float { position: absolute; top: 8px; right: 16px; z-index: 5; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 0.9rem; box-shadow: 0 2px 10px rgba(0,0,0,.15); display: flex; gap: 10px; align-items: center; }
#sprint-float[hidden] { display: none; }
#sprint-float .time { font: 600 1.15rem ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; }
body[data-mode="focus"] #sprint-float { opacity: .55; transition: opacity .2s; } body[data-mode="focus"] #sprint-float:hover { opacity: 1; }
#welcome-banner { margin: 10px auto 0; max-width: 780px; width: calc(100% - 48px); background: color-mix(in srgb, var(--accent) 14%, var(--bg)); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 12px; font-size: 0.9rem; cursor: pointer; }
#welcome-banner[hidden] { display: none; }
#focus-beat { display: none; text-align: center; font-size: 0.85rem; padding: 0 24px 8px; }
body[data-mode="focus"] #focus-beat:not(:empty) { display: block; }

/* ---- Phase 3: check and library tabs ---- */
.tabs button { padding: 6px 4px; font-size: 0.78rem; flex: 1 1 auto; min-width: 0; }
#check-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; margin: 8px 0; font-size: 0.85rem; }
#check-toggles label { display: flex; gap: 5px; align-items: center; }
.scope { margin: 6px 0; gap: 12px; }
#check-results details { margin-top: 8px; }
#check-results summary { cursor: pointer; font-size: 0.9rem; font-weight: 600; }
.finding { margin: 6px 0 8px; padding: 6px 8px; border-left: 3px solid var(--line); border-radius: 0 6px 6px 0; background: color-mix(in srgb, var(--text) 4%, transparent); font-size: 0.85rem; }
.finding.issue { border-left-color: var(--danger); }
.finding .snip { cursor: pointer; font-family: Georgia, serif; word-break: break-word; }
.finding .snip:hover { text-decoration: underline dotted; }
.finding mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.finding .msg { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.finding .acts { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.finding .acts button { font-size: 0.75rem; padding: 1px 7px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.chip { display: inline-flex; gap: 4px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 1px 4px 1px 9px; font-size: 0.8rem; }
.chip button { border: none; padding: 0 5px; color: var(--muted); }
.lexgroup { margin-bottom: 12px; } .lexgroup h3 { font-size: 0.85rem; margin: 0 0 2px; } .lexgroup form { display: flex; gap: 4px; } .lexgroup input { flex: 1; min-width: 0; }
#tab-library label, #tab-check .lexgroup input, #lib-add-form label { display: block; }
#tab-library input[type=text], #tab-library textarea, #tab-library select, #tab-check .lexgroup input, #lib-add-form input, #lib-add-form textarea, #lib-add-form select { width: 100%; font: inherit; font-size: 0.88rem; color: var(--text); background: var(--page); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; margin: 2px 0 8px; }
.lexgroup input { margin: 0 !important; }
.card { margin: 8px 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 0.9rem; }
.card .cat { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.card .name { font-weight: 600; } .card .body { margin: 3px 0 6px; } .card .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.card .acts button { font-size: 0.78rem; padding: 1px 8px; }
.pill { border: 1px solid var(--line); border-radius: 12px; padding: 2px 10px; font-size: 0.82rem; cursor: pointer; }
.pill.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
#arc-list details { margin: 6px 0; } #arc-list summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; } #arc-list ol { margin: 6px 0 6px 18px; padding: 0; font-size: 0.85rem; }

/* ---- Phase 4: story bible ---- */
body[data-view="bible"] #layout { display: none; }
#bible-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#bible-tabs { display: flex; gap: 4px; padding: 6px 14px 0; border-bottom: 1px solid var(--line); background: var(--panel); }
#bible-tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 6px 12px; }
#bible-tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.bp { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px 1fr; }
#bible-view[hidden] { display: none; }
#bible-side { background: var(--panel); border-right: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
#bible-side input[type=search], #bible-side select, #bible-detail input[type=text], #bible-detail select, #bible-detail textarea, #bible-import-form input[type=text], #bible-import-form select {
  width: 100%; font: inherit; font-size: 0.9rem; color: var(--text); background: var(--page); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
#bible-side .filters select { min-width: 0; }
.small-btn { font-size: 0.78rem; padding: 1px 8px; }
#bible-list { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0 6px; min-height: 0; }
#bible-list li { padding: 6px 8px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
#bible-list li:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
#bible-list li.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
#bible-list .nm { display: flex; gap: 6px; align-items: baseline; } #bible-list .nm b { font-weight: 600; }
#bible-list .sub { font-size: 0.78rem; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--line); }
.dot.canon { background: #4a9a5b; } .dot.proposed { background: #c79a3a; } .dot.retired { background: #8a8a8a; }
.badge { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; }
#bible-detail { padding: 18px 28px; overflow-y: auto; min-height: 0; }
#bible-empty { margin: 60px auto; text-align: center; }
#bible-form { max-width: 820px; display: flex; flex-direction: column; gap: 12px; }
#bible-form .head { align-items: center; } #bible-form h2 { font-size: 1.1rem; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0; }
#bible-form label, #bible-import-form label { display: block; font-size: 0.85rem; color: var(--muted); }
#bible-form label > input, #bible-form label > select, #bible-form label > textarea { margin-top: 3px; color: var(--text); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; } .grid2 .span2 { grid-column: 1 / -1; }
.block h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 6px 0; }
.chip a { color: var(--text); text-decoration: underline dotted; cursor: pointer; }
.chip.linked { border-color: var(--accent); }
#bible-form textarea { resize: vertical; line-height: 1.45; }
@media (max-width: 900px) { .bp { grid-template-columns: 1fr; } #bible-side, .sm-side { max-height: 40vh; } }

[hidden] { display: none !important; }

/* ---- story map panes ---- */
.sm-side { background: var(--panel); border-right: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; }
.sm-main { padding: 18px 28px; overflow-y: auto; min-height: 0; }
.sm input[type=text], .sm input[type=search], .sm select, .sm textarea { width: 100%; font: inherit; font-size: 0.9rem; color: var(--text); background: var(--page); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
.sm textarea { resize: vertical; line-height: 1.45; }
.sm label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; } .sm label > * { margin-top: 3px; color: var(--text); }
.sm .list { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; flex: 1; }
.sm .list li { padding: 6px 8px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.sm .list li:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.sm .list li.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.sm .list .sub { font-size: 0.78rem; color: var(--muted); }
.sm .banner { padding: 8px 10px; border: 1px solid var(--accent); border-radius: 8px; background: color-mix(in srgb, var(--accent) 12%, transparent); font-size: 0.88rem; }
.sm .head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; } .sm .head h2 { font-size: 1.1rem; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0; flex: 1; }
.sm .card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 0 0 14px; }
.sm .evt { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--line); font-size: 0.9rem; }
.sm .evt:first-of-type { border-top: none; }
.sm .stage { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.sm .stage:first-of-type { border-top: none; } .sm .stage .lbl { font-weight: 600; font-size: 0.9rem; } .sm .stage .rest { grid-column: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sm .stage textarea { grid-column: 1 / -1; }
.sm .kn { display: grid; grid-template-columns: 1fr 140px 1fr auto; gap: 8px; align-items: center; padding: 4px 0; }
.sm .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.sm .meter { margin: 2px 0 8px; }
.sm .tag { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .05em; border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; color: var(--muted); }
.sm .dot.open { background: #c79a3a; } .sm .dot.developing { background: #5b8fc9; } .sm .dot.resolved { background: #4a9a5b; } .sm .dot.dropped { background: #8a8a8a; }
.sm .warn { color: var(--danger); }

#live-toast { position: fixed; left: 14px; bottom: 14px; z-index: 20; background: var(--panel); color: var(--text); border: 1px solid var(--accent); border-radius: 8px; padding: 6px 12px; font-size: 0.85rem; box-shadow: 0 2px 10px rgba(0,0,0,.2); }

/* ---- Claude usage and extraction ---- */
#usage-btn { font-variant-numeric: tabular-nums; }
#usage-btn.warn { border-color: var(--danger); color: var(--danger); }
#usage-dialog h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 6px; }
#usage-dialog .big { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
#usage-dialog input[type=password], #usage-dialog input[type=number], #usage-dialog select { width: 100%; font: inherit; font-size: 0.9rem; color: var(--text); background: var(--page); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
#usage-dialog { width: min(640px, 94vw); max-height: 90vh; overflow-y: auto; }
#u-recent table { width: 100%; border-collapse: collapse; } #u-recent td { padding: 2px 6px 2px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.sm .src { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; padding: 5px 4px; border-radius: 6px; font-size: 0.88rem; }
.sm .src .sub { grid-column: 2; font-size: 0.76rem; color: var(--muted); }
.sm .prop { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; }
.sm .prop.upd { border-left: 3px solid #5b8fc9; } .sm .prop.new { border-left: 3px solid #4a9a5b; }
.sm .prop .top { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.sm .prop .top input[type=text] { flex: 1; font-weight: 600; }
.sm .prop .acts { display: flex; gap: 8px; margin-top: 6px; }
.sm .group-head { display: flex; align-items: center; gap: 8px; margin: 14px 0 8px; } .sm .group-head h3 { flex: 1; margin: 0; font-size: 1rem; }
.sm .tag.pending { color: var(--accent); border-color: var(--accent); }

/* ---- worlds, copy, history ---- */
#world-select { max-width: 200px; font: inherit; font-size: 0.9rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
#world-dialog, #copy-dialog, #deleted-dialog { width: min(520px, 94vw); }
#world-dialog input[type=text], #world-dialog textarea, #copy-dialog select, #story-world { width: 100%; font: inherit; font-size: 0.9rem; color: var(--text); background: var(--page); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; margin: 3px 0 10px; }
#bf-hist .h { padding: 6px 0; border-top: 1px solid var(--line); } #bf-hist .h:first-child { border-top: none; }
#bf-hist .chg { color: var(--muted); font-size: 0.8rem; margin: 2px 0 0 10px; word-break: break-word; }
#dl-list .h { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); } #dl-list .h span { flex: 1; }

.danger-box { border: 1px solid var(--danger); border-radius: 8px; padding: 10px 12px; margin: 8px 0 12px; }
.danger-box input[type=text] { width: 100%; margin: 6px 0 8px; }
#trash-dialog { width: min(600px, 94vw); } #tr-list .w { border-top: 1px solid var(--line); padding: 8px 0; } #tr-list .w:first-child { border-top: none; }
#tr-list .w .row { margin-top: 6px; } #tr-list input[type=text], #tr-requests input { width: 100%; font: inherit; font-size: 0.9rem; color: var(--text); background: var(--page); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }

/* ---- Phase 5: help ---- */
.tabs { flex-wrap: wrap; }
#hp-sel { padding: 6px 8px; border: 1px dashed var(--line); border-radius: 6px; margin-bottom: 4px; word-break: break-word; }
#help-ui select, #help-ui textarea { width: 100%; font: inherit; font-size: 0.88rem; color: var(--text); background: var(--page); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; margin-top: 3px; }
#help-ui label { display: block; margin-bottom: 8px; }
.hp-res .headline { font-weight: 600; margin: 0 0 8px; }
.hp-res h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 0 4px; }
.hp-res ul { margin: 0; padding-left: 18px; font-size: 0.9rem; } .hp-res li { margin: 3px 0; }
.hp-alt { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-family: Georgia, serif; font-size: 0.92rem; }
.hp-alt button { margin-top: 6px; font-family: system-ui, sans-serif; font-size: 0.75rem; padding: 1px 8px; }
.hp-foot { margin-top: 10px; font-size: 0.78rem; color: var(--muted); }
#hp-history .h { padding: 5px 0; border-top: 1px solid var(--line); cursor: pointer; } #hp-history .h:first-child { border-top: none; } #hp-history .h:hover { color: var(--accent); }
#help-dialog { width: min(560px, 94vw); max-height: 90vh; overflow-y: auto; }

/* ---- reader's review ---- */
#review-dialog { width: min(780px, 95vw); max-height: 92vh; overflow-y: auto; }
#review-dialog textarea, #review-dialog select { width: 100%; font: inherit; font-size: 0.92rem; color: var(--text); background: var(--page); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; margin: 3px 0 10px; }
#review-dialog label { display: block; font-size: 0.85rem; color: var(--muted); }
.rv h2 { font-size: 1.25rem; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0 0 2px; }
.rv .meta { font-size: 0.8rem; color: var(--muted); margin-bottom: 14px; }
.rv .impression { font-size: 1.02rem; line-height: 1.55; margin: 0 0 12px; }
.rv .verdict { border-left: 3px solid var(--accent); padding: 8px 12px; margin: 0 0 6px; background: color-mix(in srgb, var(--accent) 10%, transparent); font-weight: 600; border-radius: 0 8px 8px 0; }
.rv h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 18px 0 6px; }
.rv ul { margin: 0; padding-left: 18px; } .rv li { margin: 5px 0; line-height: 1.45; } .rv li .where { color: var(--muted); font-size: 0.85rem; }
.rv .topic { font-weight: 600; }
.rv .att { list-style: none; padding-left: 0; } .rv .att li { display: grid; grid-template-columns: 92px 1fr; gap: 8px; align-items: baseline; }
.rv .state { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .05em; border-radius: 10px; padding: 1px 8px; text-align: center; border: 1px solid var(--line); }
.rv .state.gripped { background: #4a9a5b; color: #fff; border-color: #4a9a5b; } .rv .state.engaged { border-color: #4a9a5b; color: #4a9a5b; }
.rv .state.drifting { border-color: #c79a3a; color: #c79a3a; } .rv .state.confused { border-color: #d27a3a; color: #d27a3a; } .rv .state.lost { background: var(--danger); color: #fff; border-color: var(--danger); }
.rv .foot { margin-top: 18px; font-size: 0.8rem; color: var(--muted); }
#review-hist .h { padding: 6px 0; border-top: 1px solid var(--line); cursor: pointer; font-size: 0.88rem; } #review-hist .h:hover { color: var(--accent); }
.story-picker { position: relative; margin: 6px 0; }
.story-picker[hidden] { display: none; }
.story-picker-btn { width: 100%; text-align: left; display: flex; gap: 4px; align-items: baseline; overflow: hidden; white-space: nowrap; }
.story-picker-btn b { overflow: hidden; text-overflow: ellipsis; flex: 1; font-weight: 600; }
.story-picker-menu { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; max-height: 50vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 0; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.story-opt { display: flex; gap: 6px; align-items: center; padding: 4px 10px; cursor: pointer; font-size: 0.9rem; }
.story-opt:hover { background: var(--line); }
.story-note { padding: 4px 10px; }
/* ---- accounts ---- */
body.login-page { display: grid; place-items: center; min-height: 100vh; margin: 0; padding: 16px; }
.login-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px 28px 22px; }
.login-brand { justify-content: center; margin-bottom: 14px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form h1 { font-size: 1.3rem; margin: 0; }
.login-form label { display: block; font-size: 0.9rem; }
.login-form input { display: block; width: 100%; margin-top: 4px; font: inherit; color: var(--text); background: var(--page); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; box-sizing: border-box; }
.login-form button { padding: 9px 12px; }
.login-msg { min-height: 1.4em; margin-top: 12px; color: #d8665a; font-size: 0.9rem; }
#readonly-banner { margin: 8px 24px 0; padding: 8px 12px; border: 1px solid var(--accent); border-radius: 8px; font-size: 0.9rem; }
.shared-h { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 6px; }
#account-dialog h4, #people-dialog h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 6px; }
#wd-members h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 6px; }
.admin-only[hidden] { display: none; }

#people-dialog { width: min(680px, 94vw); }
#people-dialog .row input, #people-dialog .row.tight input[type=text], #people-dialog .row.tight input[type=email] { margin-top: 0; width: auto; flex: 1; }
#people-dialog input[type=number] { width: 5em; margin-top: 0; display: inline-block; }
#pp-list .card { margin: 8px 0; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
