/* Steel City beer list
 * Layout: desktop = fixed index sidebar + flowing list; phones = index screen,
 * then the list slides in. Colours follow the festival's CAMRA-based palette. */

:root {
  --font: Montserrat, helvetica, arial, sans-serif;

  --bg: #f4f5f6;
  --surface: #ffffff;
  --ink: #3d424c;
  --ink-strong: #22262e;
  --muted: #6b7180;
  --line: #dcdee2;
  --line-strong: #b9bdc5;
  --slate: #41495a;
  --edge: #41495a;
  --on-slate: #ffffff;
  --blue: #5b6fb3;
  --on-blue: #ffffff;

  --orange: #f9b13c;
  --on-orange: #2a2e37;
  --orange-tint: #feedd2;
  --both: #fedbaf;
  --marquee: #d0d3d4;
  --on-marquee: #2f3542;
  --marquee-tint: #eceeef;
  --aqua: #00a6b4;
  --on-aqua: #ffffff;
  --aqua-tint: #d3f0f2;
  --deep: #e2541f;
  --on-deep: #ffffff;
  --deep-tint: #fbd9cc;
  --green: #3f9e7c;
  --on-green: #ffffff;
  --abv: #d6d8db;

  --map-fill: #6f7686;
  --map-empty: #e3e5e8;
  --shade: rgba(20, 22, 28, .55);

  --side-w: 380px;
  --gap: 12px;
  --tabs-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171c; --surface: #1f2229; --ink: #d8dbe0; --ink-strong: #f1f2f4; --muted: #9ca2ae;
    --line: #333844; --line-strong: #4a505d; --slate: #59627a; --edge: #aab1c0; --on-slate: #ffffff; --blue: #7486c9;
    --orange-tint: #3b301d; --marquee: #8f959c; --on-marquee: #15171c; --marquee-tint: #2a2e35;
    --aqua-tint: #12383c; --deep-tint: #3e241a; --abv: #3a3f4a;
    --map-fill: #7c8496; --map-empty: #2a2e36; --shade: rgba(0, 0, 0, .65);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15171c; --surface: #1f2229; --ink: #d8dbe0; --ink-strong: #f1f2f4; --muted: #9ca2ae;
  --line: #333844; --line-strong: #4a505d; --slate: #59627a; --edge: #aab1c0; --on-slate: #ffffff; --blue: #7486c9;
  --orange-tint: #3b301d; --marquee: #8f959c; --on-marquee: #15171c; --marquee-tint: #2a2e35;
  --aqua-tint: #12383c; --deep-tint: #3e241a; --abv: #3a3f4a;
  --map-fill: #7c8496; --map-empty: #2a2e36; --shade: rgba(0, 0, 0, .65);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
mark { background: none; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i.inline { width: 1.15em; height: 1.15em; vertical-align: -.2em; }
.i.ip { fill: currentColor; stroke: none; stroke-width: initial; width: 24px; height: 24px; }
.i.ip.inline { width: 1.2em; height: 1.2em; }
/* White details inside the programme icons take the colour behind them */
body { --icon-cut: var(--surface); }
.lists .li.on, .vbtn.on, .tab.on, .act[aria-pressed="true"], .opt.on { --icon-cut: var(--slate); }
.empty { --icon-cut: var(--bg); }
h1, h2, h3, h4 { text-wrap: balance; }

.load-error { max-width: 36em; margin: 15vh auto; padding: 0 16px; text-align: center; }

/* ---------- Shell ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  z-index: 10;
}

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 8px;
}
.logo { display: flex; align-items: center; height: 40px; color: var(--edge); text-decoration: none; font-weight: 800; flex: none; }
.logo img, .logo svg { height: 44px; width: auto; display: block; }
.logo { color: var(--ink); }
.logo span { font-size: 13px; text-transform: uppercase; line-height: 1.05; max-width: 5em; }

.lists {
  flex: 0 1 auto;
  display: flex;
  border: 1.5px solid var(--edge);
  border-radius: 10px;
  overflow: hidden;
  min-width: 0;
}
.lists .li {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 9px;
  min-width: 0;
  color: var(--edge);
  text-decoration: none;
  border-left: 1px solid var(--edge);
}
.lists .li:first-child { border-left: 0; }
.lists .li .li-t { display: none; }
.lists .li.on { flex: 0 1 auto; padding-inline: 12px; background: var(--slate); color: var(--on-slate); }
.lists .li.on .li-t { display: inline; font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; line-height: 1.1; text-align: center; text-wrap: balance; }
.lists .li:not(.on):hover { background: var(--bg); }

.views {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 0 12px 8px;
}
.seg {
  display: flex;
  border: 1.5px solid var(--edge);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}
.vbtn, .seg-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 6px 5px;
  border: 0;
  background: none;
  color: var(--edge);
  font-size: 11px;
  font-weight: 700;
  position: relative;
}
.vbtn + .vbtn { border-left: 1px solid var(--edge); }
.vbtn.on { background: var(--slate); color: var(--on-slate); }
.seg-btn { border: 1.5px solid var(--edge); border-radius: 10px; padding-inline: 18px; }
.seg-btn .dot { position: absolute; top: 5px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--deep); }

.searchbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 12px 10px;
  padding: 0 4px 0 10px;
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  color: var(--muted);
}
.searchbar:focus-within { border-color: var(--slate); }
.searchbar input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--ink-strong);
  font: inherit;
  font-size: 16px;
  padding: 8px 0;
  outline: none;
}
.searchbar input::-webkit-search-cancel-button { display: none; }
.icon-btn, .q-clear {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
}

.index {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 12px calc(var(--tabs-h) + 24px);
  background: var(--bg);
  border-top: 1px solid var(--line);
}

/* ---------- Buttons and chips ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: var(--on-blue);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.15;
  text-align: center;
}
.btn .i { width: 18px; height: 18px; }
.btn.small { padding: 6px 12px; }
.btn.ghost { background: none; color: var(--blue); box-shadow: inset 0 0 0 1.5px var(--blue); }

.bar {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  background: var(--slate);
  color: var(--on-slate);
  white-space: nowrap;
}
.bar.upper-hall, .bar-upper-hall { --bb: var(--orange); --bi: var(--on-orange); --bt: var(--orange-tint); }
.bar.marquee, .bar-marquee { --bb: var(--marquee); --bi: var(--on-marquee); --bt: var(--marquee-tint); }
.bar.guest-bar, .bar-guest-bar { --bb: var(--aqua); --bi: var(--on-aqua); --bt: var(--aqua-tint); }
.bar.keg-bar, .bar-keg-bar { --bb: var(--deep); --bi: var(--on-deep); --bt: var(--deep-tint); }
.bar.both, .bar-both { --bb: var(--both); --bi: var(--on-orange); --bt: var(--orange-tint); }
.bar, mark.bar { background: var(--bb, var(--slate)); color: var(--bi, var(--on-slate)); }

.pbtn, .abtn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: var(--bb, var(--slate));
  color: var(--bi, var(--on-slate));
  font-weight: 700;
  font-size: 13.5px;
  text-align: left;
  line-height: 1.15;
}

.pbtn span, .abtn span { min-width: 0; overflow-wrap: anywhere; }
.pbtn b, .abtn b { font-variant-numeric: tabular-nums; flex: none; }
.pbtn:disabled, .abtn:disabled { opacity: .35; }
.pbtn:not(:disabled):hover, .abtn:not(:disabled):hover { filter: brightness(1.06); }

/* ---------- Index: breweries ---------- */

/* "Showing 12 of 210 · Vegan · “citra”" with Clear */
.fnote {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  background: var(--surface);
  border-radius: 8px;
  border-left: 4px solid var(--blue);
  font-size: 13.5px;
  line-height: 1.35;
}
.fnote p { flex: 1; margin: 0; min-width: 0; }
.fnote .fsum { display: block; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.fnote.in-index { margin: -2px 0 12px; }
.fnote.in-list { margin-bottom: 12px; }
@media (min-width: 980px) { .only-phone { display: none; } }

/* Less-used actions at the foot of the index */
.index-foot {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-top: 22px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.linkbtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--blue);
  font-weight: 700;
  font-size: 13.5px;
}
.linkbtn .i { width: 18px; height: 18px; }
.linkbtn:hover { text-decoration: underline; }
.ver { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); }

.intro { display: grid; gap: 10px; font-size: 12.5px; line-height: 1.4; }
.intro-text { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px 14px; justify-items: start; text-align: left; }
.intro-text p, .intro-text div { margin: 0 0 6px; text-align: left; justify-self: stretch; }
.intro-text .bar { font-size: 14px; margin-top: 3px; }

.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 14px; }
.pgrid.two > div { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Index: regions map and country tiles ---------- */

.mapwrap { display: flex; justify-content: center; margin-bottom: 14px; }
.map {
  width: 100%;
  aspect-ratio: 34 / 53;
  max-width: 100%;
  display: grid;
  grid-template-columns: repeat(34, minmax(0, 1fr));
  grid-template-rows: repeat(53, minmax(0, 1fr));
  gap: 2px;
  container-type: inline-size;
}
.blk {
  grid-area: 1 / 1;
  border-radius: 7px;
  background: var(--map-empty);
  transition: background-color .15s;
}
.blk.has { background: var(--map-fill); cursor: pointer; }
.blk.round { border-radius: 50%; box-shadow: 0 0 0 3px var(--bg); z-index: 1; }
.blk.home.has { background: var(--orange); }
.blk.has.hl, .mlab.hl + .blk { background: var(--slate); }
.blk.home.has.hl { background: var(--deep); }
.mlab {
  z-index: 2;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--on-slate);
  font-weight: 800;
  font-size: max(12px, 4.4cqw);
  font-variant-numeric: tabular-nums;
  padding: 0;
}
.mlab.home { color: var(--on-orange); font-size: max(14px, 5.6cqw); }

