/* GTD Flow: phone first, then wider screens. Light and dark follow the system. */
:root {
  --bg: #f6f5f1; --card: #ffffff; --ink: #1f2421; --muted: #5d6662; --line: #dedbd2;
  --accent: #2f5d50; --accent-ink: #ffffff; --accent-soft: #e3eee9;
  --warn: #9a5b00; --warn-soft: #fff3df; --danger: #a8322d; --danger-soft: #fbe9e7;
  --today: #2f5d50; --overdue: #a8322d; --star: #c08a00;
  --radius: 12px; --tabs-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816; --card: #1d2320; --ink: #e8ece9; --muted: #9aa5a0; --line: #2e3633;
    --accent: #7cc2a9; --accent-ink: #0d1a15; --accent-soft: #1f3a31;
    --warn: #f0b252; --warn-soft: #3a2c14; --danger: #f08a80; --danger-soft: #3a1d1b;
    --today: #7cc2a9; --overdue: #f08a80; --star: #f0c24b;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
}
a { color: var(--accent); }
main { max-width: 760px; margin: 0 auto; padding: 8px 16px 24px; }
h1 { font-size: 1.5rem; margin: 12px 0 8px; }
h2 { font-size: 1.05rem; margin: 24px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
h2.overdue-h { color: var(--overdue); }
code { font: .9em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--accent-soft); padding: 1px 4px; border-radius: 4px; }
pre { background: var(--card); border: 1px solid var(--line); padding: 12px; border-radius: 8px; overflow-x: auto; }

/* Top bar with the capture box */
.top {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: flex; gap: 12px; align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; border-bottom: 1px solid var(--line);
}
.brand { display: none; font-weight: 700; text-decoration: none; color: var(--ink); white-space: nowrap; }
.capture { flex: 1; display: flex; gap: 8px; max-width: 760px; margin: 0 auto; }
.capture input { flex: 1; min-width: 0; }
.capture button { width: 44px; font-size: 1.4rem; padding: 0; }

/* Bottom tabs (phone); a left rail on wide screens */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tabs-h); font-size: .75rem; color: var(--muted); text-decoration: none; position: relative;
}
.tabs a .ico { font-size: 1.25rem; line-height: 1; }
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.badge { position: absolute; top: 6px; right: calc(50% - 26px); background: var(--accent); color: var(--accent-ink); border-radius: 10px; font-size: .7rem; padding: 0 6px; }

/* Forms */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  min-height: 44px;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 0; }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--ink); font-size: 1rem; }
label.inline { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 1rem; }
label.inline input { width: 22px; min-height: 22px; height: 22px; margin: 0; }
button {
  min-height: 44px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.small { min-height: 36px; padding: 4px 10px; font-size: .85rem; }
button.big { width: 100%; font-size: 1.1rem; min-height: 52px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.stack { display: block; }
.addline { display: flex; gap: 8px; margin: 12px 0; }
.addline input { flex: 1; }
.danger-row { margin-top: 16px; }
.filters { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; margin: 8px 0 12px; }

/* Messages */
.flash { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; }
.flash.err { background: var(--danger-soft); color: var(--danger); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
.hint { color: var(--muted); font-size: .9rem; }
.empty { color: var(--muted); }
.empty.big { font-size: 1.1rem; padding: 24px 0; }
.nudge { background: var(--warn-soft); padding: 10px 12px; border-radius: 10px; }
.more { margin-top: 16px; }
.crumbs { margin: 8px 0 0; font-size: .9rem; }
.outcome { font-style: italic; color: var(--muted); }
.warn { color: var(--warn); }

/* Task list */
ul.tasks, ul.projects, ul.inbox, ul.rows, ul.plain { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: flex-start; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 6px 0; padding: 4px 8px 4px 4px; }
.task form { margin: 0; }
.check {
  width: 44px; height: 44px; min-height: 44px; padding: 0; border: none; background: transparent; position: relative; color: var(--accent);
}
.check::before { content: ""; position: absolute; inset: 11px; border: 2px solid var(--muted); border-radius: 50%; }
.check:hover::before { border-color: var(--accent); }
.check.on::before { border-color: var(--accent); background: var(--accent-soft); }
.task .body { flex: 1; min-width: 0; padding: 10px 0; text-decoration: none; color: var(--ink); }
.task .title { display: block; overflow-wrap: anywhere; }
.task.closed .title { text-decoration: line-through; color: var(--muted); }
.star { color: var(--star); }
.meta { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: .8rem; color: var(--muted); margin-top: 2px; }
.due.today { color: var(--today); font-weight: 600; }
.due.overdue { color: var(--overdue); font-weight: 600; }
.ctx { color: var(--accent); }
.area, .proj { background: var(--accent-soft); border-radius: 6px; padding: 0 6px; }
.src { font-style: italic; }
.task .link { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; max-width: 30%; padding: 6px 4px; text-decoration: none; color: var(--accent); border-left: 1px solid var(--line); align-self: stretch; }
.task .link span { font-size: 1.1rem; line-height: 1; }
.task .link small { font-size: .7rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.openlink { margin: 4px 0 12px; overflow-wrap: anywhere; }
.consent ul { padding-left: 20px; }
.consent .actions { display: flex; gap: 8px; }
a.bookmarklet { display: inline-block; padding: 6px 12px; border: 1px dashed var(--accent); border-radius: 8px; text-decoration: none; font-weight: 600; cursor: grab; }

.projects li a { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 6px 0; padding: 12px; text-decoration: none; color: var(--ink); }
.projects li.closed a { opacity: .6; }
.plain li { padding: 6px 0; }
.small { font-size: .85rem; }

.card, ul.inbox > li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 8px 0; padding: 4px 12px; }
details > summary { cursor: pointer; padding: 10px 0; min-height: 44px; list-style-position: inside; }
details[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.taskform { padding-bottom: 8px; }

/* Lists switcher */
.seg { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin: 12px 0 4px; }
.seg a { flex: 1; text-align: center; padding: 8px 4px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: .9rem; }
.seg a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg small { opacity: .8; }

/* Settings */
.rows li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rows small { color: var(--muted); overflow-wrap: anywhere; }
.qr { display: block; background: #fff; padding: 8px; border-radius: 8px; margin: 8px 0; }
.secret { overflow-wrap: anywhere; }
.codes { columns: 2; font-size: 1.05rem; }
.login { max-width: 420px; margin: 10vh auto 0; text-align: left; }
.login h1 { font-size: 2rem; }

table.preview { width: 100%; border-collapse: collapse; font-size: .9rem; display: block; overflow-x: auto; }
.preview th, .preview td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }

@media (max-width: 420px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters button { grid-column: span 2; }
}
@media (min-width: 900px) {
  body { padding-bottom: 24px; padding-left: 200px; }
  .brand { display: block; }
  .tabs { top: 0; bottom: 0; right: auto; width: 200px; display: flex; flex-direction: column; border-top: none; border-right: 1px solid var(--line); padding-top: 64px; }
  .tabs a { flex-direction: row; justify-content: flex-start; gap: 12px; height: 48px; padding: 0 20px; font-size: .95rem; }
  .badge { position: static; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.confirm { padding: 8px 14px 12px; }
.confirm h2 { margin-top: 8px; }
.page { display: contents; }
