:root {
  --paper: #eef1ee; --surface: #fbfcfb; --ink: #1c2420; --muted: #5b675f; --line: #cdd5cf;
  --accent: #1f6f5c; --accent-ink: #ffffff; --warn: #9a4a12; --cell-off: #dde3de;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121614; --surface: #1b211e; --ink: #e8eee9; --muted: #98a59d; --line: #2e3833;
    --accent: #7fd1b9; --accent-ink: #0d1f19; --warn: #e3a36e; --cell-off: #26302b;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-text-size-adjust: 100%;
}
.tabs { display: flex; gap: 4px; padding: 10px 12px 0; position: sticky; top: 0; background: var(--paper); z-index: 2; }
.tabs [role=tab] {
  flex: 1; min-height: 44px; border: 0; border-bottom: 3px solid transparent; background: none;
  color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; touch-action: manipulation;
}
.tabs [role=tab][aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); }
main { max-width: 36rem; margin: 0 auto; padding: 12px 16px 48px; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button, input, select { font: inherit; color: inherit; touch-action: manipulation; }
button {
  min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.quiet { border-color: transparent; background: none; color: var(--muted); }
button:disabled { opacity: .45; cursor: not-allowed; }
input[type=text], input[type=number], select {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
label { display: block; font-size: .875rem; color: var(--muted); margin: 10px 0 4px; }
.add { padding: 4px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.add button { margin-top: 14px; width: 100%; }
.alert { margin: 8px 0 0; padding: 0; min-height: 0; color: var(--warn); font-weight: 600; }
.alert:not(:empty) { padding: 10px 12px; border-left: 4px solid var(--warn); background: var(--surface); }
.list { list-style: none; margin: 0; padding: 0; }
.task { padding: 14px 0; border-bottom: 1px solid var(--line); }
.task-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.title { font-weight: 600; overflow-wrap: anywhere; }
.pts { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.note { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.subtasks { list-style: none; margin: 8px 0 0; padding: 0; }
.subtasks label { display: flex; gap: 10px; align-items: center; min-height: 36px; margin: 0; color: var(--ink); font-size: 1rem; }
.subtasks input { width: 22px; height: 22px; accent-color: var(--accent); }
.sub-add { display: flex; gap: 8px; margin-top: 8px; }
.sub-add input { flex: 1; min-width: 0; }
.evidence { margin-top: 10px; }
.evidence textarea { width: 100%; box-sizing: border-box; font: inherit; }
.evidence-foot { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.evidence-foot .counter { flex: 1; color: var(--muted); }
.actions { display: flex; gap: 8px; margin-top: 10px; }
.empty { color: var(--muted); padding: 24px 0; }
.done h2 { font-size: 1rem; color: var(--muted); margin: 24px 0 0; }
.done .title { text-decoration: line-through; color: var(--muted); }
@media (prefers-reduced-motion: no-preference) { button { transition: background-color .15s; } }
.reward { padding: 14px 0; border-bottom: 1px solid var(--line); }
.balance { font-size: 2.25rem; font-weight: 700; margin: 12px 0 14px; font-variant-numeric: tabular-nums; }
.cells { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.cell { aspect-ratio: 1; border-radius: 4px; background: var(--cell-off); }
.cell.filled { background: var(--accent); }
.cells-more { margin: 8px 0 0; color: var(--accent); font-weight: 700; text-align: right; }
#panel-bank h2 { font-size: 1rem; color: var(--muted); margin: 28px 0 4px; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: grid; grid-template-columns: 3.2rem 1fr auto; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.history .amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.history .gain .amount { color: var(--accent); }
.history .spend .amount { color: var(--warn); }
.history time { color: var(--muted); font-size: .875rem; }
.backup { margin-top: 32px; }
.backup h2 { font-size: 1rem; color: var(--muted); margin: 0 0 4px; }
.backup button { margin-top: 8px; }
.backup input[type=file] { width: 100%; }

/* settings */
.topic { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 4px 0; border-bottom: 1px solid var(--line); }
#panel-settings h2 { margin: 20px 0 6px; }

.limit-line { margin: 8px 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.hint { margin: 6px 0 0; min-height: 1.2em; color: var(--muted); font-size: .9rem; }
.meta { margin-top: 2px; }

/* journal */
#panel-journal h2 { font-size: 1rem; color: var(--muted); margin: 20px 0 4px; }
.totals { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-variant-numeric: tabular-nums; }
.totals caption { text-align: left; font-weight: 700; padding: 4px 0; }
.totals th { text-align: left; color: var(--muted); font-size: .875rem; font-weight: 400; }
.totals th, .totals td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); }
.entry { padding: 14px 0; border-bottom: 1px solid var(--line); }
.entry summary { cursor: pointer; min-height: 36px; display: flex; align-items: center; color: var(--muted); }
.evidence-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0 8px; }
.steps { list-style: none; margin: 0 0 8px; padding: 0; }
.draft-steps { list-style: none; margin: 8px 0 0; padding: 0; }
.draft-steps li { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; border-bottom: 1px solid var(--line); }
