:root {
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1d2327; --muted: #5f666d; --line: #dedbd2;
  --accent: #1f5f4a; --accent-ink: #ffffff; --accent-soft: #e3efe9; --warn: #8a5200; --warn-soft: #fbefd9;
  --bad: #8f2d2d; --bad-soft: #f6e1e1;
}
/* Dark follows the device when the choice is Auto, and is forced when the choice is Dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #16191b; --panel: #1e2326; --ink: #e8e6e1; --muted: #9aa1a7; --line: #2f3639;
    --accent: #6fc2a2; --accent-ink: #0f1a16; --accent-soft: #1d3029; --warn: #e0b265; --warn-soft: #33290f;
    --bad: #e29a9a; --bad-soft: #3a2121;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16191b; --panel: #1e2326; --ink: #e8e6e1; --muted: #9aa1a7; --line: #2f3639;
  --accent: #6fc2a2; --accent-ink: #0f1a16; --accent-soft: #1d3029; --warn: #e0b265; --warn-soft: #33290f;
  --bad: #e29a9a; --bad-soft: #3a2121;
}
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 -apple-system, "Segoe UI", system-ui, sans-serif; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 22px; margin: 0 0 6px; }
h3 { font-size: 15px; margin: 22px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.btn { font: inherit; min-height: 44px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn:disabled { opacity: .55; cursor: wait; }
input, textarea { font: inherit; width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
label { display: block; font-weight: 600; margin: 14px 0 6px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* theme switch */
select.theme { font: inherit; min-height: 44px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
.signin-theme { display: flex; justify-content: flex-end; margin-bottom: 8px; }

/* checklist */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin: 4px 0 10px; -webkit-overflow-scrolling: touch; }
.chip { flex: none; font: inherit; min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.filters input { flex: 1 1 220px; }
.items { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); overflow: hidden; }
.items li { border-bottom: 1px solid var(--line); }
.items li:last-child { border-bottom: 0; }
.item { display: grid; grid-template-columns: 78px 1fr; gap: 2px 10px; padding: 12px 14px; color: var(--ink); text-decoration: none; min-height: 52px; }
.item:hover { background: var(--accent-soft); }
.item-id { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; padding-top: 2px; }
.item-badges { grid-column: 2; display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.items .empty { border: 0; border-radius: 0; margin: 0; }
.pill.plain { background: var(--bg); color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
.back { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); text-decoration: none; font-weight: 600; }
.detail-lines { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.detail-lines .line { display: flex; gap: 8px; width: 100%; }
.detail-lines .line textarea { flex: 1; min-width: 0; resize: none; overflow: hidden; line-height: 1.4; }
.detail-lines .line .btn { align-self: flex-start; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); cursor: pointer; }
.opt input { width: 22px; min-height: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.opt span { display: flex; flex-direction: column; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.msg.good { color: var(--accent); }

/* platform words */
.swapped { border-bottom: 1px dotted var(--accent); }
.unfilled { border-bottom: 1px dashed var(--warn); }
.reads { border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 10px 14px; background: var(--panel); }
.reads-title { margin: 0 0 6px; font-weight: 600; }
.reads ul { margin: 0; padding-left: 20px; }
.gcard { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); padding: 14px; margin-bottom: 10px; }
.gtop { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.gword { font-size: 17px; }
.gon { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
.gon input { width: 20px; min-height: 20px; height: 20px; accent-color: var(--accent); }
.gfields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.gfields label { margin: 10px 0 0; font-weight: 600; font-size: 14px; }
.gcard details { margin-top: 8px; }
.gcard details label { font-size: 14px; }
.gcard .actions { margin-top: 12px; align-items: center; }

/* sign in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 20px 16px; }
.signin-card { width: 100%; max-width: 420px; }
.signin-card .btn { width: 100%; margin-top: 16px; }
.msg { min-height: 1.5em; margin: 10px 0 0; color: var(--bad); font-weight: 600; }

/* app shell */
.top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.top .spacer { flex: 1; }
.phase { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); white-space: nowrap; }
.layout { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 62px); }
nav { border-right: 1px solid var(--line); background: var(--panel); padding: 14px 10px; }
nav .group { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 14px 10px 6px; }
nav a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 10px; border-radius: 10px; color: var(--ink); text-decoration: none; }
nav a:hover { background: var(--accent-soft); }
nav a[aria-current="page"] { background: var(--accent-soft); font-weight: 600; }
nav .num { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); font-size: 12px; display: grid; place-items: center; }
nav a[aria-current="page"] .num { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
nav .tag { margin-left: auto; font-size: 11px; color: var(--muted); white-space: nowrap; }
main { padding: 20px; min-width: 0; max-width: 900px; }
main:focus { outline: none; }

/* screens */
.lead { color: var(--muted); margin: 0 0 16px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0; }
.stat { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--panel); }
.stat .big { font-size: 18px; font-weight: 600; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.note { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 12px 14px; margin: 14px 0; font-size: 14px; }
.plan { list-style: none; margin: 0; padding: 0; }
.plan li { display: flex; gap: 10px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plan li:last-child { border-bottom: 0; }
.plan .when { flex: none; width: 100px; font-size: 12px; font-weight: 600; color: var(--muted); }
.empty { border: 1px dashed var(--line); border-radius: 14px; padding: 26px 18px; text-align: center; color: var(--muted); margin-top: 16px; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  nav { align-items: center; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; display: flex; gap: 4px; overflow-x: auto; position: sticky; top: 62px; z-index: 4; -webkit-overflow-scrolling: touch; }
  nav .group { display: none; }
  nav a { white-space: nowrap; flex: none; padding: 8px 12px; }
  nav .tag { display: none; }
  main { padding: 16px; }
  .top #who { display: none; }
}
@media (max-width: 480px) {
  .phase { display: none; }
  .top { gap: 8px; padding-left: 12px; padding-right: 12px; flex-wrap: wrap; position: static; }
  .top .spacer { flex: 1 1 0; order: 1; }
  .top #signout { order: 2; }
  .top #words-app, .top #theme-app { order: 3; flex: 1 1 calc(50% - 8px); min-width: 0; }
  .top #words-app select, .top #theme-app select { width: 100%; }
  nav { top: 0; }
  .top h1 { font-size: 18px; white-space: nowrap; }
  .top .btn, .top select.theme { font-size: 14px; padding: 8px 10px; white-space: nowrap; }
}
