:root {
  --bg: #e8ebf5;
  --panel: #fbfbfe;
  --ink: #151945;
  --muted: #494e7c;
  --line: #c3c8e0;
  --accent: #2630d0;
  --accent-ink: #ffffff;
  --mark: #ffd84a;

  --c-art: #c2410c;
  --c-film: #6d28d9;
  --c-food: #a16207;
  --c-literature: #0f766e;
  --c-music: #be185d;
  --c-outdoors: #15803d;
  --c-walks: #1d4ed8;

  --display: "Avenir Next", "Futura", "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  --text: "Iowan Old Style", "Charter", "Palatino Linotype", Georgia, serif;
  --ui: system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.0625rem;
  line-height: 1.55;
}
h1, h2, h3, p, dl, dd { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px #fff;
}
[hidden] { display: none !important; }

.skip {
  position: absolute; left: .5rem; top: -4rem; z-index: 50;
  background: var(--ink); color: #fff; padding: .6rem .9rem; border-radius: 6px;
  font-family: var(--ui);
}
.skip:focus { top: .5rem; }

/* ---------- page frame ---------- */
.page { display: flex; flex-direction: column; min-height: 100vh; }
.rail { display: contents; }
.brand { order: 1; padding: 1.5rem 1.25rem 1rem; position: relative; }
.controls { order: 2; }
.events { order: 3; }
.shortlist { order: 4; }

.brand-name {
  font-family: var(--display); font-weight: 700; font-size: 1rem; letter-spacing: .01em;
}
.brand-title {
  font-family: var(--display); font-weight: 900; line-height: .86; letter-spacing: -.045em;
  font-size: clamp(3.4rem, 17vw, 5rem);
  margin: .55rem 0 .8rem;
  display: flex; flex-direction: column;
}
.brand-title span:last-child { color: var(--accent); }
.brand-note { max-width: 26ch; color: var(--muted); font-size: 1rem; }
.to-shortlist {
  position: absolute; top: 1.25rem; right: 1.25rem;
  display: inline-flex; gap: .45rem; align-items: center;
  font-family: var(--ui); font-weight: 650; font-size: .9rem;
  color: var(--ink); text-decoration: none;
  border: 2px solid var(--ink); border-radius: 999px; padding: .35rem .8rem;
  min-height: 44px;
}

.count {
  display: inline-grid; place-items: center; min-width: 1.5rem; height: 1.5rem; padding: 0 .4rem;
  border-radius: 999px; background: var(--ink); color: #fff;
  font-family: var(--ui); font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* ---------- controls ---------- */
.controls {
  padding: .5rem 1.25rem 1.25rem;
  display: grid; gap: .9rem;
}
.field { display: grid; gap: .3rem; }
.field label { font-family: var(--ui); font-weight: 650; font-size: .9rem; }
.field input, .field select {
  width: 100%; min-height: 48px; padding: .6rem .8rem;
  background: var(--panel); border: 2px solid var(--ink); border-radius: 8px;
  font-family: var(--ui); font-size: 1rem;
}
.field input::placeholder { color: #666b98; }

.saved-toggle {
  display: flex; align-items: center; gap: .65rem; width: 100%;
  min-height: 48px; padding: .55rem .8rem;
  background: transparent; border: 2px solid var(--ink); border-radius: 8px;
  font-family: var(--ui); font-weight: 650; text-align: left;
}
.saved-toggle .count { margin-left: auto; }
.saved-toggle-mark {
  width: 1.1rem; height: 1.1rem; border: 2px solid var(--ink); border-radius: 3px; flex: none;
  background: transparent; position: relative;
}
.saved-toggle[aria-pressed="true"] { background: var(--mark); }
.saved-toggle[aria-pressed="true"] .saved-toggle-mark { background: var(--ink); }
.saved-toggle[aria-pressed="true"] .saved-toggle-mark::after {
  content: ""; position: absolute; left: 3px; top: 0; width: 5px; height: 9px;
  border: solid var(--mark); border-width: 0 2px 2px 0; transform: rotate(45deg);
}

/* ---------- events ---------- */
.events { padding: 0 1.25rem 2rem; outline: none; }
.status { font-family: var(--ui); font-size: .9rem; color: var(--muted); padding: .25rem 0 .75rem; }

.day { margin-bottom: 2.5rem; }
.day-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  border-bottom: 4px solid var(--ink); padding-bottom: .4rem;
}
.day-name {
  font-family: var(--display); font-weight: 900; letter-spacing: -.035em; line-height: 1;
  font-size: clamp(2rem, 7vw, 3.4rem);
}
.day-meta { font-family: var(--ui); font-size: .9rem; color: var(--muted); }

.scale { display: none; }

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "time save" "body body" "track track";
  gap: .5rem 1rem;
  padding: 1.1rem 0 1.2rem;
  border-bottom: 1px solid var(--line);
}
.row::before {
  content: ""; position: absolute; left: -1.25rem; top: 1.1rem; bottom: 1.2rem; width: 6px;
  background: transparent;
}
.row.is-saved::before { background: var(--mark); box-shadow: inset -2px 0 0 var(--ink); }
.row:hover { background: rgba(255,255,255,.55); }

