.preferences-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 6px 10px; flex: none;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--fg); font: inherit; cursor: pointer;
}
.preferences-btn svg { width: 17px; height: 17px; }
.preferences-btn:hover { background: var(--raise); }
.preferences-panel {
  position: fixed; inset: auto; top: var(--prefs-top, 60px); left: var(--prefs-left, 12px);
  margin: 0; width: min(350px, calc(100% - 24px)); max-height: calc(100dvh - var(--prefs-top, 60px) - 12px);
  overflow: auto; padding: 18px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--fg); box-shadow: 0 8px 28px var(--shadow);
}
.preferences-panel::backdrop { background: transparent; }
.preferences-panel h2 { margin: 0 0 14px; font: 600 17px/1.5 var(--font-body); }
.pref-snow { display: flex; align-items: center; justify-content: space-between; min-height: 44px; cursor: pointer; }
.pref-snow input { width: 18px; height: 18px; accent-color: var(--accent); }
.pref-snow:has(input:disabled) { color: var(--muted); cursor: default; }
.pref-snow:has(input:disabled) span { text-decoration: line-through; }
.snow-hint { margin: 0; color: var(--muted); font-size: 13px; }
.less-motion, :root[data-fest="on"] .off-season { display: none; }
@media (prefers-reduced-motion: reduce) {
  :root[data-fest="on"] .less-motion { display: inline; }
}
.pref-details { margin-top: 16px; border-block: 1px solid var(--line); }
.pref-details summary {
  display: flex; align-items: center; gap: 8px; min-height: 48px;
  list-style: none; cursor: pointer; touch-action: manipulation;
}
.pref-details summary::-webkit-details-marker { display: none; }
.pref-details summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.pref-details #content-status { margin-inline-start: auto; color: var(--muted); font-size: 13px; }
.pref-details summary svg { width: 12px; height: 12px; flex: none; color: var(--muted); }
.pref-details[open] summary svg { transform: rotate(90deg); }
.pref-content { min-inline-size: 0; margin: 0; padding: 0 0 12px; border: 0; }
.pref-content legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pref-switches { border: 1px solid var(--line); border-radius: 10px; }
.pref-switch {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px; padding: 6px 12px;
  font-size: 14px; font-weight: 600; cursor: pointer; touch-action: manipulation;
}
.pref-switch:first-child { border-radius: 9px; }
.pref-switches:has(#nsfl-row:not([hidden])) > .pref-switch { border-radius: 9px 9px 0 0; }
#nsfl-row { border-top: 1px solid var(--line); }
#nsfl-row .pref-switch { border-radius: 0 0 9px 9px; }
.nsfl-context { padding: 0 12px 8px; color: var(--fg); font-size: 14px; line-height: 1.5; }
.nsfl-context p { margin: 0; font-weight: 600; }
.nsfl-context a { display: inline-block; padding: 4px 0; color: inherit; text-decoration: none; }
.nsfl-context a > span { text-decoration: underline; text-underline-offset: .18em; }
.nsfl-context a svg { width: 12px; height: 12px; margin-inline-start: 4px; vertical-align: -.05em; }
.pref-switch:has(input:disabled) { color: var(--muted); cursor: default; }
@media (hover: hover) {
  .pref-switch:has(input:enabled):hover { background: var(--accent-soft); }
}
.pref-switch input {
  appearance: none; flex: none; display: grid; align-items: center;
  width: 38px; height: 22px; margin: 0; padding: 2px; border: 1px solid var(--scroll-thumb); border-radius: 20px;
  background: var(--raise); color: var(--scroll-thumb); cursor: pointer;
}
.pref-switch input::before {
  content: ""; width: 16px; height: 16px; border-radius: 50%; background: currentColor;
}
.pref-switch input:disabled { opacity: .5; cursor: default; }
.pref-switch input:checked { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pref-switch input:checked::before { transform: translateX(16px); }
.pref-switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (prefers-reduced-motion: no-preference) {
  .pref-switch input::before { transition: transform 120ms ease-out; }
}
@media (forced-colors: active) {
  .pref-switch input { appearance: auto; width: 22px; height: 22px; }
  .pref-switch input:disabled { opacity: 1; }
  .pref-switch input::before { content: none; }
}
.content-hint { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.pref-actions { display: flex; justify-content: end; margin-top: 15px; }

/* CSS uses preferences restored before first paint; hidden items never flash during filtering. */
:root:not([data-nsfl="on"]) :is(.card, .games li)[data-nsfl="1"] { display: none; }
:root:not([data-nsfw="on"]) :is(.count-adult, .count-nsfl),
:root[data-nsfw="on"] .count-general,
:root:not([data-nsfl="on"]) .count-nsfl,
:root[data-nsfl="on"] .count-adult { display: none; }
