/* Barvosklad — every colour below comes from the generated palette.
   The app writes --brand-*, --success-*, --warning-*, --danger-*, --info-* and --neutral-*
   onto :root, so the tool re-skins itself as you edit the brand colour.
   Fallbacks only cover the first paint.

   Layout: one screen, no page scroll (≥ 760px wide). Inspector on the
   left holds every control; the workspace grid holds every output. */

:root {
  --neutral-50: #f6f5fa; --neutral-100: #ebe9f3; --neutral-200: #d6d3e3;
  --neutral-300: #b9b5cc; --neutral-400: #9590ab; --neutral-500: #77728d;
  --neutral-600: #5e5a72; --neutral-700: #47445a; --neutral-800: #312f40;
  --neutral-900: #1f1d2a; --neutral-950: #0f0e17;
  --brand: #6d4aff; --on-brand: #fff;
  --brand-300: #b3a1ff; --brand-400: #8f75ff; --brand-500: #6d4aff;

  /* Fixed UI chrome: never re-tinted by the palette */
  --ui-50: #f5f5f6; --ui-100: #e9e9eb; --ui-200: #d4d4d8; --ui-300: #b4b4bb;
  --ui-400: #8e8e96; --ui-500: #6e6e76; --ui-600: #55555c; --ui-700: #404046;
  --ui-800: #2c2c31; --ui-900: #1c1c20; --ui-950: #111113;

  --bg: var(--ui-950);
  --panel: color-mix(in oklab, var(--ui-900) 70%, var(--ui-950));
  --surface-2: color-mix(in oklab, var(--ui-800) 55%, transparent);
  --line: color-mix(in oklab, var(--ui-700) 50%, transparent);
  --line-strong: var(--ui-700);
  --text: var(--ui-50);
  --text-2: var(--ui-300);
  --text-3: var(--ui-500);

  --gap: 10px;
  --radius: 16px;
  --font: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 13px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
code { font-family: var(--mono); }
button { font: inherit; color: inherit; cursor: pointer; }
.boot { display: grid; place-items: center; height: 100vh; color: #888; font-family: var(--mono); }

/* ================================================================ shell */
.shell {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  height: 100vh; height: 100dvh;
  overflow: hidden;
}

/* ---------------------------------------------------------------- inspector */
.inspector {
  display: flex; flex-direction: column; gap: 11px;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  background: color-mix(in oklab, var(--ui-900) 45%, var(--ui-950));
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--ui-800) transparent;
}
.insp-head { display: flex; align-items: center; justify-content: space-between; }
.brandmark { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -0.02em; font-size: 15px; }
.logo-mark { display: grid; grid-template-columns: repeat(3, 6px); gap: 2px; }
.logo-mark i { width: 6px; height: 6px; border-radius: 2px; }
.insp-title {
  font: 600 10.5px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-3);
  padding-top: 10px; border-top: 1px solid var(--line);
}
.insp-head + .insp-title { border-top: 0; padding-top: 0; }
.insp-block { display: flex; flex-direction: column; gap: 10px; }
.info-tip {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; flex: none;
  border: 1px solid var(--line-strong); color: var(--text-3); font: 600 11px var(--mono); cursor: help;
}

/* ---------------------------------------------------------------- workspace */
/* one shared grid, so the split lines of the top and bottom rows coincide */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--gap);
  padding: var(--gap);
  min-width: 0; min-height: 0;
}
.workspace.wide { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1fr); }
.toolbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; min-height: 34px; }
.row-visuals, .row-output { display: contents; }
.workspace.wide .row-output > :first-child { grid-column: span 2; }

