:root {
  --bg: #f4f2ec;
  --surface: #fbfaf6;
  --ink: #15171a;
  --muted: #5b5f66;
  --accent: #c92a12;
  --accent-ink: #ffffff;
  --rule: #15171a;
  --hair: #cfcbc0;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sans: "Helvetica Neue", Helvetica, "Arial Nova", Arial, "Liberation Sans", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --gutter: 32px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }
html.locked { overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  overflow-x: clip;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.wrap { width: 100%; max-width: 1400px; margin-inline: auto; padding-inline: var(--gutter); }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.skip { position: absolute; left: 16px; top: -100px; z-index: 50; background: var(--ink); color: var(--bg); padding: 12px 20px; }
.skip:focus { top: 12px; }

.label, .eyebrow, .lbl, .field label {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 2px solid var(--rule); }
.top-in { display: flex; align-items: center; justify-content: space-between; min-height: 64px; }
.brand { font-weight: 800; font-size: 1.5rem; letter-spacing: -0.04em; text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.brand span, .numeral span, .brand-foot span { color: var(--accent); }
.top nav { display: flex; gap: 4px; }
.top nav a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding-inline: 12px;
  font-size: 0.9375rem; font-weight: 600; text-decoration: none;
  border-bottom: 3px solid transparent; transition: border-color 0.18s var(--ease), background-color 0.18s var(--ease);
}
.count {
  display: inline-block; min-width: 1.6em; padding: 0 6px; text-align: center;
  font-family: var(--mono); font-size: 0.75rem; font-weight: 700; line-height: 1.7;
  background: var(--ink); color: var(--bg);
}

/* ---------- hero ---------- */
.hero { padding-block: 32px 64px; }
.eyebrow { color: var(--muted); padding-bottom: 8px; border-bottom: 1px solid var(--rule); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 48px; align-items: end; padding-block: 16px 48px; }
.numeral {
  font-weight: 800; font-size: clamp(8rem, 34vw, 31rem); line-height: 0.78; letter-spacing: -0.07em;
  margin-left: -0.04em; padding-top: 0.06em; white-space: nowrap; user-select: none;
  animation: numeral-in 0.8s var(--ease) backwards;
}
.hero-copy { padding-bottom: 8px; animation: rise 0.6s 0.15s var(--ease) backwards; }
h1 { font-size: clamp(1.9rem, 3.4vw, 3.25rem); font-weight: 800; line-height: 1.05; letter-spacing: -0.035em; max-width: 16ch; }
.lede { margin-top: 24px; max-width: 46ch; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 24px; border: 2px solid var(--ink); background: transparent;
  font-weight: 700; text-decoration: none; transition: background-color 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease);
}
.btn-primary { margin-top: 32px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.empty .btn-primary { margin-top: 24px; }
.btn-quiet { margin-top: 16px; width: 100%; }

/* ---------- timetable ---------- */
.tt { margin-top: 8px; }
.tt-cap { display: flex; flex-wrap: wrap; gap: 8px 32px; justify-content: space-between; padding-bottom: 12px; }
.tt-hint { font-size: 0.875rem; color: var(--muted); max-width: 60ch; }
.tt-scroll { overflow-x: auto; border-top: 2px solid var(--rule); border-bottom: 2px solid var(--rule); }
.tt-inner { min-width: 860px; position: relative; padding-inline-end: 24px; }
.tt-axis, .lane { display: grid; grid-template-columns: 88px minmax(0, 1fr); }
.tt-axis { border-bottom: 1px solid var(--hair); }
.tt-ticks { position: relative; height: 32px; }
.tick-l { position: absolute; top: 8px; transform: translateX(-50%); font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
.lane + .lane { border-top: 1px solid var(--rule); }
.lane-label {
  position: sticky; left: 0; z-index: 2; background: var(--bg);
  display: flex; flex-direction: column; justify-content: center; padding: 8px 8px 8px 0;
}
.lane-label strong { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.lane-label span { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
.track { position: relative; min-height: calc(var(--rows) * 52px + 16px); }
.gridline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--hair); }
.bar {
  position: absolute; left: calc(var(--l) * 1%); width: calc(var(--w) * 1% - 4px); top: calc(var(--r) * 52px + 8px); height: 44px;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; text-align: left;
  padding: 0 8px; overflow: hidden; background: var(--surface); border: 2px solid var(--ink);
  transition: background-color 0.18s var(--ease), color 0.18s var(--ease), opacity 0.18s var(--ease), transform 0.18s var(--ease);
  transform-origin: left center; animation: bar-in 0.55s var(--ease) backwards; animation-delay: calc(0.25s + var(--i) * 70ms);
}
.bar .b-t { font-family: var(--mono); font-size: 0.75rem; line-height: 14px; white-space: nowrap; }
.bar .b-n { font-size: 0.9375rem; font-weight: 700; line-height: 18px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.bar.is-saved { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.bar.is-saved .b-t::before { content: "✓ "; }
.bar:disabled { opacity: 0.28; border-style: dashed; cursor: default; }

/* ---------- browse layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); gap: 64px; padding-block: 64px 128px; border-top: 2px solid var(--rule); align-items: start; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; }
h2 { font-size: clamp(2rem, 4vw, 3rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1; }
.status { font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); }

.tools { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 24px 16px; margin-top: 32px; padding-block: 24px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.f-search { grid-column: span 7; }
.f-cat { grid-column: span 5; }
.f-day { grid-column: span 5; }
.f-toggles { grid-column: span 7; }
.field label, .lbl { color: var(--muted); }
input[type="text"], select {
  width: 100%; min-height: 48px; padding: 8px 12px; background: var(--surface);
  border: 2px solid var(--ink); border-radius: 0; font-size: 1rem;
  transition: background-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
input::placeholder { color: #6d7178; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%2315171a' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.seg { display: flex; }
.seg button, .tog {
  min-height: 48px; padding: 8px 16px; background: var(--surface); border: 2px solid var(--ink);
  font-weight: 600; font-size: 0.9375rem; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background-color 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease);
}
.seg button { flex: 1; }
.seg button + button { margin-left: -2px; }
.toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button[aria-pressed="true"], .tog[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.tog-saved[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tog[aria-pressed="true"] .count { background: var(--bg); color: var(--ink); }
.seg button:focus-visible { position: relative; z-index: 1; }

.empty { margin-top: 32px; padding: 32px; border: 2px dashed var(--ink); background: var(--surface); }
.empty[hidden] { display: none; }
.empty-big { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; margin-bottom: 8px; }

/* ---------- list ---------- */
.day { margin-top: 48px; }
.day-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 16px; padding-bottom: 12px; border-bottom: 3px solid var(--rule); }
.day-head h3 { font-size: clamp(1.75rem, 3vw, 2.5rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1; }
.day-head p { font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); }

.row {
  position: relative; display: grid; grid-template-columns: 120px minmax(0, 1fr) 128px; gap: 8px 24px;
  padding: 24px 12px 24px 16px; border-bottom: 1px solid var(--rule);
  transition: background-color 0.18s var(--ease);
  animation: rise 0.5s var(--ease) backwards; animation-delay: calc(var(--i) * 60ms);
}
.list.settled .row { animation: none; }
.row.is-saved::before { content: ""; position: absolute; left: 0; top: -1px; bottom: -1px; width: 6px; background: var(--accent); }
.time { display: flex; flex-direction: column; font-family: var(--mono); }
.t-start { font-size: 1.75rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.04em; }
.t-end { font-size: 0.8125rem; color: var(--muted); }
.r-main { min-width: 0; }
.r-cat { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; font-family: var(--mono); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.r-saved { color: var(--accent); }
.row h4 { margin-top: 4px; font-size: clamp(1.25rem, 2vw, 1.5rem); font-weight: 800; letter-spacing: -0.025em; line-height: 1.15; }
.open { position: static; background: none; border: 0; padding: 0; text-align: left; font: inherit; letter-spacing: inherit; color: inherit; font-weight: inherit; line-height: inherit; }
.open::after { content: ""; position: absolute; inset: 0; }
.open:focus-visible { outline: none; }
.open:focus-visible::after { outline: 3px solid var(--ink); outline-offset: -3px; }
.r-sum { margin-top: 8px; color: var(--muted); max-width: 58ch; font-size: 1rem; }
.r-where { margin-top: 8px; font-size: 0.9375rem; font-weight: 600; }
.r-price { text-align: right; display: flex; flex-direction: column; align-items: flex-end; }
.price { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.fmt { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.go { margin-top: auto; padding-top: 12px; font-weight: 700; font-size: 0.9375rem; transition: transform 0.18s var(--ease); }

.rail { display: block; position: relative; height: 8px; margin-top: 16px; background: repeating-linear-gradient(90deg, var(--hair) 0 1px, transparent 1px calc(100% / 13)); border-bottom: 1px solid var(--hair); }
.rail i { position: absolute; top: 0; bottom: 0; left: calc(var(--l) * 1%); width: calc(var(--w) * 1%); background: var(--ink); transform-origin: left; animation: rail-in 0.6s var(--ease) both; animation-delay: calc(0.1s + var(--i, 0) * 60ms); }
.list.settled .rail i { animation: none; }
.row.is-saved .rail i { background: var(--accent); }

/* ---------- shortlist ---------- */
.short { position: sticky; top: 88px; }
.short-in { border: 2px solid var(--ink); background: var(--surface); padding: 24px; }
.short h2 { font-size: 1.75rem; }
.short-sum { margin-top: 8px; font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); }
.short-list { margin-top: 16px; border-top: 2px solid var(--rule); }
.short-list li { border-bottom: 1px solid var(--hair); }
.s-open { position: relative; display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; width: 100%; min-height: 64px; padding: 12px 8px; background: none; border: 0; text-align: left; transition: background-color 0.18s var(--ease), transform 0.18s var(--ease); }
.s-open:focus-visible { outline-offset: -3px; }
.s-time { font-family: var(--mono); font-size: 0.8125rem; line-height: 1.35; }
.s-time b { display: block; font-size: 1rem; }
.s-title { font-weight: 700; line-height: 1.25; }
.s-meta { display: block; font-size: 0.875rem; color: var(--muted); }
.s-warn { display: block; margin-top: 4px; font-size: 0.875rem; font-weight: 700; color: var(--accent); }
.short-empty { margin-top: 16px; color: var(--muted); font-size: 0.9375rem; }
.short-list:empty { display: none; }

/* ---------- footer ---------- */
.foot { background: var(--ink); color: #e9e6dd; padding-block: 64px; }
.foot-in { display: grid; grid-template-columns: 1fr 2fr auto; gap: 32px; align-items: start; }
.brand-foot { font-weight: 800; font-size: clamp(3rem, 7vw, 6rem); letter-spacing: -0.06em; line-height: 0.85; color: var(--bg); }
.foot-in p:not(.brand-foot) { max-width: 52ch; font-size: 0.9375rem; }
.foot .brand-foot span { color: #ff6a4d; }
.to-top { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; color: var(--bg); text-decoration: underline; text-underline-offset: 4px; }

/* ---------- detail dialog ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: 0 0 0 auto; width: min(620px, 100vw); max-width: 100vw; height: 100vh; height: 100dvh; max-height: 100dvh;
  background: var(--bg); color: var(--ink); border-left: 2px solid var(--ink); overflow: hidden;
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: slide-in 0.24s var(--ease) both; }
dialog.sheet::backdrop { background: rgba(21, 23, 26, 0.6); }
.sh-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 24px; border-bottom: 2px solid var(--rule); }
.sh-top .label { color: var(--muted); }
.sh-close { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 16px; background: var(--surface); border: 2px solid var(--ink); font-weight: 700; transition: background-color 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease); }
.sh-scroll { flex: 1; overflow-y: auto; padding: 32px 24px 24px; }
.sh-cat { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.sh-cat .label { background: var(--ink); color: var(--bg); padding: 2px 10px; }
.sh-cat .r-saved { font-family: var(--mono); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.sheet h2 { margin-top: 16px; font-size: clamp(2rem, 6vw, 2.75rem); line-height: 1.02; }
.facts { margin-top: 32px; border-top: 2px solid var(--rule); }
.facts div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--hair); }
.facts dt { font-family: var(--mono); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding-top: 4px; }
.facts dd { font-weight: 600; }
.facts dd small { display: block; font-weight: 400; color: var(--muted); font-size: 0.875rem; }
.sh-rail { margin-top: 24px; }
.sh-rail .rail { margin-top: 8px; height: 12px; }
.sh-rail .rail-lab { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 0.6875rem; color: var(--muted); margin-top: 4px; }
.body { margin-top: 32px; max-width: 56ch; }
.body p + p { margin-top: 16px; }
.body p.access { padding-top: 16px; border-top: 1px solid var(--hair); }
.body p.access::before { content: "Access and practical notes"; display: block; margin-bottom: 4px; font-family: var(--mono); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.clash { margin-top: 24px; padding: 12px 16px; border: 2px solid var(--accent); color: var(--accent); font-weight: 700; font-size: 0.9375rem; }
.clash[hidden] { display: none; }
.sh-foot { padding: 16px 24px; border-top: 2px solid var(--rule); background: var(--bg); }
.save { width: 100%; min-height: 56px; padding: 12px 24px; background: var(--ink); color: var(--bg); border: 2px solid var(--ink); font-weight: 700; font-size: 1.0625rem; display: inline-flex; align-items: center; justify-content: center; gap: 12px; transition: background-color 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease); }
.save .mark { font-family: var(--mono); }
.save[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- hover / press ---------- */
@media (hover: hover) and (pointer: fine) {
  .top nav a:hover { border-color: var(--accent); }
  .btn:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }
  .btn-quiet:hover { background: var(--ink); color: var(--bg); }
  .bar:not(:disabled):hover { background: var(--ink); border-color: var(--ink); color: var(--bg); transform: translateY(-2px); }
  .bar.is-saved:hover { background: #8f1d0b; border-color: #8f1d0b; }
  .seg button:hover:not([aria-pressed="true"]), .tog:hover:not([aria-pressed="true"]) { background: #e6e2d6; }
  input[type="text"]:hover, select:hover { background: #fff; }
  .row:hover { background: var(--surface); }
  .row:hover .go { transform: translateX(6px); }
  .row:hover h4 { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
  .s-open:hover { background: #e6e2d6; }
  .sh-close:hover { background: var(--ink); color: var(--bg); }
  .save:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
  .save[aria-pressed="true"]:hover { background: #8f1d0b; border-color: #8f1d0b; }
  .to-top:hover { text-decoration-thickness: 3px; }
  .brand:hover span { text-decoration: underline; }
}
.btn:active, .bar:not(:disabled):active, .seg button:active, .tog:active, .sh-close:active, .save:active, .s-open:active { transform: scale(0.97); }
.row:active { background: #e6e2d6; }
.top nav a:active, .to-top:active { opacity: 0.7; }

input[type="text"]:focus-visible, select:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; background: #fff; }

/* ---------- motion ---------- */
@keyframes numeral-in { from { transform: translateY(24px); opacity: 0; clip-path: inset(-20% 100% -20% 0); } to { transform: none; opacity: 1; clip-path: inset(-20% -20% -20% -20%); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes bar-in { from { opacity: 0; transform: scaleX(0); } to { opacity: 1; transform: scaleX(1); } }
@keyframes rail-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes slide-in { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
  .numeral { clip-path: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 64px; }
  .short { position: static; }
  .foot-in { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  :root { --gutter: 20px; }
  .hero { padding-block: 24px 48px; }
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; padding-block: 16px 32px; }
  .numeral { font-size: clamp(7rem, 40vw, 11rem); }
  h1 { max-width: 20ch; }
  .layout { padding-block: 48px 96px; }
  .f-search, .f-cat, .f-day, .f-toggles { grid-column: span 12; }
  .tools { gap: 20px; }
  .row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "time price" "main main"; padding: 20px 8px 20px 16px; gap: 12px 16px; }
  .time { grid-area: time; flex-direction: row; align-items: baseline; gap: 12px; }
  .r-main { grid-area: main; }
  .r-price { grid-area: price; }
  .go { display: none; }
  .fmt { display: none; }
  .top nav a { padding-inline: 8px; font-size: 0.875rem; }
  .brand { font-size: 1.375rem; }
  .facts div { grid-template-columns: 96px minmax(0, 1fr); gap: 12px; }
  dialog.sheet { border-left: 0; width: 100vw; }
  .sh-top, .sh-scroll, .sh-foot { padding-inline: 20px; }
  .short-in { padding: 20px; }
  .foot { padding-block: 48px; }
}
