:root {
  --paper: #f4f6fb;
  --surface: #ffffff;
  --ink: #16195c;
  --ink-soft: #4b5180;
  --muted: #6e7398;
  --rule: #dde1ee;
  --rule-strong: #c4c9de;
  --sign: #ffcc1a;
  --sign-ink: #16195c;
  --todo: #8a90a8;
  --todo-tint: #eef0f6;
  --doing: #2459d6;
  --doing-tint: #e4ecfd;
  --waiting: #b26a00;
  --waiting-tint: #fdf0d8;
  --done: #187a45;
  --done-tint: #dcf2e5;
  --blocked: #c4291f;
  --blocked-tint: #fbe2df;
  --code: #eef0f7;
  --focus: #2459d6;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #0f1124;
    --surface: #171a33;
    --ink: #eef0ff;
    --ink-soft: #c3c7ea;
    --muted: #9298c2;
    --rule: #2a2e52;
    --rule-strong: #3a3f6a;
    --sign: #ffcc1a;
    --sign-ink: #16195c;
    --todo: #9aa0c0;
    --todo-tint: #23274a;
    --doing: #8cb0ff;
    --doing-tint: #1c2a55;
    --waiting: #f5bd5c;
    --waiting-tint: #3a2c12;
    --done: #6fd39b;
    --done-tint: #143323;
    --blocked: #ff8a7f;
    --blocked-tint: #3d1a1a;
    --code: #10132a;
    --focus: #8cb0ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-variant-numeric: tabular-nums;
}
button, select, textarea, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }

/* Top bar */
.top {
  background: var(--ink);
  color: var(--paper);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .top { background: #0a0c1c; color: var(--ink); border-bottom: 1px solid var(--rule); } }
.top-inner {
  max-width: 1320px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 12px; flex: 1 1 auto; min-width: 0; }
.brand strong { font-size: 1.15rem; letter-spacing: -0.01em; }
.brand span { opacity: .75; font-size: .92rem; }
.who { display: flex; align-items: center; gap: 12px; font-size: .9rem; flex-wrap: wrap; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: #ff8a7f; display: inline-block; }
.pulse.on { background: #6fd39b; }
.lang { display: inline-flex; border: 1px solid currentColor; border-radius: 999px; overflow: hidden; opacity: .9; }
.lang button { border: 0; background: transparent; padding: 2px 10px; cursor: pointer; font-size: .8rem; }
.lang button[aria-pressed='true'] { background: var(--sign); color: var(--sign-ink); font-weight: 700; }
.signout { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: .9rem; opacity: .85; }

/* Route line: the phases of the go-live as stops on a coach line */
.route-wrap { background: var(--surface); border-bottom: 1px solid var(--rule); }
.route {
  max-width: 1320px; margin: 0 auto; padding: 22px 20px 18px;
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr));
  position: relative;
}
.route .track, .route .fill { position: absolute; top: 37px; height: 6px; border-radius: 3px; }
.route .track { background: var(--rule); }
.route .fill { background: var(--done); transition: width .6s ease; }
.stop {
  position: relative; display: grid; justify-items: center; gap: 6px; text-align: center;
  background: none; border: 0; cursor: pointer; padding: 0 4px; color: var(--ink);
}
.stop .dot {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 4px solid var(--rule-strong); font-weight: 700; font-size: .9rem;
  position: relative; z-index: 1;
}
.stop[data-state='done'] .dot { background: var(--done); border-color: var(--done); color: var(--surface); }
.stop[data-state='current'] .dot { background: var(--sign); border-color: var(--ink); color: var(--sign-ink); }
.stop[data-state='blocked'] .dot { border-color: var(--blocked); color: var(--blocked); }
.stop .name { font-size: .82rem; font-weight: 700; line-height: 1.25; max-width: 13ch; }
.stop .count { font-size: .78rem; color: var(--muted); }

/* Summary and filters */
.summary {
  max-width: 1320px; margin: 0 auto; padding: 16px 20px 4px;
  display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center;
}
.tally { display: flex; gap: 18px; flex-wrap: wrap; font-size: .95rem; flex: 1 1 auto; }
.tally b { font-size: 1.25rem; margin-right: 4px; }
.tally .t-done b { color: var(--done); }
.tally .t-doing b { color: var(--doing); }
.tally .t-waiting b { color: var(--waiting); }
.tally .t-blocked b { color: var(--blocked); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button {
  border: 1px solid var(--rule-strong); background: var(--surface); border-radius: 999px;
  padding: 5px 14px; cursor: pointer; font-size: .88rem;
}
.filters button[aria-pressed='true'] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .filters button[aria-pressed='true'] { background: var(--sign); color: var(--sign-ink); border-color: var(--sign); } }

/* Main grid */
.layout {
  max-width: 1320px; margin: 0 auto; padding: 14px 20px 40px;
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start;
}

/* Phases */
.phase { margin-bottom: 28px; scroll-margin-top: 16px; }
.phase-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 10px; }
.phase-head .letter {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--ink); color: var(--paper); font-weight: 700; font-size: .9rem; align-self: center;
}
.phase-head h2 { margin: 0; font-size: 1.15rem; }
.phase-head .n { color: var(--muted); font-size: .9rem; }
.rows { background: var(--surface); border: 1px solid var(--rule); border-radius: 14px; overflow: hidden; }

