:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1d2321; --muted: #6b7471; --line: #e3dfd6;
  --accent: #2f6f5e; --accent-ink: #ffffff; --soft: #e4eeea; --warn: #a8641c;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #171a19; --card: #212624; --ink: #ecefed; --muted: #98a19d; --line: #323836;
    --accent: #6fbfa6; --accent-ink: #10201b; --soft: #26352f; --warn: #e0a45c; }
}
* { 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; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

#view { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 20px) 16px 190px; }
header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
h1 { font-size: 26px; line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 8px; }
h2 small { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 13px; margin-left: 6px; }
section { margin-bottom: 24px; }
.meta { color: var(--muted); font-size: 13.5px; }
p.meta { margin: 8px 0 0; }
.empty { color: var(--muted); margin: 0; }
.empty.big { padding: 28px 8px; text-align: center; }
.note { margin: 0; white-space: pre-wrap; }

.sync { font-size: 12.5px; color: var(--muted); white-space: nowrap; padding: 4px 0; }
.sync.s-error { color: var(--warn); font-weight: 600; }
.sync.s-local { color: var(--warn); }

.card { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.card + .card, .goal + .goal { margin-top: 8px; }
.card b { display: block; }
.goal .meta { display: block; margin-top: 2px; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.row b { display: inline; }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.over i { background: var(--warn); }
.bar.thin { height: 4px; margin-top: 4px; }
.cat { margin-bottom: 12px; font-size: 15px; }

.tasks { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.task { display: flex; align-items: center; gap: 4px; padding: 0 6px; min-height: 54px; }
.task + .task { border-top: 1px solid var(--line); }
.check { flex: none; width: 44px; height: 44px; display: grid; place-items: center; }
.check i { width: 24px; height: 24px; border: 2px solid var(--muted); border-radius: 50%; display: grid; place-items: center;
  font-style: normal; font-size: 14px; font-weight: 700; color: var(--accent-ink); }
.task.done .check i { background: var(--accent); border-color: var(--accent); }
.body { flex: 1; min-width: 0; text-align: left; padding: 9px 4px; display: flex; flex-direction: column; }
.title { overflow-wrap: anywhere; }
.task.done .title { color: var(--muted); text-decoration: line-through; }
.dots { color: var(--accent); letter-spacing: 2px; }
.pick { flex: none; width: 44px; height: 44px; font-size: 21px; color: var(--muted); }
.pick.on { color: var(--accent); }

.link { color: var(--accent); font-weight: 600; padding: 10px 2px; display: inline-block; text-align: left; }
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; border-radius: 12px; padding: 12px 18px; }
.ghost { color: var(--muted); padding: 12px 10px; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tiles div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-width: 0; }
.tiles b { display: block; font-size: 15px; margin-top: 2px; overflow-wrap: anywhere; }
.monthnav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.monthnav button { width: 44px; height: 44px; font-size: 24px; color: var(--accent); }
.monthnav b { text-transform: capitalize; }

label { display: block; font-size: 13.5px; color: var(--muted); margin-top: 12px; }
input:not([type=hidden]), select { display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font-size: 16px;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; }
.form .primary { margin-top: 14px; width: 100%; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

#dock { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); border-top: 1px solid var(--line);
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 6px); }
#dock > * { max-width: 536px; margin: 0 auto; }
#capture { display: flex; gap: 8px; margin-bottom: 8px; }
#capture input { margin: 0; flex: 1; min-width: 0; background: var(--card); border-radius: 12px; }
#capture button { flex: none; width: 46px; height: 46px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-size: 24px; line-height: 1; }
#capture #mic { background: var(--card); border: 1px solid var(--line); color: var(--muted); display: grid; place-items: center; }
#capture #mic.on { background: var(--warn); color: var(--bg); }
#tabs { display: grid; grid-template-columns: repeat(4, 1fr); }
#tabs button { padding: 10px 2px; font-size: 13.5px; color: var(--muted); border-radius: 10px; }
#tabs button.on { color: var(--accent); font-weight: 700; background: var(--soft); }

#sheet-wrap { position: fixed; inset: 0; background: rgb(0 0 0 / 0.45); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
#sheet { width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; background: var(--card); border-radius: 18px 18px 0 0;
  padding: 20px 16px calc(env(safe-area-inset-bottom) + 16px); }
#sheet h2 { font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 14px; }
.seg button { padding: 10px 4px; font-size: 13.5px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); }
.seg button.on { background: var(--soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.actions { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 18px; }
.actions .ghost:first-child:not(:nth-last-child(2)) { margin-right: auto; color: var(--warn); }

#toast { position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%); z-index: 20; width: max-content; max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14.5px; text-align: center; }
