:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #f8f6f2;
  --surface-3: #efece6;
  --border: #e3ded5;
  --border-strong: #cfc8bc;
  --text: #22201c;
  --muted: #6f685d;
  --accent: #c2551f;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9df;
  --warn: #9a6400;
  --warn-soft: #fff4dc;
  --error: #b42318;
  --error-soft: #fde8e6;
  --ok: #1f7a3a;
  --part-base: #e9cfa6;
  --part-lid: #dcb98a;
  --part-lip: #c89a66;
  --part-divider: #f0dcb8;
  --part-stroke: #8a5a24;
  --part-hi: #8fb0ff;
  --sheet: #f3efe7;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(30, 20, 10, 0.06), 0 6px 20px rgba(30, 20, 10, 0.07);
  --rail-w: 76px;
  --panel-w: 320px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --surface: #1f1e1b;
    --surface-2: #26241f;
    --surface-3: #2d2a24;
    --border: #35322c;
    --border-strong: #4a463e;
    --text: #ece8e1;
    --muted: #a39b8e;
    --accent: #e37440;
    --accent-ink: #1b1007;
    --accent-soft: #3a2418;
    --warn: #f0b44c;
    --warn-soft: #33270f;
    --error: #ff8a7e;
    --error-soft: #3a1714;
    --ok: #6fcf8e;
    --part-base: #6b5232;
    --part-lid: #5c4529;
    --part-lip: #4a3620;
    --part-divider: #7a6040;
    --part-stroke: #d9b07a;
    --part-hi: #3d5fcf;
    --sheet: #2a2722;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

select {
  color: var(--text);
  background-color: var(--surface-2);
  color-scheme: light dark;
}

option,
optgroup {
  color: var(--text);
  background-color: var(--surface);
}

kbd {
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 2px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: 52px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  font-size: 15px;
  white-space: nowrap;
}

.brand img {
  border-radius: 7px;
}