.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.legend .abtn { --bb: var(--slate); --bi: var(--on-slate); }
.legend.tiles { gap: 8px; }
.legend.tiles .abtn {
  flex-direction: column;
  justify-content: center;
  min-height: 78px;
  font-size: 15px;
  text-align: center;
}

/* ---------- Index: style palette ---------- */

.palette {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 58px;
  grid-auto-flow: dense;
  gap: 6px;
}
.stile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px;
  border: 0;
  border-radius: 6px;
  background: var(--c);
  color: var(--ci);
  font-weight: 800;
  font-size: var(--fs, 13px);
  line-height: 1.05;
  text-align: center;
  overflow: hidden;
}
.stile b { font-size: 11px; font-variant-numeric: tabular-nums; }
.stile:disabled { background: var(--map-empty); color: var(--muted); }
.stile:not(:disabled):hover { filter: brightness(1.07); }

/* ---------- The list ---------- */

.main { min-width: 0; padding: 12px 12px calc(var(--tabs-h) + 32px); }
.list-bar { display: none; }

.notice { margin: 0 0 12px; padding: 10px 14px; background: var(--surface); border-radius: 8px; font-size: 14px; }
.empty { max-width: 34em; margin: 10vh auto; text-align: center; color: var(--muted); }
.empty h3 { color: var(--ink-strong); font-size: 20px; margin: 0 0 8px; }

