:root {
  color-scheme: light;
  --bg: #f3eee5;
  --surface: #fffaf2;
  --surface-soft: #fbf5eb;
  --border: #ead8c7;
  --border-strong: #c98b7c;
  --text: #292521;
  --muted: #7b7168;
  --accent: #9b3f32;
  --accent-soft: rgba(155, 63, 50, 0.1);
  --success: #2f7d4f;
  --warning: #9b6a22;
  --danger: #a33a32;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --shadow-card: 0 16px 40px rgba(43, 34, 27, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 8% -8%, rgba(155, 63, 50, .10), transparent 26rem),
    radial-gradient(circle at 90% 0%, rgba(201, 139, 124, .14), transparent 28rem);
}

h1, h2, h3, p { margin-top: 0; }
a { color: var(--accent); font-weight: 800; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }

.page {
  position: relative;
  max-width: 980px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.site-header { margin-bottom: 28px; }
.eyebrow,
.debug-panel-eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

h1 {
  font-size: clamp(48px, 7vw, 76px);
  line-height: .95;
  letter-spacing: -.055em;
  margin: 10px 0 12px;
}

.lede, .meta, .description, .showtimes span, .muted { color: var(--muted); }
.lede { font-size: 14px; }

.cards { display: grid; gap: 18px; }

.movie-card {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  align-items: start;
  gap: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 1px 0 rgba(43, 34, 27, .05), var(--shadow-card);
}
.movie-card.is-selected {
  border-color: #b85a4d;
  box-shadow: 0 0 0 3px rgba(184, 90, 77, .08), 0 18px 44px rgba(43, 34, 27, .10);
}
.movie-card:focus { outline: none; }

.poster-wrap { width: 170px; }
.poster {
  width: 170px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: #e4dbcf;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .18);
}
.poster-missing { display: grid; place-items: center; color: var(--muted); font-weight: 800; text-align: center; padding: 12px; }
.movie-content { min-width: 0; }
.movie-heading { display: flex; gap: 16px; align-items: start; justify-content: space-between; }
.movie-heading > div { min-width: 0; }
.movie-heading h2 { margin-bottom: 4px; font-size: clamp(24px, 3vw, 34px); line-height: 1; letter-spacing: -.04em; overflow-wrap: anywhere; }
.meta { font-size: 13px; font-weight: 650; }
.description { line-height: 1.55; font-size: 14px; margin: 14px 0; }

.dismiss-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--border);
  background: #fffaf5;
  color: var(--accent);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}
