:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1d2422;
  --muted: #66706c;
  --line: #e3dfd6;
  --brand: #1f3a34;
  --brand-ink: #f6f4ef;
  --accent: #c8693d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 36, 34, 0.06), 0 4px 14px rgba(29, 36, 34, 0.05);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141917;
    --surface: #1d2422;
    --ink: #ecebe6;
    --muted: #9aa49f;
    --line: #2d3633;
    --brand: #a9d3c5;
    --brand-ink: #141917;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { padding-bottom: calc(64px + var(--safe-bottom)); -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: 0.02em; font-size: 1.05rem; }
.person-switch {
  margin-left: auto; display: flex; padding: 3px; gap: 2px;
  background: var(--line); border-radius: 999px;
}
.person-switch button {
  border: 0; background: transparent; padding: 5px 14px; border-radius: 999px;
  font-size: 0.9rem; color: var(--muted); cursor: pointer;
}
.person-switch button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.icon-btn { border: 0; background: transparent; color: var(--muted); padding: 6px; cursor: pointer; border-radius: 8px; }

.view { max-width: 720px; margin: 0 auto; padding: 12px 14px 24px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 0 1 120px; text-align: center; padding: 6px 8px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-size: 0.82rem;
}
.tabbar a[aria-current="page"] { color: var(--ink); background: var(--bg); font-weight: 600; }

.sheet {
  border: 0; border-radius: var(--radius); padding: 0; width: min(440px, 92vw);
  background: var(--surface); color: var(--ink); box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}
.sheet::backdrop { background: rgba(10, 14, 13, 0.45); }
.sheet form { display: grid; gap: 12px; padding: 18px; }
.sheet h2 { margin: 0 0 4px; font-size: 1.1rem; }
.sheet label { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.sheet label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.hint { margin: 0; font-size: 0.8rem; color: var(--muted); }

input, select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); outline: none;
}
input[type="checkbox"] { width: auto; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { resize: vertical; min-height: 64px; }

.row-actions { display: flex; justify-content: flex-end; gap: 8px; }
.primary, .ghost {
  border-radius: 10px; padding: 8px 16px; cursor: pointer; font-weight: 600; font-size: 0.9rem;
}
.primary { border: 0; background: var(--brand); color: var(--brand-ink); }
.ghost { border: 1px solid var(--line); background: transparent; }

.toast {
  position: fixed; left: 50%; bottom: calc(76px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 999px;
  font-size: 0.88rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

.tabbar[hidden] { display: none; }
body:has(.tabbar[hidden]) { padding-bottom: var(--safe-bottom); }
a.ghost { color: var(--ink); }
