/* Ace Countertops — design studio theme
   Brand: black-tie card table meets shop floor.
   Near-black #141414 surfaces, gold-foil ramp #F1E2A0 → #D2AE5A → #8C6E2E as a
   precious accent, paper white text, thin gold+white double keylines (the
   door-hanger rule) as the signature motif. */
:root {
  color-scheme: dark;

  /* surfaces — warm near-black elevation steps */
  --bg: #141414;
  --bg-deep: #0F0F0E;
  --surface: #1B1A17;
  --surface-hover: #262420;

  /* ink — paper white, warmed */
  --fg: #F5F1E6;
  --fg-muted: #C8C1B2;
  --fg-subtle: #9B9483;

  /* keylines */
  --border: #2D2A24;
  --border-strong: #4A4232;

  /* gold-foil ramp (sampled from the printed hanger) */
  --gold-hi: #F1E2A0;
  --gold: #D2AE5A;
  --gold-deep: #8C6E2E;

  --primary: var(--gold);
  --primary-fg: #141414;
  --primary-hover: #E3C67C;
  --accent: var(--gold-hi);
  --danger: #D98A7B;

  /* signature: thin gold rule + white hairline, like the hanger */
  --rule-gold: linear-gradient(90deg, var(--gold-deep), var(--gold) 22%, var(--gold-hi) 50%, var(--gold) 78%, var(--gold-deep));
  --rule-white: linear-gradient(90deg, rgba(255,255,255,0.55), rgba(255,255,255,0.55));

  --shadow-sm: 0px 1px 4px -2px rgba(0, 0, 0, 0.6);
  --shadow-md: 0px 8px 28px -6px rgba(0, 0, 0, 0.7);
  --radius: 8px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  overflow: hidden;
}
::selection { background: var(--gold); color: var(--primary-fg); }

.app {
  display: grid;
  grid-template-rows: 52px 1fr;
  grid-template-columns: 56px 1fr 304px;
  grid-template-areas: "header header header" "rail canvas panel";
  height: 100vh;
}

/* Assistive-tech-only text (the page <h1>: the design has no room for it, but
   the document still needs one). Out of flow, so it never disturbs a layout. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; white-space: nowrap;
  clip-path: inset(50%);
}

/* ---- header — the business card ---- */
.header {
  grid-area: header;
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px 3px;
  background: linear-gradient(180deg, #191815, #141311);
}
/* signature double keyline: gold foil rule over a white hairline */
.header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 4px;
  pointer-events: none;
  background:
    var(--rule-gold) 0 0 / 100% 1.5px no-repeat,
    var(--rule-white) 0 3px / 100% 1px no-repeat;
}
.header .mark { width: 30px; height: 30px; border-radius: 7px; }
.header .brand { font-weight: 700; letter-spacing: 0.3px; white-space: nowrap; }
.header .brand small {
  display: block; font-weight: 600; font-size: 10px;
  color: var(--gold); letter-spacing: 2.2px; text-transform: uppercase;
}
.header .spacer { flex: 1; }
.design-name {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 7px;
  padding: 7px 10px;
  width: 210px;
  font-family: var(--font);
}
.design-name::placeholder { color: var(--fg-subtle); }
.design-name:focus { outline: 2px solid var(--gold); outline-offset: -1px; }

/* ---- buttons ---- */
.btn {
  background: var(--surface-hover);
  border: 1px solid var(--border-strong);
  color: var(--fg);
  border-radius: 7px;
  padding: 7px 13px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #2F2C26; border-color: var(--gold-deep); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 72%, #C49E4C);
  color: var(--primary-fg);
  border-color: var(--gold-deep);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn.primary:hover {
  background: linear-gradient(180deg, #F7EBB4, var(--primary-hover) 72%, var(--gold));
}
.btn.ghost { background: transparent; border-color: var(--border); color: var(--fg-muted); }
.btn.ghost:hover { color: var(--fg); background: var(--surface-hover); border-color: var(--border-strong); }
.btn:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 1px; }

/* ---- left tool rail ---- */
.rail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.tool {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 17px;
  position: relative;
}
.tool:hover { background: var(--surface-hover); color: var(--fg); }
.tool:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 1px; }
.tool.active {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 72%, #C49E4C);
  color: var(--primary-fg);
  border-color: var(--gold-deep);
}
.tool .tip {
  position: absolute; left: 48px; top: 50%; transform: translateY(-50%);
  background: var(--bg-deep); border: 1px solid var(--gold-deep);
  color: var(--fg); font-size: 12px; font-weight: 600;
  padding: 4px 9px; border-radius: 6px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.12s;
  z-index: 30; box-shadow: var(--shadow-sm);
}
.tool:hover .tip { opacity: 1; }
.rail hr {
  width: 26px; border: none; margin: 4px 0; height: 3px;
  background:
    var(--rule-gold) 0 0 / 100% 1px no-repeat,
    var(--rule-white) 0 2px / 100% 1px no-repeat;
  opacity: 0.55;
}