.row { padding: 14px 16px 14px 18px; border-top: 1px solid var(--rule); position: relative; }
.row:first-child { border-top: 0; }
.row::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--todo-tint); }
.row[data-status='doing']::before { background: var(--doing); }
.row[data-status='waiting']::before { background: var(--waiting); }
.row[data-status='done']::before { background: var(--done); }
.row[data-status='blocked']::before { background: var(--blocked); }
.row.changed { animation: changed 1.6s ease-out; }
@keyframes changed { from { background: var(--sign); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .row.changed { animation: none; } .route .fill { transition: none; } }

.row-main { display: grid; grid-template-columns: 2.6em minmax(0, 1fr) auto; gap: 4px 12px; align-items: start; }
.row .id { font-weight: 700; color: var(--muted); padding-top: 4px; }
.row .title { font-weight: 700; font-size: 1.02rem; line-height: 1.35; padding-top: 3px; }
.row[data-status='done'] .title { color: var(--muted); }
.row .owner { grid-column: 2; font-size: .85rem; color: var(--ink-soft); }
.row .detail { grid-column: 2 / -1; color: var(--ink-soft); font-size: .93rem; margin-top: 4px; max-width: 78ch; overflow-wrap: anywhere; }

.pill {
  appearance: none; -webkit-appearance: none; border: 0; border-radius: 999px; cursor: pointer;
  padding: 6px 30px 6px 14px; font-weight: 700; font-size: .86rem; white-space: nowrap;
  background-repeat: no-repeat; background-position: right 10px center; background-size: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236e7398' stroke-width='1.6'/%3E%3C/svg%3E");
}
.pill[data-s='todo'] { background-color: var(--todo-tint); color: var(--ink-soft); }
.pill[data-s='doing'] { background-color: var(--doing-tint); color: var(--doing); }
.pill[data-s='waiting'] { background-color: var(--waiting-tint); color: var(--waiting); }
.pill[data-s='done'] { background-color: var(--done-tint); color: var(--done); }
.pill[data-s='blocked'] { background-color: var(--blocked-tint); color: var(--blocked); }

.cmd { grid-column: 2 / -1; display: flex; gap: 8px; margin-top: 8px; }
.cmd code {
  flex: 1; min-width: 0; background: var(--code); border-radius: 8px; padding: 8px 10px;
  font: .82rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-x: auto; white-space: pre;
}
.cmd button { border: 1px solid var(--rule-strong); background: var(--surface); border-radius: 8px; padding: 0 12px; cursor: pointer; font-size: .85rem; }

.row-foot { grid-column: 2 / -1; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-top: 8px; font-size: .85rem; color: var(--muted); }
.talk { background: none; border: 0; padding: 0; cursor: pointer; color: var(--doing); font-weight: 700; font-size: .85rem; }
.talk .badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: var(--doing); color: var(--surface); font-size: .75rem; }

