:root {
  color-scheme: dark;
  --bg: #181818;
  --card: #212121;
  --row: #2a2928;
  --line: #333230;
  --text: #ecebe8;
  --muted: #8f8b84;
  --dim: #5f5c57;
  --accent: #e07a52;
  --accent-soft: #3a2419;
  --green: #5aa37c;
  --red: #e05252;
  --amber: #c8a24a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  /* Home-screen install: don't let content slide under the notch. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

main { max-width: 720px; margin: 0 auto; padding: 16px 16px 64px; }

/* ---------- sign in ---------- */

.hero { text-align: center; padding: 18vh 8px; }
.hero .mark { width: 56px; height: 56px; color: var(--accent); }
.hero h1 { font-size: 30px; margin: 14px 0 6px; letter-spacing: -0.02em; }
.hero p { color: var(--muted); margin: 0 0 28px; }
.err { color: var(--red); font-size: 13px; }

/* ---------- chrome ---------- */

header {
  display: flex; align-items: center; gap: 8px;
  position: sticky; top: 0; z-index: 5;
  padding: 10px 0 12px;
  background: linear-gradient(var(--bg) 70%, transparent);
}

.spaces { display: flex; gap: 4px; flex: 1; }

.space {
  flex: 1; padding: 8px 10px; font: inherit; font-size: 14px;
  color: var(--muted); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.space.on { color: var(--text); background: var(--row); border-color: var(--accent); font-weight: 600; }

.icon {
  width: 36px; height: 36px; font-size: 18px;
  color: var(--muted); background: none; border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer;
}

/* ---------- capture ---------- */

.capture { display: flex; gap: 8px; margin: 6px 0 4px; }

.capture input {
  flex: 1; min-width: 0; padding: 11px 12px; font: inherit;
  color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 9px;
}
.capture input:focus { outline: none; border-color: var(--accent); }
.capture select {
  padding: 11px 8px; font: inherit; font-size: 13px;
  color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 9px;
}

.btn {
  padding: 10px 14px; font: inherit; font-size: 14px; font-weight: 500;
  color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1a1a; font-weight: 600; }
.btn.lg { padding: 13px 26px; font-size: 15px; }

.link {
  padding: 0; font: inherit; color: var(--accent);
  background: none; border: none; cursor: pointer; text-decoration: underline;
}

.hint { color: var(--dim); font-size: 12.5px; margin: 4px 2px 18px; }

/* ---------- zones ---------- */

.zone {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 11px; margin-bottom: 14px; overflow: hidden;
}
.zone h2 {
  display: flex; align-items: baseline; gap: 8px; margin: 0;
  padding: 11px 14px; background: var(--row);
  border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 600;
}
.zname { text-transform: uppercase; letter-spacing: 0.06em; }
.zhint { color: var(--dim); font-size: 11.5px; font-weight: 400; text-transform: none; letter-spacing: 0; }
.count { margin-left: auto; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.count.over { color: var(--red); font-weight: 700; }

/* Today is the only tinted block, and the only one with a hard number on it.
   The visual hierarchy IS the argument. */
.zone.today { border-color: var(--accent); }
.zone.today h2 { background: var(--accent-soft); }
.zone.today .zname { color: var(--accent); }
.zone.today .hint { padding: 0 14px 11px; margin: 8px 0 0; }

.zone ul { list-style: none; margin: 0; padding: 0; }

.item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: none; }

.check {
  flex: none; width: 18px; height: 18px; padding: 0;
  background: none; border: 1.5px solid var(--dim);
  border-radius: 5px; cursor: pointer;
}
.check:hover { border-color: var(--green); background: #1e2f26; }

.txt { flex: 1; min-width: 0; }
.title { overflow-wrap: anywhere; }
.quote { font-style: italic; }
.meta { display: flex; gap: 7px; margin-top: 2px; color: var(--dim); font-size: 11.5px; }
.key { font-variant-numeric: tabular-nums; }
.day { flex: none; width: 42px; color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }

.tag {
  padding: 1px 6px; color: var(--accent);
  border: 1px solid #5c3524; border-radius: 20px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em;
}
.tag.keep { color: var(--green); border-color: #2b4d3a; }

.bang { flex: none; font-weight: 700; font-size: 13px; letter-spacing: -1px; }
.p1 { color: var(--red); } .p2 { color: var(--accent); } .p3 { color: var(--amber); }

.acts { display: flex; flex: none; gap: 2px; }
.acts button, .acts a {
  padding: 4px 7px; font: inherit; font-size: 12px;
  color: var(--dim); background: none; border: none;
  border-radius: 6px; cursor: pointer; text-decoration: none;
}
.acts button:hover, .acts a:hover { color: var(--text); background: var(--row); }

.slot { color: var(--muted); font-size: 13.5px; }
.dash { width: 18px; height: 18px; border: 1.5px dashed var(--dim); border-radius: 5px; }
.muted { color: var(--dim); }
.empty { padding: 13px 14px; color: var(--dim); font-size: 13px; font-style: italic; }
.empty.big { padding: 40px 14px; text-align: center; }
.foot { margin: 18px 2px; font-size: 13px; }

/* ---------- words ---------- */

.zone.theme { border-color: var(--accent); }
.zone.theme h2 { background: var(--accent-soft); }
.zone.theme .zname { color: var(--accent); text-transform: none; letter-spacing: 0; font-size: 15px; }
.zone.theme .hint { padding: 11px 14px; margin: 0; }

.item summary { cursor: pointer; list-style: none; }
.item summary::-webkit-details-marker { display: none; }
.item summary .title::after { content: " ▸"; color: var(--dim); font-size: 11px; }
.item details[open] summary .title::after { content: " ▾"; }
.item .rest { white-space: pre-line; color: var(--muted); font-size: 13px; padding: 6px 0 2px; }

.line summary { cursor: pointer; list-style: none; }
.line summary::-webkit-details-marker { display: none; }
.line summary h2::after { content: "▸"; margin-left: auto; color: var(--dim); font-size: 11px; }
.line details[open] summary h2::after { content: "▾"; }
.line h2 { align-items: flex-start; }
.line .n { color: var(--dim); font-variant-numeric: tabular-nums; }
.line .zname { text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 500; line-height: 1.4; }
.zone.keeper { border-color: #2b4d3a; }
.zone.phrase { opacity: 0.68; }

.qs { padding: 12px 14px; }
.qs label { display: block; margin-bottom: 10px; }
.qs label span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.qs textarea {
  width: 100%; padding: 8px 10px; font: inherit; font-size: 14px;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; resize: vertical;
}
.qs textarea:focus { outline: none; border-color: var(--accent); }
.qs .row { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }
.closing { padding: 12px 14px; margin: 0; font-size: 15px; font-weight: 500; }

/* ---------- archive ---------- */

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.card {
  padding: 12px 8px; text-align: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.card b { display: block; font-size: 21px; font-variant-numeric: tabular-nums; }
.card span { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }

.chart { background: var(--card); border: 1px solid var(--line); border-radius: 11px; margin-bottom: 14px; }
.chart .hint { padding: 8px 14px 0; margin: 0; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 16px 14px 8px; }
.bar { display: flex; flex: 1; flex-direction: column; justify-content: flex-end; height: 100%; }
.bar .fill { background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.bar span { margin-top: 5px; color: var(--dim); font-size: 9.5px; text-align: center; }

.hbars { padding: 14px; }
.hbar { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
.hbar .lbl { width: 88px; flex: none; color: var(--muted); font-size: 12px; }
.hbar .track { flex: 1; height: 16px; background: var(--row); border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--green); border-radius: 4px; }
.hbar .num { width: 22px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: 90vw; padding: 11px 16px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; font-size: 13.5px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
.toast.warn { border-color: var(--accent); color: var(--accent); }
.toast.err { border-color: var(--red); color: #f0c8c8; }

@media (max-width: 480px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .capture select { max-width: 96px; }
}