.time { grid-area: time; font-family: var(--display); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.time-start { font-size: 1.6rem; letter-spacing: -.02em; }
.time-end { font-family: var(--ui); font-weight: 500; font-size: .85rem; color: var(--muted); margin-left: .5rem; }

.body { grid-area: body; min-width: 0; }
.row-title { font-family: var(--display); font-weight: 750; font-size: 1.3rem; line-height: 1.2; letter-spacing: -.01em; }
.open {
  all: unset; box-sizing: border-box; cursor: pointer; text-align: left;
}
.open:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; box-shadow: 0 0 0 5px #fff; }
.open::after { content: ""; position: absolute; inset: 0; }
.row:hover .open { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.row-summary { margin-top: .3rem; color: var(--muted); max-width: 62ch; }
.row-meta {
  margin-top: .55rem; display: flex; flex-wrap: wrap; gap: .25rem 1rem;
  font-family: var(--ui); font-size: .9rem;
}
.cat { display: inline-flex; align-items: center; gap: .4rem; font-weight: 650; }
.cat::before { content: ""; width: .7rem; height: .7rem; border-radius: 2px; background: var(--cat, var(--ink)); }
.price { font-weight: 650; }

.track-wrap { grid-area: track; }
.track { position: relative; height: .7rem; background: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 24%); border-bottom: 2px solid var(--line); }
.track i { position: absolute; top: 0; bottom: 0; background: var(--cat, var(--ink)); border-radius: 2px; min-width: 6px; }

.bm {
  grid-area: save; position: relative; z-index: 2;
  width: 44px; height: 44px; margin: -.4rem -.5rem 0 0;
  display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 8px;
}
.bm svg { width: 1.5rem; height: 1.5rem; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.bm[aria-pressed="true"] svg { fill: var(--mark); }
.bm:hover { background: rgba(21,25,69,.08); }

/* ---------- empty ---------- */
.empty {
  border: 2px dashed var(--ink); border-radius: 12px; padding: 2rem 1.5rem; max-width: 34rem;
  background: var(--panel);
}
.empty-title { font-family: var(--display); font-weight: 800; font-size: 1.6rem; letter-spacing: -.02em; }
.empty p + p { margin-top: .3rem; color: var(--muted); }
.btn {
  margin-top: 1.1rem; min-height: 46px; padding: .55rem 1.1rem;
  font-family: var(--ui); font-weight: 650;
  background: var(--accent); color: var(--accent-ink); border: 2px solid var(--accent); border-radius: 8px;
}
.btn:hover { background: #1a22a8; border-color: #1a22a8; }

/* ---------- shortlist ---------- */
.shortlist { padding: 1.5rem 1.25rem 3rem; background: var(--ink); color: #fff; outline: none; }
.shortlist h2 { font-family: var(--display); font-weight: 850; font-size: 1.7rem; letter-spacing: -.03em; }
.sl-empty { margin-top: .6rem; color: #d3d6f2; max-width: 34ch; }
.sl-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .25rem; }
.sl-item { border-top: 1px solid #4b5090; padding: .7rem 0; }
.sl-when { font-family: var(--ui); font-size: .85rem; color: #c9cdf0; font-variant-numeric: tabular-nums; }
.sl-open {
  all: unset; box-sizing: border-box; cursor: pointer; display: block; margin-top: .1rem;
  font-family: var(--display); font-weight: 700; font-size: 1.05rem; line-height: 1.25;
  text-decoration: underline; text-decoration-color: #7b81d1; text-underline-offset: 3px; min-height: 28px;
}
.sl-open:focus-visible { outline: 3px solid var(--mark); outline-offset: 3px; box-shadow: none; }
.sl-clash { margin-top: .2rem; font-family: var(--ui); font-size: .85rem; color: var(--mark); }
.sl-total { border-top: 2px solid #fff; padding-top: .8rem; margin-top: .4rem; font-family: var(--ui); font-weight: 650; }

/* ---------- detail ---------- */
.detail {
  margin: 0; padding: 0; border: 0;
  position: fixed; inset: 0 0 0 auto;
  width: 100%; max-width: 100%; height: 100dvh; max-height: none;
  background: var(--panel); color: var(--ink);
  overflow: auto; overscroll-behavior: contain;
}
.detail::backdrop { background: rgba(21,25,69,.55); }
.detail-inner { padding: 1.25rem 1.25rem 2.5rem; min-height: 100%; display: flex; flex-direction: column; }
.detail-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.close {
  min-height: 44px; padding: .4rem 1rem; background: transparent; border: 2px solid var(--ink); border-radius: 999px;
  font-family: var(--ui); font-weight: 650;
}
.close:hover { background: var(--ink); color: #fff; }
.detail-cat { font-family: var(--ui); }
.detail h2 {
  font-family: var(--display); font-weight: 900; letter-spacing: -.035em; line-height: 1.02;
  font-size: clamp(2rem, 8vw, 2.9rem); margin: .4rem 0 1rem;
}
.detail-when {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: .2rem .8rem;
  font-family: var(--display); font-weight: 800; font-size: 1.35rem; font-variant-numeric: tabular-nums;
  padding: .7rem 0; border-top: 4px solid var(--cat, var(--ink)); border-bottom: 1px solid var(--line);
}
.detail-when span { font-family: var(--ui); font-weight: 500; font-size: .95rem; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem 1.25rem; margin: 1.25rem 0; font-family: var(--ui); }
.facts dt { font-size: .85rem; color: var(--muted); }
.facts dd { font-weight: 650; font-size: 1.05rem; }
.detail-body { max-width: 60ch; }
.detail-body p + p { margin-top: 1rem; }
.detail-body p.access { padding-left: .9rem; border-left: 4px solid var(--cat, var(--ink)); }
.clash { margin-top: 1rem; padding: .7rem .9rem; background: var(--mark); border-radius: 8px; font-family: var(--ui); font-size: .95rem; }
.detail-actions { margin-top: auto; padding-top: 1.75rem; }
.save {
  width: 100%; min-height: 54px; padding: .7rem 1rem;
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  font-family: var(--ui); font-weight: 700; font-size: 1.05rem;
  background: var(--accent); color: #fff; border: 2px solid var(--accent); border-radius: 10px;
}
.save svg { width: 1.3rem; height: 1.3rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.save[aria-pressed="true"] { background: var(--mark); color: var(--ink); border-color: var(--ink); }
.save[aria-pressed="true"] svg { fill: var(--ink); }

[data-cat="Art"] { --cat: var(--c-art); }
[data-cat="Film"] { --cat: var(--c-film); }
[data-cat="Food"] { --cat: var(--c-food); }
[data-cat="Literature"] { --cat: var(--c-literature); }
[data-cat="Music"] { --cat: var(--c-music); }
[data-cat="Outdoors"] { --cat: var(--c-outdoors); }
[data-cat="Walks"] { --cat: var(--c-walks); }

@media (prefers-reduced-motion: no-preference) {
  .detail[open] { animation: slide .22s ease-out; }
  .detail[open]::backdrop { animation: fade .22s ease-out; }
  @keyframes slide { from { transform: translateX(2rem); opacity: 0; } to { transform: none; opacity: 1; } }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  .page { display: grid; grid-template-columns: 23rem minmax(0, 1fr); align-items: start; }
  .rail {
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    border-right: 4px solid var(--ink);
  }
  .brand, .controls, .shortlist, .events { order: 0; }
  .brand { padding: 2rem 1.75rem 1rem; }
  .brand-title { font-size: 6.2rem; }
  .to-shortlist { display: none; }
  .controls { padding: .5rem 1.75rem 1.5rem; }
  .shortlist { margin-top: auto; padding: 1.5rem 1.75rem 2rem; }
  .events { padding: 2rem 3rem 4rem 3.25rem; }
  .row::before { left: -3.25rem; width: 8px; }

  .scale {
    display: grid; grid-template-columns: 6.5rem 1fr 14rem 44px; gap: 0 1.5rem;
    font-family: var(--ui); font-size: .8rem; color: var(--muted); padding: .5rem 0 .4rem;
    border-bottom: 1px solid var(--line);
  }
  .scale-ticks { position: relative; height: 1.1rem; grid-column: 3; }
  .scale-ticks span { position: absolute; top: 0; transform: translateX(-1px); padding-left: 3px; border-left: 1px solid var(--line); line-height: 1.1rem; white-space: nowrap; }

  .row {
    grid-template-columns: 6.5rem 1fr 14rem 44px;
    grid-template-areas: "time body track save";
    gap: 0 1.5rem; align-items: start; padding: 1.25rem 0;
  }
  .row::before { top: 0; bottom: 0; }
  .time { display: flex; flex-direction: column; }
  .time-end { margin: .1rem 0 0; }
  .track-wrap { padding-top: .75rem; }
  .bm { margin: 0; }

  .detail { width: 34rem; border-left: 4px solid var(--ink); }
  .detail-inner { padding: 1.5rem 2rem 2.5rem; }
}
@media (min-width: 900px) and (max-height: 760px) {
  .brand-title { font-size: 4.6rem; }
}
