/* HD Checklist — one stylesheet, no build step, no framework.
   Desktop gets a sidebar; mobile gets a bottom tab bar and bigger tap targets. */

:root {
  --accent: #455a64;
  --accent-dark: #263238;
  --accent-soft: #eceff1;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --line: #e2e5e8;
  --ink: #1c2226;
  --ink-soft: #5f6b73;
  --ink-faint: #93a0a8;
  --done: #2e7d52;
  --warn: #b4531f;
  --radius: 12px;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #7d99a8;
    --accent-dark: #1b2429;
    --accent-soft: #232e34;
    --bg: #14191c;
    --panel: #1b2126;
    --line: #2b343a;
    --ink: #e8edf0;
    --ink-soft: #a3b0b8;
    --ink-faint: #6f7d85;
    --done: #5cc98d;
    --warn: #e08a4e;
  }
}

* { box-sizing: border-box; }

/* .lock, .modal and .toast all set an explicit `display`, which beats the browser's
   default [hidden] rule. Without this they can never actually be hidden. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ------------------------------------------------------------------ layout */

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 18px 12px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 650; font-size: 15px; margin: 0 8px 16px;
}
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px; color: var(--ink-soft); font-weight: 500;
}
.sidebar a:hover { background: var(--accent-soft); }
.sidebar a.active { background: var(--accent-soft); color: var(--ink); font-weight: 620; }

.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; }
.sidebar-foot a { flex: 1; }

.view { padding: 26px 30px 60px; max-width: 900px; width: 100%; }

.tabbar { display: none; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .view { padding: 14px 14px calc(76px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--panel);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 8px 0 6px; font-size: 10.5px; color: var(--ink-faint); min-height: 54px;
  }
  .tabbar a span { font-size: 19px; line-height: 1; }
  .tabbar a.active { color: var(--accent); }
}

/* ---------------------------------------------------------------- headings */

.page-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 4px; }
.page-head h1 { font-size: 23px; margin: 0; flex: 1; line-height: 1.25; }
.page-head .actions { display: flex; gap: 6px; flex-shrink: 0; }

.crumbs { font-size: 12.5px; color: var(--ink-faint); margin-bottom: 6px; }
.crumbs a:hover { text-decoration: underline; }
.sub { color: var(--ink-soft); font-size: 13.5px; margin: 2px 0 18px; }

h2.section { font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-faint); margin: 26px 0 9px; font-weight: 650; }

/* ------------------------------------------------------------------ panels */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card + .card { margin-top: 10px; }

.row {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
  min-height: var(--tap);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--accent-soft); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 500; }
.row-sub { font-size: 12.5px; color: var(--ink-faint); margin-top: 1px; }
.row-note { font-size: 12.5px; color: var(--ink-faint); flex-shrink: 0; white-space: nowrap; }
.row.done .row-title { color: var(--ink-faint); text-decoration: line-through; }
.row.nested { padding-left: 34px; }
.row.nested-2 { padding-left: 54px; }

.empty { padding: 26px 14px; text-align: center; color: var(--ink-faint); font-size: 13.5px; }

/* -------------------------------------------------------------- checkboxes */

.check {
  appearance: none; -webkit-appearance: none;
  width: 23px; height: 23px; flex-shrink: 0;
  border: 2px solid var(--ink-faint); border-radius: 7px;
  background: transparent; display: grid; place-items: center;
  transition: background .12s, border-color .12s;
}
.check:checked { background: var(--done); border-color: var(--done); }
.check:checked::after {
  content: ""; width: 5px; height: 10px; margin-top: -2px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(43deg);
}
/* The whole row is the tap target on a phone, not just the 23px box. */
.check-row { cursor: pointer; user-select: none; }

/* ---------------------------------------------------------------- progress */

.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--done); border-radius: 99px;
  transition: width .18s ease; }
.bar.thin { height: 4px; }

.progress-line { display: flex; align-items: center; gap: 10px; margin: 10px 0 2px; }
.progress-line .bar { flex: 1; }
.progress-line b { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; }

/* ---------------------------------------------------------------- controls */

.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 9px; padding: 8px 13px; font-size: 13.5px; font-weight: 550;
  min-height: 38px;
}
.btn:hover { background: var(--accent-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: #c33; }
.btn.small { padding: 5px 9px; min-height: 32px; font-size: 12.5px; }

.link { background: none; border: 0; color: var(--accent); padding: 4px; font-size: 13px; }
.link:hover { text-decoration: underline; }

input[type=text], input[type=password], input[type=search], textarea, select {
  width: 100%; padding: 10px 12px; font: inherit;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px;
  min-height: var(--tap);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { min-height: 74px; resize: vertical; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 5px; }

/* Segmented All / Outstanding / Completed filter. */
.segmented { display: inline-flex; background: var(--accent-soft); border-radius: 9px; padding: 3px; gap: 2px; }
.segmented button {
  border: 0; background: none; color: var(--ink-soft);
  padding: 6px 12px; border-radius: 7px; font-size: 13px; font-weight: 550; min-height: 34px;
}
.segmented button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent-soft); color: var(--ink-soft);
  border: 1px solid transparent; border-radius: 99px;
  padding: 5px 11px; font-size: 12.5px; font-weight: 520;
}
.chip.on { background: var(--accent); color: #fff; }
.chip.pick { cursor: pointer; }

/* ----------------------------------------------------------------- modal */

.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 20, 24, .45);
  display: grid; place-items: center; padding: 16px;
}
.modal-card {
  background: var(--panel); border-radius: 14px; padding: 20px;
  width: min(520px, 100%); max-height: 86vh; overflow: auto;
  box-shadow: 0 18px 50px rgba(0,0,0,.28);
}
.modal-card h2 { margin: 0 0 14px; font-size: 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal-actions .spacer { flex: 1; }

/* Scrollable multi-select list used by the "attach items" picker. */
.picker { border: 1px solid var(--line); border-radius: 9px; max-height: 44vh; overflow: auto; }
.picker label {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-bottom: 1px solid var(--line); cursor: pointer; min-height: var(--tap);
}
.picker label:last-child { border-bottom: 0; }

/* ------------------------------------------------------------------- misc */

.lock { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: grid; place-items: center; padding: 20px; }
.lock-card { width: min(340px, 100%); text-align: center; }
.lock-card h1 { font-size: 20px; margin: 0 0 4px; }
.lock-card p { color: var(--ink-soft); font-size: 13.5px; }
.lock-card input, .lock-card button { margin-top: 10px; width: 100%; }
.lock-card button[type=submit] {
  background: var(--accent); border: 1px solid var(--accent); color: #fff;
  border-radius: 9px; padding: 11px; font-weight: 600; min-height: var(--tap);
}
.lock-card .link { width: auto; margin-top: 14px; }
.lock-error { color: #c33; }

.sync-chip {
  border: 1px solid var(--line); background: var(--panel);
  width: 34px; height: 34px; border-radius: 9px; font-size: 15px; line-height: 1;
}
.sync-chip[data-state="ok"] { color: var(--done); }
.sync-chip[data-state="syncing"] { color: var(--accent); }
.sync-chip[data-state="offline"], .sync-chip[data-state="error"] { color: var(--warn); }
.sync-chip[data-state="off"] { color: var(--ink-faint); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 60;
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 99px; font-size: 13.5px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
@media (min-width: 761px) { .toast { bottom: 26px; } }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 25px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--ink-faint); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.grow { flex: 1; }
