/* The chrome is deliberately neutral grey so it doesn't skew how map colours read. */
:root {
  --bg: #f4f4f3; --panel: #ffffff; --line: #dddcd9; --ink: #1e1e1d; --muted: #6d6c68;
  --accent: #d9480f; --accent-soft: #fdece4; --radius: 6px;
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }

.bar { display: flex; align-items: center; gap: 12px; height: 46px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.bar h1 { font-size: 14px; font-weight: 600; margin: 0 6px 0 2px; letter-spacing: -0.01em; white-space: nowrap; }
.bar-group { display: flex; gap: 4px; align-items: center; }
.spacer { flex: 1; }
#zoom-readout { min-width: 42px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

button { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 10px; cursor: pointer; white-space: nowrap; }
button:hover { border-color: #a9a8a3; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 500; padding: 8px 12px; width: 100%; }
button.primary:hover { background: #3a3a38; }
.seg button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip { background: var(--accent-soft); border-color: #f4c4ae; color: #a93a0b; }

main { flex: 1; min-height: 0; display: flex; }
#stage-wrap { flex: 1; min-width: 0; position: relative; overflow: hidden; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#stage.moving { cursor: move; }
#stage.dragging { cursor: grabbing; }

#side { width: 340px; flex: none; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
#tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
#tabs button { flex: 1; border: 0; border-radius: 0; padding: 10px 0 9px; background: none; color: var(--muted); border-bottom: 2px solid transparent; }
#tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
#panes { flex: 1; overflow-y: auto; padding: 4px 14px 28px; }
.pane { display: none; }
.pane.on { display: block; }

.group { border-bottom: 1px solid #ecebe8; padding: 10px 0 12px; }
.group:last-child { border-bottom: 0; }
.group > h3 { display: flex; align-items: center; gap: 7px; margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.group.off > :not(h3) { display: none; }
.group.off > h3 { margin-bottom: 0; color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }

.row { display: grid; grid-template-columns: 104px 1fr; align-items: center; gap: 8px; min-height: 30px; }
.row > label { color: #44433f; }
.row .ctl { display: flex; align-items: center; gap: 6px; min-width: 0; }
.row input[type=range] { flex: 1; min-width: 0; accent-color: var(--ink); }
.row input[type=number] { width: 62px; text-align: right; padding: 3px 4px; border: 1px solid var(--line); border-radius: 4px; font-variant-numeric: tabular-nums; }
.row .unit { color: var(--muted); font-size: 11px; width: 18px; }
.row select, .row input[type=text] { width: 100%; padding: 4px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
input[type=color] { width: 34px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: none; cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 2px; }
.check { display: flex; align-items: center; gap: 7px; min-height: 28px; }

.themes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.theme { padding: 7px 8px; text-align: left; display: flex; flex-direction: column; gap: 5px; }
.theme .strip { display: flex; height: 16px; border-radius: 3px; overflow: hidden; }
.theme .strip i { flex: 1; }
.palette { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.palette .sw { position: relative; }
.palette .sw button { position: absolute; top: -6px; right: -6px; width: 15px; height: 15px; padding: 0; line-height: 12px; font-size: 11px; border-radius: 50%; display: none; }
.palette .sw:hover button { display: block; }

.readout { background: var(--bg); border-radius: var(--radius); padding: 8px 10px; margin: 8px 0; font-variant-numeric: tabular-nums; }
.readout b { font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 6px; }
.warn { background: var(--accent-soft); color: #8e310a; border-radius: var(--radius); padding: 8px 10px; margin: 8px 0; }
pre.spec { white-space: pre-wrap; background: var(--bg); padding: 8px 10px; border-radius: var(--radius); font: 11px/1.45 ui-monospace, Menlo, monospace; margin: 8px 0; }
#status { min-height: 18px; color: var(--muted); margin-top: 6px; }

#inspector { position: absolute; left: 12px; bottom: 12px; width: 268px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 12px; box-shadow: 0 6px 22px rgb(0 0 0 / 0.14); }
#inspector h2 { font-size: 14px; margin: 0 0 6px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#inspector h2 button { border: 0; font-size: 15px; padding: 0 4px; color: var(--muted); }
#inspector textarea { width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 4px; padding: 4px; }
#inspector .actions { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; }

#boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); font-size: 15px; color: var(--muted); z-index: 10; }

@media (max-width: 780px) {
  main { flex-direction: column; }
  #side { width: 100%; height: 45%; border-left: 0; border-top: 1px solid var(--line); }
  .bar { overflow-x: auto; }
}

#compare { position: fixed; inset: 0; z-index: 5; background: var(--bg); display: flex; flex-direction: column; padding: 12px 16px 16px; }
#compare header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; flex: none; }
#compare h2 { font-size: 15px; margin: 0; }
.compare-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 10px; }
.compare-card { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 6px; white-space: normal; min-height: 0; }
.compare-card canvas { flex: 1; min-height: 0; width: 100%; display: block; border-radius: 3px; }
.compare-card strong { font-size: 13px; margin-top: 4px; }
.compare-card span { color: var(--muted); font-size: 12px; }
@media (max-width: 780px) {
  #compare { overflow-y: auto; }
  .compare-grid { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-rows: 280px; }
}

.font-set { color: var(--muted); font-size: 12px; margin: 10px 0 5px; }
.font-set:first-child { margin-top: 0; }
.font-card { font-size: 11px; color: var(--muted); gap: 2px; }
.font-card canvas { width: 100%; height: auto; display: block; }
.font-card.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); color: var(--ink); }

#stage.sizing { cursor: none; }
#coaster { position: absolute; left: 0; top: 0; border: 1.5px solid rgb(0 0 0 / 0.75); border-radius: 50%; pointer-events: none; }
#coaster span { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 3px; padding: 0 5px; border-radius: 3px; background: rgb(255 255 255 / 0.85); font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