.flowwrap { container-type: inline-size; }
.flow {
  --cols: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 18px var(--gap);
  align-items: flex-start;
}
/* The breweries column beside a region or style heading measures itself */
.flowbox { container-type: inline-size; min-width: 0; }
/* Not enough room for a 265px card beside the heading: put the heading on top */
@container (max-width: 560px) {
  .flowwrap .big { display: block; }
  .flowwrap .big .bh { position: static; max-height: none; margin-bottom: var(--gap); }
  .flowwrap .big .bh .chips { grid-template-columns: 1fr 1fr; }
}
/* Cards are never narrower than 265px: add a column only when it fits
   (n cards x 265px + gaps of 12px) */
@container (min-width: 542px) { .flow { --cols: 2; } }
@container (min-width: 819px) { .flow { --cols: 3; } }
@container (min-width: 1096px) { .flow { --cols: 4; } }
@container (min-width: 1373px) { .flow { --cols: 5; } }
@container (min-width: 1650px) { .flow { --cols: 6; } }

/* A brewery is as wide as its beers, so small ones sit side by side */
.prod {
  --k: min(var(--n), var(--cols));
  width: calc((100% + var(--gap)) / var(--cols) * var(--k) - var(--gap));
  min-width: 0;
  scroll-margin-top: 12px;
}
.ph { background: var(--bt, var(--marquee-tint)); margin-bottom: var(--gap); }
.ph h3 {
  margin: 0;
  padding: 5px 9px 4px;
  background: var(--bb, var(--slate));
  color: var(--bi, var(--on-slate));
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}
.ph p { margin: 0; padding: 7px 9px 9px; font-size: 13px; color: var(--ink); }

