/* Base Lab — dark tabletop theme: slate, parchment and brass, with a hex motif. */
@font-face { font-family: 'Cinzel'; src: url('../fonts/cinzel-bold.woff') format('woff'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Rubik'; src: url('../fonts/rubik-bold.woff') format('woff'); font-weight: 700; font-display: swap; }

:root {
  --slate: #1c2026; --slate2: #252a32; --slate3: #313844; --line: #3d4552;
  --parch: #eadfc6; --parch2: #c9bb9c; --brass: #c79a45; --brass2: #e8c36f;
  --red: #d06a55; --radius: 10px;
  --hex: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='48.5' viewBox='0 0 28 48.5'%3E%3Cpath d='M14 0l14 8.08v16.17L14 32.33 0 24.25V8.08zM14 32.33l14 8.08M14 32.33L0 40.41M14 32.33V48.5' fill='none' stroke='%23c79a45' stroke-opacity='.06'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--slate) var(--hex); color: var(--parch);
  font: 15px/1.4 system-ui, -apple-system, 'Segoe UI', sans-serif;
  display: grid; grid-template-rows: auto 1fr auto; min-height: 100vh;
}
button, select, input { font: inherit; color: inherit; }
button {
  background: var(--slate3); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--brass); }
button:disabled { opacity: .45; cursor: default; }
button.on, .seg button.on { background: linear-gradient(#7a5a24, #5d4319); border-color: var(--brass2); color: #fff6df; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--brass2); outline-offset: 1px; }
select, input[type=text], input[type=number] {
  background: #12151a; border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; width: 100%;
}
input[type=range] { accent-color: var(--brass); width: 100%; }
input[type=checkbox] { accent-color: var(--brass); }

.top { display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: linear-gradient(#262b34, #1c2026); border-bottom: 1px solid #000; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 34px; height: 34px; fill: var(--brass); }
.logo .inner { fill: var(--slate); }
h1, h2, summary, .tpl b { font-family: 'Cinzel', Georgia, serif; letter-spacing: .03em; }
h1 { margin: 0; font-size: 26px; color: var(--brass2); text-shadow: 0 1px 0 #000; }
.tag { color: var(--parch2); font-size: 13px; }
.modes { display: flex; gap: 6px; margin-left: auto; }
.pro { font: 700 10px Rubik, sans-serif; background: var(--brass); color: #1b1408; padding: 1px 5px; border-radius: 4px; margin-left: 4px; vertical-align: 1px; font-style: normal; }
.actions { display: flex; gap: 6px; }

.layout { display: grid; grid-template-columns: 330px 1fr 230px; grid-template-areas: 'options stage saved'; min-height: 0; }
.options { grid-area: options; overflow-y: auto; padding: 10px 12px 80px; background: rgba(20,23,28,.85); border-right: 1px solid #000; max-height: calc(100vh - 120px); }
.stage { grid-area: stage; position: relative; display: flex; flex-direction: column; min-height: 0; }
.saved { grid-area: saved; padding: 12px; background: rgba(20,23,28,.85); border-left: 1px solid #000; overflow-y: auto; max-height: calc(100vh - 120px); }
.view { flex: 1; min-height: 360px; position: relative; }
.view canvas { display: block; width: 100% !important; height: 100% !important; position: absolute; inset: 0; }
.view-tools { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; pointer-events: none; }
.view-tools > * { pointer-events: auto; }
.view-tools .chk, .view-tools button { background: rgba(28,32,38,.85); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; }
.seg { display: flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 8px 0 0 8px; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.info { flex: none; height: 128px; overflow-y: auto; box-sizing: border-box; padding: 8px 14px; background: rgba(20,23,28,.9); border-top: 1px solid #000; }
.stats { font: 700 16px Rubik, sans-serif; color: var(--brass2); }
.warnings { margin: 4px 0; padding-left: 18px; color: #f0b27a; font-size: 13px; }
.warnings .err { color: var(--red); }
.tips summary { font-size: 14px; cursor: pointer; color: var(--parch2); }
.tips ul { margin: 4px 0; padding-left: 18px; font-size: 13px; color: var(--parch2); }
.busy { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(20,23,28,.92); border: 1px solid var(--brass); padding: 12px 18px; border-radius: 10px; min-width: 220px; text-align: center; }
.busy .bar { height: 6px; background: #000; border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.busy .bar i { display: block; height: 100%; width: 0; background: var(--brass); transition: width .15s; }

.sec { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; background: rgba(37,42,50,.75); }
.sec > summary { padding: 9px 12px; cursor: pointer; color: var(--brass2); font-size: 15px; list-style: none; }
.sec > summary::before { content: '⬡ '; color: var(--brass); }
.sec[open] > summary { border-bottom: 1px solid var(--line); }
.sec > :not(summary) { margin: 8px 12px; }
.field { display: block; }
.field .lbl { display: block; font-size: 13px; color: var(--parch2); margin-bottom: 3px; }
.hint { display: block; color: #9a9384; font-size: 12px; margin: 3px 0 0; }
.slider { display: flex; gap: 8px; align-items: center; }
.slider output { min-width: 58px; text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chk { display: flex; gap: 6px; align-items: center; font-size: 14px; }
.templates { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tpl { text-align: left; display: flex; flex-direction: column; padding: 7px 9px; }
.tpl b { font-size: 13px; color: var(--brass2); }
.tpl small { font-size: 11px; color: var(--parch2); }
.textures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.tex { font-size: 12px; padding: 6px 4px; position: relative; }
.tex .pro { position: absolute; top: -6px; right: -4px; }
.seed { display: flex; gap: 8px; align-items: end; }
.seed .field { flex: 1; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { display: flex; flex-direction: column; align-items: center; font-size: 12px; gap: 2px; }
.swatch input { width: 44px; height: 32px; border: 1px solid var(--line); border-radius: 6px; background: none; padding: 0; }
.army-row { display: grid; grid-template-columns: 1fr 74px 34px; gap: 6px; }
.icon { padding: 4px 8px; }

.saved h2 { margin: 0 0 8px; font-size: 17px; color: var(--brass2); }
.save-row { display: flex; gap: 6px; }
.save-row input { flex: 1; min-width: 0; }
.saved { overflow-x: hidden; }
.saved-list .load { min-width: 0; overflow: hidden; }
.saved-list { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.saved-list li { display: flex; gap: 4px; }
.saved-list .load { flex: 1; display: flex; gap: 8px; align-items: center; text-align: left; padding: 4px; }
.saved-list img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; }
.saved-list .empty { color: #9a9384; font-size: 13px; }

.downloads { position: sticky; bottom: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 16px; background: linear-gradient(#2a2f38, #1a1d22); border-top: 1px solid var(--brass); z-index: 5; }
.dl-label { color: var(--parch2); font-size: 14px; }
.downloads .primary { background: linear-gradient(#a57a2f, #7a5a24); border-color: var(--brass2); color: #fff8e6; font-weight: 600; }
.dl-status { font-size: 13px; color: var(--parch2); }
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: #2a2f38; border: 1px solid var(--brass); padding: 10px 16px; border-radius: 10px; z-index: 9; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 300px 1fr; grid-template-areas: 'options stage' 'saved saved'; }
  .saved { max-height: none; border-left: 0; border-top: 1px solid #000; }
}
@media (max-width: 720px) {
  body { font-size: 14px; }
  .top { padding: 8px 10px; gap: 8px; }
  h1 { font-size: 21px; }
  .tag { display: none; }
  .modes { margin-left: 0; width: 100%; order: 3; }
  .modes button { flex: 1; padding: 6px 4px; font-size: 13px; }
  .actions { margin-left: auto; }
  .actions button { padding: 5px 8px; }
  .layout { grid-template-columns: 1fr; grid-template-areas: 'stage' 'options' 'saved'; }
  .view { min-height: 300px; height: 52vh; flex: none; }
  .info { height: auto; overflow: visible; }
  .options { max-height: none; border-right: 0; padding-bottom: 12px; }
  body { display: block; height: auto; }
  .stage { min-height: auto; }
  .layout { grid-template-rows: auto auto auto; }
  .downloads { padding: 8px; gap: 6px; }
  .downloads button { flex: 1 1 45%; font-size: 12.5px; padding: 7px 4px; }
  .dl-label { display: none; }
  .dl-status { flex-basis: 100%; }
}
