:root {
  --bg: #1b1e24;
  --panel: #23272f;
  --panel-2: #2b3039;
  --line: #3a404b;
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --accent: #ffd54f;
  --red: #d64545;
  --blue: #3b7dd8;
  --ok: #69f0ae;
  --mid: #ffd740;
  --bad: #ff8a80;
  --hid: #ce93d8;
  --table: #15171c;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; display: flex; flex-direction: column; overflow: hidden; }
button, select, input, textarea { font: inherit; color: inherit; }
button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
button:hover { border-color: #5a6372; }
button.primary { background: #3d5a80; border-color: #4f73a3; }
button:disabled { opacity: .5; cursor: default; }
button.sm { padding: 2px 8px; font-size: 12px; }
button.ic { padding: 0 6px; border: none; background: transparent; color: var(--muted); }
button.ic:hover { color: var(--text); }
select, input[type=number], input[type=text], textarea { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
kbd { font: 11px ui-monospace, monospace; background: #111; border: 1px solid #444; border-radius: 3px; padding: 0 4px; color: var(--muted); }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 6px; }
h3 small { text-transform: none; letter-spacing: 0; }
.small { font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); font-style: italic; margin: 6px 0; }
.note { background: #3a3220; border: 1px solid #6b5a2a; border-radius: 6px; padding: 6px 8px; font-size: 12px; }
.ok { color: var(--ok); } .mid { color: var(--mid); } .bad { color: var(--bad); } .hid { color: var(--hid); }
.big { font-size: 22px; font-weight: 700; margin: 6px 0; }

.topbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.topbar .btns { display: flex; gap: 4px; }
.mapPick { display: flex; align-items: center; gap: 6px; }
.mapPick label { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.mapPick label select { color: var(--text); }
.mapPick #customSelect { max-width: 220px; }
.mapPick.custom-active label, .mapPick.custom-active #layoutSeg { opacity: .55; }
.brand { font-weight: 700; letter-spacing: .02em; }
.brand .ed { font-weight: 600; color: var(--accent); margin-left: 4px; font-size: 12px; }
.seg { display: flex; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; }
.seg button.active { background: #4b5d7a; border-color: #6c85ad; }
.toggles { display: flex; gap: 4px; flex-wrap: wrap; }
.tg { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border: 1px solid var(--line); border-radius: 12px; font-size: 12px; cursor: pointer; user-select: none; }
.tg:has(input:checked) { border-color: #6c85ad; background: #2f3a4c; }
.spacer { flex: 1; }
details.menu { position: relative; margin: 0; }
details.menu summary { list-style: none; cursor: pointer; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; background: var(--panel-2); color: var(--text); }
details.menu summary::-webkit-details-marker { display: none; }
details.menu[open] summary { border-color: #6c85ad; }
details.menu .menu-body { position: absolute; top: 110%; left: 0; z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-width: 230px; box-shadow: 0 8px 24px rgba(0,0,0,.45); }
details.menu hr { border: none; border-top: 1px solid var(--line); margin: 6px 0; }

main { flex: 1; display: grid; grid-template-columns: 270px 1fr 340px; min-height: 0; }
aside { background: var(--panel); overflow-y: auto; padding: 10px; }
aside.left { border-right: 1px solid var(--line); }
aside.right { border-left: 1px solid var(--line); }
.stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
#board { display: block; touch-action: none; cursor: default; }
#board[data-tool=measure], #board[data-tool=line] { cursor: crosshair; }
#board[data-tool=los] { cursor: cell; }
#board[data-tool=pan] { cursor: grab; }
#board.panning { cursor: grabbing; }
.status { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; gap: 12px; padding: 4px 10px; background: rgba(20,22,27,.85); font-size: 12px; pointer-events: none; }
.status .hint { color: var(--muted); text-align: right; }
.timeline { position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; background: rgba(20,22,27,.92); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; box-shadow: 0 6px 18px rgba(0,0,0,.4); max-width: calc(100% - 20px); flex-wrap: wrap; }
.timeline[hidden] { display: none; }
.timeline .step { padding: 3px 9px; font-size: 12px; }
.timeline .step.has { border-color: #5a6372; }
.timeline .step.cur { background: #4b5d7a; border-color: #8aa3cc; font-weight: 700; }
.timeline .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.timeline .tl-title { font-weight: 700; font-size: 12px; color: var(--accent); margin-right: 4px; }
.drops { position: absolute; bottom: 120%; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 260px; font-size: 12px; }
.drops ol { margin: 4px 0; padding-left: 20px; }
.toast { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: rgba(20,22,27,.92); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
#board[data-tool=radius] { cursor: crosshair; }

.army { margin-bottom: 16px; }
.army header { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.army header h2 { flex: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.army.red .dot, .ins-head.red .dot { background: var(--red); }
.army.blue .dot, .ins-head.blue .dot { background: var(--blue); }
.army ul { list-style: none; margin: 6px 0 0; padding: 0; }
.army li.unit { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; padding: 5px 6px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.army li.unit:hover { background: var(--panel-2); }
.army li.unit.sel { border-color: #6c85ad; background: #2f3a4c; }
.army li .name { font-weight: 600; }
.army li .meta { grid-column: 1; font-size: 11px; color: var(--muted); }
.army li .acts { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.warn { color: var(--bad); }
.chk { display: flex; align-items: center; gap: 6px; padding: 2px 0; cursor: pointer; }
.chk.bub i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.chk.bub b { margin-left: auto; font-weight: 600; }
.chk.bub kbd { margin-left: 4px; }
.chk .kw { display: block; width: 100%; color: var(--muted); }
.chk.bub { flex-wrap: wrap; }
.chk.bub .kw { flex-basis: 100%; padding-left: 36px; font-size: 11px; }
.eqrow { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.eqrow .chk { flex: 1; }

.ins-head { display: flex; gap: 8px; align-items: flex-start; }
.ins-head .dot { margin-top: 5px; }
.ins-head .sub { color: var(--muted); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.chip { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 0 7px; font-size: 11px; color: var(--muted); }
details { margin: 6px 0; }
details summary { cursor: pointer; color: var(--muted); }
.baseed { display: grid; grid-template-columns: 1fr auto 58px 58px auto; gap: 4px; align-items: center; margin: 4px 0; font-size: 12px; }

table.lanes { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; }
table.lanes th { text-align: left; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: 3px 4px; }
table.lanes td { border-bottom: 1px solid #30353e; padding: 4px; vertical-align: top; }
table.lanes .ws { margin-top: 2px; font-size: 11px; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; width: min(720px, 92vw); max-height: 88vh; overflow: auto; }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
dialog textarea { width: 100%; font: 12px ui-monospace, monospace; margin-top: 8px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.form label { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.form label input, .form label select { width: 60%; }
#settingsForm label input { width: 70px; }
.orgrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0; font-size: 12px; }
.orgrow label { display: flex; align-items: center; gap: 4px; }
.orgrow input[type=text] { width: 7.5em; }
.swatch { width: 18px; height: 18px; border-radius: 50%; padding: 0; border: 2px solid transparent; }
.swatch.on { border-color: #fff; }
#customUnit { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-top: 8px; }
#customUnit summary { color: var(--text); }
.legend { height: 10px; border-radius: 5px; margin-top: 4px; }
.legend-l { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.help h3 { margin-top: 12px; }
.help ul { padding-left: 18px; margin: 4px 0; }
.chk.bub b.custom-r { display: inline-flex; align-items: center; gap: 2px; }
.chk.bub b.custom-r input { width: 58px; font: inherit; font-weight: 600; text-align: right; padding: 1px 2px; }
