@font-face {
  font-family: "Work Sans";
  src: url("assets/work-sans.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/*
  Shape rule: containers 14px, controls 10px, tags and counts fully round.
  One accent (signal orange) on a charcoal base.
*/
:root {
  --bg: #0d0f12;
  --surface: #15181d;
  --surface-2: #1c2027;
  --line: #2a2f37;
  --line-strong: #4a5360;
  --text: #edeff2;
  --muted: #a6adb8;
  --accent: #ff7b47;
  --accent-ink: #1b0d06;
  --r-box: 14px;
  --r-ctl: 10px;
  --sans: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
img { display: block; max-width: 100%; }
h1, h2, h3, p, dl, dd, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: var(--r-ctl); font-weight: 600;
}
.skip:focus { top: 12px; }

.shell { width: 100%; max-width: 1360px; margin: 0 auto; padding-left: 40px; padding-right: 40px; }

/* Header */
.top { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-row { height: 64px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; border-radius: var(--r-ctl); }
.mark { position: relative; width: 26px; height: 26px; flex: none; }
.mark::before, .mark::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 5px; }
.mark::before { left: 0; top: 0; background: var(--accent); }
.mark::after { right: 0; bottom: 0; border: 2px solid var(--text); }
.brand-name { font-size: 20px; font-weight: 800; letter-spacing: -0.03em; }
.top-nav { display: flex; align-items: center; gap: 8px; }
.top-nav a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px;
  border-radius: var(--r-ctl); text-decoration: none; font-weight: 500; color: var(--muted);
  transition: color 0.2s, background-color 0.2s;
}
.top-nav a:hover { color: var(--text); background: var(--surface-2); }
.nav-count, .pill-count {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-strong);
  font-family: var(--mono); font-size: 13px; color: var(--text);
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 46px; padding: 0 22px; border-radius: var(--r-ctl);
  border: 1px solid transparent; background: none; cursor: pointer;
  font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: transform 0.2s var(--ease), background-color 0.2s, border-color 0.2s, color 0.2s;
}
.btn:active { transform: translateY(1px) scale(0.985); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #ff9066; }
.btn-quiet { border-color: var(--line-strong); color: var(--text); min-height: 40px; padding: 0 16px; }
.btn-quiet:hover { background: var(--surface-2); }
.btn-toggle { width: 100%; justify-content: space-between; border-color: var(--line-strong); background: var(--surface-2); }
.btn-toggle:hover { border-color: var(--text); }
.btn-toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-toggle[aria-pressed="true"] .pill-count { background: var(--accent-ink); color: var(--text); border-color: var(--accent-ink); }

/* Hero */
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 56px; align-items: center; padding-top: 40px; padding-bottom: 48px; }
.hero h1 { font-size: clamp(40px, 5vw, 68px); font-weight: 800; letter-spacing: -0.04em; line-height: 1.04; max-width: 11em; }
.accent { color: var(--accent); white-space: nowrap; }
.hero-sub { margin: 20px 0 28px; max-width: 34em; font-size: 18px; color: var(--muted); }
.hero-photos {
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 14px;
  height: 340px;
}
.hp { width: 100%; height: 100%; object-fit: cover; border-radius: var(--r-box); background: var(--surface-2); }
.hp-a { grid-row: 1 / span 2; object-position: 50% 30%; }
.hp-b { object-position: 50% 60%; }
.hp-c { object-position: 50% 50%; }

/* Layout */
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 40px; align-items: start; padding-bottom: 72px; }
.rail { position: sticky; top: 84px; display: grid; gap: 20px; max-height: calc(100dvh - 104px); overflow-y: auto; padding: 4px; margin: -4px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-box); padding: 20px; }
.panel-title { font-size: 18px; font-weight: 700; letter-spacing: -0.015em; margin-bottom: 16px; }

/* Controls */
.field { display: grid; gap: 8px; margin-bottom: 16px; border: 0; padding: 0; min-width: 0; }
.field label, .field legend { font-size: 14px; font-weight: 600; color: var(--muted); padding: 0; }
input[type="text"], select {
  width: 100%; min-height: 46px; padding: 0 14px; border-radius: var(--r-ctl);
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--text);
}
input[type="text"]::placeholder { color: var(--muted); opacity: 1; }
input[type="text"]:hover, select:hover { border-color: var(--text); }
select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 21px) 50%, calc(100% - 15px) 50%;
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
}
select option { background: var(--surface-2); color: var(--text); }

