/* MoonMap: the Moon's black sky around a sunlit regolith plot. One accent, lander-foil gold, for selection and the main action. */
:root {
  --sky: #0D0D0C;
  --panel: #161614;
  --raised: #201F1C;
  --raised-2: #2A2925;
  --line: #2E2C28;
  --line-2: #3B3934;
  --text: #ECE9E1;
  --muted: #A6A298;
  --faint: #8C887E;
  --foil: #D9A441;
  --foil-ink: #1A1408;
  --foil-soft: rgba(217, 164, 65, 0.14);
  --bad: #F07862;
  --bad-soft: rgba(240, 120, 98, 0.12);
  --good: #8FC79B;
  --regolith: #9B978F;
  --sans: 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
  --head: 'Jost', 'Futura', 'Segoe UI', system-ui, sans-serif;
  color-scheme: dark;
  accent-color: var(--foil);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--sky);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--foil); color: var(--foil-ink); }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--foil); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--head); font-weight: 500; letter-spacing: 0; }

/* ---------- top bar ---------- */
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--sky);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.mark { width: 30px; height: 30px; flex: none; }
.brand h1 { margin: 0; font-size: 21px; line-height: 1; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.topctl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }

/* Layer tabs: plain tabs, the active one underlined in foil. */
.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.ib.quiet-ib { border-color: transparent; color: var(--muted); }
.ib.quiet-ib:hover { color: var(--bad); }
.tab { position: relative; min-height: 44px; padding: 0 14px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font: 500 15px var(--head); }
.tab:hover { color: var(--text); background: var(--raised); }
.tab[aria-pressed="true"] { color: var(--text); }
.tab[aria-pressed="true"]::after { content: ''; position: absolute; left: 14px; right: 14px; bottom: 4px; height: 2px; border-radius: 2px; background: var(--foil); }
.tab kbd { margin-left: 6px; }

.stepper { display: flex; align-items: center; gap: 2px; color: var(--muted); }
.stepper label { display: inline-flex; align-items: center; gap: 4px; padding: 0 4px; }
.stepper input { width: 46px; height: 32px; padding: 0 4px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text); font: 600 14px var(--sans); text-align: center; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:hover { border-color: var(--line-2); }
.stepper input:focus { outline: none; border-color: var(--foil); background: var(--sky); }
.stepper i { width: 1px; height: 20px; margin: 0 8px; background: var(--line-2); }
.ib { width: 32px; height: 32px; border: 1px solid var(--line-2); border-radius: 6px; background: transparent; font-size: 16px; line-height: 1; }
.ib:hover { background: var(--raised); color: var(--text); }

