/* Action-bars, styled like the rest of mains.page: dark only, hairline borders, sand accent, pill buttons.
 * Spacing steps: 4 8 12 16 24 32 48 64. No text under 12px. Tap targets 44px or more. No inline styles anywhere (CSP). */
:root {
  color-scheme: dark;
  --ink: #0a0a0a;
  --panel: #0e0e0e;
  --raise: #141414;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.28);
  --paper: #fdfdfd;
  --muted: rgba(255, 255, 255, 0.74);
  --sand: #b59a63;
  --sand-light: #cdb27a;
  --slate: #7f9bb5;
  --ok: #7be2a1;
  --focus: #3de8ff;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --s: 48px;
}
* { box-sizing: border-box; }
::selection { background: rgba(181, 154, 99, 0.45); color: #fff; }
html { scrollbar-width: thin; scrollbar-color: rgba(181, 154, 99, 0.6) var(--ink); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: var(--ink); }
::-webkit-scrollbar-thumb { background: rgba(181, 154, 99, 0.5); border: 2px solid var(--ink); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(181, 154, 99, 0.8); }
body { margin: 0; background: var(--ink); color: var(--paper); font-family: 'Clash Grotesk', system-ui, sans-serif; font-size: 1rem; line-height: 1.6; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); font-size: 0.8125rem; line-height: 1.5; }
.sp { flex: 1; }

/* top bar and title */
.top { display: flex; align-items: center; gap: 8px; max-width: 72rem; margin: 0 auto; padding: 12px 24px; font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; }
.brand { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; transition: color 0.2s ease; }
.brand:hover { color: var(--sand-light); }
.top-sep { color: var(--muted); }
.top-here { color: var(--muted); }
.wrap { max-width: 72rem; margin: 0 auto; padding: 0 24px 32px; }
.title { margin: 0; font-size: clamp(1.75rem, 5vw, 2.5rem); font-weight: 600; letter-spacing: -0.04em; line-height: 1; }
.title-slate { color: var(--slate); }
.title-sand { color: var(--sand); }
.lede { max-width: 36rem; margin: 8px 0 0; color: rgba(255, 255, 255, 0.8); font-size: 0.9375rem; line-height: 1.5; }

/* buttons, inputs */
button, summary.btn, select, input[type=text], input:not([type]), input[type=search], textarea {
  font: inherit; color: var(--paper);
}
button, summary.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 999px; background: var(--panel); cursor: pointer;
  font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; list-style: none;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
