@font-face {
  font-family: "DM Mono";
  font-style: normal;
  font-weight: 400;
  font-display: optional;
  src: url("https://fonts.gstatic.com/s/dmmono/v16/aFTU7PB1QTsUX8KYthqQBK6PYK0.woff2") format("woff2");
}

@font-face {
  font-family: "DM Mono";
  font-style: normal;
  font-weight: 500;
  font-display: optional;
  src: url("https://fonts.gstatic.com/s/dmmono/v16/aFTR7PB1QTsUX8KYvumzEYOtbYf-Vlg.woff2") format("woff2");
}

@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: optional;
  src: url("https://fonts.gstatic.com/s/spacegrotesk/v22/V8mDoQDjQSkFtoMM3T6r8E7mPbF4C_k3HqU.woff2") format("woff2");
}

/* ---------------------------------------------------------------- tokens */

:root {
  color-scheme: dark;
  --bg: #0f1013;
  --surface: #17191e;
  --surface-2: #1e2127;
  --surface-3: #272a32;
  --ink: #f3f0e9;
  --muted: #b1afad;
  --faint: #8f8e94;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .16);
  --accent: #ff4b58;
  --accent-hover: #ff6670;
  --accent-ink: #1a0507;
  --accent-soft: rgba(255, 75, 88, .14);
  --accent-text: #ff7a83;
  --success: #8ed7a0;
  --danger: #ff9aa2;
  --rating-general: #7fd49a;
  --rating-teen: #7cb8ff;
  --rating-mature: #f2b45c;
  --rating-explicit: #ff7a83;
  --rating-bronze: #c9824d;
  --rating-silver: #c4cbd6;
  --rating-gold: #ffd34f;
  --rating-platinum: #d7edf6;
  --rating-diamond: #67d7ff;
  --backdrop: rgba(4, 5, 7, .62);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .32), 0 2px 10px -4px rgba(0, 0, 0, .35);
  --shadow: 0 2px 6px rgba(0, 0, 0, .28), 0 16px 36px -14px rgba(0, 0, 0, .55);
  --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .7), 0 2px 8px rgba(0, 0, 0, .3);
  --glow: 0 8px 24px -8px rgba(255, 75, 88, .55);
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --header-h: 60px;
  --gutter: clamp(16px, 4vw, 40px);
  --font-display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "DM Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f1ec;
  --surface: #ffffff;
  --surface-2: #f6f4ef;
  --surface-3: #ebe8e1;
  --ink: #17181b;
  --muted: #4f5157;
  --faint: #66686e;
  --line: rgba(23, 24, 27, .1);
  --line-strong: rgba(23, 24, 27, .2);
  --accent: #c41d2c;
  --accent-hover: #a91623;
  --accent-ink: #ffffff;
  --accent-soft: rgba(196, 29, 44, .1);
  --accent-text: #b31a28;
  --success: #1f6b35;
  --danger: #a3182a;
  --rating-general: #1d7a3d;
  --rating-teen: #1d5fb0;
  --rating-mature: #9a5b00;
  --rating-explicit: #b31a28;
  --rating-bronze: #8d5129;
  --rating-silver: #56616f;
  --rating-gold: #9f7500;
  --rating-platinum: #46778c;
  --rating-diamond: #087da9;
  --backdrop: rgba(20, 20, 24, .42);
  --shadow-sm: 0 1px 2px rgba(23, 24, 27, .06), 0 2px 8px -2px rgba(23, 24, 27, .08);
  --shadow: 0 2px 6px rgba(23, 24, 27, .06), 0 16px 32px -14px rgba(23, 24, 27, .18);
  --shadow-lg: 0 30px 60px -18px rgba(23, 24, 27, .3), 0 2px 8px rgba(23, 24, 27, .08);
  --glow: 0 8px 22px -8px rgba(196, 29, 44, .45);
}

/* ------------------------------------------------------------------ base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 72px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(70rem 32rem at 85% -10%, rgba(255, 75, 88, .1), transparent 70%) top / 100% 40rem no-repeat,
    var(--bg);
  color: var(--ink);
  font: 400 1rem/1.55 var(--font-display);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip;
}

[data-theme="light"] body {
  background:
    radial-gradient(70rem 32rem at 85% -10%, rgba(196, 29, 44, .07), transparent 70%) top / 100% 40rem no-repeat,
    var(--bg);
}

img {
  max-width: 100%;
  height: auto;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -.02em;
  line-height: 1.15;
}

p {
  margin: 0 0 .75em;
}

a {
  color: var(--accent-text);
}

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

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform .2s var(--ease);
}

.skip-link:focus {
  transform: none;
}

/* ----------------------------------------------------------------- icons */