.seg-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--r-ctl); }
.seg-row label { position: relative; display: block; }
.seg-row input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg-row span {
  display: grid; place-items: center; min-height: 36px; border-radius: 7px;
  font-size: 14px; font-weight: 600; color: var(--muted); transition: background-color 0.2s, color 0.2s;
}
.seg-row input:hover + span { color: var(--text); }
.seg-row input:checked + span { background: var(--text); color: var(--bg); }
.seg-row input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.check { display: flex; align-items: center; gap: 12px; min-height: 44px; margin-bottom: 12px; cursor: pointer; position: relative; font-weight: 500; }
.check input { position: absolute; opacity: 0; width: 22px; height: 22px; margin: 0; left: 0; cursor: pointer; }
.check-box { width: 22px; height: 22px; flex: none; border-radius: 6px; border: 2px solid var(--line-strong); background: var(--surface-2); display: grid; place-items: center; transition: background-color 0.2s, border-color 0.2s; }
.check-box::after { content: ""; width: 5px; height: 10px; border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); opacity: 0; }
.check input:checked + .check-box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .check-box::after { opacity: 1; }
.check input:focus-visible + .check-box { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Shortlist */
.sl-empty { color: var(--muted); font-size: 15px; max-width: 28em; }
.sl-list { display: grid; gap: 4px; margin-bottom: 14px; }
.sl-item { border-radius: var(--r-ctl); }
.sl-open {
  display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 10px; align-items: baseline; width: 100%;
  padding: 10px; border: 0; border-radius: var(--r-ctl); background: none; text-align: left; cursor: pointer;
  transition: background-color 0.2s;
}
.sl-open:hover { background: var(--surface-2); }
.sl-time { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.sl-name { font-weight: 600; line-height: 1.3; }
.sl-warn { margin: 0 10px 8px 94px; font-size: 13px; color: var(--accent); }
.sl-total { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 10px 0; margin-bottom: 12px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.sl-total strong { font-family: var(--mono); font-weight: 400; font-size: 16px; color: var(--text); }
.sl-clear { width: 100%; min-height: 40px; }

/* Results */
.status { font-family: var(--mono); font-size: 13px; color: var(--muted); margin-bottom: 20px; min-height: 20px; }
.day + .day { margin-top: 44px; }
.day-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 18px; }
.day-head h2 { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.day-date { font-family: var(--mono); font-size: 14px; color: var(--accent); }
.day-n { margin-left: auto; font-size: 14px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }

.tile {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-box);
  transition: transform 0.3s var(--ease), border-color 0.2s;
}
.tile:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.tile.is-saved { border-color: var(--accent); }
.tile-media { aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface-2); }
.tile-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s var(--ease); }
.tile:hover .tile-media img { transform: scale(1.04); }
.tile-body { display: grid; gap: 10px; padding: 16px 18px 18px; align-content: start; flex: 1; }
.tile-meta { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.cat { font-weight: 600; color: var(--accent); }
.saved-tag { font-weight: 600; color: var(--text); }
.price {
  margin-left: auto; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line-strong);
  font-family: var(--mono); font-size: 13px;
}
.price.free { color: var(--accent); border-color: var(--accent); }
.tile-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.open {
  padding: 0; border: 0; background: none; text-align: left; cursor: pointer;
  font: inherit; letter-spacing: inherit; color: inherit;
}
.open::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-box); }
.open:focus-visible { outline: none; }
.open:focus-visible::after { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile-when { font-family: var(--mono); font-size: 14px; }
.tile-where { font-size: 15px; color: var(--muted); }
.tile-sum {
  font-size: 15px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}

/* Empty, loading, error */
.empty {
  padding: 48px 32px; border: 1px dashed var(--line-strong); border-radius: var(--r-box);
  background: var(--surface); display: grid; gap: 12px; justify-items: start;
}
.empty[hidden] { display: none; }
.empty h2 { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; }
.empty p { color: var(--muted); max-width: 32em; margin-bottom: 8px; }
.skeleton { height: 150px; border-radius: var(--r-box); background: var(--surface); margin-bottom: 20px; }
.load-error { padding: 32px; border: 1px solid var(--line-strong); border-radius: var(--r-box); background: var(--surface); display: grid; gap: 12px; justify-items: start; }

.foot { padding-top: 28px; padding-bottom: 48px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; max-width: 1360px; }
.foot p { max-width: 62ch; }

/* Detail sheet */
.sheet {
  position: fixed; inset: 0; margin: 0 0 0 auto; padding: 0; border: 0;
  width: 100%; max-width: 580px; height: 100dvh; max-height: 100dvh;
  background: var(--surface); color: var(--text);
  border-left: 1px solid var(--line-strong);
}
.sheet:not([open]) { display: none; }
.sheet::backdrop { background: rgb(5 6 8 / 0.7); }
.sheet-inner { display: flex; flex-direction: column; height: 100%; }
.sheet-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.sheet-kicker { font-weight: 600; color: var(--muted); }
.sheet-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.sheet-media { aspect-ratio: 16 / 8; background: var(--surface-2); overflow: hidden; }
.sheet-media img { width: 100%; height: 100%; object-fit: cover; }
.sheet-text { padding: 24px 28px 32px; display: grid; gap: 18px; }
.d-cat { font-weight: 600; color: var(--accent); }
.d-title { font-size: 34px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.08; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fact { background: var(--surface-2); border-radius: var(--r-ctl); padding: 12px 14px; }
.fact dt { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.fact dd { font-size: 16px; font-weight: 500; line-height: 1.35; }
.fact dd small { display: block; font-family: var(--mono); font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.d-clash { padding: 12px 14px; border: 1px solid var(--accent); border-radius: var(--r-ctl); color: var(--text); font-size: 15px; }
.d-clash[hidden] { display: none; }
.d-sub { font-size: 18px; font-weight: 700; letter-spacing: -0.015em; }
.d-body { white-space: pre-line; max-width: 60ch; font-size: 17px; line-height: 1.6; color: #d7dbe1; margin-top: -8px; }
.sheet-bar { padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.btn-save { width: 100%; }
.btn-save[aria-pressed="true"] { background: var(--surface-2); color: var(--text); border-color: var(--accent); }
.btn-save[aria-pressed="true"]:hover { background: var(--surface); }

/* Motion */
@media (prefers-reduced-motion: no-preference) {
  .sheet[open] { animation: sheet-in 0.35s var(--ease); }
  .sheet[open]::backdrop { animation: fade-in 0.3s ease; }
  .boot .tile { animation: rise 0.6s var(--ease) backwards; animation-delay: calc(var(--i) * 60ms); }
  .skeleton { animation: pulse 1.4s ease-in-out infinite; }
}
@keyframes sheet-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse { 50% { opacity: 0.5; } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}

/* Tablet */
@media (max-width: 1100px) {
  .shell { padding-left: 28px; padding-right: 28px; }
  .layout { grid-template-columns: 260px minmax(0, 1fr); gap: 28px; }
  .grid { grid-template-columns: 1fr; }
  .hero { gap: 32px; }
}

/* Mobile: single column, controls first, shortlist after the list */
@media (max-width: 820px) {
  .shell { padding-left: 16px; padding-right: 16px; }
  .top-row { height: 60px; }
  .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 24px; padding-bottom: 32px; }
  .hero h1 { font-size: 42px; }
  .hero-sub { font-size: 17px; margin: 16px 0 22px; }
  .hero-photos { height: 220px; gap: 10px; }
  .layout { display: flex; flex-direction: column; gap: 24px; padding-bottom: 48px; }
  .rail { display: contents; }
  .controls { order: 1; width: 100%; }
  .results { order: 2; width: 100%; }
  .shortlist { order: 3; width: 100%; }
  .panel { padding: 16px; }
  .grid { gap: 14px; }
  .day-head h2 { font-size: 26px; }

  .tile { display: grid; grid-template-columns: 112px minmax(0, 1fr); }
  .tile-media { position: relative; aspect-ratio: auto; min-height: 150px; }
  .tile-media img { position: absolute; inset: 0; }
  .tile-body { padding: 14px 14px 14px; gap: 8px; }
  .tile-title { font-size: 18px; }
  .tile-sum { display: none; }
  .tile-where { font-size: 14px; }

  .sheet { max-width: 100%; inset: auto 0 0 0; margin: 0; height: min(92dvh, 100%); max-height: 92dvh; border-left: 0; border-top: 1px solid var(--line-strong); border-radius: var(--r-box) var(--r-box) 0 0; }
  .sheet-media { aspect-ratio: 16 / 7; }
  .sheet-text { padding: 20px 18px 28px; }
  .d-title { font-size: 28px; }
  .facts { grid-template-columns: 1fr 1fr; gap: 10px; }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
}