.cards { display: flex; flex-wrap: wrap; gap: var(--gap); }

.card {
  width: calc((100% + var(--gap)) / var(--k) - var(--gap));
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px 12px;
  align-content: start;
  padding: 12px;
  background: var(--surface);
  scroll-margin-top: 12px;
  position: relative;
}
.pic { width: 72px; height: 72px; display: grid; place-items: center; }
.pic img { max-width: 72px; max-height: 72px; width: auto; height: auto; object-fit: contain; grid-area: 1 / 1; }
.pic .ph-glass { display: none; width: 44px; height: 44px; color: var(--map-empty); grid-area: 1 / 1; }
.pic.none .ph-glass { display: block; }

.hd { align-self: center; }
.hd h4 {
  margin: 0;
  color: var(--ink-strong);
  font-size: 16.5px;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.tk { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 0; }
.tk mark { padding: 3px 5px; border-radius: 2px; font-size: 12px; font-weight: 700; line-height: 1.1; }
.tk .abv { background: var(--abv); color: var(--ink-strong); font-variant-numeric: tabular-nums; }
.tk .sty { background: var(--c); color: var(--ci); }
.badge { text-transform: uppercase; letter-spacing: .03em; }
.badge.out { background: var(--ink-strong); color: var(--surface); }
.badge.soon { background: var(--blue); color: var(--on-blue); }
.badge.low { background: var(--deep); color: var(--on-deep); }

.notes { grid-column: 1 / -1; margin: 0; font-size: 14px; color: var(--ink); }

.ft {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}
.tags { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tags .row { display: flex; flex-wrap: wrap; gap: 4px; }
.tags mark { padding: 4px 5px; border-radius: 2px; font-size: 10.5px; font-weight: 700; line-height: 1; }
.tags mark.bar { font-size: 10px; }
.tags .vegan { background: var(--green); color: var(--on-green); }
.tags .gf { background: var(--orange); color: var(--on-orange); }
.tags .alg { background: var(--slate); color: var(--on-slate); }
.tags .alg::first-letter { text-transform: uppercase; }
.tags .alg.tbc { background: none; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-strong); }

.acts { display: flex; gap: 8px; flex: none; }
.act {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--edge);
  background: var(--surface);
  color: var(--edge);
  padding: 0;
  transition: background-color .15s, color .15s;
}
.act[aria-pressed="true"] { background: var(--slate); color: var(--on-slate); }
.act:disabled { opacity: .3; }

.stars {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.stars-row { display: flex; }
.star {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--line-strong);
}
.star .i { width: 28px; height: 28px; fill: currentColor; stroke-width: 1.2; }
.star.on { color: var(--orange); }
.stxt { font-size: 12.5px; color: var(--muted); }

/* Status: sold out drinks stay in place, greyed out */
.card.st-out > :not(.ft):not(.stars) { opacity: .45; }
.card.st-out .tags { opacity: .45; }
.card.st-out .pic img { filter: grayscale(1); }

.card.flash { animation: flash 2.2s ease-out; }
@keyframes flash {
  0%, 30% { box-shadow: 0 0 0 4px var(--orange); }
  100% { box-shadow: 0 0 0 4px transparent; }
}

/* Regions and styles: heading column on the left, breweries on the right */
.big {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
  margin-bottom: 28px;
  scroll-margin-top: 0;
}
.bh {
  position: sticky;
  top: 0;
  max-height: 100vh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}
.bh-title, .bh .desc { flex: none; }
/* Only the brewery buttons scroll, so the heading stays in view */
.bh .chips { min-height: 0; overflow-y: auto; }
/* The heading column is narrow on desktop: one brewery per row */
.bh .chips { grid-template-columns: 1fr; }
.bh-title {
  padding: 14px 12px 12px;
  background: var(--c, var(--map-fill));
  color: var(--ci, var(--on-slate));
  text-align: center;
}
.bh-title h2 { margin: 0; font-size: 30px; line-height: 1.1; font-weight: 800; overflow-wrap: anywhere; }
.bh-title p { margin: 8px 0 0; font-size: 13px; font-weight: 700; }
.big-style .bh .desc {
  margin: 0;
  padding: 10px 12px;
  font-size: 13px;
  background: color-mix(in srgb, var(--c) 16%, var(--surface));
}
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px; }
.chips .pbtn { font-size: 12.5px; min-height: 32px; padding: 6px 8px; }

