:root {
  --bg: #f3f1ec;
  --ink: #1c1c1e;
  --muted: #55565c;          /* 7.0:1 on white, 6.3:1 on --bg */
  --line: #d6d3cc;
  --paper: #ffffff;
  --accent: #0b5f5a;         /* 7.5:1 on white */
  --accent-soft: #e3f0ee;
  --guide: #eceae4;
  --you: #0b5f5a;
  --focus: #b3470e;
  --avoid: #2a62a8;
  --perf: #a6401c;
  --people: #74399a;
  --over: #1d6f47;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.45; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--paper); padding: 8px 12px; border-radius: 8px; z-index: 5; }
.skip:focus { top: 8px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; max-width: 1180px; margin: 0 auto; }
.top h1 { font-size: 1.15rem; margin: 0; }
.top h1 span { font-weight: 400; color: var(--muted); }
button { font: inherit; cursor: pointer; }
.ghost { background: transparent; border: 1px solid var(--muted); color: var(--ink); border-radius: 999px; padding: 6px 14px; min-height: 36px; }

.layout { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; gap: 24px; max-width: 1180px; margin: 0 auto; padding: 0 20px 32px; align-items: start; }

/* ---------- Phone ---------- */
.phone { background: var(--paper); border: 1px solid var(--line); border-radius: 28px; overflow: hidden; display: flex; flex-direction: column; height: min(780px, calc(100vh - 90px)); position: sticky; top: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 10px 30px rgba(0,0,0,.06); }
.phone-bar { padding: 12px 18px; border-bottom: 1px solid var(--line); font-weight: 600; }
.log { list-style: none; margin: 0; padding: 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; display: flex; flex-direction: column; gap: 3px; }
.msg .bubble { padding: 10px 13px; border-radius: 16px; }
.msg.guide { align-self: flex-start; }
.msg.guide .bubble { background: var(--guide); border-bottom-left-radius: 4px; }
.msg.you { align-self: flex-end; align-items: flex-end; }
.msg.you .bubble { background: var(--you); color: #fff; border-bottom-right-radius: 4px; }
.tag { font-size: .72rem; color: var(--muted); letter-spacing: .01em; }
.tag b { font-weight: 600; }
.empty { color: var(--muted); text-align: center; margin: auto 0; padding: 0 12px; }

.composer { border-top: 1px solid var(--line); padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; background: var(--paper); }
.choices { display: flex; flex-direction: column; gap: 6px; }
.choices button { text-align: left; background: var(--accent-soft); border: 1px solid #a9cfca; color: var(--ink); border-radius: 12px; padding: 9px 12px; min-height: 44px; }
.choices button:hover { background: #d3e8e5; }
.free { display: flex; gap: 6px; }
.free input { flex: 1; min-width: 0; font: inherit; padding: 9px 12px; border: 1px solid var(--muted); border-radius: 12px; min-height: 44px; }
.free button { background: var(--accent); color: #fff; border: 0; border-radius: 12px; padding: 0 16px; min-height: 44px; }
.free input:disabled, .free button:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Observer ---------- */
.observer { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.observer > h2 { grid-column: 1 / -1; margin: 4px 0 0; font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.panel h3 { margin: 0 0 10px; font-size: .95rem; }
.panel.wide { grid-column: 1 / -1; }
.meta { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }

.map { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.map li { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 5px 8px; border-radius: 8px; font-size: .88rem; }
.map li .kind { color: var(--muted); font-size: .78rem; }
.map li.done { color: var(--muted); }
.map li.now { background: var(--accent-soft); font-weight: 600; color: var(--ink); }
.map li.now .kind { color: var(--accent); }

.beliefs { display: flex; flex-direction: column; gap: 8px; }
.brow { display: grid; grid-template-columns: 7.5rem 1fr 3.2rem; align-items: center; gap: 8px; font-size: .88rem; }
.track { height: 12px; background: #ebe8e1; border-radius: 6px; overflow: hidden; }
.fill { height: 100%; border-radius: 6px; transition: width .35s ease; }
.pctv { text-align: right; font-variant-numeric: tabular-nums; }
.history-wrap { margin-top: 10px; }
.history { display: flex; gap: 3px; height: 54px; align-items: stretch; margin-top: 4px; }
.history .col { width: 16px; display: flex; flex-direction: column-reverse; border-radius: 3px; overflow: hidden; }

.heard p { margin: 0 0 6px; }
.heard .quote { font-style: italic; }
.mini { width: 100%; border-collapse: collapse; font-size: .82rem; font-variant-numeric: tabular-nums; margin-top: 4px; }
.mini th, .mini td { padding: 3px 4px; text-align: right; border-bottom: 1px solid #eeebe5; }
.mini th:first-child, .mini td:first-child { text-align: left; }

.reason { margin: 0 0 10px; }
.table-wrap { overflow-x: auto; }
#moves { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
#moves th { text-align: right; font-weight: 600; color: var(--muted); padding: 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
#moves th:first-child, #moves td:first-child { text-align: left; }
#moves td { text-align: right; padding: 6px; border-bottom: 1px solid #eeebe5; }
#moves tr.chosen td { background: var(--accent-soft); font-weight: 600; }
#moves tr.chosen td:first-child::before { content: "Chosen: "; color: var(--accent); }
#moves .k { display: block; font-size: .75rem; color: var(--muted); font-weight: 400; }
.maths { margin-top: 10px; font-size: .85rem; }
.maths summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.maths p { margin: 6px 0; }

.card-panel { grid-column: 1 / -1; border: 2px solid var(--accent); }
.card { margin: 0; display: grid; grid-template-columns: 10rem 1fr; gap: 8px 14px; }
.card dt { color: var(--muted); font-size: .85rem; }
.card dd { margin: 0; }
.card dd.blank { color: var(--muted); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 0 12px 24px; }
  .phone { position: static; height: 72vh; min-height: 480px; }
  .observer { grid-template-columns: 1fr; }
  .card { grid-template-columns: 1fr; gap: 2px; }
  .card dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { .fill { transition: none; } }
