:root {
  --paper: #f6f1e7;
  --card: #fffdf8;
  --ink: #2b2a33;
  --muted: #7a7468;
  --line: #e4dccb;
  --accent: #2f6f6a;      /* teal ink */
  --accent-ink: #ffffff;
  --event: #c2603e;       /* terracotta for events */
  --warn-bg: #fff3d6;
  --warn: #8a5a00;
  --bad: #b3261e;
  --rule: rgba(47, 111, 106, .08);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1d1c21;
    --card: #26252c;
    --ink: #ece8df;
    --muted: #a39d92;
    --line: #3a3842;
    --accent: #6cc2b9;
    --accent-ink: #10201f;
    --event: #e8916f;
    --warn-bg: #3a3020;
    --warn: #f3c66b;
    --bad: #ff8a80;
    --rule: rgba(108, 194, 185, .06);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: "Nunito Sans", system-ui, sans-serif;
  color: var(--ink);
  background:
    repeating-linear-gradient(to bottom, transparent 0 31px, var(--rule) 31px 32px),
    var(--paper);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

main { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(110px + env(safe-area-inset-bottom)); }

.hand { font-family: "Caveat", cursive; font-weight: 700; }

.view[hidden] { display: none !important; }

/* ---------- header ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 12px; }
.bar form { margin: 0; }
.logo { font-size: 1.7rem; color: var(--accent); }
.count { color: var(--muted); font-size: .95rem; }

/* ---------- hero ---------- */
.hero { text-align: center; padding-top: 12vh; display: flex; flex-direction: column; align-items: center; gap: 18px; }
#view-capture .hero, #view-done .hero { padding-top: 8vh; }
h1.hand { font-size: 4rem; margin: 0; color: var(--accent); line-height: 1; transform: rotate(-2deg); }
h2.hand { font-size: 2.6rem; margin: 0; line-height: 1.05; }
.lede { color: var(--muted); font-size: 1.05rem; line-height: 1.5; margin: 0; max-width: 30ch; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer; text-decoration: none;
  font: inherit; font-weight: 700; border-radius: 999px;
  padding: 12px 20px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 0 rgba(0,0,0,.15); }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.15); }
.btn:disabled { opacity: .5; }
.btn.big { font-size: 1.15rem; padding: 16px 28px; min-height: 56px; }
.btn.camera { width: 100%; max-width: 320px; }
.btn svg { width: 26px; height: 26px; }

.link { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 8px 4px; }
.link.small { font-size: .92rem; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

.error { color: var(--bad); margin: 0; }
.warning { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; }

/* ---------- working ---------- */
.preview { width: 70%; max-width: 280px; border-radius: 10px; transform: rotate(-1.5deg); box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.working-msg { font-size: 1.8rem; margin: 0; }
.dots { display: flex; gap: 8px; }
.dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: bob 1s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: .15s; }
.dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bob { 0%, 100% { transform: translateY(0); opacity: .4; } 50% { transform: translateY(-8px); opacity: 1; } }

/* ---------- review items ---------- */
.items { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }

.item {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px 10px; border-left: 5px solid var(--accent);
  transition: opacity .2s;
}
.item[data-kind="event"] { border-left-color: var(--event); }
.item.off { opacity: .45; }
.item.unsure { box-shadow: 0 0 0 2px var(--warn-bg); }
.item.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.item-top { display: flex; align-items: center; gap: 10px; }

.include input { position: absolute; opacity: 0; pointer-events: none; }
.include span {
  display: block; width: 26px; height: 26px; border: 2px solid var(--line); border-radius: 7px; cursor: pointer;
}
.include input:checked + span { background: var(--accent); border-color: var(--accent); }
.include input:checked + span::after {
  content: ""; display: block; width: 7px; height: 13px; margin: 3px 0 0 8px;
  border: solid var(--accent-ink); border-width: 0 3px 3px 0; transform: rotate(45deg);
}

.seg { display: inline-flex; background: var(--paper); border-radius: 999px; padding: 3px; }
.seg button {
  border: 0; background: none; font: inherit; font-size: .9rem; font-weight: 700; color: var(--muted);
  padding: 6px 14px; border-radius: 999px; cursor: pointer;
}
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.item[data-kind="event"] .seg button.on { background: var(--event); color: #fff; }

.remove { margin-left: auto; border: 0; background: none; color: var(--muted); font-size: 1.1rem; padding: 6px 8px; cursor: pointer; }

.title-input {
  width: 100%; margin: 10px 0 6px; border: 0; border-bottom: 1.5px dashed var(--line);
  background: none; color: var(--ink); font: 700 1.6rem "Caveat", cursive; padding: 4px 2px;
}
.title-input:focus { outline: none; border-bottom-color: var(--accent); }

.read-as { margin: 0 0 6px; font-size: .85rem; color: var(--warn); }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row label { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; flex: 1 1 120px; }
.item[data-kind="task"] .ev { display: none; }

input[type="date"], input[type="time"], select, textarea {
  font: inherit; font-size: 1rem; text-transform: none; letter-spacing: 0; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; min-height: 44px; width: 100%;
}

.notes { margin-top: 8px; }
.notes summary { color: var(--muted); font-size: .9rem; cursor: pointer; padding: 4px 0; }
.notes textarea { margin-top: 6px; resize: vertical; }

.add { margin: 14px auto 0; display: block; }

.sticky-actions {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 70%, transparent);
  display: flex; justify-content: center;
}
.sticky-actions .btn { width: 100%; max-width: 528px; }

/* ---------- done ---------- */
.results { list-style: none; padding: 0; margin: 0; width: 100%; text-align: left; display: flex; flex-direction: column; gap: 8px; }
.results li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.results li a, .results li span { color: var(--ink); font-weight: 600; text-decoration: none; }
.results li a::after { content: " ↗"; color: var(--muted); }
.results li small { color: var(--muted); white-space: nowrap; }
.results li.fail { border-color: var(--bad); }
.results li.fail small { color: var(--bad); white-space: normal; text-align: right; }