/* ---------- Tabs ---------- */

.tabs {
  position: fixed;
  left: 0;
  bottom: 0;
  width: var(--side-w);
  z-index: 20;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
.tabs .seg { height: 48px; }
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 0;
  background: none;
  color: var(--edge);
  font-size: 11px;
  font-weight: 700;
  position: relative;
  padding: 2px;
}
.tab + .tab { border-left: 1px solid var(--edge); }
.tab .c { position: absolute; top: 3px; right: 6px; font-size: 10px; font-variant-numeric: tabular-nums; }
.tab.on { background: var(--slate); color: var(--on-slate); }

/* ---------- Filters panel ---------- */

.fpanel {
  position: absolute;
  inset: 0;
  z-index: 30;
  overflow-y: auto;
  background: var(--surface);
  padding: 12px 16px calc(var(--tabs-h) + 24px);
}
.fhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fhead h2 { margin: 0; font-size: 22px; font-weight: 800; text-transform: uppercase; color: var(--ink-strong); }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 8px; }
.fcol h3 { margin: 12px 0 4px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.hint { margin: 2px 0 8px; font-size: 12.5px; color: var(--muted); }
.hint.err { color: var(--deep); }
.sw {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 7px 0;
  border: 0;
  background: none;
  text-align: left;
  font-size: 14px;
}
.sw i { position: relative; flex: none; width: 40px; height: 24px; border-radius: 12px; background: var(--line-strong); transition: background-color .15s; }
.sw i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.sw[aria-checked="true"] i { background: var(--slate); }
.sw[aria-checked="true"] i::after { transform: translateX(16px); }
.opts { display: flex; flex-direction: column; border: 1.5px solid var(--edge); border-radius: 10px; overflow: hidden; }
.opt { padding: 9px 10px; border: 0; background: none; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--edge); }
.opt + .opt { border-top: 1px solid var(--edge); }
.opt.on { background: var(--slate); color: var(--on-slate); }
.factions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- Modal and toast ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px));
  background: var(--shade);
}
.dlg {
  width: 100%;
  max-width: 440px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 18px 20px 20px;
  border-radius: 12px;
  background: var(--surface);
}
.dlg > p { margin: 6px 0 4px; }
.dlg.dlg-jump { max-width: 560px; }
.dlg-h { font-size: 18px !important; text-transform: none !important; }
.jump { margin-top: 10px; }
.jump .pgrid { margin-top: 0; }
.sync-part { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.sync-part h3 { margin: 0 0 10px; font-size: 15px; color: var(--ink-strong); }
.sync-code { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.qr { width: 150px; height: 150px; background: #fff; border-radius: 6px; flex: none; }
.qr svg { width: 100%; height: 100%; display: block; }
.code { margin: 0 0 6px; font-size: 32px; font-weight: 800; letter-spacing: .12em; color: var(--ink-strong); font-variant-numeric: tabular-nums; }
.sync-code > div:last-child { flex: 1 1 160px; min-width: 0; }
.sync-join { display: flex; gap: 8px; }
.sync-join input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1.5px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink-strong);
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.toast {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabs-h) + 18px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  width: fit-content;
  max-width: min(440px, calc(100vw - 32px));
  margin-inline: auto;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink-strong);
  color: var(--surface);
  font-size: 14px;
  font-weight: 600;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }
@media (min-width: 980px) { .toast { left: var(--side-w); } }

/* ---------- Phones and small tablets ---------- */