.icon {
  display: inline-block;
  flex: none;
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.icon-search { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M16.5 16.5 21 21'/%3E%3C/svg%3E"); }
.icon-sliders { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 6h10M17 6h4M3 12h4M11 12h10M3 18h12M19 18h2'/%3E%3Ccircle cx='15' cy='6' r='2'/%3E%3Ccircle cx='9' cy='12' r='2'/%3E%3Ccircle cx='17' cy='18' r='2'/%3E%3C/svg%3E"); }
.icon-dice { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3.5' y='3.5' width='17' height='17' rx='4.5' fill='none' stroke='black' stroke-width='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Ccircle cx='12' cy='12' r='1.5'/%3E%3Ccircle cx='15.5' cy='15.5' r='1.5'/%3E%3C/svg%3E"); }
.icon-menu { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 7h16M4 12h16M4 17h16'/%3E%3C/svg%3E"); }
.icon-list { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M9 6h11M9 12h11M9 18h11M4 6h.01M4 12h.01M4 18h.01'/%3E%3C/svg%3E"); }
.icon-plus { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }
.icon-flag { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 21V4h11l-2 4 2 4H5'/%3E%3C/svg%3E"); }
.icon-code { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 8-4 4 4 4M15 8l4 4-4 4'/%3E%3C/svg%3E"); }
.icon-up { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 19V5M6 11l6-6 6 6'/%3E%3C/svg%3E"); }

/* --------------------------------------------------------------- buttons */

.signal-button,
.quiet-button,
.nav-button,
.menu-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease), box-shadow .2s var(--ease), transform .18s var(--ease);
}

.signal-button {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
}

.signal-button:hover {
  background: var(--accent-hover);
  box-shadow: var(--glow);
  transform: translateY(-1px);
}

.quiet-button,
.nav-button-solid {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--ink);
}

.quiet-button:hover,
.nav-button-solid:hover {
  border-color: var(--line-strong);
  background: var(--surface-3);
}

.signal-button:active,
.quiet-button:active,
.nav-button:active,
.menu-button:active,
.icon-button:active {
  transform: scale(.97);
}

.signal-button:disabled,
.quiet-button:disabled {
  opacity: .45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.text-button {
  padding: 6px 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: color .18s var(--ease), text-decoration-color .18s var(--ease);
}

.text-button:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}

.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  border-color: var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 1.2rem;
  font-weight: 400;
}

.icon-button:hover {
  background: var(--surface-3);
  transform: rotate(90deg);
}

/* ---------------------------------------------------------------- inputs */

:where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea) {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 1rem;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background-color .18s var(--ease);
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

:where(input:not([type="checkbox"]):not([type="radio"]), select, textarea):focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: none;
  accent-color: var(--accent);
}

:where(select) {
  padding-right: 38px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 12px center;
  background-size: 16px;
  background-repeat: no-repeat;
  cursor: pointer;
}

input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}

.field-label {
  display: block;
  margin: 16px 0 6px;
  color: var(--ink);
  font-size: .85rem;
  font-weight: 600;
}

.field-hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.5;
}

.form-status {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: .86rem;
}

.form-status:empty {
  min-height: 0;
  margin: 0;
}

.form-status[data-state="success"] {
  color: var(--success);
}

.form-status[data-state="error"] {
  color: var(--danger);
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 16px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

legend {
  float: left;
  width: 100%;
  margin: 0 0 10px;
  padding: 0;
  color: var(--faint);
  font: 500 .72rem/1.3 var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}

legend + * {
  clear: left;
}

legend small {
  text-transform: none;
  letter-spacing: 0;
}

/* ---------------------------------------------------------------- layout */

.site-shell {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
}

/* ---------------------------------------------------------------- header */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--header-h);
  margin: 0 calc(var(--gutter) * -1);
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  @media (min-width: 961px) {
    .topbar {
      background: color-mix(in srgb, var(--bg) 88%, transparent);
      -webkit-backdrop-filter: blur(14px) saturate(140%);
      backdrop-filter: blur(14px) saturate(140%);
    }
  }
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.02em;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--accent), #ff8a5c);
  box-shadow: var(--glow);
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px solid rgba(255, 255, 255, .9);
  border-radius: 50%;
  border-right-color: transparent;
  transform: rotate(-45deg);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-button {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.nav-button:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-button .icon {
  width: 16px;
  height: 16px;
  opacity: .85;
}

.topbar-quick {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-quick .signal-button {
  min-height: 38px;
  padding: 8px 14px;
}

.menu-button {
  display: none;
  width: 40px;
  padding: 0;
  border-color: var(--line);
  background: var(--surface-2);
}

/* ------------------------------------------------------------------ hero */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 32px;
  padding: clamp(28px, 5vw, 56px) 0 clamp(20px, 3vw, 36px);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  padding: 5px 12px 5px 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font: 500 .72rem/1.3 var(--font-mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(255, 75, 88, .5);
}

.hero h1 {
  font-size: clamp(2.2rem, 5.2vw, 4.2rem);
  font-weight: 700;
  letter-spacing: -.045em;
  line-height: 1;
}

.hero h1 em {
  display: block;
  color: var(--accent);
  font-style: normal;
}

.hero-dek {
  max-width: 54ch;
  margin: 18px 0 22px;
  color: var(--muted);
  font-size: clamp(.98rem, 1.4vw, 1.1rem);
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-stats > div {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.hero-stats strong {
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.hero-stats span {
  color: var(--muted);
  font-size: .85rem;
}

.virtue-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  margin: 0;
  padding-bottom: 6px;
}

.virtue-card::before {
  content: "";
  position: absolute;
  inset: 10% 6% 22%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 75, 88, .28), transparent 68%);
}

.hero-virtue {
  width: clamp(170px, 18vw, 230px);
  filter: drop-shadow(0 22px 26px rgba(0, 0, 0, .45));
}

[data-theme="light"] .hero-virtue {
  filter: drop-shadow(0 18px 22px rgba(23, 24, 27, .22));
}

.virtue-caption {
  display: grid;
  justify-items: center;
  color: var(--muted);
  font-size: .8rem;
  text-align: center;
}

.virtue-caption small {
  color: var(--faint);
  font-size: .72rem;
}

/* --------------------------------------------------------------- catalog */

.catalog {
  padding-bottom: 32px;
}

.catalog-grid {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  grid-template-areas:
    "filters toolbar"
    "filters results";
  align-items: start;
  gap: 14px 28px;
}

.catalog-toolbar {
  grid-area: toolbar;
  position: sticky;
  top: var(--header-h);
  z-index: 20;
  padding: 10px 0;
  background: var(--bg);
  box-shadow: 0 12px 14px -8px var(--bg);
}

.search-field {
  position: relative;
  display: block;
}

.search-field .icon {
  position: absolute;
  top: 50%;
  left: 16px;
  color: var(--faint);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-field input[type="search"] {
  min-height: 50px;
  padding-left: 46px;
  border-color: var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* --------------------------------------------------------- filter panel */

.filter-panel {
  grid-area: filters;
  position: sticky;
  top: calc(var(--header-h) + 14px);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--header-h) - 28px);
  max-height: calc(100dvh - var(--header-h) - 28px);
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  /* The panel itself scrolls. Its body sits inside the details element's
     internal content box, which flex sizing does not reach, so a scrolling
     body never got a height and the panel clipped everything below it. */
  overflow-x: hidden;
  overflow-y: auto;
  /* No overscroll containment: at the panel's end the wheel must carry on to
     the page, or a sidebar that starts below the fold traps the reader. */
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

.filter-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  list-style: none;
  font-weight: 650;
  cursor: pointer;
  user-select: none;
}

.filter-panel > summary::-webkit-details-marker {
  display: none;
}

.summary-label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.filter-count {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: .74rem;
  font-weight: 700;
}

.filter-count[data-count="0"],
.filter-count:not([data-count]) {
  display: none;
}

.filter-body {
  padding: 0 18px 8px;
}

.filter-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
}

.filter-footer .signal-button {
  display: none;
}

.blacklist-filter-field .field-label {
  margin-top: 4px;
}

.blacklist-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.blacklist-chips:empty {
  display: none;
}

.blacklist-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: .8rem;
  animation: pop-in .22s var(--ease) both;
}

.blacklist-chip-remove {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--accent-text);
  font-size: 1rem;
  line-height: 1;
}

