/* ============================================================
   Vexillum Studio — ceremonial crispness
   parchment & ink · brass hairlines · gallery-mounted flags
   ============================================================ */

:root {
  --parchment: #f4efe4;
  --parchment-2: #ede6d6;
  --card: #faf7ef;
  --ink: #262419;
  --ink-soft: #5c5744;
  --ink-faint: #8b8468;
  --brass: #b08d2e;
  --brass-soft: #d8c48a;
  --crimson: #bf0a30;
  --crimson-deep: #8f0722;
  --navy: #1f2a44;
  --felt: #232a3a;
  --felt-2: #2b3347;
  --hairline: rgba(38, 36, 25, 0.16);
  --shadow-1: 0 1px 2px rgba(31, 26, 10, 0.08), 0 4px 14px rgba(31, 26, 10, 0.08);
  --shadow-2: 0 2px 6px rgba(31, 26, 10, 0.12), 0 12px 34px rgba(31, 26, 10, 0.16);
  --r: 8px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--parchment);
  overflow: hidden;
}
button { font-family: inherit; color: inherit; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------------- top bar ---------------- */
.topbar {
  height: 58px;
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  background: linear-gradient(var(--card), var(--parchment-2));
  border-bottom: 1px solid var(--hairline);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset;
  position: relative; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); }
.brand-flag { width: 26px; height: 26px; }
.brand-words { display: flex; flex-direction: column; line-height: 1.02; }
.brand-name { font-family: var(--serif); font-size: 19px; font-weight: 700; letter-spacing: 0.02em; }
.brand-sub { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.24em; color: var(--brass); }

.flag-title { flex: 1; display: flex; align-items: baseline; justify-content: center; gap: 10px; min-width: 0; }
#flagName {
  font-family: var(--serif); font-style: italic; font-size: 19px;
  color: var(--ink); background: transparent; border: none;
  border-bottom: 1px dashed transparent;
  text-align: center; min-width: 60px; max-width: 320px; width: auto;
  padding: 2px 6px; transition: border-color .15s;
}
#flagName:hover, #flagName:focus { border-bottom-color: var(--brass); outline: none; }
.flag-title-hint { font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-faint); }

.topbar-acts { display: flex; align-items: center; gap: 8px; }
.topbar-sep { width: 1px; height: 24px; background: var(--hairline); }

.icon-btn {
  width: 34px; height: 34px; border-radius: var(--r);
  border: 1px solid var(--hairline); background: var(--card);
  font-size: 16px; cursor: pointer; display: grid; place-items: center;
  transition: transform .1s, box-shadow .15s, border-color .15s;
}
.icon-btn:hover { border-color: var(--brass); box-shadow: var(--shadow-1); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0); }
.icon-btn.dim { opacity: .38; }
.icon-btn.on { border-color: var(--brass); color: var(--brass); }

.btn {
  border: 1px solid var(--hairline); background: var(--card);
  border-radius: var(--r); padding: 8px 14px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  transition: transform .1s, box-shadow .15s, border-color .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--brass); box-shadow: var(--shadow-1); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(160deg, var(--crimson), var(--crimson-deep));
  border-color: var(--crimson-deep); color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,.25);
}
.btn.primary:hover { box-shadow: 0 2px 8px rgba(191,10,48,.4), var(--shadow-1); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; justify-content: center; }
.btn .dice { font-size: 15px; }
.btn.surprise { border-color: var(--brass-soft); }
.btn em { font-style: normal; font-weight: 400; font-size: 11px; opacity: .6; display: block; }
.btn[disabled] { opacity: .5; cursor: wait; }

.mode-seg {
  display: flex; border: 1px solid var(--hairline); border-radius: var(--r);
  overflow: hidden; background: var(--parchment-2);
}
.mode-btn {
  border: none; background: transparent; padding: 8px 12px; font-size: 12.5px;
  font-weight: 600; cursor: pointer; color: var(--ink-soft);
}
.mode-btn + .mode-btn { border-left: 1px solid var(--hairline); }
.mode-btn.on { background: var(--navy); color: #f3ead2; }

.drawer-toggle { display: none; }

/* ---------------- studio layout ---------------- */
.studio { display: flex; height: calc(100vh - 58px); }

.sidebar {
  width: 330px; flex: 0 0 330px;
  background: var(--parchment);
  border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column;
  z-index: 20;
}
.tabs {
  display: flex; border-bottom: 1px solid var(--hairline);
  background: var(--parchment-2);
}
.tabs [role="tab"] {
  flex: 1; padding: 11px 4px; border: none; background: transparent;
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-faint); cursor: pointer; border-bottom: 2px solid transparent;
}
.tabs [role="tab"].active { color: var(--ink); border-bottom-color: var(--crimson); }
.tab-body { flex: 1; overflow-y: auto; padding: 14px; scrollbar-width: thin; }