.dismiss-button:hover, .dismiss-button:focus-visible { border-color: var(--border-strong); background: #fff; }
.dismiss-button:disabled { cursor: wait; opacity: .65; }
.trailer { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.trailer-link, .trailer a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  color: var(--accent);
  font-weight: 800;
  line-height: 1.1;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  touch-action: manipulation;
}

.showtimes h3 { margin-bottom: 10px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.theater-list { display: grid; gap: 9px; }
.theater-group { border: 0; }
.theater-row, .theater-group summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid #eadfd3;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .55);
  cursor: pointer;
  list-style: none;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
  touch-action: manipulation;
}
.theater-group summary::-webkit-details-marker { display: none; }
.theater-group summary::after {
  content: "⌄";
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--accent);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  transition: transform .15s ease;
}
.theater-group[open] summary::after { transform: rotate(180deg); }
.theater-row:hover, .theater-group summary:hover { border-color: #c78375; background: #fff; }
.theater-group summary:focus-visible { outline: 3px solid rgba(155, 63, 50, .18); outline-offset: 2px; }
.theater-name, .theater-group summary strong { font-weight: 800; color: var(--text); }
.theater-address, .theater-group summary span:not(.showtime-count) { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.showtime-count {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.showtimes ul { list-style: none; padding: 10px 2px 2px; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.showtimes li { margin: 0; }
.showtimes .time {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--surface-soft);
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  touch-action: manipulation;
}
.empty-state { padding: 32px; background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow-card); }

.debug-body { min-height: 100vh; overflow-x: hidden; }
.debug-backdrop { display: none; }
.debug-shell { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; padding-inline: 24px; }
.debug-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 22px; }
.debug-brand, .debug-nav { display: inline-flex; align-items: center; border: 1px solid var(--border); background: rgba(255, 250, 242, .72); border-radius: 999px; box-shadow: 0 10px 28px rgba(43, 34, 27, .05); }
.debug-brand { gap: 8px; padding: 6px 13px 6px 7px; font-weight: 900; text-decoration: none; color: var(--text); }
.debug-brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--surface); }
.debug-nav { gap: 4px; padding: 4px; }
.debug-nav a, .debug-button { color: var(--accent); border-radius: 999px; padding: 8px 12px; font-size: 13px; font-weight: 850; text-decoration: none; }
.debug-nav a:hover, .debug-button:hover { background: var(--accent-soft); }
.debug-button { display: inline-flex; border: 1px solid var(--border); background: #fffaf5; }
.debug-button.primary { border-color: var(--border-strong); background: var(--accent); color: #fffaf2; }

.debug-page { max-width: 1100px; margin: 0 auto; padding: 40px 24px 80px; }
.debug-hero { margin-bottom: 28px; }
.debug-hero-copy h1 { font-size: clamp(44px, 6vw, 72px); letter-spacing: -.055em; line-height: .95; margin: 12px 0; }
.debug-hero-copy p:not(.debug-panel-eyebrow) { color: var(--muted); font-size: 14px; max-width: 620px; line-height: 1.55; }
.debug-hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.debug-health-card { display: none; }
.debug-health-pills, .debug-section-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.debug-stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin: 24px 0 28px; }
.debug-stat-grid.compact { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); margin: 14px 0 18px; }
.debug-stat {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: 0 10px 28px rgba(43, 34, 27, .06);
}
.debug-stat-icon { display: none; }
.debug-stat span, .debug-kv dt, .debug-mini-metric span {
  color: #8a7d73;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.debug-stat strong { display: block; margin-top: 6px; font-size: 24px; line-height: 1; font-weight: 900; letter-spacing: -.04em; overflow-wrap: anywhere; }
.debug-stat small { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.debug-two-col, .debug-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.debug-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 18px; box-shadow: 0 12px 32px rgba(43, 34, 27, .07); margin-bottom: 16px; }
.debug-panel-wide { grid-column: 1 / -1; }
.debug-panel h2 { margin: 0 0 14px; font-size: 20px; letter-spacing: -.035em; }
.debug-panel h3 { margin: 18px 0 10px; color: var(--muted); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; }
.debug-panel-heading { margin-bottom: 12px; }
.debug-panel-eyebrow { margin: 0 0 6px; }
.debug-process-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.debug-mini-metric { border: 1px solid #eee0d2; border-radius: var(--radius-sm); background: rgba(255,255,255,.42); padding: 10px; }
.debug-mini-metric strong { display: block; margin-top: 4px; overflow-wrap: anywhere; }
.debug-kv { display: grid; gap: 0; margin: 0; }
.debug-kv div { display: grid; grid-template-columns: 180px 1fr; gap: 16px; padding: 8px 0; border-top: 1px solid #eee0d2; }
.debug-kv div:first-child { border-top: 0; }
.debug-kv dd { margin: 0; font-weight: 800; color: var(--text); word-break: break-word; }
.debug-kv code { color: var(--text); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; background: #fffaf5; color: var(--warning); font-size: 12px; font-weight: 850; padding: 6px 10px; text-transform: capitalize; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-ok, .status-success { color: var(--success); border-color: rgba(47,125,79,.25); background: rgba(47,125,79,.08); }
.status-partial_success, .status-never-run, .status-never_run { color: var(--warning); border-color: rgba(155,106,34,.25); background: rgba(155,106,34,.08); }
.status-failed, .status-error { color: var(--danger); border-color: rgba(163,58,50,.25); background: rgba(163,58,50,.08); }
.debug-run-list { display: grid; gap: 10px; }
.debug-run-card { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(320px, 1.2fr); gap: 12px; align-items: center; border: 1px solid #eee0d2; border-radius: var(--radius-md); background: rgba(255,255,255,.42); padding: 12px; }
.debug-run-title { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.debug-run-title h3 { margin: 0; color: var(--text); font-size: 16px; letter-spacing: 0; text-transform: capitalize; }
.debug-run-id { color: var(--muted); font-weight: 900; }
.debug-run-main p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.debug-run-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.debug-run-error, .debug-error { grid-column: 1 / -1; border: 1px solid rgba(163,58,50,.25); border-radius: var(--radius-sm); background: rgba(163,58,50,.08); color: var(--danger); padding: 10px; overflow-wrap: anywhere; }
.debug-empty-row { border: 1px dashed var(--border-strong); border-radius: var(--radius-md); color: var(--muted); padding: 24px; text-align: center; }

@media (max-width: 1000px) {
  .debug-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .debug-run-card { grid-template-columns: 1fr; }
}

@media (min-width: 701px) and (max-width: 900px) {
  .page { padding: 40px 24px 72px; }
  .movie-card { grid-template-columns: 150px minmax(0, 1fr); gap: 18px; padding: 16px; }
  .poster-wrap, .poster { width: 150px; }
  .movie-heading h2 { font-size: clamp(23px, 3.8vw, 31px); }
}

@media (max-width: 700px) {
  .page, .debug-page { padding: 24px 14px 56px; }
  .site-header { margin-bottom: 14px; }
  .cards { gap: 12px; }
  .debug-shell { padding-inline: 14px; }
  .debug-topbar { flex-wrap: wrap; padding-top: 14px; }
  .movie-card { grid-template-columns: 96px minmax(0, 1fr); gap: 12px; padding: 12px; border-radius: 16px; }
  .poster-wrap, .poster { width: 96px; }
  .movie-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: start; }
  .movie-heading h2 { font-size: clamp(20px, 5vw, 24px); line-height: 1.05; }
  .meta { font-size: 12px; }
  .description {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    line-height: 1.42;
    font-size: 13px;
    margin: 8px 0;
  }
  .dismiss-button { min-height: 40px; padding: 7px 11px; }
  .trailer { margin: 6px 0 10px; }
  .trailer-link, .trailer a { min-height: 40px; font-size: 13px; }
  .showtimes h3 { margin-bottom: 8px; font-size: 11px; }
  .theater-list { gap: 7px; }
  .theater-row, .theater-group summary { grid-template-columns: minmax(0, 1fr) auto; gap: 6px; min-height: 54px; padding: 11px; }
  .theater-group summary > div { grid-column: 1 / -1; }
  .theater-name, .theater-group summary strong { font-size: 13px; line-height: 1.15; }
  .theater-address, .theater-group summary span:not(.showtime-count) { line-height: 1.25; }
  .showtime-count { justify-self: start; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-soft); padding: 3px 8px; font-size: 11px; }
  .showtimes ul { gap: 7px; padding-top: 9px; }
  .showtimes .time { min-height: 40px; padding: 8px 11px; font-size: 12px; }
  .empty-state { padding: 24px; }
  .status-grid, .debug-stat-grid, .debug-grid, .debug-two-col { grid-template-columns: 1fr; }
  .debug-process-summary, .debug-run-metrics { grid-template-columns: 1fr; }
  .metric-row, .debug-kv div { grid-template-columns: 1fr; gap: 2px; }
}

@media (max-width: 430px) {
  .page { padding: 18px 10px 48px; }
  .site-header { margin-bottom: 8px; }
  .cards { gap: 10px; }
  .movie-card { grid-template-columns: 82px minmax(0, 1fr); gap: 10px; padding: 10px; }
  .poster-wrap, .poster { width: 82px; }
  .movie-heading { gap: 6px; }
  .movie-heading h2 { font-size: clamp(18px, 5vw, 21px); }
  .description { -webkit-line-clamp: 2; margin: 6px 0; }
  .dismiss-button { min-height: 40px; padding-inline: 10px; font-size: 11px; }
  .trailer { margin: 4px 0 8px; }
  .theater-row, .theater-group summary { padding: 10px; }
  .empty-state { padding: 18px; }
}
