:root {
  --bg: #fbf6ee; --surface: #ffffff; --surface-2: #f3e9d8;
  --ink: #2b2420; --ink-2: #7a6a56;
  --tint: #b94f21; --on-tint: #ffffff; --tint-soft: #f8e9df; --tint-ink: #b04a1e;
  --dim: #cbbda7; --line: #efe4d2; --off: #857560;
  --radius-card: 18px; --radius-chip: 14px;
  --font: ui-rounded, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1612; --surface: #272019; --surface-2: #3a3026;
    --ink: #f3ece2; --ink-2: #b5a48f;
    --tint: #e8743f; --on-tint: #1b1612; --tint-soft: #3d2416; --tint-ink: #f0a57e;
    --dim: #5c5044; --line: #3a3026; --off: #9a8a76;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1612; --surface: #272019; --surface-2: #3a3026;
  --ink: #f3ece2; --ink-2: #b5a48f;
  --tint: #e8743f; --on-tint: #1b1612; --tint-soft: #3d2416; --tint-ink: #f0a57e;
  --dim: #5c5044; --line: #3a3026; --off: #9a8a76;
  color-scheme: dark;
}
@media (prefers-contrast: more) {
  :root { --ink-2: #4a3d2e; --off: #6a5a46; --dim: #8a7a66; --line: #b8a894; }
  /* The dark selectors outrank plain :root, so they need their own override. */
  :root[data-theme="dark"] { --ink-2: #d4c4ae; --off: #c4b49e; --dim: #8a7a66; --line: #8a7a66; }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --ink-2: #d4c4ae; --off: #c4b49e; --dim: #8a7a66; --line: #8a7a66; }
  }
}

* { box-sizing: border-box; }
html { font-size: 17px; -webkit-text-size-adjust: 100%; }
/* On touch devices the root follows the system body size (iOS Text Size). Body re-applies our family and 1rem. */
@media (pointer: coarse) {
  @supports (font: -apple-system-body) {
    html { font: -apple-system-body; }
  }
}
body { margin: 0; background: var(--bg); color: var(--ink); font: 1rem/1.35 var(--font); min-height: 100dvh; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--tint); outline-offset: 2px; }
a { color: var(--tint-ink); }

.plain { padding: 24px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); max-width: 40ch; }
.plain h1 { font-size: 1.6rem; margin-bottom: 8px; }