.summary {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.sum-name {
  font-weight: 600;
}

.sum-dims {
  margin-left: 6px;
}

.status {
  display: flex;
  gap: 6px;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s, background 0.12s;
}

.btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.btn-primary:hover {
  filter: brightness(1.06);
  background: var(--accent);
  border-color: var(--accent);
}

.btn:disabled,
.icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-small {
  padding: 3px 10px;
  font-size: 13px;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  width: 30px;
  height: 30px;
  cursor: pointer;
  color: var(--muted);
  display: inline-grid;
  place-items: center;
  font-size: 15px;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-group {
  display: flex;
}

.btn-group .icon-btn + .icon-btn {
  margin-left: -1px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.btn-group .icon-btn:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.link {
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-size: 13px;
}

.link:hover {
  text-decoration: underline;
}

.menu {
  position: relative;
}

.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 30;
  min-width: 240px;
}

.menu-list button,
.menu-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.menu-list button:hover {
  background: var(--surface-2);
}

.menu-field {
  color: var(--muted);
  cursor: default;
}

.menu-field select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 6px;
}

.segmented {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}

.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.segmented button + button {
  border-left: 1px solid var(--border);
}

.segmented button[aria-pressed='true'] {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.segmented-small button {
  padding: 4px 10px;
}

.pill {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
  border: 0;
  white-space: nowrap;
}

.pill-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill-error {
  background: var(--error-soft);
  color: var(--error);
}

.pill-ok {
  background: var(--surface-2);
  color: var(--ok);
  cursor: default;
}

/* ---------- layout ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: var(--rail-w) var(--panel-w) 1fr;
  min-height: 0;
}

.rail {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 6px;
  overflow-y: auto;
}

.rail-btn {
  position: relative;
  border: 0;
  background: none;
  border-radius: var(--radius-sm);
  padding: 8px 2px 6px;
  display: grid;
  justify-items: center;
  gap: 3px;
  color: var(--muted);
  cursor: pointer;
}

.rail-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.rail-btn.on {
  background: var(--accent-soft);
  color: var(--accent);
}

.rail-label {
  font-size: 10.5px;
  line-height: 1.1;
  text-align: center;
}

.rail-badge {
  position: absolute;
  top: 4px;
  right: 8px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  color: #fff;
}

.rail-badge.is-warn {
  background: var(--warn);
}

.rail-badge.is-error {
  background: var(--error);
}

.panel-side {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 0 0 24px;
}

.panel-head {
  padding: 14px 16px 8px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
}

.fields {
  padding: 4px 16px 14px;
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  grid-template-columns: 1fr 150px;
  align-items: center;
  gap: 4px 8px;
  border-radius: var(--radius-sm);
}

.field[hidden] {
  display: none;
}

.field-wide {
  grid-template-columns: 1fr;
  gap: 8px;
}

.field > label,
.field > .label {
  color: var(--muted);
}

.field .hint,
.field .live,
.field .field-issues {
  grid-column: 1 / -1;
  font-size: 12px;
}

.field .hint {
  color: var(--muted);
}

.field .live {
  color: var(--ok);
}

.field-issues:empty {
  display: none;
}

.field-issue {
  padding: 6px 9px;
  border-radius: 6px;
  margin-top: 2px;
}

.field-issue.is-warning {
  background: var(--warn-soft);
  color: var(--warn);
}

.field-issue.is-error {
  background: var(--error-soft);
  color: var(--error);
}

.field.has-error .input-wrap {
  border-color: var(--error);
  box-shadow: 0 0 0 2px var(--error-soft);
}

.field.has-warning .input-wrap {
  border-color: var(--warn);
}

.field.flash {
  animation: flash 1.2s ease-out;
}

@keyframes flash {
  0% {
    background: var(--accent-soft);
  }
  100% {
    background: transparent;
  }
}

.input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
}

.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.input-wrap input,
.input-wrap select {
  border: 0;
  background: transparent;
  padding: 6px 8px;
  width: 100%;
  min-width: 0;
  outline: none;
  font-variant-numeric: tabular-nums;
}

.input-wrap .unit {
  padding-right: 8px;
  color: var(--muted);
  font-size: 12px;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.check {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  color: var(--text) !important;
}

input[type='checkbox'] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

.chip,
.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12.5px;
  background: var(--surface-2);
  cursor: pointer;
  user-select: none;
}

.chip:hover,
.chip-check:hover {
  border-color: var(--border-strong);
}

.chip-check input {
  width: 13px;
  height: 13px;
  margin: 0;
}

.chip-check:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.chip-place {
  border-style: dashed;
  color: var(--accent);
}

/* ---------- hardware ---------- */
.hw-grid {
  display: grid;
  gap: 8px;
}

.hw-pick {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: var(--surface-2);
}

.hw-icon {
  width: 56px;
  height: 42px;
  color: var(--text);
}

.hw-icon.small {
  width: 40px;
  height: 30px;
}

.hw-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hw-pick-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.hw-sizes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.hw-list {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: grid;
  gap: 8px;
}

.hw-list-head {
  font-weight: 600;
  display: flex;
  justify-content: space-between;
}

.hw-list-head .count {
  color: var(--muted);
  font-weight: 500;
}

.hw-item {
  display: grid;
  grid-template-columns: 40px 1fr 26px;
  gap: 8px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
}

.hw-item--bad {
  border-color: var(--warn);
  background: var(--warn-soft);
}

.hw-item-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.hw-item-title .muted {
  font-weight: 400;
  font-size: 12px;
}

.hw-item-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  font-size: 12.5px;
}

.hw-item-row label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--muted);
}

.hw-item-row input[type='number'] {
  width: 56px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  padding: 2px 4px;
}

.hw-count {
  margin-left: auto;
}

.hw-adv {
  margin-top: 4px;
  font-size: 12px;
}

.hw-adv summary {
  color: var(--muted);
  cursor: pointer;
}

