:root {
  --bg: #f4f1ea;
  --paper: #fffdf8;
  --ink: #1b1a18;
  --muted: #6b675f;
  --line: #d9d4c8;
  --accent: #1f5f4a;
  --on-accent: #ffffff;
  --danger: #a4262c;
  --mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a18;
    --paper: #272522;
    --ink: #f1eee7;
    --muted: #a5a095;
    --line: #3b3834;
    --accent: #7fd1b4;
    --on-accent: #10231c;
    --danger: #f0888c;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 34rem;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem calc(2rem + env(safe-area-inset-bottom));
}

h1 {
  margin: 0;
  font: 700 1.1rem/1.2 var(--mono);
  letter-spacing: .02em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

input:not([type="checkbox"]), textarea {
  width: 100%;
  padding: .75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

textarea { resize: vertical; }

input:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  min-height: 44px;
  padding: .5rem 1.1rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  font-weight: 500;
}

button.danger {
  background: transparent;
  color: var(--danger);
  font-weight: 600;
}

.setup h1 { margin: 3rem 0 2rem; }
.setup label, dialog label { display: block; margin: .9rem 0 .3rem; color: var(--muted); font-size: .9rem; }
.setup button { width: 100%; margin-top: 1rem; }
.error { color: var(--danger); }

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.printer {
  margin: 0;
  color: var(--muted);
  font-size: .8rem;
  text-align: right;
}

.printer.bad { color: var(--danger); }

.composer { display: grid; gap: .5rem; }

.composer-actions {
  display: flex;
  justify-content: space-between;
}

.composer-actions .ghost { padding-left: 0; }

.tabs {
  display: flex;
  margin: 1.25rem 0 .75rem;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  flex: 1;
  padding: .5rem .25rem;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: .92rem;
  font-weight: 500;
  white-space: nowrap;
}

.tabs button[aria-selected="true"] {
  border-bottom-color: var(--ink);
  color: var(--ink);
  font-weight: 600;
}

.notice {
  margin: 0 0 .75rem;
  color: var(--muted);
  font-size: .9rem;
}

.list {
  display: grid;
  gap: .6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.task {
  display: flex;
  align-items: flex-start;
  gap: .25rem;
  padding: .25rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.task input {
  flex: none;
  width: 22px;
  height: 22px;
  margin: .7rem;
  accent-color: var(--accent);
}

.task-body {
  flex: 1;
  min-width: 0;
  padding: .5rem .5rem .5rem 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-weight: 400;
  text-align: left;
}

.task-title, .task-details, .task-meta {
  display: block;
  overflow-wrap: anywhere;
}

.task-title { font-weight: 600; }
.task-details { margin-top: .15rem; color: var(--muted); white-space: pre-line; font-size: .92rem; }
.task-details:empty { display: none; }
.task-meta { margin-top: .3rem; color: var(--muted); font: .75rem/1.3 var(--mono); }

.task.is-done .task-title { color: var(--muted); text-decoration: line-through; }
.task.is-pending { border-style: dashed; }

.empty {
  margin: 2.5rem 0;
  color: var(--muted);
  text-align: center;
}

dialog {
  width: min(30rem, calc(100vw - 2rem));
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
}

dialog::backdrop { background: rgb(0 0 0 / .45); }

dialog form { display: grid; gap: .35rem; }
dialog #edit-save { margin-top: .75rem; }