.panel-sec { margin-bottom: 22px; }
.panel-h {
  font-family: var(--serif); font-size: 15px; font-weight: 700; margin: 0 0 4px;
  padding-bottom: 5px; border-bottom: 1px solid var(--brass-soft);
  color: var(--ink);
}
.panel-sub {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .16em;
  color: var(--brass); margin: 14px 0 7px;
}
.panel-note { font-size: 12px; color: var(--ink-soft); margin: 2px 0 10px; }
.empty-note { font-size: 12.5px; color: var(--ink-faint); font-style: italic; padding: 8px 2px; }

/* cards / grids */
.grid { display: grid; gap: 9px; }
.grid-flags { grid-template-columns: repeat(3, 1fr); }
.grid-emblems { grid-template-columns: repeat(4, 1fr); }

.card {
  border: 1px solid var(--hairline); border-radius: var(--r);
  background: var(--card); padding: 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  transition: transform .12s, box-shadow .15s, border-color .15s;
  position: relative;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-1); border-color: var(--brass); }
.card:active { transform: translateY(0); }
.card.on { border-color: var(--crimson); box-shadow: 0 0 0 1px var(--crimson) inset; }
.card-thumb { display: block; line-height: 0; border-radius: 3px; overflow: hidden; }
.card-thumb svg { display: block; width: 100%; height: auto; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.emb-thumb { color: var(--ink); padding: 4px; }
.emb-thumb svg { box-shadow: none; }
.card-name { font-size: 10.5px; font-weight: 600; text-align: center; line-height: 1.2; color: var(--ink-soft); }
.card-note { font-size: 9.5px; color: var(--ink-faint); text-align: center; line-height: 1.2; }
.card[disabled] { opacity: .4; cursor: not-allowed; }
.saved-card { cursor: pointer; }
.saved-del {
  position: absolute; top: 3px; right: 3px; width: 18px; height: 18px;
  border-radius: 50%; border: none; background: rgba(38,36,25,.65); color: #fff;
  font-size: 12px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .15s;
}
.saved-card:hover .saved-del { opacity: 1; }

/* colour slots */
.slots { display: flex; flex-wrap: wrap; gap: 7px; margin: 8px 0; }
.slot {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  border: 1px solid var(--hairline); background: var(--card);
  border-radius: var(--r); padding: 5px 8px 5px 5px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  text-align: left;
}
.slot:hover { border-color: var(--brass); box-shadow: var(--shadow-1); }
.slot.wide { width: 100%; }
.slot-chip {
  width: 26px; height: 26px; border-radius: 6px; flex: 0 0 26px;
  background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0,0,0,.18), 0 1px 2px rgba(0,0,0,.12);
}
.slot-meta { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.slot-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-faint); }
.slot-name { font-size: 11.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }

/* sliders & toggles */
.params { margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.slider-row {
  display: grid; grid-template-columns: 76px 1fr 40px; align-items: center; gap: 8px;
  font-size: 12px;
}
.slider-label { color: var(--ink-soft); }
.slider-val { font-size: 11px; color: var(--ink-faint); text-align: right; font-variant-numeric: tabular-nums; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, var(--brass), var(--brass-soft));
  outline: none; cursor: pointer; width: 100%;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--brass);
  box-shadow: 0 1px 3px rgba(0,0,0,.25); cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--brass);
  box-shadow: 0 1px 3px rgba(0,0,0,.25); cursor: grab;
}
.toggle-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-soft); cursor: pointer; }
.toggle-row.small { font-size: 12px; }
.toggle-row input { accent-color: var(--crimson); width: 15px; height: 15px; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-btn {
  border: 1px solid var(--hairline); border-radius: 6px; background: var(--card);
  padding: 6px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
  color: var(--ink-soft);
}
.seg-btn:hover { border-color: var(--brass); }
.seg-btn.on { background: var(--navy); border-color: var(--navy); color: #f3ead2; }

/* layers */
.layers { display: flex; flex-direction: column; gap: 6px; }
.layer-row {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--hairline); border-radius: var(--r);
  background: var(--card); padding: 6px 8px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.layer-row:hover { border-color: var(--brass); }
.layer-row.on { border-color: var(--crimson); box-shadow: 0 0 0 1px var(--crimson) inset; }
.layer-thumb { width: 36px; height: 30px; display: grid; place-items: center; flex: 0 0 36px; }
.layer-thumb svg { max-width: 36px; max-height: 30px; border-radius: 2px; }
.layer-name { flex: 1; font-size: 12.5px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-acts { display: flex; gap: 2px; }
.layer-acts button {
  border: none; background: transparent; width: 24px; height: 24px;
  border-radius: 5px; font-size: 12px; cursor: pointer; color: var(--ink-faint);
}
.layer-acts button:hover { background: var(--parchment-2); color: var(--ink); }
.field-row .layer-name { font-weight: 700; }

/* ---------------- stage ---------------- */
.stage {
  flex: 1; position: relative; overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 30%, var(--felt-2), var(--felt) 70%, #1a2030);
  display: flex; flex-direction: column;
}
.stage::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 4px 4px;
}
.stage-flat { position: absolute; inset: 0; display: flex; }
.flag-frame {
  position: relative; margin: auto;
  padding: 4.2%;
  background: linear-gradient(160deg, #f8f4e8, #efe8d4);
  border: 1px solid rgba(0,0,0,.28);
  box-shadow:
    0 0 0 5px #f8f4e8,
    0 0 0 6px var(--brass-soft),
    0 0 0 9px rgba(0,0,0,.35),
    0 24px 60px rgba(0,0,0,.5);
}
.flag-wrap { width: 100%; height: 100%; position: relative; outline: none; }
.flag-wrap:focus-visible { box-shadow: 0 0 0 2px var(--brass); }
.flag-svg { position: absolute; inset: 0; }
.flag-svg svg { user-select: none; -webkit-user-drag: none; }
.stage.dragging .flag-svg svg { cursor: grabbing !important; }

/* guides */
.guides { position: absolute; inset: 0; pointer-events: none; }
.guide { position: absolute; background: rgba(252, 209, 22, 0.85); opacity: 0; transition: opacity .1s; }
.guide.on { opacity: 1; }
.guide.gv, .guide.gv2 { width: 1px; top: 0; bottom: 0; left: 50%; }
.guide.gh, .guide.gh2 { height: 1px; left: 0; right: 0; top: 50%; }

/* selection gizmo (fills the flag area) */
.gizmo { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.g-box {
  position: absolute;
  border: 1.5px dashed rgba(255, 235, 160, 0.95);
  box-shadow: 0 0 0 1px rgba(0,0,0,.35);
  border-radius: 2px;
}
@keyframes ants { to { border-color: rgba(252,209,22,.95); } }
.g-knob {
  position: absolute; width: 15px; height: 15px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--brass);
  transform: translate(-50%, -50%); pointer-events: auto; cursor: grab;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.g-rotate { cursor: alias; }
.g-scale { cursor: nwse-resize; }
.g-label {
  position: absolute; transform: translate(-50%, -100%);
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: #ffe9a8; text-shadow: 0 1px 3px rgba(0,0,0,.7); pointer-events: none;
  white-space: nowrap;
}

/* inspector (floating card) */
.inspector {
  position: absolute; left: 14px; bottom: 14px; width: 236px; z-index: 12;
  background: var(--card); border: 1px solid var(--hairline); border-radius: 10px;
  box-shadow: var(--shadow-2); padding: 10px;
}
.insp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.insp-thumb { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 34px; }
.insp-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.insp-title strong { font-size: 13px; }
.insp-title span { font-size: 10.5px; color: var(--ink-faint); }
.insp-x { border: none; background: transparent; font-size: 16px; cursor: pointer; color: var(--ink-faint); padding: 2px 6px; }
.insp-x:hover { color: var(--ink); }
.insp-body { display: flex; flex-direction: column; gap: 6px; }
.insp-acts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.chip {
  border: 1px solid var(--hairline); border-radius: 20px; background: var(--parchment);
  font-size: 11px; font-weight: 600; padding: 4px 9px; cursor: pointer;
  color: var(--ink-soft);
}
.chip:hover { border-color: var(--brass); color: var(--ink); }
.chip.on { border-color: var(--crimson); color: var(--crimson); }
.chip.danger:hover { border-color: var(--crimson); color: var(--crimson); }

/* wisdom card */
.wisdom {
  position: absolute; right: 14px; bottom: 14px; width: 252px; z-index: 12;
  background: linear-gradient(170deg, #fbf8ef, #f1e9d4);
  border: 1px solid var(--brass-soft); border-radius: 10px;
  box-shadow: var(--shadow-2); padding: 10px 12px;
}
.wisdom-head { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.wisdom-head strong { font-family: var(--serif); font-size: 13.5px; flex: 1; }
.wisdom-badge { color: var(--brass); }
.wisdom-hide { border: none; background: transparent; font-size: 15px; cursor: pointer; color: var(--ink-faint); }
.wisdom-line { font-size: 11.8px; line-height: 1.45; color: var(--ink-soft); margin: 5px 0; }
.wisdom-line.praise { color: #4a6b2f; }
.wisdom-more { margin-top: 6px; font-size: 11px; }
.wisdom-more summary { cursor: pointer; color: var(--brass); font-weight: 700; font-size: 11px; }
.wisdom-more ol { margin: 6px 0 2px; padding-left: 17px; }
.wisdom-more li { font-size: 10.8px; line-height: 1.4; color: var(--ink-soft); margin-bottom: 3px; }

/* pole view */
.stage-pole { position: absolute; inset: 0; display: flex; flex-direction: column; }
#waveCanvas { flex: 1; width: 100%; height: 100%; display: block; }
.pole-controls {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(20, 26, 40, 0.6); backdrop-filter: blur(6px);
  border-radius: 24px; padding: 8px 18px;
}
.wind { display: flex; align-items: center; gap: 10px; color: #e8dfc8; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.wind input[type="range"] { width: 150px; }

/* ---------------- color picker popover ---------------- */
.cpop {
  position: absolute; width: 284px; z-index: 100;
  background: var(--card); border: 1px solid var(--hairline); border-radius: 10px;
  box-shadow: var(--shadow-2); padding: 10px;
  opacity: 0; pointer-events: none; transform: translateY(4px) scale(.98);
  transition: opacity .14s, transform .14s;
  max-height: min(560px, 86vh); overflow-y: auto;
}
.cpop.open { opacity: 1; pointer-events: auto; transform: none; }
.cpop.picked { animation: cpop-pulse .18s; }
@keyframes cpop-pulse { 50% { transform: scale(1.015); } }
.cpop-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cpop-title { font-family: var(--serif); font-size: 13.5px; font-weight: 700; }
.cpop-close { border: none; background: transparent; font-size: 17px; cursor: pointer; color: var(--ink-faint); }
.cpop-picker { display: flex; gap: 8px; height: 130px; }
.cpop-sv {
  flex: 1; border-radius: 6px; position: relative; cursor: crosshair;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.15);
}
.cpop-sv-cursor {
  position: absolute; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 1px 3px rgba(0,0,0,.4);
  transform: translate(-50%, -50%); pointer-events: none;
}
.cpop-hue {
  width: 16px; border-radius: 6px; position: relative; cursor: pointer;
  background: linear-gradient(to bottom, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.15);
}
.cpop-hue-cursor {
  position: absolute; top: 50%; left: -2px; right: -2px; height: 8px;
  border: 2px solid #fff; border-radius: 4px; transform: translateY(-50%);
  box-shadow: 0 0 0 1px rgba(0,0,0,.4); pointer-events: none;
}
.cpop-row { display: flex; align-items: center; gap: 8px; margin: 9px 0; }
.cpop-preview { width: 30px; height: 30px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); flex: 0 0 30px; }
.cpop-hex {
  width: 76px; font: 600 12.5px var(--sans); font-variant-numeric: tabular-nums;
  border: 1px solid var(--hairline); border-radius: 6px; padding: 6px 7px; background: #fff;
  text-transform: lowercase;
}
.cpop-hex:focus { border-color: var(--brass); outline: none; }
.cpop-name { flex: 1; font-size: 11px; font-style: italic; color: var(--ink-faint); font-family: var(--serif); }
.cpop-quick { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; margin-bottom: 8px; }
.cpop-sw {
  aspect-ratio: 1; border-radius: 6px; border: none; background: var(--sw);
  cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.18);
  transition: transform .1s;
}
.cpop-sw:hover { transform: scale(1.15); box-shadow: inset 0 0 0 1px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.3); }
.cpop-pal { margin-bottom: 7px; }
.cpop-pal-name { font-size: 9.5px; text-transform: uppercase; letter-spacing: .14em; color: var(--brass); margin-bottom: 4px; }
.cpop-pal-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }

/* ---------------- modal ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(20, 22, 33, 0.55); backdrop-filter: blur(3px);
}
.modal-card {
  position: relative; width: min(430px, 92vw);
  background: var(--card); border-radius: 12px; padding: 22px;
  border: 1px solid var(--brass-soft); box-shadow: var(--shadow-2);
}
.modal-x {
  position: absolute; top: 10px; right: 12px; border: none; background: transparent;
  font-size: 20px; cursor: pointer; color: var(--ink-faint);
}
.modal-title { font-family: var(--serif); margin: 0 0 4px; font-size: 22px; }
.modal-sub { font-size: 12.5px; color: var(--ink-soft); margin: 0 0 12px; }
.export-preview { display: grid; place-items: center; padding: 12px; background: var(--parchment-2); border-radius: 8px; margin-bottom: 14px; }
.export-preview svg { max-width: 300px; box-shadow: 0 4px 18px rgba(0,0,0,.25); }
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.export-grid .btn { justify-content: center; flex-direction: column; padding: 10px; }

/* ---------------- welcome ---------------- */
.welcome {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center;
  background:
    radial-gradient(100% 80% at 50% 20%, rgba(43,51,71,.88), rgba(26,32,48,.94)),
    var(--felt);
}
.welcome-card {
  width: min(480px, 90vw); text-align: center; color: #efe8d4;
  padding: 38px 34px; border: 1px solid var(--brass-soft); border-radius: 14px;
  background: linear-gradient(170deg, rgba(250,247,239,.06), rgba(250,247,239,.02));
  box-shadow: 0 30px 80px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.04);
}
.welcome-flag { width: 44px; height: 44px; color: #efe8d4; margin-bottom: 8px; }
.welcome-card h1 { font-family: var(--serif); font-size: 34px; margin: 0 0 10px; letter-spacing: .01em; }
.welcome-sub { font-size: 14.5px; line-height: 1.55; color: #cfc6ad; margin: 0 0 22px; }
.welcome-acts { display: flex; flex-direction: column; gap: 9px; align-items: center; }
.welcome-acts .btn { width: 250px; justify-content: center; }
.welcome-foot { margin-top: 20px; font-size: 11.5px; color: #9d9478; font-style: italic; }

/* ---------------- toast ---------------- */
#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px);
  background: var(--ink); color: #f4efe4; font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: 24px; box-shadow: var(--shadow-2);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 90; max-width: 80vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.warn { background: var(--crimson-deep); }

/* confetti */
.confetti {
  position: fixed; width: 8px; height: 8px; z-index: 95; pointer-events: none;
  animation: confetti 1.1s cubic-bezier(.2,.8,.4,1) forwards;
}
@keyframes confetti {
  0% { transform: translate(0,0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}

/* focus */
:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; }
.card:focus-visible, .slot:focus-visible, .layer-row:focus-visible { outline: 2px solid var(--brass); }

/* ---------------- responsive ---------------- */
@media (max-width: 880px) {
  .drawer-toggle { display: grid; }
  .sidebar {
    position: fixed; top: 58px; bottom: 0; left: 0; width: min(330px, 86vw);
    transform: translateX(-102%); transition: transform .22s ease;
    box-shadow: var(--shadow-2);
  }
  body.drawer-open .sidebar { transform: none; }
  .flag-title-hint { display: none; }
  #flagName { font-size: 14px; max-width: 110px; }
  .brand-words { display: none; }
  .topbar { gap: 8px; padding: 0 8px; }
  .mode-btn { padding: 8px 8px; font-size: 11.5px; }
  .btn { padding: 8px 10px; font-size: 12.5px; }
  .icon-btn { width: 32px; height: 32px; }
  .inspector { left: 8px; bottom: 8px; width: min(232px, 70vw); }
  .wisdom { right: 8px; bottom: 8px; width: min(248px, 66vw); max-height: 42vh; overflow-y: auto; }
  .flag-frame { padding: 3.2%; }
}
@media (max-width: 560px) {
  .brand { display: none; }
  #btnWisdom { display: none; }
  .btn.surprise { font-size: 0; padding: 8px 9px; }
  .btn.surprise .dice { font-size: 16px; }
  #btnExport { font-size: 0; padding: 8px 10px; }
  #btnExport::after { content: "⤓"; font-size: 15px; }
  .mode-btn { padding: 8px 6px; font-size: 11px; }
  .topbar { gap: 6px; }
  .topbar-acts { gap: 4px; }
  .flag-title { flex: 1; justify-content: flex-start; }
  #flagName { text-align: left; max-width: 92px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
