/* Layout: header + live "Agora" banner + summary strip, toolbar, then a horizontally scrolling kanban (or a table), a side drawer, a card menu and toasts. */
:root {
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --surface-2: #EFECE5;
  --fg: #1F1E1C;
  --muted: #6B675F;
  --line: #E2DED5;
  --accent: #A64D29;
  --accent-soft: #F3E3DA;
  --on-accent: #FFFFFF;
  --ok: #2F6B45;
  --ok-soft: #E1EEE4;
  --info: #2D5C88;
  --info-soft: #E0EAF4;
  --warn: #8A5A00;
  --warn-soft: #F6EBD3;
  --danger: #A3302A;
  --shadow: 0 1px 2px rgba(31,30,28,.06), 0 2px 8px rgba(31,30,28,.05);
  --shadow-lift: 0 10px 28px rgba(31,30,28,.18);
  --scrim: rgba(31,30,28,.38);
  --font-display: Georgia, "Times New Roman", serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1F1E1C; --surface: #2A2926; --surface-2: #34332F; --fg: #EDEAE3; --muted: #A8A399;
    --line: #3F3D38; --accent: #E0835D; --accent-soft: #4A3227; --on-accent: #1F1E1C;
    --ok: #8CC9A0; --ok-soft: #26382C; --info: #93BBE3; --info-soft: #24323F; --warn: #E4BE72; --warn-soft: #3D3322; --danger: #F08A80;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lift: 0 10px 28px rgba(0,0,0,.5); --scrim: rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1F1E1C; --surface: #2A2926; --surface-2: #34332F; --fg: #EDEAE3; --muted: #A8A399;
  --line: #3F3D38; --accent: #E0835D; --accent-soft: #4A3227; --on-accent: #1F1E1C;
  --ok: #8CC9A0; --ok-soft: #26382C; --info: #93BBE3; --info-soft: #24323F; --warn: #E4BE72; --warn-soft: #3D3322; --danger: #F08A80;
  --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lift: 0 10px 28px rgba(0,0,0,.5); --scrim: rgba(0,0,0,.55);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 14px; line-height: 1.45; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
body.dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 20px 40px; max-width: 1680px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

header.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 20px; }
.eyebrow { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
h1 { font-family: var(--font-display); font-weight: 600; font-size: clamp(26px, 4vw, 34px); line-height: 1.1; margin: 2px 0 0; text-wrap: balance; }
.top-right { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.sync { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.sync[data-state="live"] .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.sync[data-state="error"] .dot { background: var(--accent); }

/* Live banner */
.now { display: flex; align-items: center; gap: 12px; background: var(--accent-soft); border: 1px solid transparent; border-radius: 10px; padding: 10px 14px; min-width: 0; cursor: pointer; text-align: left; width: 100%; }
.now:hover { border-color: var(--accent); }
.now .lbl { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; color: var(--accent); flex: none; }
.now .txt { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now .txt b { font-family: var(--font-display); font-weight: 600; }
.now .ago { color: var(--muted); font-size: 12.5px; flex: none; font-variant-numeric: tabular-nums; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; position: relative; }
.pulse.idle { background: var(--muted); }
@media (prefers-reduced-motion: no-preference) {
  .pulse:not(.idle)::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--accent); animation: ring 1.6s ease-out infinite; }
}
@keyframes ring { from { transform: scale(.6); opacity: .9; } to { transform: scale(1.6); opacity: 0; } }

.summary { display: flex; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stat { flex: 1 1 120px; padding: 12px 16px; display: grid; gap: 2px; border-right: 1px solid var(--line); min-width: 0; }
.stat:last-of-type { border-right: 0; }
.stat b { font-family: var(--font-display); font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.prod b { color: var(--ok); }
.stat.active b { color: var(--accent); }
.progress { flex: 1 1 100%; height: 4px; background: var(--surface-2); display: flex; }
.progress i { display: block; height: 100%; }
.progress .p-prod { background: var(--ok); }
.progress .p-dev { background: var(--info); }
.progress .p-act { background: var(--accent); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; }
.search { flex: 1 1 240px; min-width: 0; position: relative; }
.search input { width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { border: 1px solid var(--line); background: var(--surface); padding: 6px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.chip-btn[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip-btn .n { opacity: .65; font-variant-numeric: tabular-nums; margin-left: 4px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 7px 12px; font-size: 12.5px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* Board */
.board-scroll { overflow-x: auto; margin-inline: calc(-1 * max(16px, env(safe-area-inset-left, 0px))); padding-inline: max(16px, env(safe-area-inset-left, 0px)); scroll-snap-type: x proximity; padding-bottom: 8px; }
body.dragging .board-scroll { scroll-snap-type: none; }
.board { display: grid; grid-template-columns: repeat(6, minmax(250px, 1fr)); gap: 12px; min-width: min-content; align-items: start; }
.col { background: var(--surface-2); border-radius: 10px; padding: 10px; display: grid; gap: 8px; align-content: start; scroll-snap-align: start; min-width: 0; border: 2px solid transparent; transition: border-color .12s; }
.col.drop-target { border-color: var(--accent); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 4px; }
.col-head h2 { font-size: 13px; font-weight: 600; margin: 0; }
.col-head .count { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); background: var(--surface); border-radius: 999px; padding: 1px 8px; border: 1px solid var(--line); }
.col-cards { display: grid; gap: 8px; min-height: 40px; }
.swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.col-empty { font-size: 12.5px; color: var(--muted); padding: 14px 6px; text-align: center; border: 1px dashed var(--line); border-radius: 8px; }
.add-btn { border: 1px dashed var(--line); background: transparent; border-radius: 8px; padding: 8px; font-size: 12.5px; font-weight: 500; color: var(--muted); text-align: left; }
.add-btn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.drop-line { height: 3px; border-radius: 2px; background: var(--accent); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px; display: grid; gap: 7px; cursor: pointer; text-align: left; width: 100%; box-shadow: var(--shadow); transition: border-color .15s; -webkit-touch-callout: none; touch-action: manipulation; }
.card:hover { border-color: var(--accent); }
.card.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.card.is-dragged { opacity: .35; }
.card.ghost-card { position: fixed; z-index: 40; pointer-events: none; box-shadow: var(--shadow-lift); transform: rotate(1.5deg); opacity: .96; }
.card.saving { opacity: .7; }
.card-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.kid { font-family: var(--font-display); font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }
.live { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); }
.live .pulse { width: 7px; height: 7px; }
.slice { margin-left: auto; font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; white-space: nowrap; }
.menu-btn { border: 0; background: transparent; width: 26px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); flex: none; margin-right: -4px; }
.menu-btn:hover { background: var(--surface-2); color: var(--fg); }
.card-title { font-size: 13.5px; font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.card-act { font-size: 12px; color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-act b { color: var(--fg); font-weight: 500; }
.card-foot { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.dep { font-size: 11px; font-variant-numeric: tabular-nums; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); border: 0; }
.dep.met { background: var(--ok-soft); color: var(--ok); }
.dep.open { background: var(--warn-soft); color: var(--warn); }
.pr { font-size: 11.5px; font-weight: 600; color: var(--accent); text-decoration: none; margin-left: auto; }
.pr:hover { text-decoration: underline; }

.stages { display: grid; gap: 5px; }
.pips { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.pips i { height: 4px; border-radius: 2px; background: var(--line); }
.pips i.done { background: var(--ok); }
.pips i.cur { background: var(--accent); }
.stage-label { font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.stage-label b { color: var(--accent); font-weight: 600; }

/* Table */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; min-width: 860px; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; }

/* States */
.state { background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; padding: 28px 20px; display: grid; gap: 8px; justify-items: start; max-width: 640px; }
.state h2 { font-family: var(--font-display); font-weight: 600; font-size: 20px; margin: 0; }
.state p { margin: 0; color: var(--muted); max-width: 60ch; }
.ghost { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; height: 74px; }
@media (prefers-reduced-motion: no-preference) { .ghost { animation: pulseo 1.4s ease-in-out infinite; } }
@keyframes pulseo { 50% { opacity: .55; } }

/* Drawer */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100%); background: var(--surface); z-index: 21; border-left: 1px solid var(--line); display: grid; grid-template-rows: auto 1fr; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); padding-right: env(safe-area-inset-right, 0px); box-shadow: -8px 0 24px rgba(0,0,0,.12); }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 21px; line-height: 1.25; margin: 4px 0 0; text-wrap: balance; overflow-wrap: anywhere; }
.close { margin-left: auto; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; width: 34px; height: 34px; flex: none; display: grid; place-items: center; }
.drawer-body { overflow-y: auto; padding: 16px 20px 28px; display: grid; gap: 18px; align-content: start; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span, .field > label { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.field p { margin: 0; font-size: 14.5px; line-height: 1.55; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inp { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 10px; min-width: 0; }
textarea.inp { resize: vertical; min-height: 64px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 500; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.hint { font-size: 12px; color: var(--muted); margin: 0; }
.err { font-size: 12.5px; color: var(--danger); margin: 0; }
.dep-btn { cursor: pointer; font-size: 12.5px; padding: 3px 8px; }
.stage-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.stage-list li { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.stage-list li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.stage-list li.done { color: var(--fg); }
.stage-list li.done::before { background: var(--ok); border-color: var(--ok); }
.stage-list li.cur { color: var(--accent); font-weight: 600; }
.stage-list li.cur::before { border-color: var(--accent); background: var(--accent-soft); }
.link { color: var(--accent); font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 74px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: 0; }
.tl-time { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1.3; }
.tl-body { min-width: 0; display: grid; gap: 3px; }
.tl-kind { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.tl-kind.k-commit { color: var(--info); } .tl-kind.k-test, .tl-kind.k-gate, .tl-kind.k-deploy { color: var(--ok); }
.tl-kind.k-block { color: var(--danger); } .tl-kind.k-stage, .tl-kind.k-pr, .tl-kind.k-ci { color: var(--accent); }
.tl-text { font-size: 13.5px; overflow-wrap: anywhere; }
.tl-meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.tl-meta a { color: var(--accent); font-weight: 600; text-decoration: none; }
.tl-meta a:hover { text-decoration: underline; }
code.sha { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; }

/* Menu */
.menu { position: fixed; z-index: 30; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lift); padding: 6px; min-width: 210px; display: grid; gap: 1px; }
.menu .mh { font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 6px 10px 2px; }
.menu button { border: 0; background: transparent; text-align: left; padding: 7px 10px; border-radius: 6px; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.menu button:hover:not(:disabled), .menu button:focus-visible { background: var(--surface-2); outline: none; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* Toasts */
.toasts { position: fixed; z-index: 50; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; width: min(440px, calc(100% - 32px)); }
.toast { background: var(--fg); color: var(--bg); border-radius: 10px; padding: 10px 14px; display: flex; gap: 12px; align-items: center; font-size: 13px; box-shadow: var(--shadow-lift); }
.toast.error { background: var(--danger); color: #fff; }
.toast span { flex: 1; min-width: 0; }
.toast button { border: 0; background: transparent; color: inherit; font-weight: 700; text-decoration: underline; padding: 2px 4px; }

footer.note { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
footer.note button { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 12px; padding: 0; }

@media (max-width: 720px) {
  .board { grid-template-columns: repeat(6, 82vw); }
  .stat { flex-basis: 33%; border-bottom: 1px solid var(--line); }
  .stat b { font-size: 22px; }
  .drawer { top: auto; width: 100%; max-height: 90vh; border-left: 0; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; padding-left: env(safe-area-inset-left, 0px); }
  .grid2 { grid-template-columns: 1fr; }
  .now { flex-wrap: wrap; }
  .now .txt { white-space: normal; flex-basis: 100%; order: 3; }
}
[hidden] { display: none !important; }
.drawer-titles { min-width: 0; }
.drawer-form { display: grid; gap: 14px; }
.fill { flex: 1 1 180px; min-width: 0; }
.blocked { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--danger); }
.kid, .stat b { font-family: var(--font-ui); }
.kid, .live { white-space: nowrap; flex: none; }
.slice { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.grid2 { align-items: start; }
.ro-badge { font-size: 11.5px; font-weight: 600; color: var(--warn); background: var(--warn-soft); border-radius: 999px; padding: 2px 9px; }
.who { font-size: 12.5px; color: var(--muted); }
.who button { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 0 0 0 6px; }
.hub-page { max-width: 560px; margin: 0 auto; padding: 48px 16px; display: grid; gap: 12px; }
.hub-page a.btn { display: inline-block; text-decoration: none; }
.hub-page a:not(.btn) { color: var(--accent); font-weight: 600; }
.now .txt b { font-family: var(--font-ui); }
