:root {
  --bg: #ffffff; --fg: #111111; --muted: #6b6b6b; --line: #e6e6e6; --soft: #f5f5f5;
  --primary: #111111; --primary-fg: #ffffff;
  --yes: #e3f4e6; --yes-fg: #1d5e2b; --yes-line: #9fd3aa;
  --no: #fbe7e7; --no-fg: #8a1f1f; --no-line: #eab0b0;
  --danger: #b42318; --focus: #2b6cdf; --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111111; --fg: #f2f2f2; --muted: #a3a3a3; --line: #2a2a2a; --soft: #1b1b1b;
    --primary: #f2f2f2; --primary-fg: #111111;
    --yes: #16301c; --yes-fg: #9fe0ad; --yes-line: #2d6a3a;
    --no: #3a1a1a; --no-fg: #f2a5a5; --no-line: #7a2e2e;
    --danger: #ff6b5e; --focus: #7aa7ff;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 36rem; margin: 0 auto; padding: 16px 16px 64px; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 8px 0 16px; }
h2 { font-size: 1.15rem; margin: 28px 0 8px; }
a { color: inherit; text-underline-offset: 3px; }
code { font-size: .9em; background: var(--soft); padding: 2px 4px; border-radius: 6px; }
.break { word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

.nav { display: flex; gap: 20px; max-width: 36rem; margin: 0 auto; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.nav a { text-decoration: none; font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }

.flash, .notice { background: var(--soft); border-radius: var(--radius); padding: 10px 14px; }
.errors { color: var(--danger); margin: 6px 0; padding-left: 0; list-style: none; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 20px; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.wrap { flex-wrap: wrap; }
.list { list-style: none; padding: 0; margin: 0; }
.list > li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.tag { display: inline-block; font-size: .8rem; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); margin-left: 6px; }
.tag.attention { background: var(--fg); color: var(--bg); }
.tag.best { background: var(--yes); color: var(--yes-fg); }

input:not([type=checkbox]):not([type=radio]):not([type=hidden]), textarea, select { font: inherit; font-size: 16px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; max-width: 100%; }
textarea { width: 100%; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
label { font-weight: 500; }
button, .button { font: inherit; font-weight: 600; min-height: 44px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.button { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.button.secondary, button.secondary { background: var(--bg); color: var(--fg); border-color: var(--line); }
.button.small { padding: 6px 12px; font-size: .9rem; }
button.link { background: none; border: none; padding: 0 4px; text-decoration: underline; font-weight: 500; min-height: 44px; }
button.danger { background: var(--bg); color: var(--danger); border-color: var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.chip { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; min-height: 44px; font-weight: 500; }

details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--muted); }
details.confirm { margin: 12px 0; }
details.confirm > summary { color: var(--danger); }

.slot { border-bottom: 1px solid var(--line); padding: 14px 0; }
.slot .when { display: flex; flex-direction: column; margin-bottom: 8px; }
.slot.locked .when { opacity: .55; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { width: 100%; }
.choice.yes[aria-pressed="true"] { background: var(--yes); color: var(--yes-fg); border-color: var(--yes-line); }
.choice.no[aria-pressed="true"] { background: var(--no); color: var(--no-fg); border-color: var(--no-line); }
.names { margin: 0; padding-left: 18px; }

.result { border-bottom: 1px solid var(--line); padding: 10px 0; }
.result.past { opacity: .55; }
.result h2 { margin: 6px 0; font-size: 1.05rem; }
.yes-text { color: var(--yes-fg); font-weight: 600; }
.no-text { color: var(--no-fg); font-weight: 600; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); }
.grid { border-collapse: separate; border-spacing: 0; font-size: .9rem; white-space: nowrap; }
.grid th, .grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--bg); }
.grid thead th { text-align: center; vertical-align: bottom; font-weight: 600; line-height: 1.25; }
.grid thead th .when-time, .grid thead th .when-label { display: block; font-weight: 400; font-size: .8rem; color: var(--muted); }
.grid td { text-align: center; min-width: 52px; font-size: 1.05rem; font-weight: 700; position: relative; }
.grid th[scope="row"], .grid thead th:first-child { position: sticky; left: 0; z-index: 1; text-align: left; font-weight: 600; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; box-shadow: 2px 0 0 var(--line); }
.grid thead th:first-child { z-index: 2; vertical-align: bottom; }
.grid td.yes { background: var(--yes); color: var(--yes-fg); }
.grid td.no { background: var(--no); color: var(--no-fg); }
.grid td.none { color: var(--muted); }
.grid .past { opacity: .6; }
.grid thead th.best { background: var(--yes); color: var(--yes-fg); }
.grid tfoot td, .grid tfoot th { font-weight: 700; border-bottom: none; }
.grid tfoot td.best { background: var(--yes); color: var(--yes-fg); }
.grid .note-star { position: absolute; top: 2px; right: 4px; font-size: .65rem; font-weight: 400; color: var(--fg); }
.grid td.has-note { cursor: help; }

.rows { list-style: none; padding: 0; margin: 0; }
.daterow { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.daterow input[type="date"], .daterow input[name="label"] { grid-column: span 3; }
.daterow .errors { grid-column: span 3; }

.nudges a.button:visited { background: var(--soft); color: var(--muted); border-color: var(--line); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

.tag.tag-user { background: var(--soft); color: var(--fg); border: 1px solid var(--line); }
.grid tr.group th, .grid tr.group td { background: var(--soft); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding-top: 10px; }
.grid tr.subtotal th, .grid tr.subtotal td { font-size: .85rem; font-weight: 600; color: var(--muted); border-bottom: 2px solid var(--line); }
.grid .cell-badge { position: absolute; bottom: 2px; left: 4px; font-size: .7rem; font-weight: 400; color: var(--fg); opacity: .75; }
.badge-input { width: 5rem; text-align: center; }
.grid .cell-badge + .cell-badge { left: 18px; }
.install { margin: 8px 0; }