/* ---- canvas area ---- */
.canvas-wrap { grid-area: canvas; position: relative; overflow: hidden; background: var(--bg); }
#plan-host, #gl-host { position: absolute; inset: 0; }
#gl-host canvas { width: 100%; height: 100%; display: block; }
.view-toggle {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 0; z-index: 20;
  border: 1px solid var(--gold-deep); border-radius: 8px; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.view-toggle button {
  background: var(--bg-deep); color: var(--fg-muted); border: none;
  padding: 8px 18px; font-weight: 700; font-size: 12.5px; cursor: pointer;
  font-family: var(--font); letter-spacing: 0.6px;
}
.view-toggle button:hover { color: var(--fg); background: var(--surface-hover); }
.view-toggle button:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: -2px; }
.view-toggle button.active {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 72%, #C49E4C);
  color: var(--primary-fg);
}
.hint {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: color-mix(in srgb, var(--bg-deep) 90%, transparent);
  border: 1px solid var(--border-strong);
  color: var(--fg-muted); font-size: 12px;
  padding: 6px 14px; border-radius: 999px; z-index: 20;
  pointer-events: none; white-space: nowrap;
}

/* ---- right panel ---- */
.panel {
  grid-area: panel;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px;
  display: flex; flex-direction: column; gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
}
.card h2 {
  margin: 0 0 12px;
  font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--fg-subtle);
  padding-bottom: 7px;
  background:
    var(--rule-gold) 0 100% / 34px 1px no-repeat,
    var(--rule-white) 0 calc(100% - 2px) / 34px 1px no-repeat;
}
.swatches { display: block; }
.swatch {
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 5px;
  cursor: pointer;
  background: var(--surface);
  text-align: center;
}
.swatch:hover { border-color: var(--border-strong); }
.swatch:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 1px; }
.swatch.active { border-color: var(--gold); box-shadow: 0 0 0 1px color-mix(in srgb, var(--gold) 35%, transparent); }
.swatch .chip { height: 34px; border-radius: 5px; margin-bottom: 5px; }
.swatch .nm { font-size: 10.5px; font-weight: 600; color: var(--fg-muted); line-height: 1.2; }
.swatch.active .nm { color: var(--fg); }
.field { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 9px; }
.field label { color: var(--fg-muted); font-size: 12.5px; }
.field select {
  background: var(--surface-hover); color: var(--fg);
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 5px 8px; font-family: var(--font);
  /* shrink below the longest option instead of overflowing the panel */
  flex: 1 1 auto; min-width: 0; max-width: 70%;
}
.field select:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 1px; }

/* estimate — a receipt from a nice place */
.card:has(.est-total) { border-color: color-mix(in srgb, var(--gold-deep) 55%, var(--border)); }
.est-rows { display: flex; flex-direction: column; gap: 7px; margin-top: 4px; }
.est-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--fg-muted); }
.est-row b { color: var(--fg); font-weight: 600; font-family: var(--mono); font-size: 12.5px; }
.est-total {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 12px; padding-top: 12px;
  background:
    var(--rule-gold) 0 0 / 100% 1.5px no-repeat,
    var(--rule-white) 0 3px / 100% 1px no-repeat;
}
.est-total > span:first-child {
  font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--fg-muted); font-weight: 600;
}
.est-total .amt { font-size: 24px; font-weight: 800; color: var(--gold-hi); font-family: var(--mono); }
.est-note { font-size: 11px; color: var(--fg-subtle); margin-top: 8px; line-height: 1.45; }

.scene-list { display: flex; flex-direction: column; gap: 6px; }
.scene-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px;
  cursor: pointer; background: var(--surface);
}
.scene-item:hover { border-color: var(--gold); }
.scene-item:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 1px; }
.scene-item .meta { font-size: 11px; color: var(--fg-subtle); }
.empty { color: var(--fg-subtle); font-size: 12.5px; font-style: italic; }