.blacklist-chip-remove:hover {
  background: var(--accent-soft);
}

/* Filter values render as tappable chips; the real input sits invisibly on
   top of each chip so it keeps its native semantics and focus. */
.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.check-grid > label {
  position: relative;
  display: inline-flex;
}

.check-grid > label > input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.filter-value {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: .85rem;
  line-height: 1.3;
  transition: background-color .16s var(--ease), border-color .16s var(--ease), color .16s var(--ease);
}

.filter-value small {
  color: var(--faint);
  font: 500 .7rem/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.check-grid > label:hover .filter-value {
  border-color: var(--line-strong);
  background: var(--surface-3);
}

.check-grid > label > input:checked + .filter-value {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  background: var(--accent-soft);
  color: var(--ink);
}

.check-grid > label > input:checked + .filter-value small {
  color: var(--accent-text);
}

.check-grid > label > input:focus-visible + .filter-value {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.more-filter-values {
  margin-top: 10px;
}

.more-filter-values > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 500;
  list-style: none;
  cursor: pointer;
}

.more-filter-values > summary::-webkit-details-marker {
  display: none;
}

.more-filter-values > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .2s var(--ease);
}

.more-filter-values[open] > summary::after {
  transform: translateY(1px) rotate(225deg);
}

.more-filter-values > summary:hover {
  color: var(--ink);
}

