/* HUD Forge — torch-lit stone & gilded frames. Original CSS/SVG artwork only. */
:root {
  --stone-0: #15110d;        /* page */
  --stone-1: #211a13;        /* panels */
  --stone-2: #2c2319;        /* raised */
  --well: #0f0c09;           /* recessed inputs */
  --gold: #e2bf6a;
  --gold-hi: #fff0c0;
  --gold-deep: #a57a2c;
  --bronze: #6e5229;
  --text: #efe3c6;           /* parchment */
  --muted: #c6b593;
  --ember: #f08a66;
  --crimson: #8e2416;
  --tip-bg: rgba(9, 11, 26, .95);
  --tip-border: #9a9aae;

  --bg: var(--stone-0);
  --surface: var(--stone-1);
  --surface-2: var(--stone-2);
  --border: var(--bronze);
  --accent: var(--gold);
  --danger: var(--ember);

  --stage-bg: #0d1017;
  --stage-grid: rgba(226, 191, 106, .055);
  --c-bar: #e8b13e;
  --c-unit: #5fc27e;
  --c-cast: #e0624c;
  --c-cd: #7f9ff0;
  --c-aura: #c08ae0;
  --c-chat: #8fc4bb;
  --c-map: #5fb8e6;
  --c-misc: #b3a78f;
  --c-unknown: #7d7d7d;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --frame: url("../img/frame.svg") 24 / 18px stretch;
  --frame-sm: url("../img/frame.svg") 24 / 13px stretch;
  --glow: 0 0 14px rgba(255, 176, 72, .45);
  --ring: #f2b440;           /* selection and keyboard focus: warm gold, never white */
  --ring-glow: 0 0 16px rgba(255, 170, 60, .6);
  --page: clamp(1240px, 88vw, 1760px);  /* content width incl. gutters: grows on big screens */
  color-scheme: dark;
}
:root:has(main[data-page=editor]) { --page: 2400px; }  /* the editor stage uses the width */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--stone-0); scroll-padding-top: 80px; font-size: 106.25%; }
body {
  margin: 0; color: var(--text); min-height: 100vh; display: flex; flex-direction: column;
  font: 1rem/1.6 var(--serif);
  background:
    radial-gradient(ellipse 70% 45% at 50% -8%, rgba(255, 160, 60, .20), transparent 70%),
    radial-gradient(ellipse 40% 30% at 0% 30%, rgba(255, 130, 40, .07), transparent 70%),
    radial-gradient(ellipse 40% 30% at 100% 30%, rgba(255, 130, 40, .07), transparent 70%),
    url("../img/stone.svg"),
    linear-gradient(180deg, #1b1510 0%, var(--stone-0) 40%, #0f0c09 100%);
  background-color: var(--stone-0);
}
a { color: var(--gold); text-decoration-color: rgba(226, 191, 106, .45); text-underline-offset: 3px; }
a:hover { color: var(--gold-hi); }
::selection { background: rgba(226, 191, 106, .35); color: #fff; }

h1, h2, h3 { font-family: var(--display); font-weight: 600; color: var(--gold); }
h1 {
  font-size: clamp(1.75rem, 4.2vw, 2.9rem); line-height: 1.1; margin: 0 0 .35em; letter-spacing: .01em;
  font-variant: small-caps;
  background: linear-gradient(180deg, var(--gold-hi) 10%, var(--gold) 52%, var(--gold-deep) 92%) 0 0 / 100% 1.1em repeat-y;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #000) drop-shadow(0 0 18px rgba(255, 160, 60, .25));
  overflow-wrap: anywhere; text-wrap: balance;
}
h2 { font-size: 1.25rem; margin: 0 0 .5em; font-variant: small-caps; letter-spacing: .02em; text-shadow: 0 1px 0 #000; }
h3 { font-size: 1.05rem; margin: 1.2em 0 .3em; text-shadow: 0 1px 0 #000; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
  padding: 10px max(16px, calc((100% - var(--page)) / 2 + 16px));
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(180deg, #2a2017 0%, #17120d 100%);
  border-bottom: 2px solid var(--gold-deep);
  box-shadow: 0 1px 0 #000, 0 3px 0 rgba(226, 191, 106, .18), 0 10px 24px rgba(0, 0, 0, .6);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; text-decoration: none;
  font: 600 1.4rem/1 var(--display); font-variant: small-caps; letter-spacing: .04em;
  color: var(--gold); text-shadow: 0 1px 0 #000, 0 0 12px rgba(255, 160, 60, .3);
}
.brand:hover { color: var(--gold-hi); }
.brand-mark { width: 30px; height: 33px; flex: none; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .8)); }
.top nav { display: flex; gap: 6px; }
.top nav a {
  color: var(--muted); text-decoration: none; font-size: 1.05rem; font-variant: small-caps; letter-spacing: .04em;
  padding: 4px 12px; border: 1px solid transparent; border-radius: 3px;
}
.top nav a:hover { color: var(--gold-hi); text-shadow: 0 0 10px rgba(255, 170, 70, .6); }
.top nav a.active {
  color: var(--gold-hi); border-color: rgba(226, 191, 106, .45);
  background: linear-gradient(180deg, rgba(226, 191, 106, .16), rgba(226, 191, 106, .03));
  box-shadow: inset 0 1px 0 rgba(255, 240, 192, .15);
}

main { flex: 1 0 auto; width: 100%; max-width: var(--page); margin: 0 auto; padding: 32px 16px 56px; outline: none; }
.foot {
  width: 100%; max-width: var(--page); margin: 0 auto; padding: 34px 16px 28px; color: var(--muted); font-size: .85rem; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-wrap: balance;
  background: url("../img/divider.svg") center top / 140px 18px no-repeat,
    linear-gradient(90deg, transparent, rgba(199, 157, 74, .5) 30%, rgba(199, 157, 74, .5) 70%, transparent) center 9px / 100% 1px no-repeat;
}

/* ---------- text bits ---------- */
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.lead { font-size: 1.12rem; color: var(--text); opacity: .88; max-width: 60ch; margin: 0; }
.error { color: var(--ember); margin: .4em 0; }
.error:empty { display: none; }
.note, .toast {
  background: var(--tip-bg); color: var(--text);
  border: 1px solid var(--tip-border); border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .9), inset 0 0 18px rgba(80, 90, 160, .18), 0 6px 18px rgba(0, 0, 0, .7);
}
.note { padding: 8px 11px; font-size: .9rem; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px; min-height: 38px; border-radius: 4px;
  font: 600 1rem/1.2 var(--display); letter-spacing: .02em; white-space: nowrap; text-decoration: none; cursor: pointer;
  color: #f2dfb2; text-shadow: 0 1px 0 #000;
  background: linear-gradient(180deg, #4a3826 0%, #2f2317 48%, #21180f 52%, #2b2015 100%);
  border: 1px solid #a07c3c;
  box-shadow:
    inset 0 1px 0 rgba(255, 232, 170, .28), inset 0 -2px 0 rgba(0, 0, 0, .45),
    0 0 0 1px #000, 0 2px 5px rgba(0, 0, 0, .6);
  transition: box-shadow .15s, color .15s, border-color .15s, filter .15s;
}
.btn:hover {
  color: #fff4d6; border-color: var(--gold);
  box-shadow:
    inset 0 1px 0 rgba(255, 232, 170, .4), inset 0 -2px 0 rgba(0, 0, 0, .45),
    0 0 0 1px #000, 0 2px 5px rgba(0, 0, 0, .6), var(--glow);
}
.btn:active { filter: brightness(.88); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .7), 0 0 0 1px #000; transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; filter: grayscale(.6); box-shadow: inset 0 1px 0 rgba(255, 232, 170, .12), 0 0 0 1px #000; transform: none; }
.btn.primary {
  color: #ffeec4;
  background: linear-gradient(180deg, #c0402a 0%, #8e2416 48%, #6e170c 52%, #84200f 100%);
  border-color: var(--gold);
  box-shadow:
    inset 0 1px 0 rgba(255, 210, 160, .45), inset 0 -2px 0 rgba(0, 0, 0, .4), inset 0 0 0 1px rgba(60, 10, 0, .5),
    0 0 0 1px #000, 0 2px 6px rgba(0, 0, 0, .7);
}
.btn.primary:hover {
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 220, 170, .6), inset 0 -2px 0 rgba(0, 0, 0, .4),
    0 0 0 1px #000, 0 2px 6px rgba(0, 0, 0, .7), 0 0 18px rgba(255, 120, 50, .55);
}
.btn.small { padding: 5px 12px; min-height: 32px; font-size: .9rem; }
.link { background: none; border: 0; padding: 2px 0; color: var(--gold); cursor: pointer; font: inherit; text-align: start; }
.link:hover { color: var(--gold-hi); text-shadow: 0 0 8px rgba(255, 170, 70, .5); }

/* ---------- form wells ---------- */
input[type=text], input[type=search], input[type=number], textarea, select {
  font: inherit; color: var(--text); width: 100%; min-width: 0;
  background: linear-gradient(180deg, #0a0806, var(--well) 30%, #15110c);
  border: 1px solid #5c4321; border-radius: 3px; padding: 7px 10px;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .8), 0 1px 0 rgba(226, 191, 106, .12);
}
select {
  -webkit-appearance: none; appearance: none; cursor: pointer; padding-inline-end: 36px;
  background:
    url("../img/chevron.svg") right 12px center / 14px 10px no-repeat,
    linear-gradient(180deg, rgba(255, 232, 170, .07), transparent 55%),
    linear-gradient(180deg, #2a2017, #17120d);
  border-color: #7a5b2c;
  box-shadow: inset 0 1px 0 rgba(255, 232, 170, .14), 0 0 0 1px #000, 0 2px 4px rgba(0, 0, 0, .5);
}
select:hover { border-color: var(--gold); box-shadow: inset 0 1px 0 rgba(255, 232, 170, .2), 0 0 0 1px #000, 0 2px 4px rgba(0, 0, 0, .5), 0 0 10px rgba(255, 176, 72, .3); }
select:focus-visible { box-shadow: inset 0 1px 0 rgba(255, 232, 170, .2), 0 0 0 1px #000, 0 0 12px rgba(255, 176, 72, .45); }
select option { background: #1a140e; color: var(--text); }
::placeholder { color: #8f805f; opacity: 1; }
input:focus, textarea:focus, select:focus { border-color: var(--gold-deep); }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 0;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .8), 0 0 12px rgba(255, 176, 72, .45);
}
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 3px; }
.code { font-family: var(--mono); font-size: .8rem; line-height: 1.5; word-break: break-all; color: #e9dcb8; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; font-weight: 600; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }

label.check { cursor: pointer; }
label.check:hover { color: var(--gold-hi); }

/* checkbox: recessed bronze socket, gold rune tick when on */
input[type=checkbox] {
  -webkit-appearance: none; appearance: none; flex: none; width: 20px; height: 20px; margin: 0; cursor: pointer;
  border: 1px solid #8a6a35; border-radius: 3px;
  background: linear-gradient(180deg, #050403, #17120d);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .9), 0 0 0 1px #000, 0 1px 0 rgba(226, 191, 106, .2);
  transition: box-shadow .15s, border-color .15s;
}
input[type=checkbox]:hover { border-color: var(--gold); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .9), 0 0 0 1px #000, 0 0 10px rgba(255, 176, 72, .45); }
input[type=checkbox]:checked {
  border-color: var(--gold);
  background: url("../img/check.svg") center / 15px 15px no-repeat,
    radial-gradient(circle at 50% 45%, rgba(255, 160, 60, .35), transparent 70%),
    linear-gradient(180deg, #2a1b0c, #120c06);
}
input[type=checkbox]:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
label.block { margin-top: 8px; }

/* ---------- gilded panel ---------- */
.card, .side, .publish, .empty, .gallery-empty, .support {
  border: 18px solid transparent; border-image: var(--frame);
  background:
    radial-gradient(ellipse 120% 70% at 50% 0%, rgba(255, 190, 110, .07), transparent 70%),
    linear-gradient(180deg, var(--stone-2), var(--stone-1) 60%, #1a140f);
  background-clip: padding-box;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .55);
}

/* ---------- gallery ---------- */
.hero {
  display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center;
  margin: 8px auto 32px; padding-bottom: 40px; position: relative;
}
.hero > div { display: grid; gap: 14px; justify-items: center; }
.hero h1 { margin: 0; }
.hero .lead { margin: 0 auto; }
.hero:has(~ .grid.is-empty) .btn { display: none; }
.hero::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 18px;
  background: url("../img/divider.svg") center / 140px 18px no-repeat,
    linear-gradient(90deg, transparent, rgba(199, 157, 74, .55) 25%, rgba(199, 157, 74, .55) 75%, transparent) center / 100% 1px no-repeat;
}
.hero .btn { padding: 11px 26px; font-size: 1.1rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .combo { width: auto; max-width: 100%; }
.search { max-width: 440px; padding-left: 12px; }
main[data-page=gallery] .toolbar { justify-content: center; margin-bottom: 10px; }
main[data-page=gallery] .search { max-width: 520px; }
main[data-page=gallery] > p.muted { text-align: center; margin: 0 0 18px; }
.gallery-empty { max-width: 600px; margin: 6px auto 0; padding: 14px 18px 18px; text-align: center; }
.gallery-empty h2 { font-size: clamp(1.25rem, 4vw, 1.5rem); margin-bottom: .3em; text-wrap: balance; }
.gallery-empty p { margin: 0 0 14px; text-wrap: balance; }
.steps { display: inline-flex; flex-direction: column; gap: 6px; margin: 0 0 22px; padding: 0; list-style: none; counter-reset: step; text-align: start; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: baseline; }
.steps li::before {
  content: counter(step); display: inline-grid; place-items: center; width: 26px; height: 26px;
  font: 600 .9rem/1 var(--display); color: var(--gold-hi); border: 1px solid var(--gold-deep); transform: translateY(1px);
  background: radial-gradient(circle at 40% 35%, #4a3826, #1a120a); border-radius: 50%; box-shadow: 0 0 0 1px #000;
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 380px)); justify-content: center; gap: 22px; }
.grid.is-empty { display: block; }
.card {
  display: block; border-width: 13px; border-image: var(--frame-sm); overflow: hidden;
  text-decoration: none; color: var(--text); transition: box-shadow .2s, filter .2s;
}
.card:hover { box-shadow: 0 10px 28px rgba(0, 0, 0, .55), 0 0 22px rgba(255, 170, 70, .28); filter: brightness(1.08); }
.card:hover h3 { color: var(--gold-hi); }
.card:focus-visible { outline-offset: 0; }
.card-body { padding: 10px 6px 4px; }
.card h3 { margin: 0 0 2px; font-size: 1.15rem; }
.thumb { pointer-events: none; box-shadow: 0 1px 0 rgba(226, 191, 106, .35); }

/* ---------- detail ---------- */
.detail-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; margin: 4px auto 26px; }
.detail-head h1 { margin: 0; }
.detail-head p { margin: 0 0 12px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.description { white-space: pre-wrap; width: fit-content; max-width: 75ch; margin: 24px auto 0; }
main[data-page=detail] .preview { max-width: 1100px; margin: 0 auto; }
.raw { max-width: 900px; margin: 24px auto 8px; }
.raw summary { text-align: center; }
main[data-page=detail] > p.muted.small { text-align: center; }
.raw summary { cursor: pointer; font-weight: 600; color: var(--gold); font-variant: small-caps; letter-spacing: .03em; font-size: 1.05rem; }
.raw summary:hover { color: var(--gold-hi); }
.raw textarea { margin-top: 8px; }

/* ---------- stage: a game screen inside a gilded bezel ---------- */
.stage-host {
  position: relative; overflow: hidden; width: 100%; isolation: isolate;
  background:
    radial-gradient(ellipse 80% 60% at 50% 30%, #222b3a 0%, #141922 55%, var(--stage-bg) 100%);
}
.stage-host::after {
  content: ""; position: absolute; inset: 0; z-index: 20; pointer-events: none;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .65);
}
.preview, .editor-stage { box-shadow: 0 12px 32px rgba(0, 0, 0, .6); }
.preview::before, .editor-stage::before {
  content: ""; position: absolute; inset: 0; z-index: 21; pointer-events: none;
  border: 18px solid transparent; border-image: var(--frame);
}
.stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.stage-grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--stage-grid) 1px, transparent 1px), linear-gradient(90deg, var(--stage-grid) 1px, transparent 1px);
  background-size: 120px 120px;
}
.stage-center { position: absolute; left: 50%; top: 0; bottom: 0; width: 0; border-left: 1px dashed rgba(226, 191, 106, .16); }
.stage-center::after { content: ""; position: absolute; top: 50%; left: -24px; width: 48px; border-top: 1px dashed rgba(226, 191, 106, .28); }
.frame {
  --c: var(--c-misc);
  position: absolute; display: flex; align-items: center; justify-content: center; overflow: hidden;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--c) 34%, transparent), color-mix(in srgb, var(--c) 18%, rgba(0, 0, 0, .5)));
  border: 2px solid var(--c); border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .18), 0 2px 6px rgba(0, 0, 0, .55);
  color: #fff; font: 600 var(--label-px, 15px)/1.1 var(--serif); text-align: center; padding: 2px;
  text-shadow: 0 1px 2px #000, 0 0 4px #000; user-select: none; touch-action: none;
}
.frame-label { pointer-events: none; }
.frame[role=button] { cursor: grab; }
.frame[role=button]:hover { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .55), 0 0 16px var(--c); }
.frame[role=button]:active { cursor: grabbing; }
.frame.is-default { border-style: dashed; opacity: .55; }
.frame.is-broken { outline: 2px dotted var(--ember); }
.frame.is-filtered { opacity: .12; pointer-events: none; }
.frame.is-selected {
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 58%, rgba(255, 230, 170, .12)), color-mix(in srgb, var(--c) 40%, rgba(0, 0, 0, .35)));
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--ring), 0 0 0 4px rgba(0, 0, 0, .7), var(--ring-glow), 0 0 22px color-mix(in srgb, var(--c) 60%, transparent);
  z-index: 5; opacity: 1;
}
.frame:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; }
.cat-bar { --c: var(--c-bar); } .cat-unit { --c: var(--c-unit); } .cat-cast { --c: var(--c-cast); }
.cat-cd { --c: var(--c-cd); } .cat-aura { --c: var(--c-aura); } .cat-chat { --c: var(--c-chat); }
.cat-map { --c: var(--c-map); } .cat-misc { --c: var(--c-misc); } .cat-unknown { --c: var(--c-unknown); }
.cat-dot::before {
  content: ""; display: inline-block; width: .62em; height: .62em; margin-inline-end: .5em; vertical-align: .08em;
  background: var(--c); transform: rotate(45deg); border: 1px solid rgba(0, 0, 0, .7);
  box-shadow: 0 0 6px color-mix(in srgb, var(--c) 70%, transparent);
}