@media (max-width: 979px) {
  .shell { display: block; }
  .side {
    position: static;
    height: auto;
    border-right: 0;
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }
  .top { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
  .index { overflow: visible; padding-bottom: calc(var(--tabs-h) + 28px + env(safe-area-inset-bottom, 0px)); }
  .main { display: none; padding: 0 0 calc(var(--tabs-h) + 32px + env(safe-area-inset-bottom, 0px)); }

  body.show-list .side { display: none; }
  body.show-list .main { display: block; }

  .list-bar {
    position: sticky;
    top: 0;
    z-index: 15;
    display: block;
    padding: calc(6px + env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) 6px max(6px, env(safe-area-inset-left, 0px));
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }
  .back { display: flex; align-items: center; gap: 2px; padding: 8px 10px 8px 4px; border: 0; background: none; color: var(--ink-strong); font-weight: 500; }
  .lb-row { display: flex; align-items: center; gap: 2px; }
  .list-title { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; line-height: 1.2; }
  .lt-ic { flex: none; display: flex; color: var(--edge); --icon-cut: var(--surface); }
  .lt-ic .i { width: 28px; height: 28px; }
  .lt-tx { display: flex; flex-direction: column; min-width: 0; }
  .lb-btn { color: var(--ink-strong); width: 42px; height: 42px; }
  .lb-btn.on { background: var(--bg); }
  .lb-searchbar { margin: 4px 0 2px 6px; }
  .lt-tx b { font-size: 15px; color: var(--ink-strong); text-transform: uppercase; }
  .lt-tx span { font-size: 12px; color: var(--muted); }

  #notice, .empty { margin-inline: 16px; }
  #notice { padding-top: 12px; }
  .flowwrap { padding: 12px max(0px, env(safe-area-inset-right, 0px)) 0 max(0px, env(safe-area-inset-left, 0px)); }
  .prod, .card { scroll-margin-top: var(--lb, 56px); }
  .card { scroll-margin-top: calc(var(--lb, 56px) + 64px); }
  .ph { position: sticky; top: var(--lb, 54px); z-index: 5; margin-bottom: 8px; }
  .ph p { padding-block: 5px 6px; }
  .cards { gap: 8px; }
  .flow { gap: 16px var(--gap); }
  .card { padding-inline: 16px; }
  .ph h3, .ph p { padding-inline: 16px; }
  .bh-title, .big-style .bh .desc { padding-inline: 16px; }
  .chips { padding-inline: 16px; }

  .big { display: block; margin-bottom: 24px; scroll-margin-top: var(--lb, 56px); }
  .bh { position: static; max-height: none; margin-bottom: 14px; }
  .bh .chips { grid-template-columns: 1fr 1fr; }
  .bh-title h2 { font-size: 28px; }

  .tabs {
    width: 100%;
    border-right: 0;
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }
  /* Phone browsers move fixed bars a moment late when their own toolbar slides
     in or out on a fast scroll. Carry the bar's background on below the screen
     edge so the list never shows through underneath it. */
  .tabs::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 160px;
    background: var(--surface);
    pointer-events: none;
  }
  .fpanel {
    position: fixed;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  body.filters-open { overflow: hidden; }
}

@media (max-width: 420px) {
  .top { gap: 8px; padding-inline: 10px; }
  .logo img { height: 34px; }
  .lists .li { padding-inline: 7px; }
  .lists .li.on { padding-inline: 9px; }
  .lists .li.on .li-t { font-size: 11px; letter-spacing: .02em; }
  .views, .index { padding-inline: 10px; }
  .searchbar { margin-inline: 10px; }
  .vbtn, .seg-btn { font-size: 10.5px; }
  .seg-btn { padding-inline: 12px; }
  .intro-text { grid-template-columns: 1fr; }
  .fgrid { gap: 26px; }
  .sw { font-size: 13px; }
  .sw i { width: 36px; height: 22px; }
  .sw i::after { width: 16px; height: 16px; }
  .sw[aria-checked="true"] i::after { transform: translateX(14px); }
  .card { grid-template-columns: 64px minmax(0, 1fr); }
  .pic, .pic img { width: 64px; max-width: 64px; height: 64px; max-height: 64px; }
  .pic img { width: auto; height: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Very small phones: keep the selected list name on one line where possible */
@media (max-width: 340px) {
  .lists .li { padding-inline: 6px; }
  .lists .li.on { padding-inline: 7px; gap: 5px; }
  .lists .li.on .li-t { font-size: 10px; letter-spacing: 0; }
  .fgrid { grid-template-columns: 1fr; gap: 0; }
}