.more-filter-values > .check-grid {
  margin-top: 8px;
  animation: fade-up .22s var(--ease) both;
}

/* --------------------------------------------------------------- results */

.results {
  grid-area: results;
  min-width: 0;
}

.results:focus {
  outline: none;
}

.view-tabs,
.dialog-tabs {
  display: flex;
  gap: 4px;
  width: max-content;
  max-width: 100%;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
}

.view-tabs::-webkit-scrollbar,
.dialog-tabs::-webkit-scrollbar {
  display: none;
}

.view-tabs button,
.dialog-tabs button {
  flex: none;
  min-height: 36px;
  padding: 7px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 600;
  transition: background-color .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease);
}

.view-tabs button:hover,
.dialog-tabs button:hover {
  color: var(--ink);
}

.view-tabs button[aria-selected="true"],
.dialog-tabs button[aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
}

.results-topline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin: 16px 0 6px;
}

.results-topline h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--muted);
}

#result-count {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.results-controls {
  display: flex;
  gap: 8px;
}

.select-field select {
  min-height: 38px;
  padding-top: 7px;
  padding-bottom: 7px;
  border-color: var(--line);
  border-radius: 999px;
  background-color: var(--surface);
  font-size: .88rem;
}

.results-controls .select-field select {
  width: auto;
}

.community-state {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--faint);
  font-size: .8rem;
}

.community-state::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}

.community-state[data-state="ready"]::before {
  background: var(--success);
}

.community-state[data-state="loading"]::before {
  animation: blink 1.2s ease-in-out infinite;
}

.community-state[data-state="failed"] {
  color: var(--danger);
}

.community-state[data-state="failed"]::before {
  background: var(--danger);
}

.shared-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: var(--radius);
  background: var(--accent-soft);
  animation: fade-up .3s var(--ease) both;
}

.shared-banner strong {
  display: block;
}

.shared-banner span {
  color: var(--muted);
  font-size: .86rem;
}

.shared-banner > div:last-child {
  display: flex;
  align-items: center;
  gap: 10px;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.active-filters:empty {
  display: none;
}

.filter-chip {
  min-height: 32px;
  padding: 5px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: .82rem;
  font-weight: 500;
  white-space: nowrap;
  animation: pop-in .2s var(--ease) both;
  transition: background-color .16s var(--ease);
}

.filter-chip:hover {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}

/* ----------------------------------------------------------- story cards */

.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
  gap: 16px;
}

/* Until the catalog arrives the grid holds its space with two skeleton cards,
   so the pagination and footer never sit on screen only to be shoved down
   (that jump was the page's whole layout-shift score). */
.story-grid[aria-busy="true"]:empty {
  min-height: 150vh;
}

.story-grid[aria-busy="true"]:empty::before,
.story-grid[aria-busy="true"]:empty::after {
  content: "";
  height: 380px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--surface-3) 70%, transparent) 50%, transparent 70%) 0 0 / 300% 100%,
    var(--surface);
}

.story-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  content-visibility: auto;
  contain-intrinsic-size: auto 400px;
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s var(--ease);
}