/* ---- parts palette (rail groups + flyout) ---- */
#palette-groups { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.flyout {
  position: absolute; left: 8px; top: 60px; z-index: 40;
  width: 240px; max-height: calc(100% - 80px); overflow-y: auto;
  background: var(--bg-deep);
  border: 1px solid var(--gold-deep);
  border-radius: 10px;
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(241, 226, 160, 0.08);
  padding: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.flyout h2 {
  margin: 2px 2px 9px;
  font-size: 10.5px; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--fg-subtle);
  padding-bottom: 6px;
  background:
    var(--rule-gold) 0 100% / 30px 1px no-repeat,
    var(--rule-white) 0 calc(100% - 2px) / 30px 1px no-repeat;
}
.part-btn {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  width: 100%; text-align: left;
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--border); border-radius: 7px;
  padding: 8px 10px; margin-bottom: 6px;
  font-family: var(--font); font-size: 12.5px; font-weight: 600;
  cursor: pointer;
}
.part-btn:hover { border-color: var(--gold); background: var(--surface-hover); }
.part-btn .price { font-size: 10.5px; color: var(--fg-subtle); font-family: var(--mono); white-space: nowrap; }

/* ---- selection inspector ---- */
.insp-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.insp-title b { font-size: 13.5px; }
.insp-title .pid { font-size: 10px; color: var(--fg-subtle); font-family: var(--mono); }
.insp-kv { display: flex; justify-content: space-between; font-size: 12px; color: var(--fg-muted); padding: 3px 0; }
.insp-kv b { color: var(--fg); font-family: var(--mono); font-weight: 600; }
.insp-field { margin-top: 8px; }
.insp-field label {
  display: block; font-size: 11px; color: var(--fg-muted); margin-bottom: 3px;
  letter-spacing: 0.3px;
}
.insp-field input[type="number"], .insp-field select, .insp-field input[type="text"] {
  width: 100%;
  background: var(--surface-hover); color: var(--fg);
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 6px 8px; font-family: var(--mono); font-size: 12.5px;
}
.insp-field input:focus-visible, .insp-field select:focus-visible {
  outline: 2px solid var(--gold-hi); outline-offset: -1px;
}
.insp-field input.invalid { border-color: var(--danger); }
.insp-field .constraint { font-size: 10px; color: var(--fg-subtle); margin-top: 2px; font-family: var(--mono); }
.insp-field .err { font-size: 11px; color: var(--danger); margin-top: 3px; }
.insp-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.insp-check { display: flex; align-items: center; gap: 7px; margin-top: 9px; font-size: 12.5px; color: var(--fg-muted); }
.insp-check input { accent-color: var(--gold); }
.insp-children { margin-top: 10px; border-top: 1px dashed var(--border-strong); padding-top: 8px; }
.insp-child {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 8px; margin-top: 4px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; color: var(--fg-muted); cursor: pointer;
}
.insp-child:hover { border-color: var(--gold); color: var(--fg); }
.insp-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ---- slab material picker ---- */
.mat-search {
  width: 100%;
  background: var(--surface-hover); color: var(--fg);
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 7px 9px; margin-bottom: 8px;
  font-family: var(--font); font-size: 12.5px;
}
.mat-search:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: -1px; }
.mat-fams { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; }
.fam-chip {
  background: var(--surface); color: var(--fg-muted);
  border: 1px solid var(--border-strong); border-radius: 999px;
  padding: 4px 11px; font-size: 11px; font-weight: 700; cursor: pointer;
  font-family: var(--font); letter-spacing: 0.4px;
}
.fam-chip:hover { color: var(--fg); border-color: var(--gold); }
.fam-chip.active {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 72%, #C49E4C);
  color: var(--primary-fg); border-color: var(--gold-deep);
}
.swatch-grid {
  /* minmax(0,1fr): long color names must not widen columns past the panel */
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  max-height: 300px; overflow-y: auto; overflow-x: hidden; padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.swatch-grid .chip { width: 100%; height: 44px; object-fit: cover; display: block; }

/* scene list delete */
.scene-item .del {
  background: none; border: none; color: var(--fg-subtle);
  font-size: 13px; cursor: pointer; padding: 2px 6px; border-radius: 5px;
  font-family: var(--font);
}
.scene-item .del:hover { color: var(--danger); background: var(--surface-hover); }
.scene-item .del.armed { color: var(--danger); font-weight: 700; }
.scene-item .grow { flex: 1; }

.toast {
  position: fixed; bottom: 18px; right: 320px;
  background: var(--surface-hover); border: 1px solid var(--gold);
  color: var(--fg); padding: 10px 16px; border-radius: 9px;
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(241, 226, 160, 0.12);
  z-index: 100; font-weight: 600; font-size: 13px;
  opacity: 0; transition: opacity 0.2s, transform 0.2s; transform: translateY(6px);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }

/* ---- Color Studio (graph-driven palette card) ---- */
.cs-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cs-field label {
  display: block; font-size: 11px; color: var(--fg-muted); margin-bottom: 3px;
  letter-spacing: 0.3px;
}
.cs-field select {
  width: 100%;
  background: var(--surface-hover); color: var(--fg);
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 6px 8px; font-family: var(--font); font-size: 12.5px;
}
.cs-field select:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: -1px; }
.cs-results { margin-top: 4px; }
.cs-role { margin-top: 11px; }
.cs-role-name {
  font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--fg-subtle); font-weight: 700;
  padding-bottom: 4px; margin-bottom: 5px;
  background:
    var(--rule-gold) 0 100% / 22px 1px no-repeat,
    var(--rule-white) 0 calc(100% - 2px) / 22px 1px no-repeat;
}
.cs-role-name.avoid { color: var(--danger); background: none; border-bottom: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); }
.cs-opt {
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface);
  padding: 6px 8px; margin-bottom: 5px;
}
.cs-opt:hover { border-color: var(--border-strong); }
.cs-opt.avoid {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
}
.cs-opt-head { display: flex; align-items: center; gap: 7px; min-width: 0; }
.cs-chip {
  width: 18px; height: 18px; flex: none;
  border-radius: 5px; border: 1px solid var(--border-strong);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.cs-name {
  font-size: 12.5px; font-weight: 600; color: var(--fg);
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cs-badge {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--gold); border: 1px solid var(--gold-deep); border-radius: 999px;
  padding: 1px 7px; white-space: nowrap;
}
.cs-badge.avoid { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 60%, transparent); }
.cs-conf { font-size: 10px; font-family: var(--mono); color: var(--fg-subtle); white-space: nowrap; }
.cs-conf.classic { color: var(--gold-hi); }
.cs-conf.current { color: var(--fg-muted); }
.cs-conf.dated, .cs-conf.warning { color: var(--danger); }
.cs-note { font-size: 11px; color: var(--fg-subtle); line-height: 1.4; margin: 4px 0 0 25px; }