.thread { grid-column: 2 / -1; margin-top: 10px; padding: 10px 12px; background: var(--paper); border-radius: 10px; display: grid; gap: 10px; }

/* Messages (comments and chat) */
.msg { display: grid; gap: 2px; overflow-wrap: anywhere; }
.msg .head { font-size: .82rem; color: var(--muted); }
.msg .head b { color: var(--ink); font-size: .9rem; margin-right: 6px; }
.msg .text { white-space: pre-wrap; font-size: .95rem; }
.say { display: flex; gap: 8px; align-items: flex-end; }
.say textarea {
  flex: 1; min-width: 0; resize: vertical; min-height: 40px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--rule-strong); background: var(--surface); font-size: .95rem;
}
.say button { border: 0; border-radius: 10px; background: var(--ink); color: var(--paper); font-weight: 700; padding: 9px 14px; cursor: pointer; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .say button { background: var(--sign); color: var(--sign-ink); } }

/* Side panel */
.side {
  position: sticky; top: 16px; max-height: calc(100vh - 32px);
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 14px; overflow: hidden;
}
.tabs { display: flex; border-bottom: 1px solid var(--rule); }
.tabs button { flex: 1; border: 0; background: none; padding: 12px; cursor: pointer; color: var(--muted); font-weight: 700; }
.tabs button[aria-selected='true'] { color: var(--ink); box-shadow: inset 0 -3px 0 var(--sign); }
.feed { overflow-y: auto; padding: 14px; display: grid; gap: 14px; align-content: start; min-height: 240px; }
.feed .empty { color: var(--muted); }
.side .say { padding: 12px; border-top: 1px solid var(--rule); }
.log { font-size: .88rem; color: var(--ink-soft); }
.log b { color: var(--ink); }
.log time { display: block; color: var(--muted); font-size: .8rem; }
.log .s { font-weight: 700; }
.log .s[data-s='done'] { color: var(--done); }
.log .s[data-s='doing'] { color: var(--doing); }
.log .s[data-s='waiting'] { color: var(--waiting); }
.log .s[data-s='blocked'] { color: var(--blocked); }

@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: 70vh; }
}
@media (max-width: 700px) {
  .top-inner, .summary, .layout { padding-left: 16px; padding-right: 16px; }
  .brand { flex-direction: column; gap: 0; }
  .route { grid-template-columns: repeat(8, 64px); overflow-x: auto; padding: 18px 16px 14px; }
  .route .track, .route .fill { top: 33px; }
  .stop .name { font-size: .72rem; }
  .row { padding: 12px 12px 12px 16px; }
  .row-main { grid-template-columns: minmax(0, 1fr) auto; }
  .row .id { grid-column: 1; grid-row: 1; padding: 0; font-size: .82rem; }
  .row .pill { grid-column: 2; grid-row: 1 / span 2; align-self: start; }
  .row .title { grid-column: 1; grid-row: 2; padding: 0; }
  .row .owner, .row .detail, .cmd, .row-foot, .thread { grid-column: 1 / -1; }
}

/* Sign-in */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--rule); border-radius: 18px;
  padding: 28px; display: grid; gap: 16px;
}
.login .line { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--done) 0 30%, var(--sign) 30% 42%, var(--rule) 42%); }
.login .head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.login h1 { margin: 0; font-size: 1.35rem; line-height: 1.25; }
.login p { margin: 0; color: var(--ink-soft); }
.login .lang { color: var(--ink); }
.login label { display: grid; gap: 6px; font-weight: 700; font-size: .92rem; }
.login input, .login select { padding: 11px 12px; border-radius: 10px; border: 1px solid var(--rule-strong); background: var(--paper); width: 100%; }
.login button[type='submit'] { border: 0; border-radius: 10px; background: var(--ink); color: var(--paper); font-weight: 700; padding: 12px; cursor: pointer; font-size: 1rem; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .login button[type='submit'] { background: var(--sign); color: var(--sign-ink); } }
.login .error { color: var(--blocked); min-height: 1.3em; font-size: .92rem; }
