:root {
  --paper: #f6efe2;
  --paper-2: #efe5d1;
  --card: #fffaf0;
  --ink: #1f2a2e;
  --ink-soft: #4a5659;
  --rule: #d9cdb4;
  --lamp: #f2b441;
  --accent: #a8420f;
  --accent-ink: #fff8ec;
  --night: #172a2d;
  --focus: #0b5cad;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3, .brand-name { font-family: var(--serif); font-weight: 700; line-height: 1.12; margin: 0; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.tabbable:focus { outline: none; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 28px; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 6px;
}
.skip:focus { top: 12px; }

/* masthead */
.masthead { background: var(--night); color: #f6efe2; }
.masthead-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; padding-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 12px; }
.lamp { flex: none; }
.brand-name { font-size: 1.55rem; letter-spacing: 0.01em; }
.brand-sub { font-size: 0.8rem; color: #c9d3cf; }
.top-nav { display: flex; gap: 8px; }
.top-nav a {
  color: #f6efe2; text-decoration: none; padding: 8px 14px; border-radius: 999px;
  border: 1px solid rgba(246, 239, 226, 0.35); font-weight: 600; font-size: 0.92rem;
  display: inline-flex; align-items: center; gap: 8px;
}
.top-nav a:hover { background: rgba(246, 239, 226, 0.12); }
.top-nav a:focus-visible { outline-color: var(--lamp); }

/* hero */
.hero { background: linear-gradient(180deg, var(--night) 0, var(--night) 12px, var(--paper-2) 12px); border-bottom: 1px solid var(--rule); }
.hero { background: var(--paper-2); }
.hero-inner { padding-top: 44px; padding-bottom: 40px; }
.eyebrow { font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.78rem; color: var(--accent); margin-bottom: 14px; }
.hero h1 { font-size: clamp(2.1rem, 5.2vw, 3.9rem); max-width: 18ch; }
.hero h1 em { font-style: italic; color: var(--accent); }
.lede { margin-top: 16px; max-width: 56ch; font-size: 1.1rem; color: var(--ink-soft); }

/* layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; padding-top: 28px; padding-bottom: 56px; align-items: start; }

/* controls */
.controls {
  display: flex; flex-wrap: wrap; gap: 14px 16px; align-items: flex-end;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 16px;
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.grow { flex: 1 1 240px; }
.field label, .field .label { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); }
input[type="search"], select {
  height: 44px; padding: 0 12px; border: 1.5px solid #8d8470; border-radius: 8px; background: #fff; width: 100%;
}
select { min-width: 180px; }
input[type="search"]:focus-visible, select:focus-visible { outline-offset: 1px; }

.segmented { display: inline-flex; border: 1.5px solid #8d8470; border-radius: 8px; overflow: hidden; background: #fff; height: 44px; }
.segmented button { border: 0; background: transparent; padding: 0 14px; font-weight: 600; min-width: 52px; }
.segmented button + button { border-left: 1px solid #c8bda5; }
.segmented button[aria-pressed="true"] { background: var(--night); color: #fff; }
.segmented button:focus-visible { outline-offset: -3px; }

.toggles { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; flex: 1 1 100%; padding-top: 2px; }
.toggle {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 999px; border: 1.5px solid #8d8470; background: #fff; font-weight: 600;
}
.toggle svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.toggle[aria-pressed="true"] svg { fill: currentColor; }
.pill {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--lamp); color: var(--ink); font-size: 0.78rem; font-weight: 800;
}
.link-btn { background: none; border: 0; padding: 8px 4px; color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; }
.link-btn[hidden] { display: none; }

/* results */
.results-heading { font-size: 1.5rem; margin-top: 30px; }
.count { color: var(--ink-soft); font-size: 0.95rem; margin: 4px 0 6px; }

.day { margin-top: 22px; }
.day-head {
  display: flex; align-items: baseline; gap: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--ink);
}
.day-head h3 { font-size: 1.45rem; }
.day-head span { color: var(--ink-soft); font-size: 0.9rem; }
.items { list-style: none; margin: 0; padding: 0; }

.item {
  --cat: #666;
  position: relative;
  display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 18px;
  padding: 18px 12px 18px 20px;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  transition: background-color 0.15s;
}
.item::before { content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 5px; border-radius: 3px; background: var(--cat); }
.item:hover { background: var(--card); }
.when { font-family: var(--serif); line-height: 1.05; padding-top: 2px; }
.when .start { font-size: 1.7rem; font-weight: 700; }
.when .ampm { font-size: 0.9rem; margin-left: 2px; font-weight: 600; }
.when .until { display: block; margin-top: 6px; font-family: var(--sans); font-size: 0.8rem; color: var(--ink-soft); }
.meta { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--ink-soft); margin-bottom: 4px; }
.meta .cat { color: var(--ink); }
.meta .cat::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--cat); margin-right: 6px; }
.item h3 { font-size: 1.28rem; }
.open { background: none; border: 0; padding: 0; text-align: left; font: inherit; color: inherit; }
.open::after { content: ""; position: absolute; inset: 0; }
.open:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }
.open:focus-visible { outline: none; }
.open:focus-visible::after { outline: 3px solid var(--focus); outline-offset: -3px; border-radius: 6px; }
.sum { margin-top: 6px; color: var(--ink-soft); max-width: 62ch; }
.facts-line { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.9rem; font-weight: 600; }
.facts-line .price-free { color: #1d6b3a; }

.quick {
  position: relative; z-index: 2; align-self: start;
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 50%; border: 1.5px solid #8d8470; background: #fff;
}
.quick svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.quick[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.quick[aria-pressed="true"] svg { fill: currentColor; }

.empty { text-align: center; padding: 56px 20px; margin-top: 22px; border: 2px dashed #b9ad92; border-radius: var(--radius); color: var(--ink-soft); }
.empty[hidden] { display: none; }
.empty svg { color: var(--accent); }
.empty h3 { font-size: 1.5rem; color: var(--ink); margin: 10px 0 6px; }
.empty .btn { margin-top: 18px; }
.btn {
  min-height: 46px; padding: 0 20px; border-radius: 999px; border: 0; background: var(--night); color: #fff; font-weight: 700;
}
.btn:hover { background: #0e1c1e; }
.load-error { margin-top: 24px; padding: 16px; background: #fde8e2; border: 1px solid #d99; border-radius: 8px; }

/* shortlist */
.shortlist { position: sticky; top: 16px; }
.shortlist:focus { outline: none; }
.shortlist-card { background: var(--night); color: #f6efe2; border-radius: 14px; padding: 22px; }
.shortlist h2 { font-size: 1.5rem; }
.sl-sub { color: #c9d3cf; font-size: 0.9rem; margin: 4px 0 14px; }
.sl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.sl-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: start; padding: 12px; background: rgba(246, 239, 226, 0.08); border-radius: 8px; }
.sl-when { font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--lamp); font-weight: 700; }
.sl-open { background: none; border: 0; padding: 0; text-align: left; font-family: var(--serif); font-weight: 700; font-size: 1.05rem; color: #fff; text-decoration: underline; text-decoration-color: rgba(255,255,255,0.35); text-underline-offset: 3px; }
.sl-open:hover { text-decoration-color: var(--lamp); }
.sl-where { font-size: 0.85rem; color: #c9d3cf; }
.sl-remove { width: 44px; height: 44px; margin: -8px -8px 0 0; border: 0; background: none; color: #f6efe2; border-radius: 50%; font-size: 1.3rem; line-height: 1; }
.sl-remove:hover { background: rgba(246, 239, 226, 0.15); }
.shortlist :focus-visible { outline-color: var(--lamp); }
.sl-empty { color: #c9d3cf; }
.sl-foot { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(246, 239, 226, 0.25); font-weight: 600; display: grid; gap: 8px; }
.clash { background: var(--lamp); color: var(--ink); padding: 8px 10px; border-radius: 6px; font-size: 0.88rem; }
.sl-foot[hidden], .clash[hidden], .sl-empty[hidden] { display: none; }

.foot { border-top: 1px solid var(--rule); padding: 22px 0 30px; color: var(--ink-soft); font-size: 0.88rem; background: var(--paper-2); }

/* detail dialog */
dialog.sheet {
  --cat: #666;
  padding: 0; border: 0; border-radius: 16px; background: var(--card); color: var(--ink);
  width: min(680px, calc(100vw - 32px)); max-height: min(88vh, 860px); overflow: auto;
  box-shadow: 0 30px 80px rgba(10, 20, 22, 0.45);
}
dialog.sheet::backdrop { background: rgba(14, 26, 28, 0.62); }
@media (prefers-reduced-motion: no-preference) {
  dialog.sheet[open] { animation: rise 0.22s ease-out; }
  @keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
}
.sheet-top { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px 12px 24px; background: var(--card); border-bottom: 1px solid var(--rule); border-top: 6px solid var(--cat); z-index: 1; }
.sheet-top .meta { margin: 0; }
.close { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--ink); background: transparent; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.close:hover { background: var(--ink); color: #fff; }
.sheet-body { padding: 22px 24px 8px; }
.sheet h2 { font-size: clamp(1.7rem, 4vw, 2.3rem); }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; margin: 20px 0; padding: 16px 0; border-block: 1px solid var(--rule); }
.facts div { min-width: 0; }
.facts dt { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-soft); }
.facts dd { margin: 2px 0 0; font-weight: 600; }
.detail-text { white-space: pre-line; max-width: 60ch; font-size: 1.04rem; }
.sheet-actions { position: sticky; bottom: 0; padding: 14px 24px 18px; margin-top: 16px; background: var(--card); border-top: 1px solid var(--rule); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.save { min-height: 48px; padding: 0 22px; border-radius: 999px; border: 2px solid var(--accent); background: transparent; color: var(--accent); font-weight: 800; display: inline-flex; gap: 10px; align-items: center; }
.save svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.save[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.save[aria-pressed="true"] svg { fill: currentColor; }
.save-note { font-size: 0.9rem; color: var(--ink-soft); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* tablet */
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .shortlist { position: static; }
}

/* phone */
@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
  .brand-sub { display: none; }
  .brand-name { font-size: 1.35rem; }
  .top-nav a { padding: 8px 12px; }
  .hero-inner { padding-top: 28px; padding-bottom: 26px; }
  .lede { font-size: 1rem; }
  .controls { padding: 14px; }
  .field { flex: 1 1 100%; }
  select { width: 100%; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .toggle { flex: 1 1 auto; justify-content: center; }
  .item { grid-template-columns: 62px minmax(0, 1fr); gap: 12px; padding: 16px 8px 16px 16px; }
  .when .start { font-size: 1.3rem; }
  .when .until { font-size: 0.72rem; }
  .quick { position: absolute; top: 8px; right: 4px; }
  .item h3 { font-size: 1.15rem; padding-right: 40px; }
  .item .meta { padding-right: 40px; }

  dialog.sheet {
    width: 100vw; max-width: none; height: 100%; max-height: none; margin: 0; border-radius: 0;
  }
  .sheet-top { padding-left: 16px; padding-right: 10px; }
  .sheet-body { padding: 18px 16px 4px; }
  .facts { grid-template-columns: 1fr 1fr; }
  .sheet-actions { padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); }
  .save { flex: 1 1 100%; justify-content: center; }
}

@media (forced-colors: active) {
  .item::before { background: CanvasText; }
}
