/* 3dtrack: one stylesheet, light + dark, WCAG 2.2 AA (contrast ≥ 4.5:1, visible focus, 44px targets, reduced motion). */
:root {
  --bg: #f6f7f9; --panel: #fff; --ink: #111827; --muted: #4b5563; --line: #e5e7eb; --soft: #f1f5f9;
  --accent: #0f766e; --accent-ink: #fff; --accent-soft: #ccfbf1; --accent-text: #115e59;
  --warn: #92400e; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2; --ok: #166534; --ok-soft: #dcfce7; --info: #1e40af; --info-soft: #dbeafe;
  --radius: 12px; --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 4px 16px rgb(0 0 0 / .04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1014; --panel: #121a21; --ink: #e5e7eb; --muted: #a3adb8; --line: #243039; --soft: #18222b;
    --accent: #2dd4bf; --accent-ink: #042f2e; --accent-soft: #134e4a; --accent-text: #5eead4;
    --warn: #fcd34d; --warn-soft: #422006; --bad: #fca5a5; --bad-soft: #450a0a; --ok: #86efac; --ok-soft: #052e16; --info: #93c5fd; --info-soft: #172554;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--accent-text); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 24px; letter-spacing: -.02em; } h2 { font-size: 18px; } h3 { font-size: 16px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 10px 14px; z-index: 50; }
.skip:focus { left: 8px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* Shell: sidebar on desktop, bottom tabs on the phone */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; padding: 4px 10px 16px; color: var(--ink); text-decoration: none; }
.brand img { width: 30px; height: 30px; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 550; }
.nav a:hover { background: var(--soft); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.side .foot { margin-top: auto; padding: 10px; }
main { padding: 28px clamp(16px, 4vw, 40px) 60px; max-width: 1200px; width: 100%; }
.tabbar { display: none; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  main { padding: 18px 14px calc(84px + env(safe-area-inset-bottom)); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 56px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; }
  .tabbar a span[aria-hidden] { font-size: 20px; line-height: 1.2; }
  .tabbar a[aria-current="page"] { color: var(--accent-text); }
}

/* Page head */
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head p { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* Buttons and inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.big { min-height: 52px; padding: 0 24px; font-size: 17px; }
.btn.danger { color: var(--bad); }
.btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid #9ca3af; border-radius: 10px; min-height: 44px; padding: 8px 12px; width: 100%; }
textarea { min-height: 96px; resize: vertical; }
label { font-weight: 600; font-size: 14px; display: block; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.search { max-width: 280px; }

/* Panels, tiles */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); text-decoration: none; color: var(--ink); }
.tile b { display: block; font-size: 26px; letter-spacing: -.02em; }
.tile span { color: var(--muted); font-size: 13px; font-weight: 600; }
.hero { background: linear-gradient(135deg, var(--accent-soft), var(--panel)); }
.countdown { font-size: 34px; font-weight: 800; letter-spacing: -.03em; }
.pitch { font-size: 17px; max-width: 70ch; }
.bar { height: 12px; background: var(--soft); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar > div { height: 100%; background: var(--accent); }
.checklist { list-style: none; padding: 0; margin: 12px 0 0; }
.checklist li { border-top: 1px solid var(--line); }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; font-weight: 500; cursor: pointer; margin: 0; }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
.check.done span { color: var(--muted); text-decoration: line-through; }

/* Chips */
.chip { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--soft); color: var(--muted); white-space: nowrap; }
.chip.todo, .chip.idea, .chip.considering, .chip.draft { background: var(--soft); color: var(--muted); }
.chip.doing, .chip.researching, .chip.testing { background: var(--info-soft); color: var(--info); }
.chip.blocked, .chip.open { background: var(--warn-soft); color: var(--warn); }
.chip.done, .chip.go, .chip.decided, .chip.using { background: var(--ok-soft); color: var(--ok); }
.chip.dropped { background: var(--bad-soft); color: var(--bad); }
.chip.owner { background: var(--accent-soft); color: var(--accent-text); }
.overdue { color: var(--bad); font-weight: 700; }

/* Tables (sortable) */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; min-height: 32px; }
th button:focus-visible { outline: 3px solid var(--accent); }
tbody tr:hover { background: var(--soft); }
td .title-btn { all: unset; cursor: pointer; font-weight: 650; color: var(--ink); }
td .title-btn:focus-visible { outline: 3px solid var(--accent); }
tr:last-child td { border-bottom: 0; }
@media (max-width: 760px) {
  table.cards thead { display: none; }
  table.cards tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.cards td { display: flex; gap: 10px; border: 0; padding: 4px 12px; }
  table.cards td::before { content: attr(data-label); min-width: 84px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
}

/* Board */
.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.col { background: var(--soft); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.col h3 { display: flex; justify-content: space-between; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 4px 4px 8px; margin: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow); }
.card .title-btn { all: unset; cursor: pointer; font-weight: 650; display: block; margin-bottom: 6px; }
.card .title-btn:focus-visible { outline: 3px solid var(--accent); }
.card select { min-height: 36px; padding: 4px 8px; font-size: 13px; margin-top: 8px; }
@media (max-width: 760px) { .board { grid-template-columns: repeat(4, 78vw); scroll-snap-type: x mandatory; } .col { scroll-snap-align: start; } }

/* Decisions, notes, activity */
.decision { border-left: 4px solid var(--line); }
.decision.open { border-left-color: var(--warn); }
.decision.decided { border-left-color: var(--ok); }
.decision ul { margin: 8px 0; padding-left: 20px; }
.pick { background: var(--ok-soft); color: var(--ok); padding: 8px 12px; border-radius: 8px; font-weight: 600; }
.notes { display: grid; grid-template-columns: 280px 1fr; gap: 16px; }
.note-list a { display: block; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--ink); min-height: 44px; }
.note-list a[aria-current="true"] { background: var(--accent-soft); color: var(--accent-text); }
.md img { max-width: 100%; }
.md blockquote { border-left: 4px solid var(--line); margin: 0; padding: 4px 14px; color: var(--muted); }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.files { list-style: none; padding: 0; margin: 10px 0; }
.files li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
@media (max-width: 760px) { .notes { grid-template-columns: 1fr; } }
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.feed time { color: var(--muted); font-size: 13px; min-width: 92px; }
.empty { text-align: center; padding: 30px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* Dialog + toasts */
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(640px, calc(100vw - 24px)); background: var(--panel); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / .3); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog form { padding: 20px; max-height: calc(100vh - 60px); overflow: auto; }
dialog .actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 10px; font-weight: 600; max-width: 360px; }
.toast.err { background: var(--bad); color: #fff; }
@media (max-width: 760px) { .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); left: 12px; right: 12px; } }

/* Sign-in */
.center { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; margin: 0 auto; }
body.signin[data-login="on"] .when-off, body.signin[data-login="off"] .when-on { display: none; }

/* Tasks by component: queue / in progress / done; draggable queue */
.board.three { grid-template-columns: repeat(3, minmax(240px, 1fr)); }
@media (max-width: 760px) { .board.three { grid-template-columns: repeat(3, 86vw); } }
.queue { list-style: none; padding: 0; margin: 0; }
.queue li { display: grid; grid-template-columns: 18px 22px 1fr; gap: 4px; align-items: start; border-radius: 10px; }
.queue .grip { cursor: grab; color: var(--muted); padding-top: 12px; user-select: none; }
.queue .qn { font-weight: 800; color: var(--accent-text); padding-top: 10px; font-size: 13px; }
.queue li.dragging { opacity: .5; }
.queue li.drop-target { outline: 3px dashed var(--accent); outline-offset: 2px; }
.queue .card .btn.sm { min-height: 36px; min-width: 44px; }
.quick { display: grid; gap: 8px; }
.quick textarea { min-height: 72px; }