/* ---------- editor ---------- */
.import { margin-bottom: 20px; }
.import-row { display: flex; gap: 10px; align-items: stretch; }
.import-row .btn { align-self: flex-start; }
.empty { padding: 18px 14px 18px; max-width: 640px; margin: 8px auto 0; text-align: center; }
.empty .lead { margin: 0 auto; }
.empty:not([hidden]) + .import { max-width: 640px; margin: 22px auto 0; }
.editor-controls {
  display: grid; margin-bottom: 18px; padding: 4px 14px;
  background: linear-gradient(180deg, rgba(44, 35, 25, .85), rgba(26, 20, 15, .85));
  border-top: 1px solid var(--gold-deep); border-bottom: 1px solid var(--gold-deep);
  box-shadow: 0 1px 0 #000, 0 -1px 0 #000, 0 8px 20px rgba(0, 0, 0, .4);
}
.editor-controls .toolbar { justify-content: center; margin: 0; padding: 8px 0; }
.editor-controls .toolbar + .toolbar { border-top: 1px solid rgba(110, 82, 41, .5); }
.empty .btn { margin-top: 18px; }
.editor-main { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 20px; align-items: start; }
.side { padding: 6px 6px 10px; max-height: 80vh; overflow: auto; scrollbar-color: var(--bronze) transparent; }
.side > h2:first-child { margin-top: 0; }
.element-list { list-style: none; padding: 0; margin: 4px 0 0; }
.element-list li { border-bottom: 1px solid rgba(110, 82, 41, .35); }
.element-list li:last-child { border-bottom: 0; }
.element-list .link { color: var(--text); width: 100%; padding: 5px 4px; }
.element-list .link:hover { color: var(--gold-hi); background: linear-gradient(90deg, rgba(226, 191, 106, .12), transparent); }
.fields { display: grid; gap: 9px; margin: 10px 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
table.settings { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.settings th { color: var(--gold); font-weight: 600; font-variant: small-caps; }
table.settings th, table.settings td { text-align: start; padding: 3px 4px; border-bottom: 1px solid rgba(110, 82, 41, .45); }
table.settings input { padding: 3px 6px; }
.export { margin-top: 28px; }
.export-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.export-head h2 { margin: 0; }
.publish { margin: 34px auto 0; display: grid; gap: 10px; max-width: 760px; padding: 8px 10px 12px; }
.publish h2 { margin: 0; }
.publish .btn { justify-self: start; margin-top: 4px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); padding: 10px 18px; z-index: 100; max-width: calc(100vw - 32px); }
.toast.err { border-color: var(--ember); color: #ffc6b4; }

@media (max-width: 900px) {
  .editor-main { grid-template-columns: 1fr; }
  .side { max-height: none; }
  .import-row { flex-direction: column; }
}
@media (max-width: 520px) {
  .top { gap: 8px 16px; position: static; }
  html { scroll-padding-top: 0; }
  .brand { font-size: 1.2rem; }
  main { padding-top: 22px; }
  .hero .btn { width: 100%; }
  .card, .side, .publish, .empty, .gallery-empty, .support { border-width: 13px; border-image: var(--frame-sm); }
  .editor-controls { padding: 2px 8px; }
  .editor-controls .toolbar { justify-content: flex-start; }
  .preview::before, .editor-stage::before { border-width: 12px; border-image: url("../img/frame.svg") 24 / 12px stretch; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* snap guides shown while dragging */
.stage-guides { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.guide { position: absolute; background: #ffd56a; box-shadow: 0 0 6px rgba(255, 213, 106, .9); }
.guide-x { top: 0; bottom: 0; width: 2px; margin-left: -1px; }
.guide-y { left: 0; right: 0; height: 2px; margin-top: -1px; }

/* Edit Mode style grid: lines from the screen centre, highlighted X/Y axes */
.stage.show-grid .stage-grid {
  background-image: linear-gradient(rgba(255, 255, 255, .2) 2px, transparent 2px), linear-gradient(90deg, rgba(255, 255, 255, .2) 2px, transparent 2px);
}
.stage.show-grid .stage-center { display: none; }
.stage-axis { position: absolute; display: none; pointer-events: none; background: rgba(230, 80, 60, .75); box-shadow: 0 0 4px rgba(230, 80, 60, .6); }
.stage.show-grid .stage-axis { display: block; }
.stage-axis-x { left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; }
.stage-axis-y { top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; }
.guide-grid { background: #bfe3ff; box-shadow: 0 0 8px rgba(150, 210, 255, .95); }
.guide-axis { background: #ff7a5c; box-shadow: 0 0 10px rgba(255, 110, 80, 1); }
.guide-x.guide-grid, .guide-x.guide-axis { width: 3px; margin-left: -1.5px; }
.guide-y.guide-grid, .guide-y.guide-axis { height: 3px; margin-top: -1.5px; }
.grid-bar { gap: 14px 18px; }
.grid-size { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.grid-inputs { display: inline-flex; align-items: center; gap: 8px; }
.grid-inputs input[type=range] { width: 160px; }

/* range slider: recessed gold-filled groove with a gem knob */
input[type=range] {
  --fill: 50%;
  -webkit-appearance: none; appearance: none; height: 24px; margin: 0; padding: 0; background: transparent; cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 8px; border-radius: 4px;
  background: linear-gradient(180deg, #f0d48a, #a57a2c) 0 0 / var(--fill) 100% no-repeat, linear-gradient(180deg, #050403, #15110c);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .9), 0 0 0 1px #5c4321, 0 1px 0 rgba(226, 191, 106, .2);
}
input[type=range]::-moz-range-track {
  height: 8px; border-radius: 4px; background: linear-gradient(180deg, #050403, #15110c);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .9), 0 0 0 1px #5c4321, 0 1px 0 rgba(226, 191, 106, .2);
}
input[type=range]::-moz-range-progress { height: 8px; border-radius: 4px; background: linear-gradient(180deg, #f0d48a, #a57a2c); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; margin-top: -6px; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #ffd9a0 0 12%, #e0702c 34%, #6a1d08 70%);
  border: 2px solid var(--gold); box-shadow: 0 0 0 1px #000, 0 2px 4px rgba(0, 0, 0, .8);
  transition: box-shadow .15s;
}
input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #ffd9a0 0 12%, #e0702c 34%, #6a1d08 70%);
  border: 2px solid var(--gold); box-shadow: 0 0 0 1px #000, 0 2px 4px rgba(0, 0, 0, .8);
}
input[type=range]:hover::-webkit-slider-thumb { box-shadow: 0 0 0 1px #000, 0 2px 4px rgba(0, 0, 0, .8), 0 0 12px rgba(255, 150, 60, .8); }
input[type=range]:hover::-moz-range-thumb { box-shadow: 0 0 0 1px #000, 0 2px 4px rgba(0, 0, 0, .8), 0 0 12px rgba(255, 150, 60, .8); }
input[type=range]:focus-visible { outline: 2px solid var(--ring); outline-offset: 3px; border-radius: 4px; }
.grid-size input.grid-num { width: 72px; }

/* Ko-fi: compact panel at the bottom of pages (no QR there) */
.support { display: flex; gap: 12px 20px; align-items: center; justify-content: space-between; margin: 40px auto 0; padding: 2px 8px; max-width: 640px; border-width: 13px; border-image: var(--frame-sm); }
.support .btn { flex: none; }
.support-text h2 { font-size: 1.05rem; margin-bottom: .15em; }
.support-text p { margin: 0; font-size: .88rem; }

/* header "Support" button opening the Ko-fi dialog */
.top-support {
  display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 4px 10px; cursor: pointer;
  font: 600 .9rem/1 var(--display); color: var(--muted); background: transparent;
  border: 1px solid rgba(138, 106, 53, .6); border-radius: 4px;
}
.top-support:hover, .top-support:focus-visible { color: var(--gold-hi); border-color: var(--gold); box-shadow: var(--glow); }
.top-support-icon { width: 20px; height: 20px; flex: none; }
.foot-support { white-space: nowrap; }
@media (max-width: 560px) {
  .support { flex-direction: column; text-align: center; }
}
main[data-page=gallery] .support { margin-top: 48px; }

/* class / spec */
.class-badge {
  display: inline-block; margin: 2px 0 4px; padding: 1px 8px; border-radius: 999px; font-size: .8rem; font-weight: 700;
  color: var(--class-color, var(--text)); border: 1px solid color-mix(in srgb, var(--class-color, #888) 60%, transparent);
  background: color-mix(in srgb, var(--class-color, #888) 12%, transparent); vertical-align: middle; letter-spacing: .02em;
}
h2 .class-badge { font-size: .8rem; margin-inline-start: 6px; }
.template-note { margin: 0 0 16px; padding: 12px 16px; border: 1px solid var(--gold-deep); border-radius: 4px; background: linear-gradient(180deg, var(--stone-2), var(--stone-1)); box-shadow: 0 0 0 1px #000, 0 8px 20px rgba(0, 0, 0, .4); }
.template-note h2 { margin-bottom: .3em; }
.template-note p { margin: 0 0 4px; }

/* picture boxes for classes and specs (PNG in public/img/classes and public/img/specs) */
.icon-box {
  --class-color: var(--gold);
  position: relative; display: inline-grid; place-items: center; flex: none; width: 48px; height: 48px; overflow: hidden;
  border: 2px solid #8a6a35; border-radius: 5px;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--class-color) 30%, #1a140e), #0b0907 75%);
  box-shadow: 0 0 0 1px #000, inset 0 0 0 1px rgba(0, 0, 0, .7), inset 0 0 10px rgba(0, 0, 0, .8);
}
.icon-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.icon-mono { font: 600 1.45rem/1 var(--display); color: var(--class-color); text-shadow: 0 1px 0 #000, 0 0 8px color-mix(in srgb, var(--class-color) 60%, transparent); }
.icon-any .icon-mono { color: var(--gold); font-size: 1.2rem; }

.class-picker { display: grid; gap: 10px; }
.pick-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pick-specs { padding-top: 10px; border-top: 1px solid rgba(110, 82, 41, .5); }
.pick-tile {
  --class-color: var(--gold);
  display: flex; flex-direction: column; align-items: center; gap: 5px; width: 84px; padding: 8px 4px 7px; cursor: pointer;
  font: 600 .82rem/1.15 var(--display); color: var(--muted); text-align: center;
  background: linear-gradient(180deg, rgba(44, 35, 25, .9), rgba(22, 17, 12, .9));
  border: 1px solid rgba(138, 106, 53, .55); border-radius: 5px; box-shadow: 0 0 0 1px #000;
  transition: border-color .15s, box-shadow .15s, color .15s;
}
.pick-tile:hover { color: var(--text); border-color: var(--gold-deep); box-shadow: 0 0 0 1px #000, 0 0 10px rgba(255, 176, 72, .3); }
.pick-tile:hover .icon-box { border-color: var(--gold); }
.pick-tile[aria-pressed="true"] {
  color: var(--gold-hi); border-color: var(--gold);
  background: linear-gradient(180deg, color-mix(in srgb, var(--class-color) 22%, #2c2319), #17120d);
  box-shadow: 0 0 0 1px #000, 0 0 14px color-mix(in srgb, var(--class-color) 55%, transparent), inset 0 1px 0 rgba(255, 240, 192, .2);
}
.pick-tile[aria-pressed="true"] .icon-box { border-color: var(--ring); box-shadow: 0 0 0 1px #000, 0 0 10px color-mix(in srgb, var(--class-color) 70%, transparent); }
.pick-name { overflow-wrap: break-word; hyphens: auto; }
.pick-caption { font: 500 .8rem/1.2 var(--serif); color: var(--muted); }
.pick-specs .pick-tile { width: 104px; }

.gallery-classes { display: grid; justify-items: center; gap: 12px; margin: 4px auto 22px; }
.gallery-classes .pick-row { justify-content: center; }
.gallery-classes .link-templates { font-weight: 600; }
.pick-field { border: 0; margin: 0; padding: 0; min-width: 0; }
.pick-field legend { padding: 0; margin-bottom: 6px; font-size: .9rem; font-weight: 600; color: var(--muted); }
.pick-field .pick-classes .pick-tile { width: 62px; font-size: .8rem; }
.pick-field .pick-classes .icon-box { width: 40px; height: 40px; }
.pick-field .pick-specs .pick-tile { width: 100px; }

.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 20px; margin: 8px 0 24px; }
.class-card {
  --class-color: var(--accent); padding: 4px 6px 8px;
  border: 13px solid transparent; border-image: var(--frame-sm);
  background: radial-gradient(ellipse 120% 60% at 50% 0%, color-mix(in srgb, var(--class-color) 14%, transparent), transparent 70%), linear-gradient(180deg, var(--stone-2), var(--stone-1) 60%, #1a140f);
  background-clip: padding-box; box-shadow: 0 10px 28px rgba(0, 0, 0, .55);
}
.class-card h2 { display: flex; align-items: center; gap: 12px; color: var(--class-color); margin: 0 0 12px; font-size: 1.35rem; text-shadow: 0 1px 2px #000; }
.class-card h2 .icon-box { width: 56px; height: 56px; }
.spec-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.spec-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; padding: 10px 4px 9px; text-align: center; text-decoration: none;
  color: var(--text); font: 600 .9rem/1.2 var(--display);
  background: linear-gradient(180deg, rgba(44, 35, 25, .9), rgba(22, 17, 12, .9));
  border: 1px solid rgba(138, 106, 53, .55); border-radius: 5px; box-shadow: 0 0 0 1px #000;
}
.spec-tile:hover, .spec-tile:focus-visible { color: var(--gold-hi); border-color: var(--gold); box-shadow: 0 0 0 1px #000, 0 0 14px color-mix(in srgb, var(--class-color) 55%, transparent); }
.spec-tile .role { font-size: .8rem; padding: 1px 4px; white-space: normal; }
.role { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; border-radius: 4px; border: 1px solid currentColor; white-space: nowrap; }
.role-tank { color: #7fb2ff; } .role-healer { color: #6fe08f; } .role-melee { color: #ff8a6a; } .role-ranged { color: #e8b13e; } .role-support { color: #c79bff; }
@media (max-width: 520px) {
  .pick-row { gap: 6px; }
  .pick-tile, .pick-specs .pick-tile { width: 62px; font-size: .8rem; padding: 6px 2px; }
  .pick-tile .icon-box { width: 38px; height: 38px; }
  .pick-specs .pick-tile { width: 76px; }
  .pick-caption { font-size: .8rem; }
  .gallery-classes .pick-row, .pick-field .pick-row { justify-content: center; }
  .top nav a { padding: 4px 7px; }
  .top nav { gap: 2px; }
}

/* language switcher: a compact gilded select in the header */
.lang-slot { margin-inline-start: auto; display: flex; align-items: center; }
.lang-select { max-width: 11em; }
.lang-select .combo-input { min-height: 32px; padding: 4px 30px 4px 10px; font-size: .85rem; background-position: right 10px center, 0 0, 0 0; }

/* right-to-left (Arabic): the game screen, coordinates and export strings stay left-to-right */
[dir=rtl] .combo-input { background-position: left 12px center, 0 0, 0 0; padding-inline: 10px 36px; }
[dir=rtl] .lang-select .combo-input { padding: 4px 10px 4px 30px; background-position: left 10px center, 0 0, 0 0; }
.stage-host, .code, input[type=number] { direction: ltr; }
[dir=rtl] .code { text-align: left; }
@media (max-width: 520px) {
  .lang-select { max-width: 9.5em; }
  .lang-select .combo-input { font-size: .8rem; }
}

/* long spec and role names (Treffsicherheit, Совершенствование) wrap instead of clipping in narrow tiles */
.spec-tile { min-width: 0; }
.spec-tile .spec-name, .spec-tile .role, .pick-name, .pick-caption { max-width: 100%; overflow-wrap: anywhere; hyphens: auto; }
@media (max-width: 520px) {
  .spec-tile { font-size: .8rem; padding-inline: 3px; }
}

/* editor: class / talent tree switcher */
.class-switch {
  display: grid; gap: 12px; margin: 0 0 18px; padding: 12px 16px 14px;
  background: linear-gradient(180deg, rgba(44, 35, 25, .85), rgba(26, 20, 15, .85));
  border: 1px solid rgba(165, 122, 44, .7); border-radius: 4px; box-shadow: 0 0 0 1px #000, 0 8px 20px rgba(0, 0, 0, .4);
}
.class-switch-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 4px 14px; text-align: center; }
.class-switch-head h2 { margin: 0; }
.class-switch-head p { margin: 0; }
.class-switch .pick-row { justify-content: center; }
.class-switch .pick-tile { width: 76px; }
.class-switch .pick-specs .pick-tile { width: 104px; }
.class-switch-actions { display: flex; justify-content: center; }
.empty:not([hidden]) ~ .class-switch { max-width: 920px; margin: 22px auto 0; }
@media (max-width: 520px) {
  .class-switch { padding: 10px 8px 12px; }
  .class-switch .pick-tile { width: 62px; }
  .class-switch .pick-specs .pick-tile { width: 76px; }
  .class-switch-actions .btn { width: 100%; white-space: normal; }
}

/* ---------- welcome: hero actions and "how it works" ---------- */
.hero > .hero-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.how {
  list-style: none; margin: 0 auto 30px; padding: 0; max-width: 1040px;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px;
}
.how li {
  display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px;
  background: linear-gradient(180deg, rgba(44, 35, 25, .7), rgba(22, 17, 12, .7));
  border: 1px solid rgba(138, 106, 53, .55); border-radius: 5px; box-shadow: 0 0 0 1px #000;
}
.how-num {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  font: 600 1.05rem/1 var(--display); color: var(--gold-hi); border: 1px solid var(--gold-deep);
  background: radial-gradient(circle at 40% 35%, #4a3826, #1a120a); box-shadow: 0 0 0 1px #000;
}
.how h3 { margin: 2px 0 4px; font-size: 1.05rem; }
.how p { margin: 0; font-size: .92rem; }
@media (max-width: 760px) { .how { grid-template-columns: 1fr; } }

/* ---------- gallery sections ---------- */
.gallery-section { margin: 8px 0 34px; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 20px; margin-bottom: 8px; text-align: center; }
.section-head h2 { margin: 0; font-size: 1.45rem; }
.gallery-section > p.muted { text-align: center; margin: 0 auto 18px; max-width: 62ch; }
label.sort { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.sort-select .combo-input { min-height: 34px; padding-top: 4px; padding-bottom: 4px; }
.starter-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.starter-card { --class-color: var(--gold); }
.starter-card h3 { display: flex; align-items: center; gap: 10px; color: var(--class-color); }
.starter-card h3 .icon-box { width: 30px; height: 30px; }
.starter-card h3 .icon-mono { font-size: 1rem; }
.starter-meta .role { white-space: normal; text-align: start; } /* long two-role labels (es, pt, ru) wrap instead of clipping */
.starter-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; margin: 6px 0 0; }
.starter-card:hover .starter-meta .muted { color: var(--gold-hi); }

/* ---------- detail: tools, report, delete ---------- */
.detail-tools { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: 12px 24px; margin: 22px auto 0; max-width: 760px; }
.report summary { cursor: pointer; color: var(--muted); font-size: .9rem; text-decoration: underline; text-underline-offset: 3px; }
.report summary:hover { color: var(--gold-hi); }
.report[open] summary { color: var(--gold); }
.report-form { display: grid; gap: 8px; width: min(460px, calc(100vw - 32px)); margin-top: 8px; }
.report-form .btn { justify-self: start; }
.btn.danger { color: #ffd2c4; border-color: #b4543c; background: linear-gradient(180deg, #4a1f16, #2a120c); }
.btn.danger:hover { border-color: var(--ember); box-shadow: 0 0 0 1px #000, 0 0 12px rgba(240, 120, 90, .45); }

/* ---------- Ko-fi note after a copy ---------- */
.kofi-nudge {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: fit-content; max-width: 100%;
  margin: 10px auto 0; padding: 6px 8px 6px 14px; font-size: .9rem;
  background: var(--tip-bg); border: 1px solid var(--tip-border); border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .9), 0 4px 12px rgba(0, 0, 0, .6);
}
.export-head + .kofi-nudge { margin: 0 0 8px auto; }
.nudge-close {
  flex: none; width: 26px; height: 26px; padding: 0; border: 1px solid transparent; border-radius: 3px; cursor: pointer;
  font: 600 1.1rem/1 var(--serif); color: var(--muted); background: transparent;
}
.nudge-close:hover { color: var(--gold-hi); border-color: var(--bronze); }

/* ---------- editor: compact bar above the stage ---------- */
.editor-bar { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 12px; }
.editor-title { margin: 0 8px 0 0; font-size: 1.6rem; }
.editor-bar-end { display: flex; flex-wrap: wrap; gap: 8px; margin-inline-start: auto; }
.drop > summary { list-style: none; gap: 8px; }
.drop > summary::-webkit-details-marker { display: none; }
.drop > summary::after { content: ""; width: 12px; height: 9px; background: url("../img/chevron.svg") center / 12px 9px no-repeat; transition: transform .15s; }
.drop[open] > summary::after { transform: rotate(180deg); }
.drop[open] > summary { border-color: var(--gold); color: var(--gold-hi); }
.drop-panel {
  position: absolute; top: calc(100% + 6px); inset-inline-start: 0; z-index: 40; width: min(560px, 100%);
  display: grid; gap: 10px; padding: 14px 16px;
  background: linear-gradient(180deg, #2c2319, #18130e); border: 1px solid var(--gold-deep); border-radius: 5px;
  box-shadow: 0 0 0 1px #000, 0 16px 36px rgba(0, 0, 0, .75);
}
.drop-panel.drop-wide { width: min(960px, 100%); }
.drop-panel > p { margin: 0; text-align: center; }
.drop-panel .pick-row { justify-content: center; }
.drop-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.drop-label { color: var(--muted); }
.class-current {
  --class-color: var(--muted);
  color: var(--class-color); font-weight: 600; max-width: 16em; overflow: hidden; text-overflow: ellipsis;
}
.sample-note { margin: -4px 0 12px; font-size: .9rem; color: var(--muted); }
.editor-main + .template-note { margin-top: 16px; }
.editor .editor-controls { margin-top: 16px; }
@media (max-width: 700px) {
  .editor-bar { gap: 8px; }
  .editor-title { flex-basis: 100%; }
  .editor-bar-end { margin-inline-start: 0; }
  .drop[open] { flex-basis: 100%; }
  .drop-panel, .drop-panel.drop-wide { position: static; width: auto; margin-top: 8px; }
}

/* ---------- dialogs (support, keyboard shortcuts) ---------- */
.dialog {
  padding: 0; max-width: min(460px, calc(100vw - 32px)); color: var(--text);
  background: linear-gradient(180deg, #2c2319, #17120d); border: 1px solid var(--gold-deep); border-radius: 6px;
  box-shadow: 0 0 0 1px #000, 0 24px 60px rgba(0, 0, 0, .8);
}
.dialog::backdrop { background: rgba(5, 4, 3, .72); }
.dialog-body { display: grid; gap: 12px; padding: 16px 20px 20px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { margin: 0; font-size: 1.25rem; }
.dialog-close {
  flex: none; width: 32px; height: 32px; padding: 0; cursor: pointer; border-radius: 4px;
  font: 600 1.3rem/1 var(--serif); color: var(--muted); background: transparent; border: 1px solid transparent;
}
.dialog-close:hover { color: var(--gold-hi); border-color: var(--bronze); }
.dialog p { margin: 0; }
.kofi-dialog .btn.primary { justify-self: center; }
.kofi-qr { margin: 0; display: grid; justify-items: center; gap: 6px; }
/* light quiet zone so phones scan it on the dark theme */
.kofi-qr img { width: 180px; height: 180px; padding: 12px; background: #fbf4e2; border-radius: 6px; box-shadow: 0 0 0 1px #000; }
@media (max-width: 700px) { .kofi-qr { display: none; } }
.keys-dialog { max-width: min(560px, calc(100vw - 32px)); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; align-items: baseline; }
.keys dt { margin: 0; }
.keys dd { margin: 0; color: var(--muted); font-size: .92rem; }
kbd {
  display: inline-block; padding: 1px 7px; font: 600 .8rem/1.5 var(--mono); color: var(--gold-hi); white-space: nowrap;
  background: #0f0c09; border: 1px solid var(--bronze); border-bottom-width: 2px; border-radius: 4px;
}

/* ---------- editor: stage viewport, zoom, selection, status ---------- */
.stage-viewport { position: relative; overflow: hidden; touch-action: pan-x pan-y; }
.stage-viewport.is-zoomed { overflow: auto; overscroll-behavior: contain; scrollbar-color: var(--bronze) #0d1017; }
.stage-viewport.can-pan, .stage-viewport.is-panning { cursor: grab; }
.stage-viewport.is-panning { cursor: grabbing; }
.stage-sizer { position: relative; }
.editor-stage .stage-viewport { cursor: crosshair; }
.editor-stage .stage-viewport.can-pan { cursor: grab; }
.marquee { position: absolute; z-index: 30; pointer-events: none; border: 2px dashed var(--ring); background: rgba(255, 220, 140, .1); }
.frame { touch-action: none; }
.frame-label { display: block; max-width: 100%; overflow-wrap: normal; word-break: normal; }
.frame.label-hidden .frame-label { visibility: hidden; }
.frame.is-selected.is-primary { box-shadow: 0 0 0 3px var(--ring), 0 0 0 5px rgba(0, 0, 0, .75), 0 0 0 7px rgba(242, 180, 64, .55), 0 0 30px rgba(255, 170, 60, .7); }
.stage-col { min-width: 0; display: grid; gap: 8px; }
.stage-status {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px;
  padding: 6px 10px; font-size: .88rem; color: var(--muted);
  background: rgba(15, 12, 9, .7); border: 1px solid rgba(110, 82, 41, .5); border-radius: 4px;
}
.status-text { min-width: 0; overflow-wrap: anywhere; }
.zoom-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.zoom-tools .btn.small { min-width: 32px; padding: 4px 9px; }
.zoom-label { min-width: 3.6em; text-align: center; color: var(--text); font-variant-numeric: tabular-nums; }
.help-btn { font-weight: 700; }
.sel-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 10px; padding: 6px 10px;
  background: linear-gradient(180deg, rgba(44, 35, 25, .9), rgba(22, 17, 12, .9));
  border: 1px solid rgba(165, 122, 44, .7); border-radius: 4px; box-shadow: 0 0 0 1px #000;
}
.sel-count { font-weight: 600; color: var(--gold); }
.sel-group { display: flex; gap: 4px; }
.align-btn { gap: 6px; }
.align-icon { width: 16px; height: 16px; flex: none; background: currentColor; -webkit-mask: var(--icon) center / 16px 16px no-repeat; mask: var(--icon) center / 16px 16px no-repeat; }
.align-left { --icon: url("../img/align-left.svg"); }
.align-hcenter { --icon: url("../img/align-hcenter.svg"); }
.align-right { --icon: url("../img/align-right.svg"); }
.align-top { --icon: url("../img/align-top.svg"); }
.align-vmiddle { --icon: url("../img/align-vmiddle.svg"); }
.align-bottom { --icon: url("../img/align-bottom.svg"); }
.align-screenX { --icon: url("../img/align-screenX.svg"); }
.align-screenY { --icon: url("../img/align-screenY.svg"); }
.align-distX { --icon: url("../img/align-distX.svg"); }
.align-distY { --icon: url("../img/align-distY.svg"); }
@media (max-width: 900px) { .align-text { display: none; } }
@media (max-width: 700px) {
  .editor-bar .btn { min-height: 32px; padding: 5px 10px; font-size: .9rem; }
  .sel-bar { gap: 6px 8px; padding: 6px 8px; }
}

/* light card thumbnails (no scaling transform, frames in percent) */
.thumb-stage {
  position: relative; overflow: hidden; width: 100%; isolation: isolate; contain: strict;
  background: radial-gradient(ellipse 80% 60% at 50% 30%, #222b3a 0%, #141922 55%, var(--stage-bg) 100%);
}
.thumb-stage .frame { border-width: 1px; border-radius: 1px; padding: 0; box-shadow: none; text-shadow: none; }

/* ---------- compact class / talent tree chips ---------- */
.class-picker { display: grid; gap: 6px; }
.chip-row { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--bronze) transparent; padding: 2px; }
.chip-specs { padding-top: 2px; }
.chip {
  --class-color: var(--gold);
  flex: none; display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 3px 9px 3px 4px; cursor: pointer;
  font: 600 .85rem/1.1 var(--display); color: var(--muted); white-space: nowrap;
  background: linear-gradient(180deg, rgba(44, 35, 25, .92), rgba(22, 17, 12, .92));
  border: 1px solid rgba(138, 106, 53, .55); border-radius: 999px; box-shadow: 0 0 0 1px #000;
}
.chip:hover { color: var(--text); border-color: var(--gold-deep); }
.chip[aria-pressed="true"] {
  color: var(--gold-hi); border-color: var(--class-color);
  background: linear-gradient(180deg, color-mix(in srgb, var(--class-color) 24%, #2c2319), #17120d);
  box-shadow: 0 0 0 1px #000, 0 0 10px color-mix(in srgb, var(--class-color) 45%, transparent);
}
.chip:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.chip-dot.icon-box { width: 22px; height: 22px; border-width: 1px; border-radius: 50%; }
.chip-dot .icon-mono { font-size: .8rem; }
.chip-caption { font: 500 .8rem/1 var(--serif); color: var(--muted); }
.chip[aria-pressed="true"] .chip-caption { color: var(--text); }
.drop-panel .chip-row { flex-wrap: wrap; justify-content: center; overflow: visible; }
.pick-field .chip-row { flex-wrap: wrap; overflow: visible; }

/* home: one slim sticky bar with search and chips */
.filter-bar {
  position: sticky; top: var(--header-h, 58px); z-index: 9; display: grid; gap: 6px;
  margin: 0 -8px 18px; padding: 8px;
  background: linear-gradient(180deg, rgba(27, 21, 16, .97), rgba(21, 17, 13, .97));
  border-bottom: 1px solid rgba(165, 122, 44, .45); box-shadow: 0 8px 16px rgba(0, 0, 0, .35);
}
.filter-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.filter-row .search { flex: 0 1 210px; min-width: 140px; }
.filter-row .chip-classes { flex: 1 1 auto; min-width: 0; }
.filter-bar .chip-specs:not([hidden]) { padding-inline-start: 2px; }
@media (max-width: 700px) {
  .filter-row { flex-wrap: wrap; }
  .filter-row .search { flex: 1 1 100%; }
  .filter-row .chip-classes { flex-basis: 100%; }
}
@media (max-width: 520px) { .filter-bar { top: 0; } }

/* "how it works": folded after the first visit */
.how-wrap { margin: 0 auto 18px; max-width: 1040px; }
.how-wrap > summary {
  width: fit-content; margin: 0 auto; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px;
  font: 600 .95rem/1 var(--display); color: var(--gold); font-variant: small-caps; letter-spacing: .03em; padding: 6px 10px;
}
.how-wrap > summary::-webkit-details-marker { display: none; }
.how-wrap > summary::after { content: ""; width: 12px; height: 9px; background: url("../img/chevron.svg") center / 12px 9px no-repeat; transition: transform .15s; }
.how-wrap[open] > summary::after { transform: rotate(180deg); }
.how-wrap > summary:hover { color: var(--gold-hi); }
.how-wrap .how { margin-top: 10px; margin-bottom: 8px; }
.hero { margin-bottom: 18px; padding-bottom: 28px; gap: 16px; }

/* style segmented control */
.style-switch { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid rgba(138, 106, 53, .6); border-radius: 5px; background: rgba(15, 12, 9, .7); }
.style-switch[hidden] { display: none; }
.style-label { padding: 0 8px; font-size: .85rem; color: var(--muted); }
.seg { min-height: 30px; padding: 4px 10px; cursor: pointer; font: 600 .85rem/1 var(--display); color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 3px; }
.seg:hover { color: var(--text); }
.seg[aria-checked="true"] { color: var(--gold-hi); border-color: var(--gold-deep); background: linear-gradient(180deg, rgba(226, 191, 106, .2), rgba(226, 191, 106, .05)); }
.seg:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.starter-style { display: flex; justify-content: center; margin: -6px 0 14px; }
@media (max-width: 520px) {
  .editor-bar .style-switch { flex-basis: 100%; justify-content: space-between; }
  .starter-style .style-switch { max-width: 100%; overflow-x: auto; }
}
.starter-style { flex-wrap: wrap; gap: 8px 12px; }

/* ---------- addon profiles ---------- */
.addon-chips { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 4px; padding: 0; }
.addon-chip {
  padding: 1px 7px; font-size: .8rem; font-weight: 600; color: #cfe3ff;
  border: 1px solid rgba(127, 159, 240, .55); border-radius: 3px; background: rgba(60, 80, 140, .2);
}
.detail-head .addon-chips { justify-content: center; }
.addon-field { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 8px; }
.addon-field legend { padding: 0; margin-bottom: 4px; font-size: .9rem; font-weight: 600; color: var(--muted); }
.addon-field > p { margin: 0; }
.addon-rows { display: grid; gap: 10px; }
.addon-row { display: grid; gap: 6px; padding: 8px; border: 1px solid rgba(110, 82, 41, .5); border-radius: 4px; background: rgba(15, 12, 9, .5); }
.addon-row.is-over, .addon-total.is-over { border-color: var(--ember); color: var(--ember); }
.addon-row-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 12px; }
.addon-name { flex: 1 1 200px; }
.addon-size { padding-bottom: 8px; }
.addon-remove { padding-bottom: 8px; }
.addon-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.addon-foot p { margin: 0; }
.addons-detail { max-width: 900px; margin: 22px auto 0; }
.addons-detail > summary { cursor: pointer; text-align: center; font-weight: 600; color: var(--gold); font-variant: small-caps; letter-spacing: .03em; font-size: 1.05rem; }
.addons-detail > summary:hover { color: var(--gold-hi); }
.addons-detail > p { text-align: center; }
.addon-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 12px; }
.addon-item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 6px; }
.addon-item-head .btn { margin-inline-start: auto; }
.addon-text {
  max-height: 9em; overflow: auto; margin: 0; padding: 8px 10px; white-space: pre-wrap; word-break: break-all;
  background: #0b0907; border: 1px solid #5c4321; border-radius: 3px;
}
.seg { white-space: nowrap; }
.style-label { white-space: nowrap; }

/* ---------- addon windows from SavedVariables (Beta) ---------- */
:root { --c-addon: #4fd8c4; }
.cat-addon { --c: var(--c-addon); }
.frame.addon-frame { border-style: dashed; background: color-mix(in srgb, var(--c-addon) 16%, rgba(0, 0, 0, .45)); }
.frame.addon-frame.is-approx { border-style: dotted; }
.addon-badge {
  position: absolute; top: 2px; inset-inline-start: 2px; padding: 0 5px; font: 600 11px/1.5 var(--serif);
  color: #072a26; background: var(--c-addon); border-radius: 2px; pointer-events: none;
}
.thumb-stage .addon-badge { display: none; }
.beta-badge {
  display: inline-block; padding: 0 6px; font: 700 .8rem/1.6 var(--serif); letter-spacing: .04em; vertical-align: middle;
  color: #072a26; background: var(--c-addon); border-radius: 3px;
}
.sv-panel { gap: 8px; }
.sv-file { color: var(--muted); }
.sv-file input[type=file] { color: var(--text); font: inherit; font-size: .9rem; max-width: 100%; }
.sv-file input[type=file]::file-selector-button {
  margin-inline-end: 10px; padding: 5px 12px; cursor: pointer; font: 600 .9rem/1.2 var(--display); color: #f2dfb2;
  background: linear-gradient(180deg, #4a3826, #21180f); border: 1px solid #a07c3c; border-radius: 4px;
}
.sv-steps { margin: 0; padding-inline-start: 1.4em; color: var(--muted); }
.sv-steps li { margin: 2px 0; }
.sv-busy::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-inline-end: 8px; vertical-align: -1px; border: 2px solid var(--gold-deep); border-top-color: var(--gold-hi); border-radius: 50%; animation: sv-spin .8s linear infinite; }
@keyframes sv-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sv-busy::before { animation: none; } }
.addon-legend { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 10px auto 0; color: var(--muted); }
.legend-swatch { width: 16px; height: 10px; border: 2px dashed var(--c-addon); background: color-mix(in srgb, var(--c-addon) 16%, transparent); }
.sv-detail { max-width: 760px; margin: 14px auto 0; }
.sv-detail > summary { cursor: pointer; text-align: center; color: var(--gold); font-weight: 600; }
.sv-detail > summary:hover { color: var(--gold-hi); }
.sv-apply { display: grid; gap: 8px; margin-top: 8px; }
.sv-result { display: grid; gap: 6px; }
.sv-result p { margin: 0; }
.share-frames { display: grid; gap: 2px; }
.share-frames p { margin: 0; }


/* ---------- compact, readable layout across resolutions ---------- */
:root { --gap-1: 4px; --gap-2: 8px; --gap-3: 12px; --gap-4: 16px; --gap-5: 24px; --gap-6: 32px; }
main { padding: var(--gap-5) var(--gap-4) var(--gap-6); }
main[data-page=editor] { padding-top: var(--gap-3); }
.hero { margin: 0 auto var(--gap-4); padding-bottom: var(--gap-5); gap: var(--gap-3); }
.hero > div { gap: var(--gap-2); }
.lead { line-height: 1.55; }
.gallery-section { margin: var(--gap-2) 0 var(--gap-5); }
.section-head { margin-bottom: var(--gap-2); }
.grid { gap: var(--gap-4); }
.card-body { padding: var(--gap-2) var(--gap-1) var(--gap-1); }
.card h3 { font-size: 1.1rem; }
.support { margin-top: var(--gap-6); }
main[data-page=gallery] .support { margin-top: var(--gap-6); }
.foot { padding-top: var(--gap-6); }
.small, .muted.small { font-size: .875rem; line-height: 1.5; }
p, li, dd { max-width: 75ch; }
.hero p, .section-head p, .gallery-section > p, .foot, .drop-panel p, .dialog p, .detail-head p { margin-inline: auto; }
/* small-caps only for short headings and labels; running text stays plain */
.how h3, .card h3, .dialog-head h2, .side h2 { font-variant: normal; letter-spacing: 0; }

/* editor: one toolbar row that stays reachable, the stage right under it */
.editor-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.editor-bar {
  position: sticky; top: var(--header-h, 58px); z-index: 8; margin: 0 calc(-1 * var(--gap-2)) var(--gap-2); padding: var(--gap-2);
  background: linear-gradient(180deg, rgba(27, 21, 16, .97), rgba(21, 17, 13, .97)); border-bottom: 1px solid rgba(165, 122, 44, .4);
}
.bar-pick { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; font-size: .875rem; color: var(--muted); }
.bar-pick .bar-select .combo-input { min-height: 36px; padding-top: 4px; padding-bottom: 4px; font-size: .9rem; }
.sample-note { margin: 0 0 var(--gap-2); }
.editor-main { gap: var(--gap-4); }
.stage-col { gap: var(--gap-2); }
.sel-bar { margin: 0; }
.side {
  position: sticky; top: calc(var(--header-h, 58px) + var(--bar-h, 56px) + 8px);
  max-height: calc(100vh - var(--header-h, 58px) - var(--bar-h, 56px) - 24px); padding: 0 6px 10px;
}
.side-head {
  position: sticky; top: 0; z-index: 2; margin: 0 -6px var(--gap-2); padding: var(--gap-2) 6px var(--gap-2);
  background: linear-gradient(180deg, #2c2319, #261e16); border-bottom: 1px solid rgba(110, 82, 41, .5);
}
.side-head h2 { margin: 2px 0 0; }
.side-head p { margin: 4px 0 0; }
@media (max-width: 900px) { .side { position: static; max-height: none; } }

/* short screens: only the site header stays pinned */
@media (max-height: 700px) {
  .filter-bar, .editor-bar { position: static; }
  .side { position: static; max-height: 70vh; }
}
.editor-bar { gap: var(--gap-2); }
.editor-bar .btn { min-height: 34px; padding: 5px 11px; font-size: .9rem; }
.editor-bar-end { gap: 6px; }
@media (max-width: 1500px) {
  .bar-pick > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* ---------- editor side panel: inspector on top, grouped list below ---------- */
.editor-main { grid-template-columns: minmax(0, 1fr) 360px; }
.editor-main.side-rail { grid-template-columns: minmax(0, 1fr) 36px; }
.editor-main .side {
  --side-top: calc(var(--header-h, 58px) + var(--bar-h, 56px) + 8px);
  position: sticky; top: var(--side-top); max-height: calc(100vh - var(--side-top) - 12px);
  display: flex; flex-direction: column; padding: 0; overflow: hidden;
  border: 1px solid rgba(165, 122, 44, .7); border-image: none; border-radius: 4px;
  box-shadow: 0 0 0 1px #000, 0 10px 28px rgba(0, 0, 0, .55);
}
.side-top { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-bottom: 1px solid rgba(110, 82, 41, .5); background: linear-gradient(180deg, #2c2319, #261e16); }
.side-title { margin: 0; flex: 1; font-size: 1.1rem; }
.rail-btn, .sheet-close {
  flex: none; width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer; color: var(--gold);
  background: linear-gradient(180deg, #2a2017, #17120d); border: 1px solid #7a5b2c; border-radius: 3px; font: 700 1.2rem/1 var(--serif);
}
.rail-btn:hover, .sheet-close:hover { color: var(--gold-hi); border-color: var(--gold); }
.rail-btn:focus-visible, .sheet-close:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.rail-icon { width: 9px; height: 9px; border-top: 2px solid currentColor; border-right: 2px solid currentColor; transform: rotate(45deg); margin-inline-end: 3px; }
:root[dir=rtl] .rail-icon { transform: rotate(-135deg); }
.rail-label { display: none; }
.sheet-close { display: none; }
.side-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 8px 10px; }
.side-search { min-height: 36px; padding: 5px 10px; }
.side-defaults { font-size: .875rem; white-space: nowrap; }
.inspector {
  flex: none; overflow: auto; padding: 8px 10px 10px; max-height: calc((100vh - var(--side-top)) * .6);
  border-top: 1px solid rgba(110, 82, 41, .5); border-bottom: 2px solid rgba(165, 122, 44, .6);
  background: rgba(15, 12, 9, .45); scrollbar-color: var(--bronze) transparent;
}
.insp-hint { margin: 2px 0; }
.insp-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.insp-name { margin: 0; font-size: 1.1rem; font-variant: normal; overflow-wrap: anywhere; }
.insp-info { margin: 0 0 8px; overflow-wrap: anywhere; }
.insp-multi p { margin: 4px 0 0; }
.insp-addon p { margin: 4px 0 0; }
.insp-xy { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
label.inline { flex-direction: row; align-items: center; gap: 6px; }
label.inline > span { flex: none; }
.inspector input[type=number], .inspector .combo-input { min-height: 34px; padding-top: 4px; padding-bottom: 4px; }
.insp-anchor { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; margin-top: 8px; align-items: start; }
.insp-anchor-side { display: grid; gap: 6px; min-width: 0; }
.insp-anchor-side .row { gap: 6px; flex-wrap: nowrap; }
.insp-anchor-side .btn.small { padding: 4px 9px; min-height: 30px; white-space: nowrap; }
.pt-grid { display: grid; grid-template-columns: repeat(3, 26px); gap: 3px; direction: ltr; padding: 4px; background: var(--well); border: 1px solid #5c4321; border-radius: 3px; box-shadow: inset 0 2px 5px rgba(0, 0, 0, .8); }
.pt { width: 26px; height: 26px; display: grid; place-items: center; cursor: pointer; background: #1d170f; border: 1px solid #5c4321; border-radius: 3px; padding: 0; }
.pt span { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.pt:hover { border-color: var(--gold); }
.pt[aria-pressed=true] { background: rgba(242, 180, 64, .22); border-color: var(--ring); box-shadow: 0 0 8px rgba(255, 170, 60, .45); }
.pt[aria-pressed=true] span { background: var(--gold-hi); box-shadow: 0 0 6px var(--ring); }
.pt:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.inspector .sel-bar { margin: 8px 0 0; padding: 6px; gap: 6px; }
.inspector .sel-bar[data-n="1"] .sel-count, .inspector .sel-bar[data-n="1"] .sel-group:not(:nth-of-type(3)) { display: none; }
.inspector .sel-bar .btn.small { padding: 4px 8px; min-height: 30px; }
.inspector summary { cursor: pointer; color: var(--gold); font: 600 .95rem/1.3 var(--display); padding: 6px 0; list-style: none; }
.inspector summary::-webkit-details-marker { display: none; }
.inspector summary::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-inline-end: 8px; border-top: 2px solid currentColor; border-right: 2px solid currentColor; transform: rotate(45deg); transition: transform .12s; }
:root[dir=rtl] .inspector summary::before { transform: rotate(-135deg); }
.inspector details[open] > summary::before { transform: rotate(135deg); }
.inspector summary:hover { color: var(--gold-hi); }
.inspector summary:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.insp-settings { margin-top: 6px; border-top: 1px solid rgba(110, 82, 41, .45); }
.set-box { display: grid; gap: 6px; padding-bottom: 4px; }
.set-row.inline { justify-content: space-between; }
.set-row.inline > input, .set-row.inline > .combo { width: 55%; flex: none; }
.adv { margin-top: 4px; }
.adv summary { font-size: .875rem; color: var(--muted); }
.adv p { margin: 0 0 6px; }
.adv-table table.settings { font-size: .875rem; }
.side-body { flex: 1 1 auto; min-height: 120px; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: var(--bronze) transparent; }
.side-empty { padding: 10px 12px; margin: 0; }
.group + .group { border-top: 1px solid rgba(110, 82, 41, .4); }
.group-head {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 10px; cursor: pointer; text-align: start;
  background: linear-gradient(180deg, rgba(44, 35, 25, .9), rgba(30, 24, 17, .9)); border: 0; color: var(--gold); font: 600 .95rem/1.3 var(--display);
}
.group-head:hover { color: var(--gold-hi); }
.group-head:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.group-chev { width: 7px; height: 7px; flex: none; border-top: 2px solid currentColor; border-right: 2px solid currentColor; transform: rotate(45deg); transition: transform .12s; }
:root[dir=rtl] .group-chev { transform: rotate(-135deg); }
.group.is-open .group-chev { transform: rotate(135deg); }
.group-count { color: var(--muted); font-weight: 500; font-size: .875rem; }
.group-head .beta-badge { margin-inline-start: auto; }
.row-list { list-style: none; margin: 0; padding: 0; }
.row-btn {
  display: flex; align-items: center; gap: 4px; width: 100%; min-height: 32px; padding: 3px 10px; cursor: pointer; text-align: start;
  color: var(--text); font: inherit; font-size: 1rem; background: none; border: 0; border-inline-start: 3px solid transparent;
}
.row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: .875rem; }
.row-moved { margin-inline-start: auto; color: var(--gold); font-size: .875rem; flex: none; }
.row-btn:hover, .row-btn.is-hover { color: var(--gold-hi); background: linear-gradient(90deg, rgba(226, 191, 106, .14), transparent); }
:root[dir=rtl] .row-btn:hover, :root[dir=rtl] .row-btn.is-hover { background: linear-gradient(270deg, rgba(226, 191, 106, .14), transparent); }
.row-btn.is-active { box-shadow: inset 0 0 0 2px var(--ring); }
.row-btn.is-selected { color: var(--gold-hi); background: rgba(242, 180, 64, .16); border-inline-start-color: var(--ring); }
.row-btn.is-primary { background: rgba(242, 180, 64, .26); }
.row-btn:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.frame.is-hover:not(.is-selected) { box-shadow: 0 0 0 2px var(--ring), 0 0 14px rgba(255, 170, 60, .55); }

@media (min-width: 901px) {
  .editor-main.side-rail .side { min-height: 150px; align-items: center; }
  .editor-main.side-rail .side > :not(.side-top):not(.rail-label) { display: none; }
  .editor-main.side-rail .side-top { padding: 4px; border: 0; background: none; }
  .editor-main.side-rail .side-title { display: none; }
  .editor-main.side-rail .rail-label { display: block; order: 2; writing-mode: vertical-rl; color: var(--muted); font-size: .875rem; padding: 8px 0; }
  .editor-main.side-rail .rail-icon { transform: rotate(-135deg); margin-inline-end: 0; margin-inline-start: 3px; }
  :root[dir=rtl] .editor-main.side-rail .rail-icon { transform: rotate(45deg); }
}
@media (max-height: 700px) and (min-width: 901px) {
  .editor-main .side { --side-top: calc(var(--header-h, 58px) + 8px); }
}
.side-fab { display: none; }
@media (max-width: 900px) {
  .editor-main, .editor-main.side-rail { grid-template-columns: minmax(0, 1fr); }
  .editor-main .side {
    position: fixed; inset-inline: 0; bottom: 0; top: auto; z-index: 40; height: 55vh; max-height: 55vh; border-radius: 10px 10px 0 0;
    background: linear-gradient(180deg, var(--stone-2), var(--stone-1) 60%, #1a140f);
    transform: translateY(105%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s;
  }
  .editor-main.sheet-open .side { transform: none; visibility: visible; transition: transform .2s ease; }
  .inspector { max-height: 60%; }
  .rail-btn { display: none; }
  .sheet-close { display: grid; }
  .side-fab { display: inline-flex; position: fixed; inset-inline-end: 14px; bottom: 14px; z-index: 39; box-shadow: 0 4px 14px rgba(0, 0, 0, .7); }
  .editor-main.sheet-open ~ .side-fab { display: none; }
}
@media (prefers-reduced-motion: reduce) { .editor-main .side, .group-chev { transition: none; } }
.inspector .sel-bar[data-n="1"] { border: 0; background: none; box-shadow: none; padding: 0; margin-top: 6px; }
.inspector .sel-bar[data-n="1"] .btn.small { min-height: 28px; padding: 2px 8px; }
.side-top { padding-block: 4px; }
.side-tools { padding-block: 6px; }
.side-search { min-height: 34px; }

/* ---------- type-ahead combobox (replaces <select>) ---------- */
.combo { position: relative; display: inline-block; min-width: 0; max-width: 100%; }
label > .combo, .insp-anchor-side .combo { display: block; }
.combo .combo-input {
  cursor: pointer; text-overflow: ellipsis; padding-inline-end: 36px; border-color: #7a5b2c;
  background:
    url("../img/chevron.svg") right 12px center / 14px 10px no-repeat,
    linear-gradient(180deg, rgba(255, 232, 170, .07), transparent 55%),
    linear-gradient(180deg, #2a2017, #17120d);
  box-shadow: inset 0 1px 0 rgba(255, 232, 170, .14), 0 0 0 1px #000, 0 2px 4px rgba(0, 0, 0, .5);
}
.combo .combo-input:hover { border-color: var(--gold); box-shadow: inset 0 1px 0 rgba(255, 232, 170, .2), 0 0 0 1px #000, 0 2px 4px rgba(0, 0, 0, .5), 0 0 10px rgba(255, 176, 72, .3); }
.combo .combo-input:focus-visible, .combo.is-open .combo-input { outline: 2px solid var(--ring); outline-offset: 0; cursor: text; box-shadow: inset 0 1px 0 rgba(255, 232, 170, .2), 0 0 0 1px #000, 0 0 12px rgba(255, 176, 72, .45); }
.combo .combo-input:disabled { opacity: .55; cursor: not-allowed; }
.combo-list {
  position: fixed; z-index: 200; margin: 0; padding: 3px; list-style: none; overflow-y: auto; overscroll-behavior: contain;
  width: max-content; max-width: min(26rem, calc(100vw - 8px)); scrollbar-color: var(--bronze) transparent;
  background: #1a140e; border: 1px solid var(--gold-deep); border-radius: 3px; box-shadow: 0 0 0 1px #000, 0 10px 24px rgba(0, 0, 0, .7);
}
.combo-option { padding: 6px 10px; min-height: 32px; display: flex; align-items: center; cursor: pointer; color: var(--text); font-size: .95rem; border-radius: 2px; overflow-wrap: anywhere; }
.combo-option[aria-selected=true] { color: var(--gold-hi); font-weight: 600; }
.combo-option[aria-selected=true]::before { content: "✓"; margin-inline-end: 6px; color: var(--gold); }
.combo-option.is-active, .combo-option:hover { background: rgba(242, 180, 64, .2); box-shadow: inset 0 0 0 1px var(--ring); }
.combo-empty { color: var(--muted); cursor: default; font-style: italic; }
.combo-empty:hover { background: none; box-shadow: none; }
@media (max-width: 700px), (pointer: coarse) {
  .combo .combo-input { min-height: 36px; }
  .combo-option { min-height: 40px; }
}

/* home: chip rows and card grids centred */
.filter-row { justify-content: center; }
.filter-row .chip-classes, .filter-bar .chip-specs { justify-content: center; flex-wrap: wrap; overflow: visible; }
.starter-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 300px)); justify-content: center; }

/* ---------- home: three-step builder in one centred column ---------- */
.home-col { max-width: 1100px; margin-inline: auto; }
.home-col .hero { margin-bottom: var(--gap-3); padding-bottom: var(--gap-3); gap: var(--gap-2); }
.home-col .hero h1 { font-size: clamp(1.6rem, 3.6vw, 2.4rem); margin: 0; }
.builder { display: grid; gap: var(--gap-2); justify-items: center; }
.builder .chip-row { justify-content: center; flex-wrap: wrap; overflow: visible; }
.step-title { display: flex; align-items: center; gap: 8px; margin: var(--gap-2) 0 0; font-size: 1.05rem; font-variant: normal; }
.step-num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--gold-deep); color: var(--gold-hi); font: 700 .85rem/1 var(--serif); background: rgba(226, 191, 106, .12); }
.builder .starter-style { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap-2) var(--gap-4); margin: 0; }
.builder-preview { width: 100%; max-width: min(100%, max(480px, calc((100vh - 400px) * 16 / 9))); margin: 0; }
.builder-note { margin: 0; text-align: center; max-width: 70ch; }
.builder-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap-3); }
.builder-actions .btn { min-height: 44px; }
.copy-done { text-align: center; min-height: 0; }
.copy-done p { margin: 4px auto; }
.copy-ok { color: var(--gold-hi); }
.home-invite { text-align: center; margin: var(--gap-5) auto; }
.shared-filter { position: static; box-shadow: none; margin-inline: 0; background: none; border-bottom: 0; }
.shared-status { text-align: center; }
@media (max-width: 520px) {
  .builder-actions { flex-direction: column; align-self: stretch; }
  .builder-actions .btn { width: 100%; justify-content: center; }
}
.home-col .hero { padding-bottom: 0; margin-bottom: 0; }
.home-col .hero::after { display: none; }
.home-col .hero .lead { font-size: 1rem; }
.builder-preview { max-width: min(100%, max(520px, calc((100vh - 470px) * 16 / 9))); }
.builder-step3 { width: 100%; display: grid; gap: var(--gap-1); justify-items: center; }
@media (min-width: 521px) {
  /* the buttons stay on the first screen while the builder is in view */
  .builder-step3 { position: sticky; bottom: 0; z-index: 5; padding: var(--gap-2) 0; background: linear-gradient(180deg, transparent, rgba(21, 17, 13, .96) 30%); }
}
.builder .starter-style > .style-switch { flex-wrap: wrap; justify-content: center; max-width: 100%; }
.builder .starter-style > * { max-width: 100%; }