@media (hover: hover) and (pointer: fine) {
  .story-card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow);
    transform: translateY(-3px);
  }
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font: 500 .7rem/1.3 var(--font-mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.world-label {
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.source-label {
  color: var(--faint);
}

.story-card h4 {
  font-size: 1.18rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.story-author {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: .88rem;
}

.story-summary {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
}

.story-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.meta-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  max-width: 100%;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: .8rem;
  line-height: 1.35;
}

.meta-chip small {
  color: var(--faint);
  font-size: .7rem;
}

.meta-chip strong {
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.story-card[data-rating="General"] .meta-chip[data-kind="rating"] { --chip: var(--rating-general); }
.story-card[data-rating="Teen"] .meta-chip[data-kind="rating"] { --chip: var(--rating-teen); }
.story-card[data-rating="Mature"] .meta-chip[data-kind="rating"] { --chip: var(--rating-mature); }
.story-card[data-rating="Explicit"] .meta-chip[data-kind="rating"] { --chip: var(--rating-explicit); }

.meta-chip[data-kind="rating"] {
  border-color: color-mix(in srgb, var(--chip, var(--faint)) 45%, transparent);
  background: color-mix(in srgb, var(--chip, var(--faint)) 12%, transparent);
}

.meta-chip[data-kind="rating"] strong {
  color: var(--chip, var(--ink));
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.source-links a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color .18s var(--ease), box-shadow .2s var(--ease), transform .18s var(--ease);
}

.source-links a[data-primary="true"] {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
}

.source-links a:hover {
  transform: translateY(-1px);
  background: var(--surface-3);
}

.source-links a[data-primary="true"]:hover {
  background: var(--accent-hover);
  box-shadow: var(--glow);
}

.rating-row {
  display: inline-flex;
  align-items: center;
  gap: 0;
}

.rating-row button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--surface-3);
  font-size: 1.12rem;
  line-height: 1;
  transition: color .15s var(--ease), transform .15s var(--ease);
}

[data-theme="light"] .rating-row button {
  color: #cfcbc2;
}

.rating-row button:hover {
  transform: scale(1.18);
  color: var(--faint);
}

.rating-row[data-rating-tier="1"] { --rating-color: var(--rating-bronze); }
.rating-row[data-rating-tier="2"] { --rating-color: var(--rating-silver); }
.rating-row[data-rating-tier="3"] { --rating-color: var(--rating-gold); }
.rating-row[data-rating-tier="4"] { --rating-color: var(--rating-platinum); }
.rating-row[data-rating-tier="5"] { --rating-color: var(--rating-diamond); }

.rating-row[data-rating-tier]:not([data-rating-tier="0"]) button[data-lit="true"] {
  color: var(--rating-color);
  text-shadow: 0 0 12px color-mix(in srgb, var(--rating-color) 45%, transparent);
}

.rating-row button[aria-pressed="true"] {
  animation: star-pop .35s var(--ease);
}

.rating-summary {
  margin-left: 6px;
  color: var(--faint);
  font-size: .74rem;
  white-space: nowrap;
}

.card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  font-size: .8rem;
}

.tag-disclosure {
  margin-right: auto;
}

.tag-disclosure[open] {
  flex: 1 1 100%;
  order: 3;
}

.tag-disclosure > summary,
.correction-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--faint);
  font-size: .8rem;
  font-weight: 500;
  list-style: none;
  cursor: pointer;
  transition: color .16s var(--ease);
}

.tag-disclosure > summary::-webkit-details-marker {
  display: none;
}

.tag-disclosure > summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .2s var(--ease);
}

.tag-disclosure[open] > summary::after {
  transform: translateY(1px) rotate(225deg);
}

.tag-disclosure > summary:hover,
.correction-button:hover {
  color: var(--ink);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 220px;
  margin-top: 6px;
  padding: 2px 2px 4px;
  overflow-y: auto;
  animation: fade-up .22s var(--ease) both;
}

.tag-list span {
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .74rem;
  overflow-wrap: anywhere;
}

.story-select {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 10px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  transition: background-color .16s var(--ease), border-color .16s var(--ease), color .16s var(--ease);
}

.story-select input {
  width: 15px;
  height: 15px;
}

.story-select:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.story-select:has(input:checked) {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: var(--accent-soft);
  color: var(--ink);
}

.story-card.is-spotlight {
  animation: spotlight 1.4s var(--ease) 2;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 6px;
  grid-column: 1 / -1;
  padding: 48px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--muted);
  text-align: center;
  animation: fade-up .3s var(--ease) both;
}

.empty-state strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.empty-state span {
  max-width: 48ch;
  font-size: .9rem;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 26px;
}

#page-status {
  color: var(--muted);
  font-size: .88rem;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- footer */

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 18px 32px;
  padding: 28px 0 calc(40px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .86rem;
}

.site-footer strong {
  color: var(--ink);
}