/* ---- "If you wait" wear advisor (inside the estimate card) ---- */
.wear-advisor { margin-top: 9px; }
.wa-toggle {
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: var(--font); font-size: 11.5px; font-weight: 700;
  color: var(--gold); letter-spacing: 0.3px;
}
.wa-toggle::before { content: "▸ "; font-size: 10px; }
.wa-toggle.open::before { content: "▾ "; }
.wa-toggle:hover { color: var(--gold-hi); text-decoration: underline; }
.wa-toggle:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 1px; border-radius: 4px; }
.wa-body { margin-top: 8px; }
.wa-sub {
  font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--fg-subtle); font-weight: 700; margin: 8px 0 5px;
}
.wa-chain {
  display: flex; flex-wrap: wrap; align-items: center; row-gap: 5px; column-gap: 5px;
  border: 1px solid var(--border); border-radius: 7px; background: var(--surface);
  padding: 7px 9px; margin-bottom: 6px;
}
.wa-node {
  font-size: 11.5px; font-weight: 600; color: var(--fg); white-space: nowrap;
}
.wa-hop {
  display: inline-flex; flex-direction: column; align-items: center;
  line-height: 1.15; cursor: help;
}
.wa-hop .arr { color: var(--gold); font-size: 12px; font-weight: 700; }
.wa-hop .lag { font-size: 8.5px; font-family: var(--mono); color: var(--fg-subtle); white-space: nowrap; }
.wa-hop .sev { font-size: 8.5px; font-family: var(--mono); color: var(--fg-subtle); white-space: nowrap; }
.wa-hop .sev.grim { color: var(--danger); }
.wa-together { margin-top: 4px; }
.wa-item {
  display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap;
  padding: 4px 0; font-size: 12px;
  border-bottom: 1px dashed var(--border);
}
.wa-item:last-child { border-bottom: none; }
.wa-tag {
  flex: none; font-size: 9px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
  border-radius: 999px; padding: 1px 7px; white-space: nowrap;
}
.wa-tag.forced { color: var(--primary-fg); background: linear-gradient(180deg, var(--gold-hi), var(--gold) 72%, #C49E4C); }
.wa-tag.recommended { color: var(--gold); border: 1px solid var(--gold-deep); }
.wa-tag.opportunistic { color: var(--fg-subtle); border: 1px solid var(--border-strong); }
.wa-what { font-weight: 600; color: var(--fg); white-space: nowrap; }
.wa-why { flex: 1 1 100%; font-size: 10.5px; color: var(--fg-subtle); line-height: 1.35; }

/* ============================================================
   Mobile / tablet studio layout (≤860px).
   Desktop is a fixed 3-column grid; below 860px the tool rail
   goes horizontal and the right panel becomes a bottom sheet
   toggled by #panel-toggle. Above 860px none of this applies.
   ============================================================ */
.panel-toggle, .panel-scrim { display: none; }

@media (max-width: 860px) {
  .app {
    /* minmax(0,1fr) not 1fr: a bare 1fr track can't shrink below its widest
       child's content (the horizontal rail / canvas), which would force the
       whole column — and the page — wider than the viewport. */
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "header" "rail" "canvas";
    height: 100dvh;
  }
  .header, .rail, .canvas-wrap { min-width: 0; }

  /* header condenses: the gold wordmark logo already reads "Ace Countertops",
     so drop the redundant brand text + GPU badge + spacer + button labels.
     With the spacer gone, the name input fills the gap between logo and the
     undo/redo/new/save buttons instead of pushing them off-screen. */
  .header { padding: 0 10px; gap: 8px; }
  .header .brand, #gpu-badge, .header .spacer { display: none; }
  .header .lbl { display: none; }
  .design-name { min-width: 0; flex: 1 1 auto; }
  .header .btn { padding-left: 10px; padding-right: 10px; }

  /* tool rail: vertical strip -> horizontal scrollable bar under the header */
  .rail {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .rail::-webkit-scrollbar { display: none; }
  #palette-groups { display: flex; flex-direction: row; gap: 8px; }
  .rail hr {
    width: 3px; height: 26px; margin: 0 2px;
    background:
      var(--rule-gold) 0 0 / 1px 100% no-repeat,
      var(--rule-white) 2px 0 / 1px 100% no-repeat;
  }
  .tool { flex: 0 0 auto; }
  .tool .tip { display: none; } /* hover tooltips are pointless on touch */

  /* right panel becomes a slide-up bottom sheet */
  .panel {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    grid-area: unset;
    max-height: 80dvh;
    border-left: none;
    border-top: 1px solid var(--gold-deep);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(calc(100% + 2px));
    transition: transform 0.25s ease;
    z-index: 40;
    padding-top: 20px;
  }
  .panel.open { transform: none; }
  /* grab handle */
  .panel::before {
    content: "";
    position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: 2px;
    background: var(--border-strong);
  }

  .panel-scrim {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 35;
  }
  .panel-scrim.open { opacity: 1; pointer-events: auto; }

  .panel-toggle {
    display: block;
    position: fixed;
    right: 14px; bottom: 14px;
    z-index: 45;
    padding: 11px 18px;
    border-radius: 999px;
    border: 1px solid var(--gold-deep);
    background: linear-gradient(180deg, var(--gold-hi), var(--gold) 72%, #C49E4C);
    color: var(--primary-fg);
    font: 650 0.9rem/1 var(--font);
    box-shadow: var(--shadow-sm), 0 6px 18px rgba(0, 0, 0, 0.4);
    cursor: pointer;
  }
  /* While the sheet is open the toggle STAYS in the tab order and becomes the
     sheet's close control — hiding it (display:none) stranded keyboard users
     inside the sheet with no way out. It moves above the sheet, over the
     dimmed area, so it never sits on top of a control inside the sheet. */
  .panel-toggle[aria-expanded="true"] {
    top: 12px; bottom: auto;
    z-index: 50;
    background: linear-gradient(180deg, #2b2926, #1c1b19);
    border-color: var(--gold);
    color: var(--gold-hi);
  }
  .panel-toggle:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }

  .toast { right: 14px; bottom: 74px; }
}