.panel {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px 12px; overflow: hidden;
}
.panel-title { display: flex; align-items: center; gap: 10px; flex: none; height: 26px; margin-bottom: 8px; min-width: 0; }
.panel-title b { font-weight: 600; font-size: 13px; white-space: nowrap; }
.panel-title small { color: var(--text-3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-body { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.tabs { display: flex; gap: 2px; padding: 2px; border-radius: 999px; background: var(--surface-2); min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; color: var(--text-2); padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.tabs button.on { background: var(--ui-50); color: var(--ui-950); }

/* ================================================================ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; padding: 0 16px; border-radius: 999px;
  border: 1px solid transparent; font-weight: 500; font-size: 13px; white-space: nowrap;
  transition: transform .15s, background-color .2s, border-color .2s;
}
.btn.sm { height: 28px; padding: 0 12px; font-size: 12px; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-400); }
.btn.ghost { border-color: var(--line-strong); background: transparent; }
.btn.ghost:hover { border-color: var(--ui-500); }
.btn.icon { width: 34px; padding: 0; border-color: var(--line-strong); background: transparent; flex: none; }
.btn.wide { width: 100%; }

.seg {
  display: inline-flex; flex-wrap: nowrap; gap: 2px; padding: 2px; max-width: 100%; min-width: 0;
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
}
.seg::-webkit-scrollbar { display: none; }
.seg.wrap { flex-wrap: wrap; overflow-x: visible; border-radius: 14px; }
.seg button {
  flex: none; border: 0; background: transparent; color: var(--text-2);
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--ui-50); color: var(--ui-950); }

.chip {
  border: 1px solid var(--line-strong); background: transparent; color: var(--text-3);
  padding: 2px 9px; border-radius: 999px; font-size: 11px; font-family: var(--mono);
}
.chip.on { color: var(--text); border-color: var(--brand-400); background: color-mix(in oklab, var(--brand-500) 18%, transparent); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: 999px; font: 500 11px var(--mono); white-space: nowrap; flex: none; min-width: max-content;
}
.pill i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--success-300); background: color-mix(in oklab, var(--success-500) 16%, transparent); }
.pill.info { color: var(--info-300); background: color-mix(in oklab, var(--info-500) 18%, transparent); }
.pill.warn { color: var(--warning-300); background: color-mix(in oklab, var(--warning-500) 16%, transparent); }
.pill.bad { color: var(--danger-300); background: color-mix(in oklab, var(--danger-500) 18%, transparent); }

.toggle { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-2); cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle .knob { width: 28px; height: 16px; border-radius: 999px; background: var(--ui-800); position: relative; transition: background .2s; flex: none; }
.toggle .knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--ui-300); transition: transform .2s, background .2s; }
.toggle input:checked + .knob { background: var(--brand); }
.toggle input:checked + .knob::after { transform: translateX(12px); background: var(--on-brand); }

.ctl-group { display: flex; flex-direction: column; gap: 6px; }
.ctl-label { font: 500 10.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.ctl-label .fit { font-style: normal; color: var(--brand-300); text-transform: none; letter-spacing: 0; }
.mini-range { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
.mini-range span { display: flex; justify-content: space-between; }
.mini-range b { font: 500 11.5px var(--mono); color: var(--text); }
.mini-range input { accent-color: var(--brand); margin: 0; height: 14px; }

/* ---------------------------------------------------------------- colour editor */
.brand-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.brand-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px 0 4px; border-radius: 999px;
  border: 1px solid var(--line-strong); font-size: 12px; cursor: pointer; background: transparent; color: var(--text-2);
}
.brand-chip.on { border-color: var(--text); color: var(--text); }
.brand-chip .sw { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.brand-chip .x { border: 0; background: none; color: var(--text-3); padding: 0; font-size: 14px; line-height: 1; }
.brand-chip.add { border-style: dashed; color: var(--text-3); padding: 0 10px; }
.brand-chip.role { color: var(--text); }
.brand-chip.role.off { color: var(--text-3); border-style: dashed; }
.brand-chip.role.off .sw { opacity: .35; }
label.sw { position: relative; cursor: pointer; flex: none; }
label.sw input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.role-add { display: flex; align-items: center; gap: 6px; }
.role-add .role-color { width: 26px; height: 26px; padding: 0; border: 1px solid var(--line-strong); border-radius: 50%; background: none; flex: none; cursor: pointer; }
.role-add .role-color::-webkit-color-swatch-wrapper { padding: 2px; }
.role-add .role-color::-webkit-color-swatch { border: 0; border-radius: 50%; }
.role-add .role-color::-moz-color-swatch { border: 0; border-radius: 50%; }
.role-add .role-name { flex: 1; min-width: 0; height: 26px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--ui-950); color: var(--text); font: 12px var(--font); }

.swatch-big { display: flex; height: 56px; border-radius: 12px; overflow: hidden; flex: none; }
.swatch-big .half { flex: 1; position: relative; transition: background .15s; }
.swatch-big .tag {
  position: absolute; right: 6px; bottom: 6px; font: 500 10px var(--mono);
  background: rgba(0,0,0,.45); color: #fff; padding: 2px 7px; border-radius: 999px;
}
.editor-row { display: flex; gap: 6px; align-items: center; }
.hex {
  flex: 1 1 0; width: 0; min-width: 0; height: 34px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--text); padding: 0 13px; font: 500 13px var(--mono); text-transform: lowercase;
}
.hex:focus { outline: none; border-color: var(--brand-400); }

.channel { display: flex; flex-direction: column; gap: 3px; }
.channel-head { display: flex; justify-content: space-between; align-items: center; }
.channel-label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.num { width: 64px; text-align: right; background: transparent; border: 0; color: var(--text); font: 500 12px var(--mono); padding: 0; }
.num:focus { outline: none; color: var(--brand-300); }
.num::-webkit-inner-spin-button { display: none; }
.channel-track { position: relative; height: 18px; }
.channel-track .track {
  position: absolute; top: 3px; left: 0; width: 100%; height: 12px; border-radius: 999px;
  background: var(--ui-900); box-shadow: inset 0 0 0 1px var(--line);
}
.range { position: absolute; inset: 0; width: 100%; margin: 0; appearance: none; -webkit-appearance: none; background: transparent; cursor: pointer; }
.range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--thumb); border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.5);
}
.range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--thumb); border: 3px solid #fff; }

