:root {
  --bg: #f6f5f1; --card: #ffffff; --ink: #1b1d1a; --muted: #62675f; --line: #e2e0d8;
  --accent: #0b6e5a; --accent-ink: #ffffff; --accent-soft: #dcefe9;
  --warn: #9a4a00; --warn-soft: #fbead6; --danger: #b3261e;
  --on: #0b6e5a; --off: #9a9d96; --shadow: 0 1px 2px rgba(0,0,0,.06);
  --tabbar-h: 56px; --bar-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141614; --card: #1e211e; --ink: #ecefe9; --muted: #a2a89f; --line: #30352f;
    --accent: #43c3a5; --accent-ink: #06231c; --accent-soft: #1d3a32;
    --warn: #f0b36b; --warn-soft: #3a2b16; --danger: #ff8f86;
    --on: #43c3a5; --off: #7a7f77; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #141614; --card: #1e211e; --ink: #ecefe9; --muted: #a2a89f; --line: #30352f;
  --accent: #43c3a5; --accent-ink: #06231c; --accent-soft: #1d3a32;
  --warn: #f0b36b; --warn-soft: #3a2b16; --danger: #ff8f86;
  --on: #43c3a5; --off: #7a7f77; --shadow: none;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); overflow-x: hidden;
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.brand-header { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12px) 16px 0; }
.brand-header img { display: block; width: 160px; max-width: 100%; height: auto; padding: 8px 10px; border-radius: 12px; background: #faf0e2; }
main { padding: 12px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px); max-width: 640px; margin: 0 auto; min-width: 0; }
main.has-bar { padding-bottom: calc(var(--tabbar-h) + var(--bar-h) + env(safe-area-inset-bottom) + 24px); }
h1 { font-size: 28px; line-height: 1.15; margin: 8px 0 16px; letter-spacing: -.01em; overflow-wrap: anywhere; }
h1.welcome-intro { font: inherit; color: var(--muted); margin: 0 0 12px; }
h2 { font-size: 13px; text-transform: none; letter-spacing: .02em; color: var(--muted); font-weight: 600; margin: 24px 4px 8px; }
p { margin: 0 0 12px; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.pad { padding: 14px 16px; }
.btn { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btns .btn { flex: 1 1 120px; white-space: nowrap; padding: 0 12px; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 6px 8px 6px 16px; min-width: 0; }
.row .grow { flex: 1 1 auto; min-width: 0; }
.row .title { font-weight: 600; overflow-wrap: anywhere; }
.row .sub { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
a.row, button.row { width: 100%; text-align: left; background: none; border: 0; color: inherit; text-decoration: none; }
.chev { width: 20px; height: 20px; stroke: var(--muted); fill: none; stroke-width: 2; flex: none; }

.toggle { width: 44px; height: 44px; flex: none; border-radius: 22px; border: 0; background: transparent; display: grid; place-items: center; padding: 0; }
.toggle svg { width: 24px; height: 24px; fill: none; stroke: var(--off); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.toggle[aria-pressed="true"] svg { stroke: var(--on); }
.toggle[aria-pressed="true"] { background: var(--accent-soft); }
.toggle:focus-visible, .btn:focus-visible, .seg button:focus-visible, .switch:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; gap: 2px; margin-bottom: 12px; }
.seg button { flex: 1; min-height: 40px; border: 0; background: transparent; border-radius: 10px; font-weight: 600; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.switch { width: 52px; height: 32px; border-radius: 16px; border: 0; background: var(--off); position: relative; flex: none; padding: 0; margin-right: 8px; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 13px; background: #fff; transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch-row { display: flex; align-items: center; min-height: 56px; padding: 6px 8px 6px 16px; gap: 8px; }
.switch-row .grow { flex: 1; min-width: 0; }

.day { font-size: 13px; font-weight: 700; color: var(--muted); margin: 20px 4px 6px; position: sticky; top: 0; }
.ev { display: flex; gap: 12px; padding: 10px 8px 10px 16px; min-height: 52px; align-items: flex-start; }
.ev .when { width: 58px; flex: none; font-size: 14px; color: var(--muted); padding-top: 2px; font-variant-numeric: tabular-nums; }
.ev .grow { flex: 1; min-width: 0; }
.ev .title { font-weight: 600; overflow-wrap: anywhere; }
.ev .sub { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.ev.hidden-ev .title { text-decoration: line-through; color: var(--muted); }
.ev .reason { font-size: 13px; color: var(--warn); }
.ev .bell { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--on); stroke-width: 1.8; margin-top: 2px; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); margin-right: 6px; }
.pill.removed { background: var(--warn-soft); color: var(--warn); }

#tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
#tabbar a { flex: 1; height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); text-decoration: none; min-width: 0; }
#tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabbar a[aria-current="page"] { color: var(--accent); font-weight: 700; }

#bar-slot { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); z-index: 4; }
.bar { display: flex; align-items: center; gap: 12px; min-height: var(--bar-h); padding: 8px 16px; background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -4px 12px rgba(0,0,0,.06); }
.bar .grow { flex: 1; min-width: 0; }
.bar .count { font-weight: 700; }
.bar .btn { flex: none; }

.back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 8px 0 0; border: 0; background: none; color: var(--accent); font-weight: 600; text-decoration: none; }
.back svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.2; }
.field { width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); padding: 0 14px; }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 10px 14px; font-size: 14px; margin: 12px 0; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

#overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
#overlay[hidden], #toast[hidden] { display: none; }
.sheet { background: var(--card); width: 100%; max-width: 640px; border-radius: 18px 18px 0 0; padding: 20px 16px calc(env(safe-area-inset-bottom) + 16px); }
.sheet h3 { margin: 0 0 8px; font-size: 18px; overflow-wrap: anywhere; }
#toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 76px); background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; z-index: 30; text-align: center; }
.spinner { text-align: center; color: var(--muted); padding: 40px 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.link-btn { min-height: 44px; min-width: 44px; padding: 0 4px 0 8px; border: 0; background: none; color: var(--accent); font-weight: 600; }
.link-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