.site-footer p {
  max-width: 60ch;
  margin: 6px 0 0;
}

.footer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
}

/* --------------------------------------------------------- quick actions */

.quick-actions {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 30;
  display: grid;
  gap: 10px;
}

.quick-actions button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: opacity .22s var(--ease), transform .22s var(--ease), background-color .18s var(--ease);
}

.quick-actions button:hover {
  background: var(--accent);
  color: var(--accent-ink);
}

.quick-actions button:not([data-visible="true"]) {
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) scale(.9);
}

#quick-filters {
  display: none;
}

/* --------------------------------------------------------------- dialogs */

dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: min(88vh, 880px);
  max-height: min(88dvh, 880px);
  padding: 24px 26px 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  overscroll-behavior: contain;
}

dialog[open] {
  animation: dialog-in .26s var(--ease) both;
}

dialog::backdrop {
  background: var(--backdrop);
}

dialog[open]::backdrop {
  animation: fade-in .22s ease both;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.dialog-head h2 {
  font-size: clamp(1.35rem, 3vw, 1.7rem);
}

.kicker {
  margin: 0 0 6px;
  color: var(--accent-text);
  font: 500 .7rem/1.3 var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.dialog-intro {
  color: var(--muted);
}

dialog p {
  color: var(--muted);
  font-size: .95rem;
}

dialog fieldset > label,
.account-gate-dismiss-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  color: var(--ink);
  font-size: .93rem;
  cursor: pointer;
}

dialog fieldset > label:not(:last-child) {
  margin-bottom: 2px;
}

.preference-tag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 2px 12px;
}

.preference-tag-grid label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: .9rem;
  cursor: pointer;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

dialog form > .signal-button[type="submit"] {
  width: 100%;
  min-height: 46px;
  margin-top: 18px;
}

.dialog-tabs {
  margin: 4px 0 18px;
}

[role="tabpanel"] {
  animation: fade-up .22s var(--ease) both;
}

[role="tabpanel"]:focus {
  outline: none;
}

.story-picker {
  max-height: 300px;
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-y: auto;
}

.story-picker:empty {
  display: none;
}

.story-picker > .field-hint {
  margin: 0;
  padding: 14px;
}

.picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background-color .15s var(--ease);
}

.picker-row:last-child {
  border-bottom: 0;
}

.picker-row:hover {
  background: var(--surface-2);
}

.picker-row > span {
  display: grid;
  min-width: 0;
}

.picker-row strong {
  overflow: hidden;
  font-size: .92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-row span span {
  color: var(--faint);
  font-size: .8rem;
}

.saved-lists {
  display: grid;
  gap: 8px;
}

.saved-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.saved-list > div:first-child {
  display: grid;
}

.saved-list > div:first-child span {
  color: var(--faint);
  font-size: .82rem;
}

.saved-list-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.saved-list-actions .quiet-button {
  min-height: 34px;
  padding: 6px 12px;
  font-size: .82rem;
}

.backup-tools,
.sync-code-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

.sync-code-row input {
  flex: 1 1 180px;
  width: auto;
}

#backup-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.file-button {
  cursor: pointer;
}

.sync-code-value {
  font: 500 1rem/1.3 var(--font-mono);
  letter-spacing: .06em;
}

.policy-notice {
  margin: 0 0 6px;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  font-size: .88rem;
}

.policy-notice strong {
  color: var(--ink);
}

.turnstile-slot {
  margin-top: 16px;
}

.turnstile-slot:empty {
  margin: 0;
}

.embed-code {
  font: .82rem/1.5 var(--font-mono);
}

.updates-dialog-body .dialog-intro {
  margin-bottom: 4px;
}

.updates-section-heading {
  margin: 20px 0 8px;
  font-size: 1rem;
}

.updates-section-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: .92rem;
}

.updates-section-list li {
  margin-bottom: 6px;
}

.updates-section-list strong {
  color: var(--ink);
}

/* ------------------------------------------------------------- tablet / phone
   At 960px and below the sidebar becomes a bottom sheet, the header folds its
   tools into a menu, and the search bar sticks under the header with the
   Filters button beside it. JS reads the same breakpoint (COMPACT_LAYOUT). */