button::after, summary.btn::after { content: ''; position: absolute; inset: -4px 0; }
button:hover, summary.btn:hover { border-color: #fff; background: #fff; color: #000; }
button.primary, button.chip2.on, .chip.on { border-color: var(--sand); background: var(--sand); color: #0a0a0a; }
button.primary:hover { border-color: var(--sand-light); background: var(--sand-light); color: #0a0a0a; }
summary.btn::-webkit-details-marker, summary::-webkit-details-marker { display: none; }
select, input[type=text], input:not([type]), input[type=search], textarea {
  min-height: 40px; padding: 0 12px; border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 999px; background: var(--panel); font-size: 0.875rem;
  transition: border-color 0.2s ease;
}
select:hover, select:focus, input:hover, input:focus, textarea:hover, textarea:focus { border-color: var(--sand); }
textarea { padding: 12px 16px; border-radius: 0.5rem; min-height: 96px; width: 100%; }
input::placeholder, textarea::placeholder { color: rgba(255, 255, 255, 0.45); }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--sand); flex: none; }
label.inl { display: inline-flex; gap: 8px; align-items: center; min-height: 40px; font-size: 0.875rem; }

/* the tool bar */
.tools { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.tools .group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
details.more { position: relative; }
details.more .menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; min-width: 15rem; display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid var(--line-strong); border-radius: 0.5rem; background: var(--panel); box-shadow: 0 16px 32px rgba(0, 0, 0, 0.6); }
details.more .menu button { justify-content: flex-start; width: 100%; border-color: transparent; text-align: left; }
details.more .menu button:hover { border-color: #fff; }

/* layout */
.work { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@media (min-width: 1100px) {
  .work { grid-template-columns: minmax(0, 1fr) 16.5rem; }
  #right { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; overscroll-behavior: contain; }
  #right #abilities { max-height: none; overflow: visible; }
}
#left { min-width: 0; }
.card { margin-bottom: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 0.5rem; background: var(--panel); transition: border-color 0.2s ease; }
#left .card:last-child { margin-bottom: 0; }
.card:hover { border-color: rgba(181, 154, 99, 0.6); }
.gridhead { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 0 0 8px; }
.ptitle { margin: 0; font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
#stats { margin-top: 4px; }
.gridhead.cmp { margin-top: 0; }

/* bars: the bottom bar is the in-game main bar */
#grid, #cmpGrid { overflow-x: auto; padding-bottom: 8px; }
.bars { width: max-content; min-width: 100%; }
.layer { display: flex; gap: 4px; align-items: center; margin-bottom: 4px; flex-wrap: nowrap; }
.layer .lname { width: 40px; flex: none; color: var(--muted); font-family: var(--mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
.gap { width: 8px; flex: none; }
.rowtog { width: 40px; height: 40px; min-height: 0; padding: 0; flex: none; opacity: 0.6; border-radius: 0.5rem; font-size: 1rem; }
.rowtog::after { inset: -4px; }
.rowtog.on { opacity: 1; border-color: var(--slate); background: var(--slate); color: #0a0a0a; }
.slot { position: relative; flex: none; width: var(--s); height: var(--s); border: 1px solid var(--line-strong); border-radius: 0.5rem; background: var(--raise); overflow: hidden; cursor: pointer; transition: border-color 0.2s ease, transform 0.15s ease; }
.slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slot .k { position: absolute; left: 4px; top: 0; z-index: 2; font: 700 0.75rem/1.3 var(--mono); color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 6px #000; }
.slot .rl { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px 4px 0; color: var(--muted); font-size: 0.75rem; line-height: 1.1; text-align: center; }
.slot:not(.ro):hover { border-color: var(--sand-light); transform: translateY(-2px); }
.slot.sel { outline: 3px solid var(--sand); outline-offset: 2px; z-index: 3; }
.slot.role { border-style: dashed; }
.slot.missing { border-style: dashed; border-color: var(--sand); }
.slot.missing .rl { color: var(--sand-light); }
.slot.pin::after { content: ""; position: absolute; right: 4px; bottom: 4px; z-index: 2; width: 8px; height: 8px; border-radius: 50%; background: var(--sand); }
.slot.ro { cursor: default; opacity: 0.92; }
.slot.over { outline: 2px solid var(--focus); }
.slot.custom { border-color: var(--muted); color: var(--muted); }
.slot.unbound { opacity: 0.22; }
.slot.bound-empty { border: 1px dashed rgba(181, 154, 99, 0.7); }
.slot.nokey { opacity: 0.4; border-style: dashed; }
.slot.paged { box-shadow: inset 0 -4px 0 var(--slate); }
.slot.swaps img { opacity: 0.55; }
.slot.stack { outline: 3px solid var(--sand); box-shadow: 0 0 12px var(--sand); transform: scale(1.06); }
.slot .sb, .slot .cb, .slot .tk { position: absolute; z-index: 2; padding: 0 3px; border-radius: 2px; font: 700 0.75rem/1.25 var(--mono); text-transform: uppercase; pointer-events: none; }
.slot .sb { left: 1px; bottom: 0; background: rgba(0, 0, 0, 0.75); color: #fff; }
.slot .cb { right: 2px; bottom: 1px; background: var(--sand); color: #0a0a0a; }
.slot .tk { left: 3px; top: 16px; background: var(--sand); color: #0a0a0a; }
.slot .sw { position: absolute; right: 4px; top: 16px; z-index: 2; color: var(--sand-light); font-size: 1rem; line-height: 1; text-shadow: 0 0 3px #000, 0 0 3px #000; }
body.kb #grid .slot { cursor: crosshair; outline: 1px dashed var(--slate); }
body.kb #grid .slot:hover { outline: 2px solid var(--sand); }
#kbMode.primary { box-shadow: 0 0 0 2px rgba(181, 154, 99, 0.5); }
.scrollhint { display: none; }
@media (max-width: 800px) { .scrollhint { display: block; margin: 0 0 8px; } }

/* the panel under the bars: what a button does and its macro */
#inspector { columns: 2 18rem; column-gap: 24px; min-height: 4rem; }
#inspector > * { break-inside: avoid; }
#inspector h3 { margin: 0 0 4px; font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }
#inspector table { width: 100%; margin: 8px 0; border-collapse: collapse; }
#inspector td { padding: 4px 8px 4px 0; border-top: 1px solid var(--line); vertical-align: middle; font-size: 0.875rem; }
#inspector .empty { display: flex; align-items: center; justify-content: center; min-height: 3rem; column-span: all; color: var(--muted); text-align: center; }
.ico { width: 24px; height: 24px; margin-right: 8px; border-radius: 4px; vertical-align: middle; background: var(--raise); }
pre.macro { margin: 4px 0 8px; padding: 8px 12px; overflow: auto; border: 1px solid var(--line); border-radius: 0.5rem; background: var(--ink); color: rgba(255, 255, 255, 0.85); font: 0.8125rem/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; }
.why, .guide-note { margin: 12px 0 4px; padding: 8px 12px; border-left: 3px solid var(--sand); background: var(--ink); color: rgba(255, 255, 255, 0.85); font-size: 0.875rem; line-height: 1.5; column-span: all; }
.why b { display: block; margin-bottom: 4px; }
table.outc { width: 100%; margin: 8px 0; border-collapse: collapse; font-size: 0.8125rem; }
table.outc th { color: var(--muted); font-weight: 400; text-align: left; }
table.outc td, table.outc th { padding: 4px 8px 4px 0; border-top: 1px solid var(--line); }
.m8 { margin: 8px 0; } .m10 { margin: 12px 0; } .mt8 { margin-top: 8px; } .row8 { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; } .blk6 { display: block; margin-top: 8px; } .gridall { grid-column: 1 / -1; padding: 12px; }

/* ability palette */
.abilcard { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px 8px; padding: 0 0 8px; }
.chip2 { min-height: 36px; padding: 0 12px; letter-spacing: 0.06em; }
#specChips { align-items: center; }
.chip { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 999px; background: var(--sand); color: #0a0a0a; cursor: grab; font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap; user-select: none; }
#abilities { max-height: 34rem; margin-top: 8px; overflow: auto; overscroll-behavior: contain; }
.rgroup { margin: 12px 0 4px; color: var(--sand); font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.15em; text-transform: uppercase; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 4px; padding: 4px; }
.tiles .rgroup { grid-column: 1 / -1; margin: 12px 0 0; }
.tiles .rgroup:first-child { margin-top: 0; }
.tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; min-height: 44px; padding: 2px; border: 1px solid transparent; border-radius: 0.5rem; cursor: grab; user-select: none; transition: border-color 0.2s ease; }
.tile img { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 0.5rem; background: var(--raise); object-fit: cover; pointer-events: none; }
.tile:hover { border-color: rgba(181, 154, 99, 0.6); }
.tile.armed { border-color: var(--sand); background: var(--raise); }
.tile.placed img { opacity: 0.4; }
.tile .tn { max-width: 100%; height: 2.6em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 0.75rem; line-height: 1.3; text-align: center; word-break: break-word; }
.tile .sb { position: absolute; left: 6px; top: 28px; padding: 0 3px; border-radius: 2px; background: rgba(0, 0, 0, 0.8); color: #fff; font: 700 0.75rem/1.25 var(--mono); text-transform: uppercase; pointer-events: none; }
.tile .ck { position: absolute; right: 4px; top: 4px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--sand); color: #0a0a0a; font-size: 0.75rem; font-weight: 700; pointer-events: none; }
.tile .sodb, .sodb { position: absolute; right: 4px; top: 36px; padding: 0 4px; border-radius: 2px; background: var(--sand); color: #0a0a0a; font: 700 0.75rem/1.25 var(--mono); pointer-events: none; }
.badge { display: inline-block; padding: 0 8px; border: 1px solid rgba(181, 154, 99, 0.8); border-radius: 999px; color: var(--sand); font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.06em; white-space: nowrap; }
#abDetail { display: flex; gap: 8px; align-items: flex-start; min-height: 4.5rem; margin-top: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 0.5rem; background: var(--ink); }
#abDetail .big { width: 40px; height: 40px; flex: none; border: 1px solid var(--line); border-radius: 0.5rem; }
#abDetail .txt { min-width: 0; flex: 1; overflow: auto; }
#abDetail .desc { margin-top: 4px; font-size: 0.8125rem; line-height: 1.4; }
.customrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
.customrow input { flex: 1; min-width: 8rem; }
details.hint { margin: 12px 0 0; }
details.hint summary { display: flex; align-items: center; min-height: 40px; cursor: pointer; color: var(--sand); font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; }
details.hint summary:hover { color: var(--sand-light); }
#macroHint { margin: 4px 0; }
.chips.tiny { gap: 4px; }

/* dialogs */
dialog { width: min(32rem, 92vw); max-height: 88vh; padding: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 0.5rem; background: var(--panel); color: var(--paper); }
dialog::backdrop { background: rgba(0, 0, 0, 0.82); }
#dlgForm { max-height: 86vh; padding: 16px 24px 24px; overflow: auto; }
#dlgForm h2 { margin: 0 0 12px; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
#dlgForm h4 { margin: 24px 0 8px; color: var(--sand); font-family: var(--mono); font-size: 0.75rem; font-weight: 400; letter-spacing: 0.15em; text-transform: uppercase; }
dialog label { display: block; margin: 12px 0; font-size: 0.9375rem; }
dialog input, dialog select, dialog textarea { display: block; width: 100%; margin-top: 4px; }
dialog .row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 16px; }
#dlg.wide { width: min(58rem, 94vw); }
table.guide { width: 100%; margin-bottom: 8px; border-collapse: collapse; font-size: 0.8125rem; }
table.guide th, table.guide td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.guide th { color: var(--muted); font-weight: 400; }
table.guide td:first-child { font-family: var(--mono); font-weight: 700; white-space: nowrap; }
@media (max-width: 640px) { #dlg.wide { width: 96vw; } #dlgForm { padding: 16px; } table.guide { display: block; overflow-x: auto; } }

#toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; max-width: min(36rem, 92vw); padding: 12px 24px; border-radius: 999px; background: var(--sand); color: #0a0a0a; font-size: 0.9375rem; line-height: 1.4; text-align: center; opacity: 0; transform: translateX(-50%); pointer-events: none; transition: opacity 0.2s ease; }
#toast.on { opacity: 1; }

/* footer */
.foot { max-width: 72rem; margin: 0 auto; padding: 16px 24px 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.875rem; }
.foot p { margin: 8px 0; }
.foot-links { display: flex; flex-wrap: wrap; gap: 0 24px; font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; }
.foot-links a { display: inline-flex; align-items: center; min-height: 40px; text-decoration: none; }
.foot a:hover { color: var(--sand-light); }
.foot-line { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; margin-top: 8px; font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; }

@media (max-width: 600px) { .top, .wrap, .foot { padding-left: 16px; padding-right: 16px; } .lede { font-size: 0.9375rem; } .card { padding: 12px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } .slot:not(.ro):hover { transform: none; } }

/* view switch, options with a plain-words line under each */
.pagehead { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; justify-content: space-between; margin: 0 0 16px; }
.views { display: flex; gap: 8px; }
.views button[aria-pressed='true'] { border-color: var(--sand); background: rgba(181, 154, 99, 0.16); color: var(--sand-light); }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0 16px; margin: 0 0 8px; }
.opt { display: flex; gap: 8px; align-items: flex-start; min-height: 40px; padding: 4px 0; cursor: pointer; }
.opt input { margin-top: 2px; }
.opt b { display: block; font-size: 0.875rem; font-weight: 600; }
.opt small { display: block; color: var(--muted); font-size: 0.8125rem; line-height: 1.4; }
.field { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 0.875rem; }
.field select { flex: 1; min-width: 0; }
#search { display: block; width: 100%; margin: 0 0 4px; }
label.only { display: flex; margin: 0 0 8px; }
.abilcard h2 { margin-bottom: 0; }

/* macros view */
.mhelp { max-width: 38rem; margin: 4px 0 12px; }
.mtools { border-bottom: 0; padding-bottom: 0; margin-bottom: 12px; }
.mtools input { flex: 1; min-width: 12rem; }
.mbox { border-top: 1px solid var(--line); }
.mbox:last-child { border-bottom: 1px solid var(--line); }
summary.mgroup { display: flex; align-items: center; gap: 8px; min-height: 40px; margin: 0; cursor: pointer; list-style: none; color: var(--sand); font-family: var(--mono); font-size: 0.75rem; font-weight: 400; letter-spacing: 0.15em; text-transform: uppercase; }
summary.mgroup::-webkit-details-marker { display: none; }
summary.mgroup::before { content: '+'; width: 16px; color: var(--sand); font-size: 1rem; }
.mbox[open] > summary.mgroup::before { content: '-'; }
summary.mgroup:hover { color: var(--sand-light); }
.mintro { max-width: 38rem; margin: 0 0 8px; }
.mbox .mgrid { margin-bottom: 12px; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 8px; }
.mcard { display: flex; flex-direction: column; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 0.5rem; background: var(--panel); transition: border-color 0.2s ease; }
.mcard:hover { border-color: rgba(181, 154, 99, 0.6); }
.mtitle { margin: 0 0 4px; font-size: 0.9375rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.mcard .macro { flex: 1; }
.mhead { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.mhead .mtitle { margin: 4px 0 0; }
.mcard .muted { margin: 0 0 4px; }
.mcopy { flex: none; }

/* tidy toolbar */
.tools .profile { flex: 1 1 18rem; }
.tools .profile label.inl { flex: 1; min-width: 0; }
.tools .profile select { flex: 1; min-width: 0; }
@media (max-width: 600px) {
  .tools { gap: 8px; }
  .tools .group.actions { width: 100%; gap: 8px; }
  .mtools input, .mtools label { flex: 1 1 100%; }
}

/* first step on an empty bar */
.start { margin: 0 0 8px; padding: 8px 12px; border-left: 3px solid var(--sand); background: var(--ink); color: rgba(255, 255, 255, 0.85); font-size: 0.875rem; line-height: 1.5; }

/* the Season of Discovery chip is long, so it gets its own full-width row */
#specChips .chip2.sod { flex: 1 1 100%; padding: 0 8px; letter-spacing: 0.02em; white-space: nowrap; }

/* layout picker: each setup drawn as a small keyboard */
#dlg.wide .lgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 8px; margin: 8px 0; }
.lrow { display: grid; grid-template-columns: minmax(0, 1fr) 12rem; gap: 12px; }
.lhelp { margin: 8px 0; }
.lhelp a { color: var(--sand); }
dialog label.lcard { position: relative; display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 0.5rem; background: var(--ink); cursor: pointer; transition: border-color 0.2s ease; }
dialog label.lcard:hover { border-color: rgba(181, 154, 99, 0.6); }
dialog label.lcard:has(input:checked) { border-color: var(--sand); box-shadow: inset 0 0 0 1px var(--sand); }
dialog label.lcard:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.lhead { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; justify-content: space-between; }
.lhead b { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }
.ltag { color: var(--sand); font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; }
.lblurb { font-size: 0.875rem; line-height: 1.4; }
.lblank { display: grid; place-items: center; min-height: 6rem; border: 1px dashed var(--line-strong); border-radius: 0.5rem; color: var(--muted); font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; }
.kbd { display: flex; flex-direction: column; gap: 2px; padding: 8px; border: 1px solid var(--line); border-radius: 0.5rem; background: var(--panel); }
.kr { display: flex; gap: 2px; }
.kr1 { margin-left: 8px; } .kr2 { margin-left: 14px; } .kr3 { margin-left: 22px; }
.kk { display: inline-grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font: 0.75rem/1 var(--mono); }
.kk.used { border-color: var(--sand); background: var(--sand); color: #0a0a0a; }
.kk.mod { border-color: var(--sand); color: var(--sand-light); }
.kk.wide { width: auto; padding: 0 8px; }
.kbd .kr:last-of-type { margin-top: 4px; }
.thumb { display: grid; grid-auto-flow: column; grid-template-rows: repeat(3, 20px); grid-auto-columns: 24px; gap: 2px; margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--line); }
.thumb .kk { width: 24px; }
.thumb .kk.first { background: var(--sand-light); border-color: var(--sand-light); }
@media (max-width: 640px) { .lrow { grid-template-columns: 1fr; } }

/* layout picker v2: a list on the left, the chosen setup on the right */
.lquiz { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 8px 16px; margin: 8px 0; }
fieldset.quiz { min-width: 0; margin: 0; padding: 0; border: 0; }
.quiz legend { margin: 0 0 4px; padding: 0; color: var(--muted); font-size: 0.8125rem; }
.qopts { display: flex; flex-wrap: wrap; gap: 4px; }
dialog label.qopt { display: inline-flex; align-items: center; min-height: 40px; margin: 0; padding: 0 12px; border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 999px; font-size: 0.8125rem; cursor: pointer; transition: background-color 0.2s ease, border-color 0.2s ease; }
dialog label.qopt:hover { border-color: #fff; }
dialog label.qopt:has(input:checked) { border-color: var(--sand); background: var(--sand); color: #0a0a0a; }
dialog label.qopt:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.lreco { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--sand); background: var(--ink); font-size: 0.9375rem; }
.lsplit { display: grid; grid-template-columns: minmax(0, 19rem) minmax(0, 1fr); gap: 16px; align-items: start; margin: 8px 0; }
@media (max-width: 800px) { .lsplit { grid-template-columns: 1fr; } }
.llist { display: flex; flex-direction: column; gap: 4px; }
dialog label.lopt { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 0.5rem; background: var(--ink); cursor: pointer; transition: border-color 0.2s ease; }
dialog label.lopt:hover { border-color: rgba(181, 154, 99, 0.6); }
dialog label.lopt:has(input:checked) { border-color: var(--sand); box-shadow: inset 0 0 0 1px var(--sand); }
dialog label.lopt:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.lbadge { padding: 0 8px; border-radius: 999px; background: var(--sand); color: #0a0a0a; font: 700 0.75rem/1.5 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; }
.ldetail-wrap { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 0.5rem; background: var(--ink); }
.ldetail h4 { margin: 12px 0 4px; color: var(--sand); font: 400 0.75rem var(--mono); letter-spacing: 0.15em; text-transform: uppercase; }
.ldh { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; margin: 0 0 4px; font-size: 1.125rem; font-weight: 700; letter-spacing: -0.01em; }
.lwhy { margin: 0 0 4px; font-size: 0.875rem; line-height: 1.5; }
.lsrc { margin: 0; padding-left: 16px; font-size: 0.8125rem; }
.lsrc a { color: var(--sand); }
dialog label.lcmp { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 8px; font-size: 0.8125rem; color: var(--muted); }
dialog label.lcmp select { display: inline-block; width: auto; margin: 0; }
.ldetail .kbd { align-self: flex-start; width: max-content; max-width: 100%; }
.mousebox { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 8px 0 0; }
.mousebox .thumb { margin: 0; padding: 0; border: 0; }
.kk.other { border-color: var(--slate); background: var(--slate); color: #0a0a0a; }
.kk.both { border-color: var(--slate); background: var(--sand); color: #0a0a0a; box-shadow: 0 0 0 1px var(--slate); }
.scr { display: flex; align-items: flex-end; justify-content: center; min-height: 6.5rem; padding: 12px; border: 1px solid var(--line); border-radius: 0.5rem; background: linear-gradient(#111, #0a0a0a); }
.scr-stack { display: flex; flex-direction: column; gap: 2px; width: 100%; max-width: 24rem; }
.scr-row { display: flex; gap: 8px; align-items: center; }
.scr-name { flex: none; width: 7rem; color: var(--muted); font: 0.75rem/1.2 var(--mono); text-align: right; }
.scr-cells { display: flex; flex: 1; gap: 2px; }
.scr-cell { flex: 1; height: 12px; border: 1px solid var(--line-strong); border-radius: 2px; background: var(--raise); }
.scr-row:last-child .scr-cell { border-color: var(--sand); }

/* keyboard view */
.vtabs { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0 0 16px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button[aria-pressed='true'] { border-color: var(--sand); background: rgba(181, 154, 99, 0.16); color: var(--sand-light); }
.kbd { width: max-content; min-width: 100%; }
.krow { display: flex; gap: 4px; align-items: center; margin-bottom: 4px; }
.krow.k1 { padding-left: calc(var(--s) * 0.5 + 2px); }
.krow.k2 { padding-left: calc(var(--s) * 0.75 + 3px); }
.krow.k3 { padding-left: calc(var(--s) * 1.25 + 5px); }
.krow.kmouse { margin-top: 16px; }
.krow .lname { width: 56px; }
.kcap { display: grid; place-items: center; flex: none; width: var(--s); height: var(--s); border: 1px dashed var(--line-strong); border-radius: 0.5rem; color: rgba(255, 255, 255, 0.55); font: 700 0.75rem/1 var(--mono); cursor: default; transition: border-color 0.2s ease; }
.kcap:hover { border-color: rgba(181, 154, 99, 0.6); }
.kcap.over { outline: 2px solid var(--focus); }

/* starter bars picker */
.starters { margin: 0 0 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.starters > summary { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; list-style: none; color: var(--sand); font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.15em; text-transform: uppercase; }
.starters > summary::-webkit-details-marker { display: none; }
.starters > summary::before { content: '+'; width: 16px; font-size: 1rem; }
.starters[open] > summary::before { content: '-'; }
.starters > summary:hover { color: var(--sand-light); }
.starters > .muted { margin: 0 0 12px; }
.srow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 8px; }
.scls { width: 5.5rem; flex: none; color: rgba(255, 255, 255, 0.85); font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; }
.starter-note { min-height: 1.5em; margin: 8px 0 16px; }
@media (max-width: 480px) { .scls { width: 100%; } }

/* how to use: tour, tips, first-visit nudge */
.help-btn { margin-left: auto; }
.howto { margin: 0 0 12px; font-size: 0.9375rem; }
.tour-shield { position: fixed; inset: 0; z-index: 60; background: transparent; }
.tour-hole { position: fixed; z-index: 61; display: none; border: 2px solid var(--sand); border-radius: 0.5rem; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.72); pointer-events: none; }
.tour-hole.on { display: block; }
.tour-card { position: fixed; z-index: 62; left: 50%; bottom: 16px; width: min(26rem, calc(100vw - 32px)); max-height: 60vh; overflow: auto; padding: 16px; transform: translateX(-50%); border: 1px solid var(--sand); border-radius: 0.5rem; background: var(--panel); color: var(--paper); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6); }
.tour-card.top { top: 16px; bottom: auto; }
.tour-card.center { top: 50%; bottom: auto; transform: translate(-50%, -50%); }
.tour-card h2 { margin: 0 0 8px; font-size: 1.25rem; }
.tour-card p { margin: 0 0 16px; font-size: 0.9375rem; line-height: 1.5; }
.tour-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.tour-count { color: var(--muted); font: 400 0.75rem/1 var(--mono); }
.tour-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.tour-skip { border-color: transparent; background: transparent; color: var(--muted); }
.tour-nudge { position: fixed; z-index: 40; right: 16px; bottom: 16px; width: min(22rem, calc(100vw - 32px)); padding: 16px; border: 1px solid var(--sand); border-radius: 0.5rem; background: var(--panel); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6); }
.tour-nudge p { margin: 0 0 12px; font-size: 0.9375rem; line-height: 1.5; }
#tipsDlg form { max-height: 88vh; overflow: auto; padding: 24px; }
#tipsDlg h2 { margin: 0 0 8px; }
.tips-sec h3 { margin: 16px 0 4px; font-size: 1rem; color: var(--sand-light); }
.tips-sec ul { margin: 0; padding-left: 20px; font-size: 0.9375rem; line-height: 1.5; }
.tour-shield.dim { background: rgba(0, 0, 0, 0.72); }

/* options folded away, one class at a time in the starter picker */
.optbox { margin: 0 0 8px; }
.optbox > summary { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; cursor: pointer; list-style: none; color: var(--muted); font: 400 0.75rem/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; }
.optbox > summary::-webkit-details-marker { display: none; }
.optbox > summary::before { content: '+'; }
.optbox[open] > summary::before { content: '-'; }
.optbox > summary:hover { color: var(--sand-light); }
.srow .scls { width: auto; margin-right: 8px; }
#starterList { display: grid; gap: 12px; margin-bottom: 8px; }
#starterList .tree { border-color: var(--sand); color: var(--sand-light); }
#starterList .tree:hover { background: var(--sand); color: #0a0a0a; }
#starterList .seg button { display: inline-flex; align-items: center; gap: 8px; }
.bico { flex: none; width: 24px; height: 24px; border-radius: 0.25rem; }
#starterList .seg button { padding-left: 8px; }
#curTitle { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.filters, .cmpbox > summary { margin: 0 0 8px; }
.filters > summary, .cmpsum { display: flex; align-items: center; gap: 8px; min-height: 36px; cursor: pointer; list-style: none; color: var(--muted); font: 400 0.75rem/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; }
.filters > summary::-webkit-details-marker, .cmpsum::-webkit-details-marker { display: none; }
.filters > summary::before, .cmpsum::before { content: '+'; }
.filters[open] > summary::before, .cmpbox[open] > .cmpsum::before { content: '-'; }
.filters > summary:hover, .cmpsum:hover { color: var(--sand-light); }
.cmpbox { padding-top: 4px; padding-bottom: 4px; }
.cmpbox[open] { padding-bottom: 16px; }
.tile .tn { word-break: normal; overflow-wrap: break-word; hyphens: manual; }

/* hold the space the script fills in, so the page does not jump when it loads */
#starterList { min-height: 9.5rem; }
#grid { min-height: 20rem; }
@media (min-width: 768px) { #grid { min-height: 22.5rem; } }
@media (min-width: 900px) and (max-width: 1199px) { #grid { min-height: 27.75rem; } }
@media (min-width: 1200px) { #grid { min-height: 25rem; } }
@media (max-width: 480px) { #starterList { min-height: 14rem; } }