.acts, .row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { min-height: 36px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--raised); font-weight: 600; }
.btn:hover { background: var(--raised-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--foil); border-color: var(--foil); color: var(--foil-ink); }
.btn.primary:hover { background: #E5B458; }
.btn.quiet { background: transparent; }
.btn.quiet:hover { background: var(--raised); }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 296px minmax(0, 1fr) 320px; align-items: start; min-height: calc(100vh - 66px); }
.side { position: sticky; top: 0; max-height: 100vh; overflow: auto; background: var(--panel); }
.catalog { border-right: 1px solid var(--line); padding: 12px 10px 20px; }
.panel { border-left: 1px solid var(--line); }
.stage { min-width: 0; padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- catalog ---------- */
.search { display: flex; align-items: center; gap: 8px; padding: 0 10px; margin: 0 2px 10px; border-radius: 6px; background: var(--sky); border: 1px solid var(--line-2); }
.search:focus-within { border-color: var(--foil); }
.search svg { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; height: 38px; border: 0; background: transparent; color: var(--text); font: inherit; caret-color: var(--foil); }
.search input:focus { outline: none; }
.search input::placeholder { color: var(--faint); }

.drawer + .drawer { margin-top: 6px; }
.drawer-head { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 8px; border: 0; border-radius: 6px; background: transparent; text-align: left; }
.drawer-head:hover { background: var(--raised); }
.drawer-head span { flex: 1; font: 500 17px var(--head); }
.drawer-head em, .sec-head em { font-style: normal; color: var(--faint); font-size: 12.5px; }
.chev { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transform: rotate(-90deg); transition: transform 160ms cubic-bezier(.2, .7, .3, 1); }
.open > button > .chev { transform: none; }
.drawer-body { padding: 0 0 4px 8px; margin-left: 15px; border-left: 1px solid var(--line); }

.sec-head { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 34px; padding: 4px 6px; border: 0; border-radius: 6px; background: transparent; text-align: left; color: var(--muted); font-weight: 600; font-size: 13px; }
.sec-head span { flex: 1; }
.sec-head .chev { width: 13px; height: 13px; }
.sec-head:hover { color: var(--text); background: var(--raised); }
.sec-body { display: flex; flex-direction: column; padding-bottom: 4px; }
.empty { margin: 8px 6px; color: var(--muted); }

.tool { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 4px 8px 4px 4px; border: 0; border-radius: 6px; background: transparent; text-align: left; touch-action: none; cursor: grab; }
.tool:hover { background: var(--raised); }
.tool.on { background: var(--foil-soft); box-shadow: inset 0 0 0 1px var(--foil); }
.sw { width: 34px; height: 34px; flex: none; border-radius: 6px; display: flex; align-items: center; justify-content: center; box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.45); }
.sw.lg { width: 44px; height: 44px; border-radius: 8px; box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.45); }
.nm { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.nm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nm small { color: var(--faint); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct { color: var(--text); font-weight: 600; font-size: 13px; }
.ct::before { content: '×'; color: var(--faint); margin-right: 1px; font-weight: 400; }
/* Undo, redo and the eraser sit in a row above the zoom controls. */
.viewtools { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.edit { display: flex; gap: 4px; }
.iconbtn { display: inline-flex; align-items: center; gap: 6px; }
.iconbtn:disabled { opacity: 0.4; cursor: default; }
.iconbtn:disabled:hover { background: transparent; }
.btn.eraser { color: var(--bad); }
.btn.eraser.on { background: var(--bad); border-color: var(--bad); color: #1A1408; }

/* ---------- board ---------- */
.stage > * { flex: none; }
/* The board takes whatever height is left under the toolbar, so Fit always shows the whole grid. */
.stage { height: calc(100vh - 66px); }
.stage > .board { flex: 1 1 0; min-height: 320px; }
.boardbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.status { flex: 1; min-width: 240px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 40px; color: var(--muted); }
.toggle { display: inline-flex; align-items: center; gap: 6px; }
.toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.zoom { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.zoom span { min-width: 46px; text-align: center; color: var(--text); font-weight: 600; }
.zoom [aria-pressed="true"] { color: var(--foil); }
.shell.no-pieces { grid-template-columns: minmax(0, 1fr) 320px; }
.shell.no-pieces .catalog { display: none; }
/* Hiding the details panel gives its width to the board; hiding both sides makes the map full width. */
.shell.no-panel { grid-template-columns: 296px minmax(0, 1fr); }
.shell.no-pieces.no-panel { grid-template-columns: minmax(0, 1fr); }
.shell.no-panel .panel { display: none; }
.status > span:first-child { flex: 1; min-width: 220px; }
.status b { color: var(--text); font-weight: 600; }
.mats { display: flex; gap: 4px; }
.mat { min-height: 30px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-2); background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.mat::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.mat:hover { color: var(--text); background: var(--raised); }
.mat[aria-pressed="true"] { color: var(--text); border-color: var(--c); background: var(--raised); }

/* The board is a scrolling viewport: zoom sets the drawing's pixel size, drag on empty ground pans. */
.board { overflow: auto; border-radius: 8px; background: #121211; border: 1px solid var(--line); touch-action: none; user-select: none; -webkit-user-select: none; overscroll-behavior: contain; }
.board.panning { cursor: grabbing; }
.board svg { display: block; margin: 0 auto; }
.lbl { fill: var(--faint); font: 500 13px var(--sans); text-anchor: middle; }
.ht { fill: #3A3833; font: 700 10.5px var(--sans); text-anchor: end; }
.capsules { stroke-dasharray: 0.1 11; }

/* ---------- right panel ---------- */
.block { padding: 16px 18px; }
.block + .block { border-top: 1px solid var(--line); }
.block h2 { margin: 0 0 10px; font-size: 16px; }
.block-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.block-top h2 { margin: 0; }
.close { width: 30px; height: 30px; flex: none; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); }
.close:hover { background: var(--raised); color: var(--text); }
.close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.inspector { position: relative; }
.inspector .head { padding-right: 34px; }
.close.corner { position: absolute; top: 12px; right: 12px; }
/* The blueprint check folds down to one line with the total and power. */
.check-head { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; margin: -4px 0 10px; padding: 4px 0; border: 0; background: transparent; text-align: left; }
.check-head span { flex: 1; font: 500 16px var(--head); }
.check-head em { font-style: normal; color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.check-head em.bad { color: var(--bad); }
.check:not(.open) .check-head { margin-bottom: -4px; }
.tips-link { margin: 0; padding: 4px 18px 16px; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.head h3 { margin: 0; font-size: 19px; line-height: 1.2; }
.head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.note { margin: 0 0 12px; color: var(--muted); }

.rows { margin: 0 0 12px; }
.rows div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.rows div:last-child { border-bottom: 0; }
.rows dt { color: var(--muted); }
.rows dd { margin: 0; text-align: right; font-weight: 600; }
.rows dd small { color: var(--faint); font-weight: 400; }
.rows .bad dd { color: var(--bad); }
.rows .total { margin-top: 4px; border-top: 1px solid var(--line-2); }
.rows .total dt { color: var(--text); font-weight: 600; }
.rows .total dd { font-size: 16px; }
.kg { white-space: nowrap; }
.kg::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: var(--c); }
.kg + .kg { margin-left: 8px; }

.power { margin: 0 0 14px; }
.power-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.power-top span { color: var(--muted); }
.power-top b { font-size: 16px; }
.power-top small { color: var(--faint); font-weight: 400; }
.bar { height: 6px; border-radius: 3px; background: var(--raised-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--foil); transition: width 200ms ease-out; }
.power.bad .bar i { background: var(--bad); }
.power.bad b { color: var(--bad); }
.power > small { display: block; margin-top: 6px; color: var(--faint); }

.ports { list-style: none; margin: 0 0 12px; padding: 0; }
.ports li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.ports li::before { content: ''; width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--c); }
.ports li em { margin-left: auto; font-style: normal; font-size: 12.5px; color: var(--bad); }
.ports li.ok em { color: var(--good); }
.flag { margin: 0 0 12px; padding: 8px 10px; border-radius: 6px; background: var(--raised); color: var(--muted); font-size: 13px; }
.flag b { color: var(--foil); font-weight: 600; }
.keys { margin: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--faint); font-size: 12.5px; }
.keys span { white-space: nowrap; }
kbd { display: inline-block; min-width: 20px; padding: 0 5px; border-radius: 4px; border: 1px solid var(--line-2); border-bottom-width: 2px; background: var(--raised); color: var(--text); font: 600 11px/18px var(--sans); text-align: center; }

.issues { list-style: none; margin: 4px 0 0; padding: 0; }
.issues li { padding: 8px 10px; border-radius: 6px; background: var(--bad-soft); color: #F6B3A6; font-size: 13px; }
.issues li + li { margin-top: 6px; }
.issues li.info { background: var(--raised); color: var(--muted); }
.fine { margin: 4px 0 0; color: var(--good); font-size: 13px; }

footer { padding: 14px 20px 28px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12.5px; }
footer p { margin: 0; max-width: 100ch; }
footer b { color: var(--foil); font-weight: 600; }
.ghost { position: fixed; width: 52px; height: 52px; border-radius: 8px; display: flex; align-items: center; justify-content: center; pointer-events: none; box-shadow: 6px 8px 0 rgba(0, 0, 0, 0.5); z-index: 10; }
.ghost[hidden] { display: none; }

/* ---------- smaller screens ---------- */
@media (max-width: 1180px) {
  .shell { grid-template-columns: 272px minmax(0, 1fr); }
  .shell.no-pieces { grid-template-columns: minmax(0, 1fr); }
  .shell.no-panel { grid-template-columns: 272px minmax(0, 1fr); }
  .shell.no-pieces.no-panel { grid-template-columns: minmax(0, 1fr); }
  .panel { grid-column: 1 / -1; position: static; max-height: none; border-left: 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; }
  .panel .block + .block { border-top: 0; border-left: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .top { padding: 10px 16px; }
  .shell { grid-template-columns: 1fr; }
  .stage { order: -1; padding: 12px 16px; }
  .side { position: static; max-height: none; }
  .catalog { border-right: 0; border-top: 1px solid var(--line); }
  .panel { grid-template-columns: 1fr; }
  .panel .block + .block { border-left: 0; border-top: 1px solid var(--line); }
  .tab kbd { display: none; }
  .acts { width: 100%; }
  .acts .btn { flex: 1; padding: 0 8px; font-size: 13px; white-space: nowrap; }
  .stage { height: auto; }
  .stage > .board { flex: none; height: 62vh; }
  .shell.no-pieces { grid-template-columns: 1fr; }
  .shell.no-panel, .shell.no-pieces.no-panel { grid-template-columns: 1fr; }
}

/* Community links match the planner's existing gold accent. */
.discord-link { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--foil); text-decoration: none; white-space: nowrap; }
footer .community { margin-bottom: 10px; color: var(--muted); }
.community a { color: var(--foil); text-underline-offset: 3px; }
.community a:hover { color: var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }