:root {
  --bg: #faf6ef;
  --surface: #ffffff;
  --surface-2: #f3ece0;
  --text: #2a1d1f;
  --muted: #6e5f60;
  --border: #e4d8c6;
  --accent: #7a1f2b;        /* curtain maroon */
  --accent-strong: #5a1420;
  --gold: #c9962b;
  --gold-soft: #f5e6c3;
  --header-bg: #2b0b11;
  --header-text: #f7ecd8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(43, 11, 17, .06), 0 4px 16px rgba(43, 11, 17, .06);
  --badge-gold-text: #7a5410;
  color-scheme: light;
  --serif: "Playfair Display", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Dark theme: used when the device prefers dark and the visitor hasn't chosen light,
   or whenever the visitor has chosen dark with the header toggle (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #160a0d;
    --surface: #221216;
    --surface-2: #2c181d;
    --text: #f3e9e3;
    --muted: #b7a3a3;
    --border: #3d252b;
    --accent: #e0707f;
    --accent-strong: #f08a98;
    --gold: #e2b54f;
    --gold-soft: #3a2c14;
    --badge-gold-text: #e2b54f;
    --header-bg: #0e0507;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #160a0d;
    --surface: #221216;
    --surface-2: #2c181d;
    --text: #f3e9e3;
    --muted: #b7a3a3;
    --border: #3d252b;
    --accent: #e0707f;
    --accent-strong: #f08a98;
    --gold: #e2b54f;
    --gold-soft: #3a2c14;
    --badge-gold-text: #e2b54f;
    --header-bg: #0e0507;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--sans);
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); }
h2 { font-size: 1.5rem; margin-top: 2rem; }
h3 { font-size: 1.15rem; }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px; z-index: 10; }

/* ---------- header ---------- */
.site-header { background: var(--header-bg); color: var(--header-text); }
.marquee-lights {
  height: 6px;
  background: radial-gradient(circle, var(--gold) 2px, transparent 2.5px) 0 0 / 18px 6px repeat-x;
  opacity: .9;
}
.header-inner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px;
  padding-top: 14px; padding-bottom: 14px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  color: var(--header-text); text-decoration: none;
  font-family: var(--serif); font-weight: 800; font-size: 1.3rem;
}
.brand:hover { color: #fff; }
.brand-mark { color: var(--gold); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  color: var(--header-text); text-decoration: none; padding: 6px 8px; border-radius: 8px;
  font-weight: 500;
}
.nav a:hover, .nav a[aria-current] { background: rgba(255, 255, 255, .1); color: #fff; }
.nav a[aria-current] { box-shadow: inset 0 -2px 0 var(--gold); }
.search-form { flex: 1; min-width: 0; }
.search-form input {
  width: 100%; padding: 8px 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.08); color: var(--header-text); font: inherit;
}
.search-form input::placeholder { color: rgba(247, 236, 216, .6); }

main { min-height: 60vh; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 24px 0; font-size: .9rem; }
.site-footer p { margin: .25em 0; }

/* ---------- components ---------- */
.hero {
  margin-top: 20px;   /* the home page's opening box sits a little below the header */
  background: linear-gradient(135deg, #7a1f2b, #3a0d16);
  color: #fbefe0; border-radius: var(--radius); padding: clamp(24px, 5vw, 48px);
  position: relative; overflow: hidden; box-shadow: var(--shadow);
}
.hero::after {
  content: ""; position: absolute; inset: auto -40px -60px auto; width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(201, 150, 43, .45), transparent 70%);
}
.hero h1 { color: #fff; }
.hero a { color: #f5e6c3; }   /* fixed: the hero is maroon in both themes */
.hero .btn { color: #2b0b11; }
.hero .btn-ghost {
  background: #fbefe0; color: #5a1420; border: 1px solid #fbefe0;
}
.hero .btn-ghost:hover { background: #fff; border-color: #fff; color: #3a0d16; }
.hero .eyebrow { color: var(--gold); }
.eyebrow {
  text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; font-weight: 600;
  color: var(--accent); margin: 0 0 .5em;
}
.btn {
  display: inline-block; padding: 10px 18px; border-radius: 999px; font-weight: 600;
  text-decoration: none; background: var(--gold); color: #2b0b11; border: 0;
}
.btn:hover { filter: brightness(1.08); color: #2b0b11; }
.btn-ghost { background: transparent; color: inherit; border: 1px solid currentColor; }
.btn-ghost:hover { color: inherit; background: rgba(255,255,255,.08); }
.btn-small { padding: 6px 12px; font-size: .85rem; }
.facts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 16px; }
.fact-card { background: var(--surface, rgba(255,255,255,.04)); border: 1px solid var(--border, rgba(127,127,127,.25));
             border-radius: var(--radius); padding: 18px 20px; }
.fact-card .eyebrow { margin-bottom: 4px; }
.fact-number { margin: 0 0 8px; }
.fact-number strong { font-family: "Playfair Display", serif; font-size: 2.2rem; color: var(--gold); line-height: 1.1; }
.fact-number span { color: var(--muted); }
.fact-card p:last-child { margin-bottom: 0; }
.fact-list { margin: 6px 0 0; padding-left: 1.1em; }
.fact-list li { margin: 2px 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.section-head h2 { margin-bottom: 0; }
.section-head + * { margin-top: 12px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 24px 0; }
.stats-4 { grid-template-columns: repeat(4, 1fr); }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center;
}
.stat strong { display: block; font-family: var(--serif); font-size: 2rem; color: var(--accent); }
.stat span { color: var(--muted); font-size: .9rem; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px;
}
.card h3 { margin: 0; }
.card h3 a { color: var(--text); text-decoration: none; }
.card h3 a:hover { color: var(--accent); }
.card .meta { color: var(--muted); font-size: .9rem; margin: 0; }
a.card { text-decoration: none; color: inherit; transition: transform .12s ease, border-color .12s; }
a.card:hover { transform: translateY(-2px); border-color: var(--gold); color: inherit; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge-gold { background: var(--gold-soft); color: var(--badge-gold-text); border-color: var(--gold); }
.badge-place-1 { background: var(--gold); color: #2b0b11; border-color: var(--gold); }
.badge-place-2 { background: #d9dadf; color: #333; border-color: #c4c5cb; }
.badge-place-3 { background: #d9a77a; color: #3a210c; border-color: #c48f60; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }

.breadcrumbs { font-size: .9rem; color: var(--muted); margin-bottom: 12px; }
.breadcrumbs a { color: var(--muted); }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; }

.page-head { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; margin-bottom: 8px; }
.page-head .poster { width: 180px; border-radius: var(--radius); box-shadow: var(--shadow); }
.page-head > div { flex: 1 1 320px; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 24px; padding: 0; margin: 12px 0; list-style: none; color: var(--muted); }
.facts strong { color: var(--text); font-weight: 600; }

.video { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; margin: 16px 0; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.gallery { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.gallery figure { margin: 0; }
.gallery img { aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; width: 100%; }
.gallery figcaption { font-size: .8rem; color: var(--muted); }

.filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 20px; }
.filter-tabs a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); text-decoration: none; color: var(--text); background: var(--surface); font-size: .9rem; }
.filter-tabs a[aria-current] { background: var(--accent); border-color: var(--accent); color: #fff; }

.empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 24px; text-align: center; color: var(--muted); }
.club-logo { width: 64px; height: 64px; object-fit: contain; border-radius: 8px; }
.prose { max-width: 70ch; }

@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .stats-4 { grid-template-columns: 1fr 1fr; }
  .stat strong { font-size: 1.5rem; }
  .hide-sm { display: none; }
}

.sources { font-size: .85rem; color: var(--muted); padding-left: 1.2em; word-break: break-all; }
.prose a { overflow-wrap: anywhere; }   /* long gallery links in descriptions wrap on phones */

.person-facts { margin: 4px 0 0; display: grid; gap: 2px; font-size: .9rem; }
.person-facts div { display: flex; gap: 8px; }
.person-facts dt { color: var(--muted); min-width: 3.5em; }
.person-facts dd { margin: 0; }
.person .also { font-size: .85rem; margin: 6px 0 0; color: var(--muted); }
.repeat-list { padding-left: 1.2em; }
.repeat-list li { margin: 4px 0; }

/* sortable tables */
.sort-button {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit;
}
.sort-button::after { content: "↕"; opacity: .35; font-size: .9em; }
th[aria-sort="ascending"] .sort-button::after { content: "↑"; opacity: 1; }
th[aria-sort="descending"] .sort-button::after { content: "↓"; opacity: 1; }
th[aria-sort] { color: var(--text); }
.sort-button:hover { color: var(--accent); }
.sort-button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
th.num .sort-button { flex-direction: row-reverse; }

/* search autocomplete */
.search-form.has-autocomplete { position: relative; }
.autocomplete-list {
  position: absolute; z-index: 20; top: calc(100% + 6px); right: 0;
  width: max(100%, min(380px, calc(100vw - 32px)));
  margin: 0; padding: 6px; list-style: none;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
  max-height: min(420px, 70vh); overflow-y: auto;
}
.autocomplete-list[hidden] { display: none; }
.autocomplete-list li {
  display: flex; flex-direction: column; gap: 1px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.autocomplete-list li[aria-selected="true"] { background: var(--surface-2); outline: 1px solid var(--gold); }
.ac-label { font-weight: 600; }
.ac-label mark { background: var(--gold-soft); color: inherit; border-radius: 2px; padding: 0 1px; }
.ac-meta { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.autocomplete-all { color: var(--accent); font-size: .9rem; border-top: 1px solid var(--border); margin-top: 4px; }
@media (max-width: 640px) {
  .autocomplete-list { width: 100%; }
}

/* theme toggle */
.theme-toggle {
  flex: none; display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0; border-radius: 50%; cursor: pointer;
  color: var(--header-text); background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .2);
}
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { background: rgba(255, 255, 255, .16); }
.theme-toggle:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle [data-icon] { display: none; }
:root:not([data-theme]) .theme-toggle [data-icon="auto"],
:root[data-theme="light"] .theme-toggle [data-icon="light"],
:root[data-theme="dark"] .theme-toggle [data-icon="dark"] { display: inline; }

/* photo gallery */
.photo-grid { columns: 220px; column-gap: 12px; }
.photo-tile { break-inside: avoid; margin: 0 0 12px; }
.photo-tile > a { display: block; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.photo-tile img { width: 100%; height: auto; transition: transform .2s ease; }
.photo-tile > a:hover img { transform: scale(1.03); }
.photo-tile > a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.photo-tile figcaption { font-size: .85rem; color: var(--muted); padding: 6px 2px 0; }
.photo-tile .photo-people { display: block; color: var(--text); margin-top: 2px; }

.lightbox {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: rgba(10, 4, 6, .94); color: #f7ecd8;
}
.lightbox::backdrop { background: rgba(0, 0, 0, .6); }
.lightbox[open] { display: grid; grid-template-rows: 1fr auto; }
.lightbox-stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 48px 56px 8px; }
.lightbox-stage img {
  display: block; width: auto; height: auto; object-fit: contain; border-radius: 6px;
  max-width: calc(100vw - 112px);
  max-height: calc(100dvh - 150px);   /* leave room for the caption and buttons */
}
.lightbox-caption { text-align: center; padding: 8px 16px 20px; }
.lightbox-caption p { margin: 0; }
.lightbox-caption .lb-meta { font-size: .85rem; opacity: .75; margin-top: 2px; }
.lightbox-caption .lb-people { font-size: .9rem; margin-top: 2px; }
.lightbox button {
  position: absolute; display: grid; place-items: center; width: 44px; height: 44px;
  border-radius: 50%; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08);
  color: inherit; font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.lightbox button:hover { background: rgba(255,255,255,.18); }
.lightbox button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.lb-close { top: 8px; right: 8px; }
.lb-prev { left: 8px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 8px; top: 50%; transform: translateY(-50%); }
.lb-count { position: absolute; top: 18px; left: 16px; font-size: .85rem; opacity: .75; }
@media (max-width: 640px) {
  .photo-grid { columns: 2; column-gap: 8px; }
  .photo-tile { margin-bottom: 8px; }
  .lightbox-stage { padding: 56px 8px 8px; }
  .lightbox-stage img { max-width: calc(100vw - 16px); max-height: calc(100dvh - 210px); }
  .lb-prev, .lb-next { top: auto; bottom: -52px; transform: none; }
  .lightbox-caption { padding-top: 60px; }
}

.show-nickname { margin-top: -6px; color: var(--muted); font-style: italic; }

/* Year hero image (e.g. the theme logo): full width, never cropped, on its own light panel. */
.theme-subtitle { margin: -6px 0 12px; font-size: 1.15rem; font-style: italic; color: var(--muted); }
.video-card h3 { margin: 2px 0 4px; font-size: 1.05rem; }
.video-card .eyebrow { margin: 10px 0 0; }
.video-card p.muted { margin: 4px 0 0; font-size: .85rem; }
.video-thumb { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
               background: #000; }
.video-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-thumb-blank { display: block; position: relative; width: 100%; height: 100%;
                     background: linear-gradient(135deg, #2a1b22, #120b0f); }
.video-thumb-time { position: absolute; left: 10px; bottom: 8px; color: #fff; font-size: .75rem; letter-spacing: .04em;
                    text-transform: uppercase; opacity: .8; }
.video-thumb, .video-thumb:hover { text-decoration: none; }
.video-play { position: absolute; inset: 0; margin: auto; width: 48px; height: 48px; border-radius: 50%;
              background: rgba(0, 0, 0, .65); color: #fff; display: grid; place-items: center; font-size: 18px;
              padding-left: 3px; box-sizing: border-box; transition: background .12s; }
.video-thumb:hover .video-play { background: var(--accent, #c00); }
.about-photos { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 12px 0 4px; }
.about-photos figure { margin: 0; }
.about-photos img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: var(--radius); display: block; }
.about-photos figcaption { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.year-hero { margin: 0 0 24px; border-radius: var(--radius); overflow: hidden; background: #f9f7f8;
             box-shadow: var(--shadow); }
.year-hero img { display: block; width: 100%; max-height: 400px; object-fit: contain; margin: 0 auto; }

/* Judges' score tables */
.scores .score-rank { font-size: .75em; color: var(--muted); margin-left: 2px; }
.scores tfoot th { border-top: 2px solid var(--border, rgba(127,127,127,.4)); }
.score-help { font-size: .85rem; color: var(--muted); padding-left: 1.1em; }

/* News */
.news-list { display: grid; gap: 12px; }
.news-item { background: var(--surface); border: 1px solid var(--border, rgba(127,127,127,.25));
             border-radius: var(--radius); padding: 14px 18px; }
.news-item h3 { margin: 2px 0 4px; }
.news-item p { margin: 4px 0; }


/* Hosts & band page: the hosts' songs */
.host-songs { max-width: 70ch; margin: 0 0 24px; padding-left: 1.6em; }
.host-songs li { padding: 3px 0; }

/* Videos page and the home page's link to it */
a.stat { text-decoration: none; color: inherit; transition: border-color .15s; }
a.stat:hover { border-color: var(--accent); }
.year-jump { line-height: 1.9; }
.video-year { margin-bottom: 8px; scroll-margin-top: 80px; }
.home-videos { margin: 8px 0 28px; }

/* Show page: the show's logo / title card beside the title */
.show-head.has-logo { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.show-logo { width: 200px; max-height: 140px; object-fit: contain; border-radius: var(--radius); flex: none; }
@media (max-width: 640px) {
  .show-head.has-logo { flex-direction: column-reverse; align-items: flex-start; gap: 8px; }
  .show-logo { width: 150px; }
}

/* Sources page */
.year-jump { line-height: 1.9; }
.source-year { margin-top: 28px; }
.source-list { padding-left: 1.2em; }
.source-list li { margin: 0 0 10px; }
.source-url { overflow-wrap: anywhere; font-size: .9rem; }
.source-used { display: block; font-size: .8rem; color: var(--muted); }

/* ---------- main menu: icons in a bottom bar on phones ---------- */
.nav-icon { display: none; width: 24px; height: 24px; }
@media (max-width: 640px) {
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    flex-wrap: nowrap; justify-content: space-around; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--header-bg); border-top: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, .25);
    transition: transform .25s ease;
  }
  .nav.nav-hidden { transform: translateY(100%); }
  .nav a.nav-secondary { display: none; }   /* News and About are only in the hamburger menu on phones */
  .nav a { flex: 1 1 0; display: flex; justify-content: center; padding: 10px 0; min-width: 0; }
  .nav a[aria-current] { box-shadow: inset 0 -3px 0 var(--gold); }
  .nav-icon { display: block; }
  .nav-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
  }
  /* Keep the end of the page clear of the bar. */
  .site-footer { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .nav { transition: none; } }

/* ---------- search: behind a magnifier button ---------- */
/* The header is one row (brand, menu, theme and search buttons); the search box opens on its own row below.
   Without JavaScript the button stays hidden and the box is shown as before. */
.header-tools { display: contents; }
.theme-toggle { margin-left: auto; }
.search-toggle { display: none; }
.search-toggle:not([hidden]) {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 36px; height: 36px; padding: 0; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .08); color: var(--header-text);
}
.search-toggle svg { width: 18px; height: 18px; }
.search-toggle:hover, .search-toggle[aria-expanded="true"] { background: rgba(255, 255, 255, .16); }
.search-toggle:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.search-form { flex: 1 1 100%; }
.search-collapsible:not(.search-open) .search-form { display: none; }
@media (min-width: 641px) {
  .header-inner { gap: 12px 16px; }
  /* Its own row (box plus left margin fill the width), right-aligned under the buttons. */
  .search-form { flex: 0 0 min(420px, 100%); margin-left: calc(100% - min(420px, 100%)); }
}
@media (max-width: 640px) {
  .header-inner { gap: 10px 8px; }
}

/* ---------- hamburger menu (phones and tablets) ---------- */
.menu-toggle, .mobile-menu { display: none; }
@media (max-width: 1100px) {
  .menu-toggle:not([hidden]) {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; padding: 0; border-radius: 999px; cursor: pointer;
    border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .08); color: var(--header-text);
  }
  .menu-toggle svg { width: 18px; height: 18px; }
  .menu-toggle [data-icon="close"], .menu-toggle[aria-expanded="true"] [data-icon="open"] { display: none; }
  .menu-toggle[aria-expanded="true"] [data-icon="close"] { display: block; }
  .menu-toggle:hover, .menu-toggle[aria-expanded="true"] { background: rgba(255, 255, 255, .16); }
  .menu-toggle:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
  .site-header { position: relative; }
  .mobile-menu:not([hidden]) {
    display: block; position: absolute; left: 0; right: 0; top: 100%; z-index: 60;
    background: var(--header-bg); border-top: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 8px 20px rgba(0, 0, 0, .35); padding: 6px 0 10px;
  }
  .mobile-menu a {
    display: flex; align-items: center; gap: 14px; padding: 12px 20px;
    color: var(--header-text); text-decoration: none; font-weight: 500;
  }
  .mobile-menu a:hover, .mobile-menu a[aria-current] { background: rgba(255, 255, 255, .08); color: #fff; }
  .mobile-menu a[aria-current] { box-shadow: inset 3px 0 0 var(--gold); }
  .mobile-menu .nav-icon { display: block; width: 22px; height: 22px; flex: none; }
  .mobile-menu .nav-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
}
@media (max-width: 640px) {
  /* Brand plus theme, search and menu buttons on one row. The title keeps its full size (1.3rem) and only
     shrinks on a phone too narrow for it: the row's width (100cqi) minus the three 36px buttons, the gaps
     between the four items and the star's gap is what's left, and the star plus title are about 10.15em
     wide (10.3 leaves a little slack). Below 15px it stops shrinking and the title is cut short with “…”. */
  .header-inner { gap: 10px 6px; container-type: inline-size; }
  .brand { font-size: 1.1rem; font-size: clamp(15px, (100cqi - 134px) / 10.3, 1.3rem); min-width: 0; }
  .brand span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (min-width: 641px) and (max-width: 1100px) {
  /* Too narrow for the word menu on the header's one row: tablets use the hamburger menu instead. */
  .nav { display: none; }
}