.readout { margin: 0; display: grid; gap: 3px; }
.readout div { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; }
.readout dt { color: var(--text-3); white-space: nowrap; }
.readout dd { margin: 0; font-family: var(--mono); color: var(--text-2); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================================================================ visuals */
.plane {
  position: relative; width: 100%; height: 100%; border-radius: 10px; overflow: hidden; touch-action: none;
  background:
    repeating-linear-gradient(45deg, transparent 0 6px, color-mix(in oklab, var(--ui-800) 35%, transparent) 6px 7px),
    var(--ui-950);
}
.plane canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.plane-over { cursor: crosshair; }
.wheel-wrap { position: relative; height: 100%; aspect-ratio: 1 / 1; max-width: 100%; margin: 0 auto; }
.plane.round { border-radius: 50%; }
.wheel-geo { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.wheel-geo .orbit { fill: none; stroke: rgba(255,255,255,.4); stroke-width: .3; stroke-dasharray: 1 1.2; }
.wheel-geo .harmony { fill: rgba(255,255,255,.05); stroke: rgba(255,255,255,.7); stroke-width: .35; }
.wheel-geo .spoke { stroke: rgba(255,255,255,.35); stroke-width: .25; }

.solid { display: flex; flex-direction: column; gap: 8px; height: 100%; }
.solid-canvas {
  position: relative; flex: 1; min-height: 0; border-radius: 10px; overflow: hidden;
  background: var(--ui-950);
}
.solid-canvas canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.solid-canvas canvas:active { cursor: grabbing; }
.solid-caption {
  position: absolute; left: 8px; top: 8px; pointer-events: none;
  font: 500 10px var(--mono); color: rgba(255,255,255,.7);
  background: rgba(10,10,12,.55); padding: 2px 7px; border-radius: 4px;
}
.solid-layers { display: flex; flex-wrap: wrap; gap: 5px; flex: none; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11.5px; color: var(--text-3); margin-left: auto; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 9px; border-radius: 3px; display: inline-block; }
.lg-srgb { background: linear-gradient(90deg, var(--danger-500), var(--warning-400), var(--success-500), var(--info-500)); }
.lg-p3 { background: linear-gradient(90deg, var(--danger-500), var(--success-500)); box-shadow: inset 0 0 0 1px rgba(255,255,255,.6); }
.lg-real { background: repeating-linear-gradient(45deg, #333 0 2px, #777 2px 5px); }
.lg-none { background: var(--ui-950); box-shadow: inset 0 0 0 1px var(--line-strong); }
.computing { color: var(--warning-300); font-family: var(--mono); }

/* ================================================================ palette */
.palette {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: grid; grid-template-rows: 14px; grid-auto-rows: minmax(30px, 1fr); gap: 4px;
  scrollbar-width: thin; scrollbar-color: var(--ui-800) transparent;
}
.steps-head, .prow { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 4px; }
.steps-head { grid-template-columns: 150px repeat(11, minmax(0, 1fr)); font: 500 10px var(--mono); color: var(--text-3); align-items: end; }
.steps-head > span { text-align: center; }
.pbase {
  border-radius: 8px; padding: 3px 9px; display: flex; flex-direction: column; justify-content: center;
  cursor: copy; transition: background .3s; min-width: 0; overflow: hidden;
}
.pbase[title^="Edit"] { cursor: pointer; }
.pbase.on { box-shadow: inset 0 0 0 2px currentColor; }
.ctl-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; }
.sel-role { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 26px; font-size: 12px; color: var(--text-2); }
.sel-role b { color: var(--text); font-weight: 600; }
.sel-role small { color: var(--text-3); font-size: 11px; }
.pbase-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 12px; }
.pbase-top b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pbase code { font-size: 10.5px; font-weight: 600; }
.pbase small { font: 10px var(--mono); opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pscale { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 3px; }
.cell {
  border: 0; border-radius: 6px; padding: 3px 4px; display: flex; flex-direction: column;
  justify-content: space-between; align-items: flex-start; min-width: 0; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
  transition: background .3s, transform .12s;
}
.cell:hover { transform: scale(1.06); z-index: 1; }
.cell span { font: 600 9.5px var(--mono); opacity: .85; }
.cell code { font-size: 9px; opacity: .75; white-space: nowrap; }

/* ================================================================ output tabs */
.export { display: flex; flex-direction: column; gap: 8px; height: 100%; min-height: 0; }
.export-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; flex: none; }
.export-bar .btn { margin-left: auto; }
.code {
  flex: 1; min-height: 0; margin: 0; overflow: auto; padding: 10px 12px; border-radius: 10px;
  background: var(--ui-950); border: 1px solid var(--line); font: 11.5px/1.55 var(--mono); color: var(--text-2);
  white-space: pre; scrollbar-width: thin; scrollbar-color: var(--ui-800) transparent;
}

.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; height: 100%; min-height: 0; }
.mock { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.mock.light { --m-bg: var(--neutral-50); --m-surface: #fff; --m-text: var(--neutral-900); --m-text-2: var(--neutral-600); --m-line: var(--neutral-200); }
.mock.dark { --m-bg: var(--neutral-950); --m-surface: var(--neutral-900); --m-text: var(--neutral-50); --m-text-2: var(--neutral-400); --m-line: var(--neutral-800); }
.mock { background: var(--m-bg); color: var(--m-text); }
.mock-top { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--m-line); background: var(--m-surface); font-size: 12px; flex: none; }
.mock-nav { color: var(--m-text-2); font-size: 11.5px; }
.badge { margin-left: auto; font: 600 10px var(--mono); padding: 2px 7px; border-radius: 5px; background: var(--brand-2-100, var(--brand-100)); color: var(--brand-2-800, var(--brand-800)); }
.mock.dark .badge { background: var(--brand-2-900, var(--brand-900)); color: var(--brand-2-200, var(--brand-200)); }
.mock-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.mock-bars { display: flex; align-items: flex-end; gap: 6px; flex: 1; min-height: 24px; padding: 6px 8px; background: var(--m-surface); border: 1px solid var(--m-line); border-radius: 8px; }
.mock-bars i { flex: 1; border-radius: 4px 4px 2px 2px; }
.mock-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.m-primary { border: 0; border-radius: 999px; padding: 5px 11px; background: var(--brand); color: var(--on-brand); font-weight: 500; font-size: 11.5px; }
.m-secondary { border: 1px solid var(--m-line); border-radius: 999px; padding: 4px 11px; background: var(--m-surface); color: var(--m-text); font-size: 11.5px; }
.m-link { color: var(--brand-3-600, var(--brand-600)); font-size: 11.5px; font-weight: 500; }
.mock.dark .m-link { color: var(--brand-3-300, var(--brand-300)); }
.alerts { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.alert { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 7px; font-size: 11px; white-space: nowrap; overflow: hidden; }
.alert i { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.alert span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
  background: var(--ui-50); color: var(--ui-950); padding: 8px 16px; border-radius: 999px;
  font: 500 12px var(--mono); animation: toast .25s ease-out;
}
@keyframes toast { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ================================================================ responsive */
/* tablets: narrower inspector; chroma × lightness moves into the tabs (JS) */
@media (max-width: 1279px) {
  .shell { grid-template-columns: 264px minmax(0, 1fr); }
  .steps-head, .prow { grid-template-columns: 112px minmax(0, 1fr); }
  .steps-head { grid-template-columns: 112px repeat(11, minmax(0, 1fr)); }
  .cell code { display: none; }
  .legend { gap: 10px; }
  .pbase-top { flex-direction: column; align-items: flex-start; gap: 0; }
  .pbase small { display: none; }
  .tabs + small { display: none; }
}
/* tablet portrait: palette and output tabs get full-width rows of their own */
@media (max-width: 1099px) and (orientation: portrait) {
  .workspace { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
               grid-template-rows: auto minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, .8fr); }
  .row-output > * { grid-column: 1 / -1; }
}
/* short screens: tighten the inspector so it fits without scrolling */
@media (max-height: 920px) and (min-width: 760px) {
  .inspector { gap: 9px; padding-top: 10px; }
  .insp-block { gap: 7px; }
  .swatch-big { height: 36px; }
  .seg button { padding: 3px 9px; }
}
@media (max-height: 800px) and (min-width: 760px) {
  .readout { display: none; }
}
/* ================================================================ phone
   Chosen in JS (narrow or short viewports): a single screen with a header,
   one view at a time and a bottom tab bar. Nothing scrolls except long
   lists inside their own box. */
.swatch-dot { width: 34px; height: 34px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.inspector .swatch-dot { display: none; }

.m-app {
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh; height: 100dvh; overflow: hidden;
}
.m-header {
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--ui-900) 45%, var(--ui-950));
}
.m-header .brandmark { font-size: 14px; margin-right: auto; white-space: nowrap; }
.m-header .seg button { padding: 3px 8px; font-size: 11px; }
.m-header .btn.icon { width: 30px; height: 30px; }
.m-main { display: flex; min-height: 0; min-width: 0; }
.m-view { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 10px 12px; }

.m-pick-visual { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.m-pick-visual > .seg.scroll { flex: none; align-self: flex-start; max-width: 100%; }
.m-pick-plane { flex: 1 1 auto; min-height: 130px; display: flex; flex-direction: column; }
.m-pick-plane .plane { border-radius: 14px; }
.m-pick-controls { display: flex; flex-direction: column; gap: 10px; flex: none; }
.m-pick-controls .sliders { display: flex; flex-direction: column; gap: 8px; }

.m-harmony { display: flex; gap: 8px; align-items: center; flex: none; }
.seg.scroll { flex: 1; }
.m-hint { margin: -4px 0 0; font-size: 11px; color: var(--brand-300); flex: none; }
.m-app .palette { grid-auto-rows: minmax(28px, 1fr); gap: 3px; }
.m-app .prow, .m-app .steps-head { grid-template-columns: 74px minmax(0, 1fr); gap: 3px; }
.m-app .steps-head { grid-template-columns: 74px repeat(11, minmax(0, 1fr)); font-size: 8.5px; }
.m-app .pscale { gap: 2px; }
.m-app .cell { border-radius: 4px; padding: 0; }
.m-app .cell span, .m-app .cell code { display: none; }
.m-app .cell:hover { transform: none; }
.m-app .pbase { padding: 2px 7px; border-radius: 6px; }
.m-app .pbase-top { flex-direction: column; align-items: flex-start; gap: 0; font-size: 11px; }
.m-app .pbase code { font-size: 9.5px; }
.m-app .pbase small { display: none; }

.m-fill { flex: 1; min-height: 0; }
.m-app .panel { padding: 8px 10px 10px; }
.m-app .panel-title { height: 28px; }
.m-app .tabs { flex: 1; }
.m-readout { display: flex; gap: 10px; align-items: center; flex: none; font-size: 11.5px; color: var(--text-2); }
.m-readout .swatch-dot { width: 20px; height: 20px; }
.m-app .legend { margin-left: 0; gap: 10px; font-size: 10.5px; flex: none; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
.m-app .alerts { grid-template-columns: 1fr; }

.m-tabbar {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  background: color-mix(in oklab, var(--ui-900) 45%, var(--ui-950));
  padding-bottom: env(safe-area-inset-bottom);
}
.m-tabbar button {
  border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 7px; color: var(--text-3); font-size: 11px; font-weight: 500;
}
.m-tabbar svg { width: 22px; height: 22px; fill: currentColor; }
.m-tabbar button.on { color: var(--brand-300); }

.m-sheet-wrap {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end;
  background: rgba(0, 0, 0, .5); animation: fade .2s ease-out;
}
.m-sheet {
  width: 100%; max-height: 82dvh; display: flex; flex-direction: column;
  background: var(--ui-900); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0;
  padding: 12px 14px calc(16px + env(safe-area-inset-bottom));
  animation: sheet-up .25s ease-out;
}
.m-sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex: none; }
.m-sheet-body { overflow-y: auto; overscroll-behavior: contain; }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.m-app .toast { bottom: calc(78px + env(safe-area-inset-bottom)); }

/* phone landscape: plane beside the controls, slimmer bars */
@media (orientation: landscape) {
  .m-pick { flex-direction: row; }
  .m-pick-visual { flex: 1.3; min-width: 0; }
  .m-pick-plane { min-height: 0; }
  .m-pick-controls { flex: 1; min-width: 0; overflow-y: auto; }
  .m-tabbar button { flex-direction: row; justify-content: center; gap: 6px; padding: 5px 0; }
  .m-tabbar svg { width: 18px; height: 18px; }
  .m-header { padding-top: 6px; padding-bottom: 6px; }
  .m-view { gap: 6px; padding-top: 6px; padding-bottom: 6px; }
  .m-hint { display: none; }
  .m-app .palette { grid-auto-rows: minmax(16px, 1fr); grid-template-rows: 12px; gap: 2px; }
  .m-app .prow, .m-app .steps-head { grid-template-columns: 150px minmax(0, 1fr); }
  .m-app .steps-head { grid-template-columns: 150px repeat(11, minmax(0, 1fr)); }
  .m-app .pbase-top { flex-direction: row; align-items: baseline; justify-content: space-between; width: 100%; }
}
