/* =============================================================================================
   Settings (settings.html, 2026-11-19). The account's own page, so it wears the dashboard's
   "seal and wine": the brand mark's gold and wine on warm parchment, every value already solved
   for contrast in dashboard.css and copied here rather than re-invented. Flat like the rest of the
   site: square corners, no shadows; separation by a rule or a fill step.
   Full-bleed pattern: the same tokens on body:has(.settings-main) and .settings-main.
   The Settings pop-up (settings-popup.js, 2026-11-29) holds the same content in a
   .settings-pop-body instead: same tokens, but NOT body:has(), which would repaint whatever page
   the pop-up opened on. Its card is light in both themes, like the game menus, so light-dark()
   resolves to the light values there.
   ============================================================================================= */
body:has(.settings-main),
.settings-main,
.settings-pop-body {
    --bg-page: #f4efe4;
    --bg-page: light-dark(#f4efe4, #141017);
    --surface: #fffdf8;
    --surface: light-dark(#fffdf8, #1f1821);
    --sunk: #efe7d6;
    --sunk: light-dark(#efe7d6, #191319);
    --rule: #e3dac6;
    --rule: light-dark(#e3dac6, #3a2a34);
    --ink: #2a1b22;
    --ink: light-dark(#2a1b22, #f2e9dd);
    --ink-soft: #5d4a53;
    --ink-soft: light-dark(#5d4a53, #c3b3ac);
    --accent: #88682f;                       /* gold as TEXT: 4.50 / 5.08 (dashboard.css) */
    --accent: light-dark(#88682f, #e8bd6d);
    --wine: #4a2c3a;
    --wine: light-dark(#4a2c3a, #6b3f53);
    --on-wine: #fbf3e6;
    --gold: #e8bd6d;                         /* gold as a FILL, ink on it is --brand-ink */
    --warn: #a53a4e;
    --warn: light-dark(#a53a4e, #f0a0b0);
}
body:has(.settings-main) { background: var(--bg-page); }

.settings-main {
    max-width: 960px;
    margin: 0 auto;
    padding: 96px 20px 64px;
    color: var(--ink);
}
.set-title { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-title); margin: 0 0 18px; line-height: 1.2; }

/* ---- the tabs: full trapezoids like the masthead's, the slant computed from the height so the
   corners always land on it (the masthead learned this the hard way, 2026-11-19) ---- */
@property --sth { syntax: "<length>"; inherits: false; initial-value: 40px; }
.set-tabs { display: flex; gap: 2px; padding: 0 14px; box-shadow: inset 0 -4px 0 var(--wine); overflow-x: auto; scrollbar-width: none; }
.set-tab {
    --sth: 40px;
    --slant: calc(var(--sth) * 0.32492);
    position: relative;
    isolation: isolate;
    z-index: var(--i, 1);
    flex: none;
    align-self: flex-end;
    height: var(--sth);
    margin-bottom: 0;
    padding: 0 22px 0 12px;
    border: 0;
    background: var(--surface);
    color: var(--ink);
    font: 600 var(--fs-14) var(--font-body);
    white-space: nowrap;
    cursor: pointer;
    box-shadow: inset 0 1px 0 var(--rule);
    transition: --sth 0.18s var(--ease-out, ease);
}
.set-tab::before, .set-tab::after { content: ""; position: absolute; z-index: -1; top: 0; bottom: 0; width: calc(var(--slant) * 2); background: inherit; transform-origin: bottom; }
.set-tab::before { right: calc(var(--slant) * -1); transform: skewX(18deg); box-shadow: inset -1px 0 0 var(--rule), inset 0 1px 0 var(--rule); }
.set-tab::after { left: calc(var(--slant) * -1); transform: skewX(-18deg); box-shadow: inset 1px 0 0 var(--rule), inset 0 1px 0 var(--rule); }
.set-tab:hover { --sth: 44px; }
.set-tab[aria-selected="true"] { --sth: 48px; z-index: 9; background: var(--wine); color: var(--on-wine); box-shadow: none; }
.set-tab[aria-selected="true"]::before, .set-tab[aria-selected="true"]::after { box-shadow: none; }
.set-tab:focus-visible { outline: 2px solid var(--gold); outline-offset: -5px; }

/* ---- panels and rows ---- */
.set-panel { background: var(--surface); padding: 6px 24px 18px; box-shadow: inset 0 0 0 1px var(--rule); animation: khanjpFadeIn var(--dur-2, 0.22s) ease both; }
.set-panel:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.set-panel[hidden] { display: none; }
.set-h { margin: 22px 0 2px; font: 700 var(--fs-12) var(--font-body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.set-danger-h { color: var(--warn); }
.set-row { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--rule); }
.set-row:last-child { border-bottom: 0; }
.set-text { flex: 1 1 300px; min-width: 0; }
.set-label { margin: 0; font: 600 var(--fs-16) var(--font-body); color: var(--ink); }
.set-label label { cursor: pointer; }
.set-text p, .set-danger p { margin: 3px 0 0; color: var(--ink-soft); font-size: var(--fs-14); line-height: 1.5; max-width: 60ch; }
.set-strong { color: var(--ink) !important; font-weight: 600; }
.set-status { color: var(--ink) !important; font-weight: 600; min-height: 0; }
.set-status:empty { display: none; }
.set-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.set-pic { display: flex; gap: 16px; align-items: center; }

/* ---- controls ---- */
.set-seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--sunk); box-shadow: inset 0 0 0 1px var(--rule); }
.set-seg button { min-height: 40px; padding: 0 13px; border: 0; background: none; color: var(--ink-soft); font: 600 var(--fs-14) var(--font-body); cursor: pointer; }
.set-seg button:hover { color: var(--ink); }
.set-seg button[aria-pressed="true"] { background: var(--wine); color: var(--on-wine); }
.set-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* the volume sliders: a flat track filled in wine up to the value, a square thumb in gold */
.set-vol { display: inline-flex; align-items: center; gap: 10px; }
.set-vol output { min-width: 3.2em; text-align: right; font: 700 var(--fs-14) var(--font-body); font-variant-numeric: tabular-nums; color: var(--ink); }
.set-vol input[type="range"] {
    --pct: 100%;
    -webkit-appearance: none;
    appearance: none;
    width: 220px;
    max-width: 52vw;
    height: 28px;
    margin: 0;
    background: transparent;
    cursor: pointer;
}
.set-vol input[type="range"]::-webkit-slider-runnable-track {
    height: 8px;
    background: linear-gradient(to right, var(--wine) var(--pct), var(--sunk) var(--pct));
    box-shadow: inset 0 0 0 1px var(--rule);
}
.set-vol input[type="range"]::-moz-range-track { height: 8px; background: var(--sunk); box-shadow: inset 0 0 0 1px var(--rule); }
.set-vol input[type="range"]::-moz-range-progress { height: 8px; background: var(--wine); }
.set-vol input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 22px;
    margin-top: -7px;
    border: 0;
    background: var(--gold);
    box-shadow: inset 0 0 0 2px var(--wine);
}
.set-vol input[type="range"]::-moz-range-thumb { width: 18px; height: 22px; border: 0; border-radius: 0; background: var(--gold); box-shadow: inset 0 0 0 2px var(--wine); }
.set-vol input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.set-mix { display: grid; grid-template-columns: auto auto; gap: 6px 12px; align-items: center; justify-items: start; }
.set-mix > span:not(.set-seg) { font: 700 var(--fs-12) var(--font-body); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.set-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 16px; border: 0; background: var(--gold); color: var(--brand-ink, #4a2c3a); font: 600 var(--fs-14) var(--font-body); cursor: pointer; }
.set-btn:hover { background: #f0cd87; }
.set-btn:disabled { opacity: 0.55; cursor: default; }
.set-quiet { background: none; color: var(--ink); box-shadow: inset 0 0 0 1px var(--rule); }
.set-quiet:hover { background: var(--sunk); }
.set-quiet[aria-pressed="true"] { background: var(--wine); color: var(--on-wine); box-shadow: none; }
/* --warn is a deep red by day and a pale pink at night, so the label flips with it */
.set-del { background: var(--warn); color: #fff; color: light-dark(#fff, #2a1b22); }
.set-del:hover { background: var(--warn); filter: brightness(1.08); }
.set-btn:focus-visible, .set-in:focus-visible, .set-sel:focus-visible, .set-quiet:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label.set-btn:has(+ input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.set-in, .set-sel { min-height: 42px; padding: 0 12px; border: 0; background: var(--sunk); color: var(--ink); box-shadow: inset 0 0 0 1px var(--rule); font: inherit; font-size: var(--fs-14); }
.set-in { width: 220px; max-width: 100%; }
.set-sel { max-width: 280px; font-weight: 600; }
.set-code { width: 120px; letter-spacing: 0.2em; font-variant-numeric: tabular-nums; }
.set-dev { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.set-chip { display: inline-flex; align-items: center; min-height: 30px; padding: 0 10px; font: 700 var(--fs-12) var(--font-body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); box-shadow: inset 0 0 0 1px var(--rule); }
.set-chip.is-on { color: var(--on-wine); background: var(--wine); box-shadow: none; }
.set-meter { width: 240px; max-width: 100%; height: 8px; margin-top: 10px; background: var(--sunk); box-shadow: inset 0 0 0 1px var(--rule); }
.set-meter i { display: block; width: 0; height: 100%; background: var(--wine); transition: width 0.08s linear; }
.set-limit { margin: 14px 0 0; padding: 11px 14px; background: var(--sunk); box-shadow: inset 3px 0 0 var(--gold); color: var(--ink-soft); font-size: var(--fs-14); line-height: 1.5; }
.set-sample { font-size: var(--fs-21) !important; color: var(--ink) !important; margin-top: 12px !important; }
.set-sample rt { font-size: 0.5em; color: var(--ink-soft); }
.set-ava { flex: none; width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: var(--gold) center / cover no-repeat; color: var(--brand-ink, #4a2c3a); font: 600 var(--fs-26)/1 var(--font-display); }
.set-mfa-setup { margin-top: 12px; display: grid; gap: 10px; justify-items: start; }
.set-mfa-setup[hidden] { display: none; }
.set-mfa-setup img { background: #fff; padding: 8px; }
.set-key code { font-size: var(--fs-14); word-break: break-all; color: var(--ink); }
.set-signedout { padding: 22px 0; display: grid; gap: 12px; justify-items: start; }
/* a display rule outranks the hidden attribute, so each half answers [hidden] itself */
.set-signedout[hidden], #set-signedin[hidden] { display: none; }
.set-signedout p { margin: 0; color: var(--ink-soft); }
.set-danger { padding: 4px 0 6px; display: grid; gap: 10px; justify-items: start; }
.set-danger.hidden { display: none; }
.set-confirm { display: grid; gap: 8px; justify-items: start; }
.set-sep { width: 100%; border: 0; border-top: 1px solid var(--rule); margin: 6px 0; }

@media (max-width: 860px) {
    .settings-main { padding: 76px 16px calc(40px + var(--tabbar-h, 0px)); }
    .set-panel { padding: 4px 16px 14px; }
    .set-dev { align-items: flex-start; }
    .set-tabs { padding: 0 10px; }
    .set-tab { font-size: var(--fs-14); padding: 0 16px 0 10px; }
}

/* In the pop-up: the card supplies the padding, the heading is the dialog's title. */
.settings-pop-body { color: var(--ink); }
.settings-pop-body .set-title { font-size: var(--fs-26); margin: 0 44px 14px 0; }
/* style.css's `.modal-card h3` (26px, 20px under) outranks .set-label, which is an h3 in the
   audio and account rows; this puts the row headings back to their own size. */
.settings-pop-body h3.set-label { margin: 0; font: 600 var(--fs-16) var(--font-body); color: var(--ink); }
@media (max-width: 860px) {
    .settings-pop-body .set-panel { padding: 4px 12px 14px; }
}

/* 320px: the slider gives way, so its percentage stays on the screen. */
@media (max-width: 400px) {
    .set-vol input[type="range"] { width: 34vw; }
    .set-vol { gap: 6px; }
}