@media (max-width: 960px) {
  :root {
    --header-h: 56px;
  }

  .nav-label {
    display: none;
  }

  .topbar-quick .nav-button-solid,
  .topbar-quick .signal-button {
    width: 40px;
    min-height: 40px;
    padding: 0;
  }

  .menu-button {
    display: inline-flex;
  }

  .topbar-actions {
    position: absolute;
    top: calc(100% + 8px);
    right: var(--gutter);
    display: grid;
    gap: 2px;
    width: min(260px, calc(100vw - 32px));
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(.98);
    transform-origin: top right;
    transition: opacity .18s var(--ease), transform .18s var(--ease), visibility 0s linear .18s;
  }

  .topbar[data-menu="open"] .topbar-actions {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity .18s var(--ease), transform .18s var(--ease);
  }

  .topbar-actions .nav-button {
    justify-content: flex-start;
    width: 100%;
    min-height: 44px;
    color: var(--ink);
  }

  .catalog-grid {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "toolbar filters"
      "results results";
    gap: 0;
  }

  .topbar {
    background: var(--bg);
  }

  .catalog-toolbar {
    padding: 8px 8px 8px 0;
  }

  /* Closed: the summary is the Filters button beside the search bar. */
  .filter-panel {
    position: sticky;
    top: var(--header-h);
    z-index: 21;
    align-self: start;
    max-height: none;
    margin: 0;
    padding: 8px 0;
    border: 0;
    border-radius: 0;
    background: var(--bg);
    box-shadow: 0 12px 14px -8px var(--bg);
    overflow: visible;
  }

  .filter-panel > summary {
    min-height: 50px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    font-size: .92rem;
  }

  /* Open: the details element becomes the dimmed backdrop and its three
     children stack into a sheet anchored to the bottom of the screen. */
  .filter-panel[open] {
    position: fixed;
    inset: 0;
    z-index: 60;
    align-self: stretch;
    justify-content: flex-end;
    padding: 0;
    background: var(--backdrop);
    animation: fade-in .2s ease both;
  }

  .filter-panel[open] > summary,
  .filter-panel[open] > .filter-body,
  .filter-panel[open] > .filter-footer {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    background: var(--surface);
    animation: sheet-in .3s var(--ease) both;
  }

  .filter-panel[open] > summary {
    position: relative;
    min-height: 58px;
    padding: 18px 20px 10px;
    border: 0;
    border-radius: 22px 22px 0 0;
    box-shadow: none;
    font-size: 1.05rem;
  }

  .filter-panel[open] > summary::before {
    content: "";
    position: absolute;
    top: 7px;
    left: 50%;
    width: 38px;
    height: 4px;
    border-radius: 2px;
    background: var(--line-strong);
    transform: translateX(-50%);
  }

  .filter-panel[open] > summary::after {
    content: "Done";
    margin-left: auto;
    color: var(--accent-text);
    font-size: .9rem;
    font-weight: 600;
  }

  .filter-panel[open] > .filter-body {
    flex: 0 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    max-height: calc(86vh - 140px);
    max-height: calc(86dvh - 140px);
    padding: 0 20px 12px;
  }

  .filter-panel[open] > .filter-footer {
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 20px -12px rgba(0, 0, 0, .45);
  }

  .filter-footer .signal-button {
    display: inline-flex;
    flex: 1 1 auto;
    max-width: 260px;
    min-height: 46px;
  }

  body:has(.filter-panel[open]) {
    overflow: hidden;
  }

  .results-topline {
    margin-top: 12px;
  }

  #quick-filters {
    display: grid;
  }
}

@media (max-width: 640px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) 92px;
    align-items: start;
    gap: 6px 14px;
    padding: 20px 0 10px;
  }

  .hero-copy {
    display: contents;
  }

  .hero-badge {
    grid-column: 1 / -1;
    justify-self: start;
    margin-bottom: 4px;
    font-size: .64rem;
  }

  .hero h1 {
    grid-column: 1;
    align-self: center;
    font-size: 2rem;
  }

  .virtue-card {
    grid-column: 2;
    grid-row: 2;
    padding: 0;
  }

  .hero-virtue {
    width: 92px;
  }

  .virtue-caption {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .hero-dek {
    grid-column: 1 / -1;
    margin: 6px 0 10px;
    font-size: .93rem;
  }

  .hero-stats {
    grid-column: 1 / -1;
    gap: 6px;
  }

  .hero-stats > div {
    padding: 5px 11px;
    box-shadow: none;
  }

  .hero-stats strong {
    font-size: .92rem;
  }

  .hero-stats span {
    font-size: .76rem;
  }

  .filter-panel > summary .summary-label {
    gap: 0;
    font-size: 0;
  }

  .filter-panel[open] > summary .summary-label {
    gap: 9px;
    font-size: 1.05rem;
  }

  .filter-panel:not([open]) > summary {
    width: 50px;
    justify-content: center;
    padding: 0;
  }

  .filter-panel:not([open]) .filter-count {
    position: absolute;
    top: 2px;
    right: -4px;
    min-width: 20px;
    padding: 2px 6px;
    font-size: 0;
  }

  .filter-panel:not([open]) .filter-count::after {
    content: attr(data-count);
    font-size: .68rem;
  }

  .filter-panel > summary {
    position: relative;
  }

  .view-tabs {
    width: 100%;
  }

  .view-tabs button {
    flex: 1 1 0;
    padding-inline: 8px;
  }

  .results-topline h3 {
    font-size: .95rem;
  }

  .select-compact {
    display: none;
  }

  .story-grid {
    gap: 12px;
  }

  .story-card {
    gap: 9px;
    padding: 16px;
    border-radius: 18px;
    contain-intrinsic-size: auto 380px;
  }

  .story-card h4 {
    font-size: 1.1rem;
  }

  .story-summary {
    -webkit-line-clamp: 3;
    line-clamp: 3;
  }

  .meta-chip {
    padding: 3px 8px;
    font-size: .78rem;
  }

  .card-actions {
    gap: 8px;
  }

  .source-links {
    flex: 1 1 100%;
  }

  .source-links a[data-primary="true"] {
    flex: 1 1 auto;
    justify-content: center;
    min-height: 42px;
  }

  .rating-row button {
    width: 34px;
    height: 38px;
  }

  dialog {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    margin: auto 0 0;
    padding: 20px 18px calc(22px + env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: 22px 22px 0 0;
  }

  dialog[open] {
    animation: sheet-in .3s var(--ease) both;
  }

  .preference-tag-grid {
    grid-template-columns: 1fr 1fr;
  }

  .pagination {
    justify-content: space-between;
  }

  .site-footer {
    font-size: .82rem;
  }
}

@media (pointer: coarse) {
  .filter-value {
    padding: 8px 12px;
  }

  .tag-disclosure > summary,
  .correction-button,
  .story-select {
    min-height: 38px;
  }
}

/* ---------------------------------------------------------------- motion
   Only transform and opacity animate, so nothing here forces layout. Cards
   fade in once per render; Virtue and the badge dot loop slowly. */

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(.9); }
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
}

@keyframes sheet-in {
  from { transform: translateY(40px); opacity: 0; }
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
}

@keyframes float {
  from { transform: translateY(0) rotate(-.6deg); }
  to { transform: translateY(-10px) rotate(.6deg); }
}

@keyframes halo {
  from { transform: scale(.94); opacity: .8; }
  to { transform: scale(1.06); opacity: 1; }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 75, 88, .55); }
  70%, 100% { box-shadow: 0 0 0 8px rgba(255, 75, 88, 0); }
}

@keyframes shimmer {
  to { background-position: -150% 0, 0 0; }
}

@keyframes blink {
  50% { opacity: .3; }
}

@keyframes star-pop {
  40% { transform: scale(1.35); }
}

@keyframes spotlight {
  0% { box-shadow: 0 0 0 0 var(--accent), var(--shadow); }
  100% { box-shadow: 0 0 0 14px transparent, var(--shadow); }
}

@media (prefers-reduced-motion: no-preference) {
  .story-card {
    animation: card-in .38s var(--ease) both;
  }

  .story-card:nth-child(2) { animation-delay: .03s; }
  .story-card:nth-child(3) { animation-delay: .06s; }
  .story-card:nth-child(4) { animation-delay: .09s; }
  .story-card:nth-child(5) { animation-delay: .12s; }
  .story-card:nth-child(6) { animation-delay: .15s; }
  .story-card:nth-child(n + 7) { animation-delay: .18s; }

  .hero-virtue {
    animation: float 4.2s ease-in-out infinite alternate;
  }

  .virtue-card::before {
    animation: halo 4.2s ease-in-out infinite alternate;
  }

  .badge-dot {
    animation: pulse 2.4s ease-out infinite;
  }

  .story-grid[aria-busy="true"]:empty::before,
  .story-grid[aria-busy="true"]:empty::after {
    animation: shimmer 1.4s linear infinite;
  }

  .hero-copy > * {
    animation: fade-up .5s var(--ease) both;
  }

  .hero-copy > :nth-child(2) { animation-delay: .05s; }
  .hero-copy > :nth-child(3) { animation-delay: .1s; }
  .hero-copy > :nth-child(4) { animation-delay: .15s; }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