.wrap { max-width: 680px; margin: 0 auto; padding: 0 max(16px, env(safe-area-inset-right)) calc(84px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.holiday { padding-top: 24px; }
.holiday + .holiday { margin-top: 32px; border-top: 1px solid var(--line); }
.holiday h2 { font-size: 2rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; }
.sub { color: var(--ink-2); font-size: 0.88rem; margin-top: 2px; }
.you { font-size: 0.88rem; margin-top: 4px; color: var(--ink-2); }
.you b { color: var(--ink); font-weight: 600; }
.you button { color: var(--tint-ink); font-weight: 600; min-height: 44px; padding: 0 8px; margin-left: 2px; }

.seg { display: flex; background: var(--surface-2); border-radius: 999px; padding: 3px; margin-top: 12px; }
.seg button { flex: 1; min-height: 44px; border-radius: 999px; font-size: 0.88rem; font-weight: 600; color: var(--ink); }
.seg button[aria-selected="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.strip { display: flex; gap: 8px; overflow-x: auto; margin-top: 12px; padding-bottom: 4px; scrollbar-width: none; }
.strip button { flex: 0 0 auto; min-height: 44px; min-width: 64px; padding: 0 14px; border-radius: 999px; background: var(--surface-2); font-size: 0.88rem; font-weight: 600; }
.strip button[aria-selected="true"] { background: var(--tint); color: var(--on-tint); }

.week-range { color: var(--ink-2); font-size: 0.88rem; margin-top: 8px; }
.cards { display: grid; gap: 12px; margin-top: 16px; }
.card { background: var(--surface); border-radius: var(--radius-card); padding: 14px; }
.card-head { display: block; width: 100%; text-align: left; min-height: 44px; }
.card h3 { font-size: 1rem; font-weight: 600; line-height: 1.3; }
.meta { display: block; color: var(--ink-2); font-size: 0.76rem; font-weight: 400; margin-top: 2px; }
.note { color: var(--ink-2); font-size: 0.76rem; margin-top: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.chip { flex: 1 1 44px; min-width: 44px; min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: var(--surface-2); border-radius: var(--radius-chip); font-size: 0.76rem; font-weight: 600; line-height: 1.1; transition: background 120ms, color 120ms; }
.chip .n { font-size: 0.65rem; min-height: 0.8em; }
.chip[aria-pressed="true"] { background: var(--tint); color: var(--on-tint); }
.chip[aria-pressed="true"] .n::before { content: "✓ "; }
.chip[disabled] { color: var(--off); background: var(--surface-2); cursor: default; }
.chip[disabled] span:first-child { text-decoration: line-through; }
.chip:active:not([disabled]) { transform: scale(0.97); }

.detail { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 6px; font-size: 0.88rem; }
.detail-list div { display: grid; grid-template-columns: 76px 1fr; gap: 8px; }
.detail dt { color: var(--ink-2); font-weight: 600; } .detail dd { margin: 0; }
.going { margin-top: 8px; display: grid; gap: 3px; font-size: 0.88rem; }
.going em { font-style: normal; display: inline-block; width: 40px; font-weight: 600; color: var(--ink-2); }
.btn { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 999px; font-weight: 600; font-size: 0.94rem; text-decoration: none; }
.btn-tint { background: var(--tint-soft); color: var(--tint-ink); margin-top: 12px; }
.btn-fill { background: var(--tint); color: var(--on-tint); width: 100%; }
.btn[disabled] { opacity: .5; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); z-index: 5; }
.tabs button { flex: 1; min-height: 52px; display: grid; justify-items: center; gap: 2px; font-size: 0.65rem; font-weight: 500; color: var(--ink-2); padding: 6px 0; }
.tabs button svg { width: 26px; height: 26px; fill: currentColor; }
.tabs button { position: relative; }
.tabs button[aria-selected="true"] { color: var(--tint-ink); font-weight: 600; }
.tabs button[aria-selected="true"]::before { content: ""; position: absolute; top: 0; left: 50%; width: 32px; height: 3px; margin-left: -16px; border-radius: 0 0 3px 3px; background: var(--tint); }

#sheet { position: fixed; inset: 0; z-index: 10; }
.sheet-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 10; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: 22px 22px 0 0; padding: 8px max(16px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); z-index: 11;
  max-width: 680px; margin: 0 auto; transition: transform 250ms ease-out; }
.sheet.dragging { transition: none; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--dim); margin: 0 auto 10px; }
.sheet-bar { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.sheet-bar button { min-height: 44px; padding: 0 8px; font-weight: 600; color: var(--tint-ink); }
.sheet h2 { font-size: 1.3rem; font-weight: 700; margin-top: 4px; }
.sheet p { color: var(--ink-2); font-size: 0.88rem; margin: 4px 0 12px; }
.field { display: grid; gap: 4px; margin-top: 10px; }
.field label { font-size: 0.88rem; font-weight: 600; }
.field input, .field textarea { font: inherit; font-size: max(1rem, 16px); color: var(--ink); background: var(--surface); border: 1.5px solid var(--ink-2); border-radius: 12px; padding: 11px 12px; min-height: 44px; }
.field input[aria-invalid="true"] { border-color: var(--tint-ink); border-width: 2.5px; }
.err { color: var(--tint-ink); font-size: 0.88rem; font-weight: 600; }
.field textarea { min-height: 88px; resize: vertical; }
[hidden] { display: none !important; }
.toast { position: fixed; left: max(16px, env(safe-area-inset-left)); right: max(16px, env(safe-area-inset-right)); bottom: calc(76px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-size: 0.88rem; z-index: 20; max-width: 480px; margin: 0 auto; }
.foot { color: var(--ink-2); font-size: 0.76rem; margin-top: 32px; }

@media (prefers-reduced-motion: reduce) {
  .chip, .sheet { transition: none; }
  .chip:active:not([disabled]) { transform: none; }
}
@media (min-width: 720px) {
  .tabs { position: sticky; top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); padding-bottom: 0; }
  .tabs button { grid-auto-flow: column; min-height: 48px; font-size: 0.88rem; }
  .wrap { padding-bottom: 48px; }
}
