.appearance-console > [data-admin="menu"] {
  justify-self: start;
  padding-inline: 14px;
}

.appearance-console > [data-admin="exit"] {
  justify-self: start;
  width: auto;
}

.theme-options {
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.theme-options legend {
  margin-block-end: 8px;
  font-weight: 850;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.theme-choice {
  display: grid;
  grid-template: "preview preview" auto "radio name" auto "description description" 1fr / auto minmax(0, 1fr);
  gap: 5px 7px;
  align-items: center;
  padding: 7px 7px 10px;
  cursor: pointer;
  color: var(--theme-text, var(--ink));
  background: var(--theme-card, white);
  border: 2px solid var(--theme-line, #86969b);
  border-radius: var(--theme-radius, 12px);
}

.theme-choice:hover, .theme-choice:has(:checked) {
  border-color: var(--theme-link, #174e65);
}

.theme-choice:has(:checked) {
  box-shadow: inset 0 0 0 1px var(--theme-link, #174e65);
}

.theme-choice:has(:focus-visible) {
  outline: 3px solid var(--theme-link, #174e65);
  outline-offset: 3px;
}

.theme-choice input {
  grid-area: radio;
  width: 16px;
  height: 16px;
  margin: 0 0 0 2px;
  accent-color: var(--theme-radio, #176781);
  cursor: inherit;
}

.theme-name {
  grid-area: name;
  font: 700 1rem/1.15 var(--display);
}

.theme-description {
  grid-area: description;
  align-self: start;
  padding-inline: 2px;
  font-size: .79rem;
  line-height: 1.25;
}

.theme-swatch {
  grid-area: preview;
  display: grid;
  place-items: center;
  height: 88px;
  margin-block-end: 4px;
  overflow: hidden;
  background: var(--theme-backdrop);
  border-radius: max(2px, calc(var(--theme-radius) - 4px));
}

.theme-swatch-window {
  display: grid;
  grid-template-columns: 1fr 30%;
  align-content: start;
  align-items: center;
  gap: 5px;
  width: min(80%, 126px);
  padding: 9px;
  color: var(--theme-text);
  background: var(--theme-card);
  border: var(--theme-edge);
  border-radius: max(2px, calc(var(--theme-radius) * .55));
  box-shadow: var(--theme-shadow);
}

.theme-swatch i {
  display: block;
  height: 4px;
  background: currentColor;
  border-radius: calc(var(--theme-radius) * .3);
}

.theme-swatch i:nth-child(1) { width: 75%; }
.theme-swatch i:nth-child(2) { background: var(--theme-bar); height: 8px; }
.theme-swatch i:nth-child(3) { grid-column: 1 / -1; width: 48%; opacity: .48; }
.theme-swatch i:nth-child(4) {
  grid-column: 1 / -1;
  width: 65%;
  height: 12px;
  background: var(--theme-action);
  border: var(--theme-edge);
}

@media (min-width: 580px) {
  .theme-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .theme-swatch { height: 106px; }
}

@media (min-width: 760px) {
  .theme-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

[data-theme-preview="original"] {
  --theme-backdrop: #e5f1ef radial-gradient(#a7c3bb 1px, transparent 1px) 0 0 / 8px 8px;
  --theme-card: #fffdf7;
  --theme-bar: #20a4c8;
  --theme-action: #ffd43b;
  --theme-text: #1b2330;
  --theme-edge: 2px solid #1b2330;
  --theme-radius: 12px;
  --theme-shadow: 3px 3px 0 #1b2330;
}

@media screen {
  :is(:root[data-ui-theme="hq-noir"], [data-theme-preview="hq-noir"]) {
    --theme-grain: radial-gradient(ellipse at 34% 26%, #ffffff0b .3px, transparent .85px) 0 0 / 3px 4px,
      radial-gradient(ellipse at 67% 71%, #00000017 .45px, transparent .9px) 1px 2px / 5px 7px,
      repeating-linear-gradient(115deg, #ffffff04 0 .45px, transparent 1px 4px);
    --theme-backdrop: var(--theme-grain),
      radial-gradient(ellipse at 68% 0%, #33353a, transparent 62%),
      linear-gradient(155deg, #151618, #080809 74%);
    --theme-card: linear-gradient(150deg, #28292de8, #151619f5 76%);
    --theme-wash: #242529;
    --theme-note: linear-gradient(138deg, #303138e8, #1a1b1ff5);
    --theme-bar: linear-gradient(160deg, #303136e8, #131417df 74%);
    --theme-action: linear-gradient(177deg, #f8f8fb 0%, #e8e9ed 42%, #c3c6cd 48%, #e2e4e9 100%);
    --theme-action-text: #111215;
    --theme-text: #f5f5f7;
    --theme-muted: #bfc1c8;
    --theme-link: #eef0f5;
    --theme-radio: #d3d5db;
    --theme-line: #888b94;
    --theme-edge: 1px solid #6a6d75;
    --theme-radius: 12px;
    --theme-shadow: inset 0 1px 0 #ffffff25, 0 4px 14px #0005;
    --theme-inset: inset 0 1px 3px #0006;
    --theme-type: "Segoe UI", Arial, sans-serif;
    --theme-accent: #e4e6eb;
    --theme-input: #141518;
  }

  :is(:root[data-ui-theme="glassy"], [data-theme-preview="glassy"]) {
    --theme-backdrop: radial-gradient(ellipse at 9% 0%, #aaf2ec, transparent 56%),
      radial-gradient(ellipse at 92% 10%, #dccbff, transparent 52%), linear-gradient(150deg, #f8fcff, #acbdf6);
    --theme-card: linear-gradient(145deg, #ffffffec, #edf0ffe8);
    --theme-wash: #e6ecfa;
    --theme-note: #f0ecfc;
    --theme-bar: linear-gradient(125deg, #caf6eeeb, #e1d6fff5);
    --theme-action: linear-gradient(135deg, #47459b, #5b3e8b);
    --theme-action-text: #fff;
    --theme-text: #242447;
    --theme-muted: #454967;
    --theme-link: #493888;
    --theme-line: #8892b9;
    --theme-edge: 1px solid #979fc9;
    --theme-radius: 19px;
    --theme-shadow: inset 0 1px 0 #ffffffc9, 0 7px 18px #3d428324;
    --theme-inset: 0 2px 6px #3d428329;
    --theme-type: Nunito, "Segoe UI", sans-serif;
    --theme-accent: #d7cdff;
    --theme-input: #fbfbff;
  }

  :is(:root[data-ui-theme="relief"], [data-theme-preview="relief"]) {
    --theme-backdrop: radial-gradient(ellipse at 50% 0%, #e1e9fa, transparent 78%), #bac7df;
    --theme-card: linear-gradient(#f7f9ff, #e2e8f4);
    --theme-wash: #d9e6fa;
    --theme-note: #e8eefa;
    --theme-bar: linear-gradient(#acbde2, #cdd9f0);
    --theme-action: linear-gradient(#fff0cc, #ffcc78);
    --theme-action-text: #3a270e;
    --theme-text: #202c46;
    --theme-muted: #42526b;
    --theme-link: #304777;
    --theme-line: #7486a9;
    --theme-edge: 1px solid #899bb9;
    --theme-radius: 15px;
    --theme-shadow: inset 0 2px 0 #fffc, 0 4px 0 #7486ab, 0 8px 13px #344b6d30;
    --theme-inset: inset 0 2px 4px #7486ab46, 0 1px 0 #fff;
    --theme-type: Nunito, "Segoe UI", sans-serif;
    --theme-accent: #ffdd9c;
    --theme-input: #f8faff;
  }

  :is(:root[data-ui-theme="cartoon"], [data-theme-preview="cartoon"]) {
    --theme-backdrop: #ffe9f0 radial-gradient(#eaa1bb 1.25px, transparent 1.25px) 0 0 / 10px 10px;
    --theme-card: #fffdf0;
    --theme-wash: #d5f7df;
    --theme-note: #ffe3ed;
    --theme-bar: #ff9aab;
    --theme-action: #ffe050;
    --theme-action-text: #392247;
    --theme-text: #392247;
    --theme-muted: #5c4169;
    --theme-link: #772b6a;
    --theme-line: #75446c;
    --theme-edge: 2.5px solid #392247;
    --theme-radius: 21px;
    --theme-shadow: 4px 4px 0 #392247;
    --theme-inset: 1px 1px 0 #392247;
    --theme-type: Fredoka, "Arial Rounded MT Bold", sans-serif;
    --theme-accent: #ffe050;
    --theme-input: #fffdf7;
  }

  :is(:root[data-ui-theme="terminal"], [data-theme-preview="terminal"]) {
    --theme-backdrop: repeating-linear-gradient(0deg, #09231f 0 2px, #0d2923 2px 4px);
    --theme-card: #14332c;
    --theme-wash: #1b3d34;
    --theme-note: #102b25;
    --theme-bar: #193d35;
    --theme-action: #c1fb88;
    --theme-action-text: #142a10;
    --theme-text: #e1f6e8;
    --theme-muted: #b7d4c6;
    --theme-link: #d1ff9d;
    --theme-radio: #177254;
    --theme-line: #669f86;
    --theme-edge: 1px solid #669f86;
    --theme-radius: 4px;
    --theme-shadow: 0 0 12px #80f5b41a;
    --theme-inset: inset 0 0 10px #0005;
    --theme-type: "JetBrains Mono", Consolas, monospace;
    --theme-accent: #c1fb88;
    --theme-input: #102b25;
  }

  :is(:root[data-ui-theme="archive"], [data-theme-preview="archive"]) {
    --theme-backdrop: repeating-linear-gradient(0deg, transparent 0 26px, #8b56371a 26px 27px), #ead9bc;
    --theme-card: #fff9eb;
    --theme-wash: #f3e5cd;
    --theme-note: #f6e8d0;
    --theme-bar: #ead4ae;
    --theme-action: #722f3f;
    --theme-action-text: #fff9eb;
    --theme-text: #372b27;
    --theme-muted: #654e48;
    --theme-link: #722f3f;
    --theme-line: #a6907c;
    --theme-edge: 1px solid #a6907c;
    --theme-radius: 4px;
    --theme-shadow: 1px 2px 0 #ddc9ae, 0 4px 10px #58403525;
    --theme-inset: inset 0 1px 4px #58403520;
    --theme-type: Georgia, "Times New Roman", serif;
    --theme-accent: #efd1ab;
    --theme-input: #fffbf2;
  }

  :root[data-ui-theme]:not([data-ui-theme="original"]) {
    --display: var(--theme-type);
    --game-paper: var(--theme-card);
    --paper: var(--theme-input);
    --edge: var(--theme-edge);
    --shadow: var(--theme-shadow);
    --yellow: var(--theme-accent);
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) body {
    color: var(--theme-text);
    background: var(--theme-backdrop);
    background-attachment: fixed;
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) :is(.shell, .console, .kit) {
    background: var(--theme-card);
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) :is(.aside, .dashcard, .bar, .nav, .item, .mark, .tag, .onboarding-credits span, .ch-dialog, .qcard) {
    color: var(--theme-text);
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) :is(.bar, .nav) {
    background: var(--theme-bar);
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) :is(.k, .aside .k, .eyebrow, .kicker, .foot, .hint, .muted, .item small, .ch-status, .stats-source) {
    color: var(--theme-muted);
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) :is(a, .admin-credit, .back, .linkbtn, .stats-details summary, .rank-empty .icon) {
    color: var(--theme-link);
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) :focus-visible {
    outline: 3px solid var(--theme-link);
    outline-offset: 3px;
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) :is(.panel, .mission-rule, .grid .person, .item, .secondary, .option, .ch-head .ch-exit, .ch-card, .stats-kpi, .stats-panel, .stats-action, .qcard) {
    color: var(--theme-text);
    background: var(--theme-card);
    border: var(--edge);
    border-radius: var(--theme-radius);
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) :is(.ticket, .sheet, .paper, .aside .standcard, .kraft-question, .wheel-clues, .ch-area .paper, .candidate-grid) {
    color: var(--theme-text);
    background: var(--theme-note);
    border: var(--edge);
    border-radius: var(--theme-radius);
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) :is(.standcard, .qcard) .qr {
    background: white;
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) :is(.family, .intel, .sus-guide, .rank-empty, .game-update, .message, .bubble, .ch-dialog .ch-help, .chat-composer .ch-chips button) {
    color: var(--theme-text);
    background: var(--theme-wash);
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) :is(.item .mark, .tag, .unknown) {
    color: var(--theme-text);
    background: var(--theme-wash);
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) .btn {
    color: var(--theme-action-text);
    background: var(--theme-action);
    border: var(--edge);
    border-radius: var(--theme-radius);
    box-shadow: var(--shadow);
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) .btn.accept { background: #8ae5a4; color: #172e26; }
  html[data-ui-theme]:not([data-ui-theme="original"]) .btn.accuse-action { background: #aa2e43; color: white; }
  html[data-ui-theme]:not([data-ui-theme="original"]) :is(.choice, .nav .current, .bar .steps, .bar .score, .locale-options [aria-pressed="true"], .locale-options button:hover, .ch-filters [aria-pressed="true"]) {
    color: #1b2330;
    background: var(--theme-accent);
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) :is(.btn, .secondary, .option):active:not(:disabled) {
    box-shadow: var(--theme-inset);
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) :is(.field, textarea, .locale-picker summary, .locale-options, .on .ctaArea) {
    background: var(--theme-input);
    color: var(--theme-text);
    border-color: var(--theme-line);
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) :is(.field, textarea) {
    box-shadow: var(--theme-inset);
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) :is(.field, textarea)::placeholder {
    color: var(--theme-muted);
    opacity: 1;
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) :is(.ch-dialog, #restartDialog, #installHelp) {
    background: var(--theme-card);
    color: var(--theme-text);
    border-color: var(--theme-line);
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) :is(.statline, .stats-kpi .stats-note, .stats-hour) { color: var(--theme-muted); }
  html[data-ui-theme]:not([data-ui-theme="original"]) .stats-console {
    --stats-wash: var(--theme-wash);
    --stats-muted: var(--theme-muted);
    --stats-accent: var(--theme-link);
    --stats-line: var(--theme-line);
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) .stats-kpis .stats-kpi-accent,
  html[data-ui-theme]:not([data-ui-theme="original"]) :is(.chan, .flag, .hq-banner, .ch-banner, .ch-badge, .rank-medal, .map-key i, .legend b, .evidence span, .chat-bubble, .radio-dial, .code-slot, .code-row, .scratch-card, .uv-dossier, .polaroid) {
    color: #1b2330;
  }

  html[data-ui-theme]:not([data-ui-theme="original"]) .map-key .map-key-done { color: white; }
  html[data-ui-theme]:not([data-ui-theme="original"]) .items :is(.item.harvested, .clue-validated) .mark { color: #14613d; background: #e3f8e7; }
  html[data-ui-theme]:not([data-ui-theme="original"]) .evidence .evidence-check { color: #14613d; }

  html[data-ui-theme="glassy"] :is(.bar, .nav) {
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }

  html:root[data-ui-theme="hq-noir"] {
    color-scheme: dark;
    --wordmark-dot: #c3c6cd;
  }

  html:root[data-ui-theme="hq-noir"] body {
    font-family: var(--theme-type);
    font-weight: 400;
  }

  html:root[data-ui-theme="hq-noir"] :is(.shell, .console) {
    background: var(--theme-grain), var(--theme-card);
  }

  html:root[data-ui-theme="hq-noir"] :is(.bar, .nav, .ch-dialog) {
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
  }

  html:root[data-ui-theme="hq-noir"] :is(.operation-name, .theme-name, h1, h2) {
    letter-spacing: -.025em;
  }

  html:root[data-ui-theme="hq-noir"] .aside h2 {
    font-weight: 650;
  }

  html:root[data-ui-theme="hq-noir"] .aside .rule {
    height: 1px;
    background: linear-gradient(90deg, #f5f5f7, #777a83);
  }

  html:root[data-ui-theme="hq-noir"] :is(.btn.accept, .nav .scan) {
    background: var(--theme-action);
    color: var(--theme-action-text);
  }

  html:root[data-ui-theme="hq-noir"] :is(.btn.accuse-action, .case-stamp) {
    background: var(--theme-wash);
    color: var(--theme-text);
    border-color: var(--theme-line);
  }

  html:root[data-ui-theme="hq-noir"] .nav .current:not(.scan) {
    color: var(--theme-text);
    background: var(--theme-wash);
    box-shadow: inset 0 2px 0 var(--theme-link);
  }

  html:root[data-ui-theme="hq-noir"] .bar :is(button.score, small.steps),
  html:root[data-ui-theme="hq-noir"] .hero .stamp {
    color: var(--theme-text);
    background: var(--theme-input);
    box-shadow: inset 0 0 0 1px var(--theme-line);
  }

  html:root[data-ui-theme="hq-noir"] :is(.chan, .flag, .ch-banner, .ch-badge, .progress-dots .found) {
    background: var(--theme-accent);
  }

  html:root[data-ui-theme="hq-noir"] .progress-dots i:not(.found) {
    background: var(--theme-input);
    border-color: var(--theme-line);
  }

  html:root[data-ui-theme="hq-noir"] :is(.items .item.harvested .mark, .items .clue-validated .mark) {
    color: var(--theme-action-text);
    background: var(--theme-accent);
    border-color: var(--theme-line);
  }

  html:root[data-ui-theme="hq-noir"] .steps .ok {
    background: #9c9fa7;
  }

  html:root[data-ui-theme="hq-noir"] .error {
    color: var(--theme-text);
  }

  html[data-ui-theme="terminal"] :is(.operation-name, .theme-name) { letter-spacing: -.025em; }
  html[data-ui-theme="terminal"] :is(.bar, .nav, .stats-details, .item) { border-color: #669f86; }
  html[data-ui-theme="terminal"] progress { accent-color: #c1fb88; }
  html[data-ui-theme="terminal"] .aside .rule { background: #c1fb88; }
  html[data-ui-theme="terminal"] .error { color: #ffc0c0; }

  html[data-ui-theme="archive"] .bar { border-bottom: 3px double #8d6655; }
  html[data-ui-theme="archive"] .nav { border-top: 3px double #8d6655; }
  html[data-ui-theme="archive"] .item .mark { border: 1px solid #b9a186; }
}