.hw-remove {
  width: 26px;
  height: 26px;
}

/* ---------- designs ---------- */
.designs-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.design-list {
  display: grid;
  gap: 6px;
}

.design-row {
  display: grid;
  grid-template-columns: 1fr 30px;
  gap: 6px;
  align-items: center;
}

.design-open {
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: grid;
  cursor: pointer;
}

.design-open:hover {
  border-color: var(--border-strong);
}

.design-open .muted {
  font-size: 12px;
}

/* ---------- main ---------- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.tab {
  border: 0;
  background: none;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 550;
}

.tab[aria-selected='true'] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.view {
  flex: 1;
  min-height: 0;
  position: relative;
}

.view[hidden] {
  display: none !important;
}

.view-scroll {
  overflow: auto;
  padding: 16px;
}

.viewport {
  position: absolute;
  inset: 0;
}

.viewport canvas {
  display: block;
}

.tip,
.sheet-tip {
  position: absolute;
  pointer-events: none;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 5;
}

.placing-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-weight: 600;
  z-index: 6;
}

.placing-bar .btn {
  background: rgba(255, 255, 255, 0.2);
  border-color: transparent;
  color: inherit;
}

.view-controls {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  box-shadow: var(--shadow);
}

.view-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.view-controls input[type='range'] {
  width: 110px;
  accent-color: var(--accent);
}

.selection {
  position: absolute;
  right: 12px;
  top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow);
  min-width: 190px;
  font-variant-numeric: tabular-nums;
}

.selection h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.selection div {
  color: var(--muted);
}

.sel-actions {
  display: flex;
  gap: 12px;
  margin-top: 6px;
}

/* ---------- sheets ---------- */
#sheets {
  display: grid;
  gap: 20px;
  align-content: start;
}

.sheet-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.sheet-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
  flex-wrap: wrap;
}

.sheet-tools {
  display: flex;
  gap: 6px;
}

.sheet-stage {
  position: relative;
  aspect-ratio: 2 / 1;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  outline: none;
  touch-action: none;
}

.sheet-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

.sheet-svg:active {
  cursor: grabbing;
}

.sheet-svg .sheet {
  fill: var(--sheet);
  stroke: var(--border-strong);
  stroke-width: 2;
}

.sheet-svg .sheet-margin {
  fill: none;
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 8 8;
}

.sheet-svg .part {
  stroke: var(--part-stroke);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  cursor: grab;
  transition: filter 0.1s;
}

.part--base {
  fill: var(--part-base);
}

.part--lid {
  fill: var(--part-lid);
}

.part--lip {
  fill: var(--part-lip);
}

.part--divider {
  fill: var(--part-divider);
}

.sheet-svg .part:hover {
  filter: brightness(1.08);
}

.sheet-svg .part--hi {
  fill: var(--part-hi);
}

.sheet-svg .part--fixed {
  stroke-dasharray: 6 4;
}

.sheet-svg .dragging .part {
  opacity: 0.7;
}

.sheet-svg .label {
  fill: var(--text);
  opacity: 0.75;
  pointer-events: none;
  font-family: system-ui, sans-serif;
}

.sheet-help {
  font-size: 12px;
  margin-top: 6px;
}

/* ---------- parts ---------- */
.dims {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.stat .k {
  color: var(--muted);
  font-size: 12px;
}

.stat .v {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

th,
td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  background: var(--surface-2);
}

tbody tr[data-id] {
  cursor: pointer;
}

tbody tr[data-id]:hover {
  background: var(--surface-2);
}

tbody tr.selected {
  background: var(--accent-soft);
}

td.num,
th.num {
  text-align: right;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 8px;
  border: 1px solid var(--part-stroke);
  vertical-align: -1px;
}

.swatch--base {
  background: var(--part-base);
}

.swatch--lid {
  background: var(--part-lid);
}

.swatch--lip {
  background: var(--part-lip);
}

.swatch--divider {
  background: var(--part-divider);
}

.subhead {
  margin: 20px 0 8px;
  font-size: 14px;
}

.notes {
  display: grid;
  gap: 6px;
}

.note {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 0;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.note-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.note-error {
  background: var(--error-soft);
  color: var(--error);
}

/* ---------- dialogs ---------- */
.dlg,
.wizard {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  box-shadow: var(--shadow);
  max-width: min(92vw, 560px);
}

.dlg::backdrop,
.wizard::backdrop {
  background: rgba(20, 15, 10, 0.45);
  backdrop-filter: blur(2px);
}

.dlg form,
.dlg > h3,
.dlg > table,
.dlg > footer {
  padding: 0 20px;
}

.dlg h3 {
  margin: 18px 0 6px;
  font-size: 16px;
}

.dlg p {
  margin: 0 0 10px;
  color: var(--muted);
}

.dlg footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px 18px;
}

.dlg-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: var(--surface-2);
}

.keys td {
  padding: 6px 10px;
  border: 0;
}

.keys td:first-child {
  white-space: nowrap;
}

/* wizard */
.wizard {
  width: min(92vw, 720px);
  max-width: none;
}

.wizard-form header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0;
}

.wizard-steps {
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
}

.wizard-steps .on {
  color: var(--accent);
  font-weight: 600;
}

.wizard-steps .done {
  color: var(--ok);
}

.wizard-body {
  padding: 10px 20px;
  min-height: 300px;
}

.wizard-form footer {
  display: flex;
  gap: 8px;
  padding: 10px 20px 18px;
  border-top: 1px solid var(--border);
}

.spacer {
  flex: 1;
}

.lead {
  margin: 8px 0 14px;
  font-size: 15px;
}

.preset-grid,
.material-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.preset,
.material {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 12px;
  text-align: left;
  display: grid;
  gap: 4px;
  cursor: pointer;
}

.preset:hover,
.material:hover {
  border-color: var(--border-strong);
}

.preset.on,
.material.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.preset-art svg {
  width: 100%;
  height: 60px;
  fill: none;
  stroke: var(--part-stroke);
  stroke-width: 1.8;
}

.preset-art rect {
  fill: var(--part-base);
}

.wizard-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.wizard-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.wizard-fields label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.size-hint {
  margin-top: 8px;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 9px 14px;
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  max-width: calc(100% - 32px);
  display: flex;
  gap: 14px;
  align-items: center;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.toast-undo {
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

/* ---------- mobile ---------- */
.mnav {
  display: none;
}

@media (max-width: 900px) {
  :root {
    --panel-w: 100%;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
  }

  .summary {
    order: 5;
    flex-basis: 100%;
    font-size: 13px;
  }

  .status {
    display: none;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  .rail,
  .panel-side,
  .main {
    grid-row: 1;
    grid-column: 1;
  }

  .rail {
    display: none;
  }

  .panel-side {
    display: none;
    border-right: 0;
  }

  body[data-mobile='design'] .panel-side {
    display: block;
  }

  body[data-mobile='design'] .main {
    display: none;
  }

  .tabs {
    display: none;
  }

  .mnav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mnav-btn {
    border: 0;
    background: none;
    padding: 12px 4px;
    color: var(--muted);
    font-weight: 600;
    cursor: pointer;
    border-top: 2px solid transparent;
  }

  .mnav-btn.on {
    color: var(--accent);
    border-top-color: var(--accent);
  }

  .view-controls {
    left: 8px;
    right: 8px;
    bottom: 8px;
    justify-content: space-between;
  }

  .view-controls input[type='range'] {
    width: 80px;
  }

  .selection {
    right: 8px;
    top: 8px;
  }

  .sheet-stage {
    aspect-ratio: 4 / 3;
  }

  .mobile-sections {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 10px 12px 0;
  }

  .mobile-sections .chip.on {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
  }
}

@media (min-width: 901px) {
  .mobile-sections {
    display: none;
  }
}
