:root {
  color-scheme: dark;
  --bg: #0e0e11;
  --bg-deep: #0b0b0e;
  --chrome: #0d0d10;
  --panel: #141417;
  --field: #141418;
  --raised: #1c1c21;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #f2f1ee;
  --text-2: #e6e5e2;
  --text-3: #d8d7d4;
  --muted: #9a9aa0;
  --muted-2: #7a7a82;
  --muted-3: #6a6a72;
  --faint: #4a4a52;
  --accent: #f26b2a;
  --accent-soft: rgba(242, 107, 42, 0.15);
  --accent-ink: #1a0d05;
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.1);
  --danger: #c86b5a;
  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --rail-w: 74px;
  --panel-w: 348px;
  --ruler-w: 74px;
}

@keyframes lcpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(242, 107, 42, 0.45); }
  50% { box-shadow: 0 0 0 7px rgba(242, 107, 42, 0); }
}
@keyframes lcfade { from { opacity: 0; } to { opacity: 1; } }
@keyframes lcsheet { from { transform: translateY(102%); } to { transform: translateY(0); } }
@keyframes lcspin { to { transform: rotate(360deg); } }

* { box-sizing: border-box; }

/* Layout rules below use display:flex/grid on elements that also toggle the
   hidden attribute, which would otherwise lose to the UA stylesheet. */
[hidden] { display: none !important; }

body {
  margin: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% -10%, #101013 0%, #050506 60%);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button { min-width: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: #ff8b52; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.icon-sprite { display: none; }
.icon {
  width: 1.25em; height: 1.25em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}

#v02-form {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh;
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  height: 54px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: var(--chrome);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 13px; letter-spacing: -0.5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 14px; font-weight: 700; }
.brand-text small { font-size: 10.5px; color: var(--muted-3); letter-spacing: 0.2px; }
.topbar-divider { width: 1px; height: 22px; background: var(--line-strong); }

.file-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 11px; max-width: 240px;
  background: #17171b; border: 1px solid var(--line-strong);
  border-radius: 8px; color: var(--text-3);
  font-size: 12.5px; font-weight: 600;
}
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .icon { color: var(--muted-2); }

.status-pill {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.status-pill.is-ready { background: var(--green-soft); border: 1px solid rgba(52, 211, 153, 0.35); color: var(--green); }
.status-pill.is-stale { background: var(--accent-soft); border: 1px solid rgba(242, 107, 42, 0.35); color: var(--accent); }
.status-pill.is-working { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line-strong); color: var(--muted); }
.status-pill.is-error { background: rgba(200, 107, 90, 0.1); border: 1px solid rgba(200, 107, 90, 0.4); color: var(--danger); }

.ghost-button {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.11); border-radius: 9px;
  color: var(--text-3); font-size: 12.5px; font-weight: 600;
}
.ghost-button:hover { background: #17171b; }
.ghost-button:disabled,
.toolbar-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.toolbar-action.is-primary {
  color: var(--accent);
  border-color: rgba(242, 107, 42, 0.35);
  background: rgba(242, 107, 42, 0.08);
}
.toolbar-action.is-primary:hover { background: rgba(242, 107, 42, 0.14); }

.primary-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 13px; font-weight: 800;
}
.primary-button:hover { color: var(--accent-ink); background: #ff8248; }
.subtle-link { font-size: 12px; font-weight: 700; color: var(--muted); }
.subtle-link:hover { color: var(--accent); }
.eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--muted-2);
  font: 800 10.5px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------ quote page */
.quote-page {
  min-height: 100vh;
  min-height: 100svh;
  height: auto;
  overflow: auto;
}
.quote-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
}
.quote-shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 36px;
}
.quote-empty {
  min-height: calc(100svh - 120px);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  text-align: center;
}
.quote-empty h1,
.quote-preview-header h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 42px);
  letter-spacing: -0.04em;
}
.quote-empty p {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}
.quote-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px 300px;
  gap: 12px;
  align-items: start;
}
.quote-preview-card,
.quote-price-card,
.quote-cost-card,
.quote-piece-card,
.quote-profile-section {
  background: rgba(20, 20, 23, 0.82);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 28px 80px -54px rgba(0, 0, 0, 0.8);
}
.quote-preview-card { padding: 14px; min-width: 0; }
.quote-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.quote-preview-frame {
  position: relative;
  --quote-frame-height: min(70svh, 760px);
  height: var(--quote-frame-height);
  min-height: 460px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 16px;
  background:
    linear-gradient(45deg, rgba(255,255,255,0.025) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.025) 25%, transparent 25%),
    #08080a;
  background-size: 24px 24px;
}
.quote-preview-frame::after {
  content: "Recalculando…";
  position: absolute;
  opacity: 0;
  pointer-events: none;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(20, 20, 23, 0.82);
  border: 1px solid var(--line-strong);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 800;
  transition: opacity 0.14s ease;
}
.quote-preview-frame.is-loading::after { opacity: 1; }
.quote-preview-frame img {
  display: block;
  width: auto;
  height: var(--quote-frame-height);
  max-width: 100%;
  max-height: var(--quote-frame-height);
  object-fit: contain;
  transition: opacity 0.14s ease;
}
.quote-preview-frame.is-loading img { opacity: 0.38; }
.quote-sidebar,
.quote-metrics-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 76px;
}
.quote-price-card,
.quote-cost-card,
.quote-piece-card,
.quote-profile-section { padding: 14px; }
.quote-price-card > strong {
  display: block;
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 34px;
  letter-spacing: -0.06em;
}
.quote-price-card p,
.quote-dimension-note,
.quote-section-title p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}
.quote-price-list {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
}
.quote-price-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}
.quote-price-list dt {
  color: var(--muted-2);
  font-size: 11.5px;
}
.quote-price-list dd {
  margin: 0;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}
.quote-section-title { margin-bottom: 12px; }
.quote-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.quote-pricing-hint {
  position: relative;
}
.quote-pricing-hint summary {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text-2);
  font: 900 12px var(--mono);
  cursor: pointer;
  list-style: none;
}
.quote-pricing-hint summary::-webkit-details-marker { display: none; }
.quote-pricing-hint div {
  position: absolute;
  right: 0;
  top: 30px;
  z-index: 10;
  width: min(280px, calc(100vw - 48px));
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: rgba(16, 16, 19, 0.96);
  box-shadow: 0 22px 60px rgba(0,0,0,.48);
}
.quote-pricing-hint p + p { margin-top: 8px; }
.quote-size-editor {
  display: grid;
  grid-template-columns: 1fr 34px 1fr;
  gap: 8px;
  align-items: end;
}
.quote-size-editor .field {
  gap: 4px;
}
.quote-size-editor input {
  min-width: 0;
}
.quote-dimension-note {
  margin-top: 8px;
  font-size: 11px;
}
.quote-piece-list { margin-top: 10px; }
.quote-profile-grid {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.quote-profile-card {
  width: 100%;
  text-align: left;
}
.quote-profile-card:disabled {
  opacity: 0.7;
  cursor: wait;
}
.quote-mobile-bar { display: none; }

/* ------------------------------------------------------------------ shell */
.studio { flex: 1; display: flex; min-height: 0; position: relative; }

.tool-rail {
  width: var(--rail-w); flex: none;
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 10px 0;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  background: var(--bg-deep);
  z-index: 70;
}
.rail-spacer { flex: 1; }
.rail-button {
  width: 58px; height: 54px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: transparent; border: none; border-radius: 11px;
  color: var(--muted); transition: background 0.15s, color 0.15s;
}
.rail-button .icon { width: 20px; height: 20px; }
.rail-button span { font-size: 9px; font-weight: 600; color: var(--muted-2); }
.rail-button:hover { background: rgba(255, 255, 255, 0.05); }
.rail-button.is-active { background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(242, 107, 42, 0.35); color: var(--accent); }
.rail-button.is-active span { color: var(--accent); }
.rail-help { height: 44px; }

/* ------------------------------------------------------------------ stage */
.stage {
  flex: 1; position: relative; min-width: 0;
  display: flex; align-items: center; justify-content: center;
  --preview-frame-w: min(72vw, 560px);
  --preview-frame-h: min(78vh, 720px);
  --source-ratio-value: 0.7142857;
  padding: 0 22px;
  background-color: var(--bg);
  background-image: radial-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 22px 22px;
  overflow: hidden;
}

.mode-switch {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 30; display: flex; gap: 3px; padding: 4px;
  background: rgba(18, 18, 22, 0.82); backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.09); border-radius: 11px;
}
.mode-switch button {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: none; border-radius: 8px;
  background: transparent; color: #b0b0b6;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.mode-switch button .icon { width: 14px; height: 14px; }
.mode-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.stage-canvas {
  position: relative;
  width: 100%; height: 100%; max-height: 100%;
  padding: 58px 0 48px;
  display: flex; align-items: center; justify-content: center;
}
.stage:not(.has-result):not(.has-source) .stage-canvas { display: none; }

.preview-layout {
  width: 100%; height: 100%; min-width: 0;
  display: flex; align-items: center; justify-content: center;
  gap: 16px;
}

.preview-grid {
  display: flex; align-items: center; justify-content: center;
  gap: 16px; width: auto; max-width: 100%; height: 100%; min-width: 0;
}
.preview-card {
  flex: 0 0 auto;
  width: var(--preview-frame-w);
  height: var(--preview-frame-h);
  margin: 0;
}
.image-stage {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 6px; overflow: hidden;
  background: #0a0a0c;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.image-stage img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0;
}
.image-stage #original-preview,
.image-stage .split-original-preview {
  object-fit: fill;
  max-width: none;
}
.image-stage img.has-image { opacity: 1; }

.stage-tag {
  position: absolute; top: 10px; left: 10px; z-index: 6;
  padding: 3px 9px; border-radius: 20px;
  background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(6px);
  font: 600 10px var(--mono); color: #eee;
  pointer-events: none;
}
.stage-tag-right { left: auto; right: 10px; }

/* view modes */
.stage.view-single #original-preview-card,
.stage.view-split #original-preview-card { display: none; }
.stage.has-source:not(.has-result) #original-preview-card { display: block; }
.stage.has-source:not(.has-result) .preview-card.is-result { display: none; }
.stage:not(.view-split) .result-stage .split-original-preview { display: none; }
.stage:not(.view-split) .split-divider,
.stage:not(.view-split) .split-control { display: none; }
.stage:not(.view-split) .result-stage .stage-tag { display: none; }

.result-stage .split-original-preview {
  z-index: 3;
  clip-path: inset(0 calc(100% - var(--preview-split)) 0 0);
}
.split-divider {
  position: absolute; top: 0; bottom: 0; left: var(--preview-split);
  transform: translateX(-50%);
  width: 3px; background: #fff; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.4);
}
.split-handle {
  width: 30px; height: 30px; border-radius: 50%;
  background: #fff; color: #111;
  display: grid; place-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}
.split-control { position: absolute; inset: 0; z-index: 6; }
.split-control input[type="range"] {
  width: 100%; height: 100%; margin: 0;
  opacity: 0; cursor: ew-resize;
}

/* empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; text-align: center; max-width: 340px;
}
.stage.has-source .empty-state, .stage.has-result .empty-state { display: none; }
.empty-icon {
  width: 88px; height: 88px; border-radius: 20px;
  border: 2px dashed rgba(255, 255, 255, 0.16);
  display: grid; place-items: center; color: var(--faint);
}
.empty-icon .icon { width: 38px; height: 38px; }
.empty-state strong { font-size: 17px; color: var(--text-2); }
.empty-state small { font-size: 13px; color: var(--muted-2); line-height: 1.5; }

.preview-loader {
  position: absolute; inset: 0; z-index: 45;
  display: grid; place-items: center;
  align-content: center; gap: 8px;
  background: rgba(8, 8, 10, 0.58);
  backdrop-filter: blur(3px);
  text-align: center;
}
.stage.is-loading .preview-layout { filter: saturate(0.8) brightness(0.72); }
.loader-spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  animation: lcspin 0.8s linear infinite;
}
.preview-loader strong { font-size: 14px; color: var(--text-2); }
.preview-loader small { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------- layer ruler */
.layer-ruler {
  position: relative;
  width: var(--ruler-w); height: 100%; z-index: 25;
  flex: 0 0 var(--ruler-w);
  display: flex; flex-direction: column;
}
.layer-ruler[hidden] { display: none; }
.ruler-cap {
  font: 700 8px var(--mono); color: var(--muted-2);
  letter-spacing: 0.6px; text-align: center; margin-bottom: 7px;
}
.ruler-cap-dim { color: #5a5a62; margin: 7px 0 0; }
.ruler-track { position: relative; flex: 1; min-height: 0; }
.layer-ruler.is-insert-target .ruler-track::after {
  content: "";
  position: absolute;
  top: -8px;
  bottom: -8px;
  right: -8px;
  width: 52px;
  border: 2px solid var(--accent);
  border-radius: 18px;
  pointer-events: none;
  box-shadow: 0 0 0 5px rgba(242, 107, 42, 0.12), 0 0 28px rgba(242, 107, 42, 0.18);
  z-index: 4;
}
.ruler-add-button {
  width: 36px; min-height: 34px;
  margin: 8px 0 0 auto;
  display: grid; place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018)),
    #141418;
  color: var(--text-3);
  font: 900 18px var(--mono);
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035), 0 8px 22px -10px rgba(0, 0, 0, 0.6);
}
.ruler-add-button:hover,
.ruler-add-button.is-armed {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.ruler-add-button.is-armed {
  animation: lcpulse 1.2s ease-in-out infinite;
}
.ruler-add-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  animation: none;
}
.core-stack {
  position: absolute; top: 0; bottom: 0; right: 0; width: 36px;
  border-radius: 13px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 8px 22px -8px rgba(0, 0, 0, 0.6);
}
.core-stack::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0) 42%, rgba(255, 255, 255, 0.07));
}
.core-segment {
  position: relative;
  flex: 1; min-height: 0; border-top: 1px solid rgba(0, 0, 0, 0.16);
  cursor: pointer;
}
.core-segment.is-boundary { border-top-color: rgba(255, 255, 255, 0.55); }
.core-segment:hover { filter: brightness(1.12); }
.core-segment.is-unused {
  cursor: default;
  background: #101013 !important;
  border-top-color: rgba(255, 255, 255, 0.06);
}
.core-segment.is-unused::before,
.core-segment.is-unused::after {
  content: "";
  position: absolute;
  inset: 1px 4px;
  pointer-events: none;
}
.core-segment.is-unused::before {
  background: linear-gradient(
    to bottom right,
    transparent calc(50% - 0.8px),
    rgba(255, 255, 255, 0.42) calc(50% - 0.8px),
    rgba(255, 255, 255, 0.42) calc(50% + 0.8px),
    transparent calc(50% + 0.8px)
  );
}
.core-segment.is-unused::after {
  background: linear-gradient(
    to top right,
    transparent calc(50% - 0.8px),
    rgba(255, 255, 255, 0.42) calc(50% - 0.8px),
    rgba(255, 255, 255, 0.42) calc(50% + 0.8px),
    transparent calc(50% + 0.8px)
  );
}

.core-boundaries { position: absolute; inset: 0; pointer-events: none; }
.core-boundary {
  position: absolute; right: 20px; transform: translateY(-50%);
  display: flex; align-items: center; gap: 5px;
  padding: 3px 7px 3px 6px; border-radius: 9px;
  background: #1c1c22; color: var(--text-2);
  font: 700 10px var(--mono); white-space: nowrap;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  pointer-events: auto; cursor: grab; user-select: none; touch-action: none;
}
.core-boundary:active { cursor: grabbing; }
.core-boundary.is-dragging { background: var(--accent); color: var(--accent-ink); }
.core-boundary.is-max-layer {
  background: #2a241d;
  color: #ffe7d1;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 111, 42, 0.45);
}
.core-boundary.is-max-layer.is-dragging {
  background: var(--accent);
  color: var(--accent-ink);
}
.core-boundary-dot {
  width: 11px; height: 11px; border-radius: 3px; flex: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.core-color-popover {
  position: fixed; z-index: 180;
  width: min(296px, calc(100vw - 24px));
  padding: 10px;
  background: #151518;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}
.core-color-popover-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 8px;
}
.core-color-popover-head strong { font-size: 12.5px; color: var(--text-2); }
.core-color-popover-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 7px;
}
.core-color-popover-footer {
  display: flex;
  justify-content: flex-end;
  min-height: 34px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.popover-trash-button {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid rgba(200, 107, 90, 0.42);
  border-radius: 10px;
  background: rgba(200, 107, 90, 0.1);
  color: #f0b2a6;
}
.popover-trash-button .icon {
  width: 16px;
  height: 16px;
}
.popover-trash-button:hover {
  background: #c86b5a;
  border-color: #c86b5a;
  color: #1a0805;
}
.core-color-option {
  position: relative; width: 100%; aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px; background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.26);
}
.core-color-option.is-selected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------- tool panel */
.panel-scrim { display: none; }

.tool-panel {
  position: absolute; left: calc(var(--rail-w) + 10px); top: 12px; bottom: 16px;
  width: var(--panel-w); z-index: 60;
  display: none; flex-direction: column; min-height: 0;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7);
  animation: lcfade 0.18s ease;
}
.studio.panel-open .tool-panel { display: flex; }
.panel-grip { display: none; }

.panel-header {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.panel-title { display: flex; align-items: center; gap: 10px; }
.panel-title .icon { width: 18px; height: 18px; color: var(--accent); }
.panel-title strong { font-size: 15px; font-weight: 700; }
.panel-body { flex: 1; overflow-y: auto; padding: 16px; }
.panel-tab { display: flex; flex-direction: column; gap: 14px; }
.panel-tab[hidden] { display: none; }

/* --------------------------------------------------------------- controls */
.section-label {
  font: 600 11px var(--mono); color: var(--muted-3);
  text-transform: uppercase; letter-spacing: 0.6px;
}
.section-head { display: flex; align-items: center; justify-content: space-between; }
.section-hint { font: 500 11px var(--mono); color: var(--muted-3); }
.divider { height: 1px; border: none; background: rgba(255, 255, 255, 0.07); margin: 2px 0; }
.button-row { display: flex; gap: 8px; }
.self-start { align-self: flex-start; }

.icon-button {
  width: 30px; height: 30px; display: grid; place-items: center;
  background: transparent; border: none; border-radius: 8px;
  color: var(--muted-2);
}
.icon-button:hover { background: rgba(255, 255, 255, 0.06); }

.accent-button {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border: none; border-radius: 11px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 13.5px;
}
.accent-button:hover { background: #ff7d3d; }
.accent-button:disabled { opacity: 0.55; cursor: not-allowed; }
.accent-button.wide { width: 100%; }
.accent-button.is-fresh {
  background: rgba(20, 24, 22, 0.6); color: var(--green);
  border: 1px solid rgba(52, 211, 153, 0.3); cursor: default;
}
.accent-button.is-working {
  background: rgba(242, 107, 42, 0.78);
  color: var(--accent-ink);
}
.accent-button.is-error {
  background: rgba(200, 107, 90, 0.16);
  border: 1px solid rgba(200, 107, 90, 0.48);
  color: #f0b2a6;
}

.secondary-action {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 12px; background: var(--raised);
  border: 1px solid rgba(255, 255, 255, 0.09); border-radius: 9px;
  color: var(--text-2); font-weight: 600; font-size: 12.5px;
}
.secondary-action:hover:not(:disabled) { background: #24242a; }
.secondary-action:disabled { opacity: 0.45; cursor: not-allowed; }
.secondary-action.wide { width: 100%; padding: 11px; }
.secondary-action.is-danger { color: var(--danger); flex: none; }
.button-row .secondary-action:first-child { flex: 1; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 11px; color: var(--muted-2); }
.field input[type="number"], .field input[type="text"], .field select {
  width: 100%; padding: 10px 12px;
  background: var(--field); border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px; color: var(--text);
  font-size: 13.5px; font-weight: 600;
}
.field input[type="number"] { font-family: var(--mono); }
.field select { appearance: none; cursor: pointer; }
.field select:disabled { opacity: 0.55; cursor: not-allowed; }
.field input:focus-visible, .field select:focus-visible,
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

.control-label { display: flex; align-items: center; gap: 6px; }
.control-label strong { font-size: 13px; font-weight: 600; color: var(--text-2); }
.hint {
  width: 15px; height: 15px; flex: none; padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: 50%;
  background: transparent; color: var(--muted-3);
  font-size: 9px; font-weight: 700; line-height: 1;
}
.hint:hover { color: var(--accent); border-color: var(--accent); }
.hint-bubble {
  position: fixed; z-index: 200; max-width: 260px;
  padding: 9px 11px; border-radius: 9px;
  background: #1c1c22; border: 1px solid var(--line-strong);
  color: var(--text-3); font-size: 12px; line-height: 1.45;
  box-shadow: 0 12px 32px -10px rgba(0, 0, 0, 0.8);
}

.note {
  display: flex; gap: 8px; align-items: flex-start; margin: 0;
  padding: 10px 12px; border-radius: 10px;
  background: var(--field); border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 12px; color: var(--muted); line-height: 1.45;
}
.note.is-good { background: var(--green-soft); border-color: rgba(52, 211, 153, 0.2); color: #a8d8c4; }
.note.is-good .icon { color: var(--green); margin-top: 1px; }

.print-actions-panel {
  display: grid;
  gap: 10px;
}
.print-action-card {
  width: 100%;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--raised);
  color: var(--text-2);
  text-align: left;
}
.print-action-card:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: #202026;
}
.print-action-card:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}
.print-action-card.is-primary {
  border-color: rgba(242, 107, 42, 0.42);
  background: rgba(242, 107, 42, 0.1);
}
.print-action-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--accent);
}
.print-action-card strong {
  display: block;
  font-size: 13.5px;
}
.print-action-card small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
}

/* corte */
.size-row { display: flex; align-items: flex-end; gap: 8px; }
.size-row .icon-button {
  flex: none; width: 38px; height: 40px; margin-bottom: 1px;
  background: var(--field); border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted-2);
}
.size-row .icon-button.is-active {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
}
.inline-check { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.inline-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.inline-check span:last-child { font-size: 13px; color: var(--text-3); }
.check-box {
  width: 20px; height: 20px; flex: none; border-radius: 6px;
  display: grid; place-items: center;
  background: var(--field); border: 1px solid rgba(255, 255, 255, 0.18);
  color: transparent;
}
.check-box .icon { width: 12px; height: 12px; stroke-width: 2.6; }
.inline-check input:checked + .check-box {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.inline-check input:focus-visible + .check-box { outline: 2px solid var(--accent); outline-offset: 2px; }

.ratio-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ratio-button {
  padding: 9px 6px; border-radius: 9px;
  background: var(--field); border: 1px solid var(--line);
  color: var(--muted); font: 600 12px var(--mono);
}
.ratio-button.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* paleta */
.segmented {
  display: flex; gap: 3px; padding: 4px;
  background: var(--field); border: 1px solid var(--line); border-radius: 10px;
}
.segmented button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px; border: none; border-radius: 8px;
  background: transparent; color: var(--muted);
  font-size: 12.5px; font-weight: 600;
}
.segmented button .icon { width: 14px; height: 14px; }
.segmented button.is-active { background: var(--accent); color: var(--accent-ink); }

.palette-wheel-card {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
}
.palette-wheel-card input[type="color"] {
  width: 100%;
  height: 42px;
  padding: 3px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  background: var(--field);
}

.palette-selection-strip { display: flex; flex-direction: column; gap: 7px; }
.palette-slot {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: 10px;
  background: var(--field); border: 1px solid var(--line);
}
.palette-slot .slot-order { font: 600 10px var(--mono); color: #5a5a62; width: 14px; flex: none; }
.palette-slot .slot-swatch {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: var(--swatch, #333);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.palette-slot .slot-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.palette-slot .slot-text strong { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.palette-slot .slot-text small { font: 500 10px var(--mono); color: var(--muted-3); }
.palette-slot.is-empty .slot-swatch {
  background: transparent; border: 1px dashed rgba(255, 255, 255, 0.2); box-shadow: none;
}

.palette-color-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.palette-color-button {
  aspect-ratio: 1; border: none; border-radius: 9px; padding: 0;
  display: grid; place-items: center;
  background: var(--swatch, #333); color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  position: relative;
}
.palette-color-button .icon {
  width: 15px; height: 15px; stroke-width: 3; opacity: 0;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}
.palette-color-button.is-selected { box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px var(--panel); }
.palette-color-button.is-selected .icon { opacity: 1; }
.palette-color-grid.is-locked .palette-color-button { cursor: not-allowed; opacity: 0.7; }
.td-dot {
  position: absolute; right: 4px; bottom: 4px;
  width: 7px; height: 7px; border-radius: 50%;
  background: #777; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
}
.td-dot.td-high { background: var(--green); }
.td-dot.td-medium { background: #e0a341; }
.td-dot.td-low { background: #8b8790; }
.modal-feedback { margin: 0; font-size: 11.5px; color: var(--muted-3); }

/* algoritmo */
.preset-grid { display: flex; flex-direction: column; gap: 8px; }
.preset-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 13px; border-radius: 11px;
  background: var(--field); border: 1px solid var(--line);
  transition: background 0.15s, border-color 0.15s;
}
.preset-card:hover { background: #1a1a1f; }
.preset-main { display: flex; align-items: center; gap: 11px; min-width: 0; }
.preset-icon { width: 19px; height: 19px; color: var(--muted-2); }
.preset-text { display: flex; flex-direction: column; text-align: left; min-width: 0; }
.preset-text strong { font-size: 13.5px; font-weight: 700; color: var(--text); }
.preset-text strong,
.preset-text em,
.viz-text strong,
.viz-text small,
.core-band-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preset-text em {
  font-style: normal; font-size: 10.5px; font-weight: 600;
  color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.3px; margin-top: 2px;
}
.preset-badge {
  font: 600 10px var(--mono); color: var(--muted-2);
  padding: 3px 7px; border-radius: 6px; background: rgba(255, 255, 255, 0.05);
}
.preset-card.is-selected {
  background: var(--accent-soft); border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.preset-card.is-selected .preset-icon,
.preset-card.is-selected .preset-badge { color: var(--accent); }
.preset-card.is-selected .preset-text em { color: rgba(242, 107, 42, 0.8); }
.preset-card.is-adjusted .preset-text em::after { content: " · ajustado"; }
.preset-card[data-preset-status="custom"] .preset-text em { color: var(--green); }

.save-preset-form { display: flex; flex-direction: column; gap: 8px; }
.save-preset-form input {
  padding: 10px 12px; background: var(--field);
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 9px;
  color: var(--text); font-size: 13px;
}
#save-feedback { font-size: 11.5px; color: var(--muted-3); }

/* ajustes */
.slider-group { display: flex; flex-direction: column; gap: 18px; }
.intent-control { display: flex; flex-direction: column; gap: 8px; }
.intent-head { display: flex; align-items: center; justify-content: space-between; }
.intent-head output { font: 600 12px var(--mono); color: var(--accent); }

input[type="range"] {
  width: 100%; height: 4px; margin: 0;
  accent-color: var(--accent); cursor: pointer;
}
input[type="range"]:disabled { cursor: not-allowed; }
.toggle-line {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--field); border: 1px solid rgba(255, 255, 255, 0.07);
}
.toggle-line input { margin-top: 2px; accent-color: var(--accent); }
.toggle-line span { display: flex; flex-direction: column; gap: 2px; }
.toggle-line strong { font-size: 12.5px; color: var(--text); }
.toggle-line small { font-size: 11px; color: var(--muted-2); line-height: 1.35; }
.expert-panel {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
  padding: 11px; border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.expert-panel[hidden] { display: none; }
.expert-panel .field { min-width: 0; }
.expert-panel .field input { font-family: var(--mono); }
.expert-panel .expert-wide { grid-column: 1 / -1; }

/* impressão */
.print-profile-grid { display: flex; flex-direction: column; gap: 8px; }
.print-profile-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 13px; border-radius: 11px;
  background: var(--field); border: 1px solid var(--line);
  color: var(--text); text-align: left;
}
.print-profile-card:hover { background: #1a1a1f; }
.print-profile-card.is-selected {
  background: var(--accent-soft); border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.print-profile-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.print-profile-main strong { font-size: 13.5px; }
.print-profile-main small {
  font: 600 10.5px var(--mono); color: var(--muted-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.print-profile-badge {
  flex: none; font: 700 9px var(--mono); text-transform: uppercase;
  padding: 4px 7px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.07); color: var(--muted-2);
}
.print-profile-badge[data-risk="high"] { color: #f0b2a6; background: rgba(200, 107, 90, 0.14); }
.print-profile-badge[data-risk="medium"] { color: #f0c16c; background: rgba(224, 163, 65, 0.14); }
.print-profile-badge[data-risk="low"] { color: #a8d8c4; background: var(--green-soft); }
.print-summary-card {
  display: flex; flex-direction: column; gap: 11px;
  padding: 12px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.print-summary-title { display: flex; flex-direction: column; gap: 4px; }
.print-summary-title strong { font-size: 13.5px; color: var(--text); }
.print-summary-title small { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.print-summary-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.print-summary-cell {
  padding: 9px 10px; border-radius: 9px;
  background: var(--field); border: 1px solid rgba(255, 255, 255, 0.06);
}
.print-summary-cell span {
  display: block; margin-bottom: 3px;
  font-size: 10px; color: var(--muted-2);
}
.print-summary-cell strong {
  font: 700 12px var(--mono); color: var(--text-2);
}
.print-actions { display: flex; flex-direction: column; gap: 8px; }

/* color core */
.core-brand { display: flex; align-items: center; gap: 8px; color: var(--accent); }
.core-brand span { font: 700 12px var(--mono); color: var(--text-3); letter-spacing: 0.4px; }
.core-brand .icon { width: 15px; height: 15px; }
#core-content { display: flex; flex-direction: column; gap: 14px; }
.core-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.core-stat {
  padding: 11px 12px; border-radius: 10px;
  background: var(--field); border: 1px solid rgba(255, 255, 255, 0.07);
}
.core-stat span { display: block; font-size: 10.5px; color: var(--muted-2); margin-bottom: 4px; }
.core-stat strong { font: 700 15px var(--mono); color: var(--text); }

.core-bands-list {
  display: flex; flex-direction: column; gap: 1px;
  border-radius: 10px; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.core-band-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; background: var(--field);
}
.core-swatch {
  width: 20px; height: 20px; border-radius: 5px; flex: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.core-band-range { flex: 1; font: 600 11px var(--mono); color: var(--muted); }
.core-band-name { font-size: 12px; font-weight: 600; color: var(--text-2); }
.core-band-name {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
}
.core-band-optics {
  font: 600 9.5px var(--mono); color: var(--muted-3);
}

.meta-link { font-size: 12px; color: var(--muted); align-self: flex-start; }
.meta-link:hover { color: var(--accent); }
.debug-toggle {
  align-self: flex-start;
  display: flex; align-items: center; gap: 7px; padding: 0;
  background: none; border: none; color: var(--muted-2);
  font-size: 12px; font-weight: 600;
}
.debug-toggle .icon { width: 13px; height: 13px; }
#debug-block {
  margin: 0; padding: 12px; border-radius: 10px;
  background: #0a0a0c; border: 1px solid rgba(255, 255, 255, 0.07);
  font: 500 10.5px/1.6 var(--mono); color: #7a9a7a;
  overflow-x: auto;
}

/* ---------------------------------------------------------------- overlays */
.guide-overlay, .modal-overlay { position: fixed; inset: 0; z-index: 120; display: none; }
.guide-overlay.is-open, .modal-overlay.is-open { display: block; }
.guide-backdrop, .modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }

.guide-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(480px, 100%);
  display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--line-strong);
  animation: lcfade 0.2s ease;
}
.guide-header {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.guide-header h2 { margin: 0; font-size: 18px; }
.guide-close {
  width: 32px; height: 32px; display: grid; place-items: center;
  background: transparent; border: none; border-radius: 8px; color: var(--muted-2);
}
.guide-close:hover { background: rgba(255, 255, 255, 0.06); }
.guide-body { flex: 1; overflow-y: auto; padding: 20px; }
.guide-section { margin-bottom: 22px; }
.guide-section h3 { margin: 0 0 8px; font-size: 14px; color: var(--text); }
.guide-section p, .guide-section li { font-size: 13px; line-height: 1.6; color: var(--muted); }
.guide-section p { margin: 0 0 8px; }
.guide-section ul { margin: 0 0 8px; padding-left: 18px; }
.guide-section strong { color: var(--text-3); }

.modal-panel {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100% - 32px)); max-height: calc(100% - 48px);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
}
.modal-header {
  flex: none; display: flex; align-items: flex-start; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.modal-header h2 { margin: 4px 0 0; font-size: 16px; }
.modal-close {
  width: 30px; height: 30px; display: grid; place-items: center;
  background: transparent; border: none; border-radius: 8px; color: var(--muted-2);
}
.modal-close:hover { background: rgba(255, 255, 255, 0.06); }
.modal-body { flex: 1; overflow-y: auto; padding: 18px; }
.modal-footer {
  flex: none; display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 18px; border-top: 1px solid var(--line); background: #101013;
}

.crop-modal {
  width: min(620px, calc(100vw - 32px));
  height: min(760px, calc(100svh - 32px));
  max-height: calc(100svh - 32px);
}
.crop-modal .modal-body {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}

.crop-stage {
  position: relative;
  width: 100%;
  max-width: 100%;
  flex: none;
  min-height: 0;
  margin: 0 auto;
  aspect-ratio: var(--crop-ratio, 63.5 / 88.9);
  overflow: hidden; border-radius: 10px;
  background: #0a0a0c; cursor: grab; touch-action: none;
  user-select: none;
}
.crop-stage:active { cursor: grabbing; }
.crop-stage img {
  position: absolute; max-width: none;
  pointer-events: none; user-select: none;
  -webkit-user-drag: none;
}
.crop-shadow {
  position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  border-radius: 10px;
}
.zoom-control {
  display: flex; align-items: center; gap: 12px;
  flex: none;
  min-height: 30px;
  margin-top: 0; font-size: 12px; color: var(--muted);
}
.zoom-control input { flex: 1; min-width: 0; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 960px) {
  :root {
    --ruler-w: 56px;
    --panel-w: 100%;
    --mobile-rail-h: 72px;
  }

  body { overflow: hidden; min-height: 100svh; }
  #v02-form { min-height: 100svh; height: 100svh; }
  .studio { flex-direction: column-reverse; }
  .file-chip { display: none; }

  .tool-rail {
    width: 100%; height: var(--mobile-rail-h); flex-direction: row;
    align-items: stretch; padding: 6px 4px 8px; gap: 2px;
    border-right: none; border-top: 1px solid var(--line);
    overflow-x: auto;
  }
  .rail-spacer, .rail-help { display: none; }
  .rail-button { min-width: 64px; flex: 1; height: auto; }

  .stage { padding: 0 12px; }
  .stage {
    height: calc(100svh - 126px);
    min-height: calc(100svh - 126px);
    align-items: center;
    justify-content: center;
  }
  .stage-canvas {
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 58px 0 78px;
  }
  .preview-layout { gap: 8px; }
  .preview-grid {
    width: auto;
    height: auto;
    gap: 8px;
    align-items: center;
    justify-content: center;
  }
  .preview-card {
    width: var(--preview-frame-w);
    height: var(--preview-frame-h);
    min-width: 0;
  }
  .image-stage {
    width: 100%;
    height: 100%;
  }
  .stage.view-side-by-side .preview-grid {
    flex-direction: column;
  }
  .stage.view-side-by-side .preview-card {
    width: var(--preview-frame-w);
    height: var(--preview-frame-h);
  }
  .layer-ruler { height: 100%; }

  .tool-panel {
    left: 0; right: 0; top: auto; bottom: var(--mobile-rail-h); width: auto;
    max-height: min(68%, calc(100% - var(--mobile-rail-h)));
    border-radius: 22px 22px 0 0;
    border: none; border-top: 1px solid var(--line-strong);
    box-shadow: 0 -20px 60px -10px rgba(0, 0, 0, 0.6);
    animation: lcsheet 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .studio.panel-open .panel-scrim {
    display: block; position: absolute; inset: 0 0 var(--mobile-rail-h); z-index: 55;
    background: rgba(0, 0, 0, 0.55); animation: lcfade 0.2s ease;
  }
  .panel-grip { display: flex; justify-content: center; padding: 8px 0 2px; }
  .panel-grip::before {
    content: ""; width: 38px; height: 4px; border-radius: 3px;
    background: rgba(255, 255, 255, 0.2);
  }

  .palette-color-grid { grid-template-columns: repeat(8, 1fr); }
  .quote-main { grid-template-columns: 1fr; }
  .quote-sidebar,
  .quote-metrics-column {
    position: static;
    order: -1;
  }
  .quote-preview-frame { min-height: 360px; }
  .mode-switch button span { display: none; }
  .crop-modal {
    width: calc(100vw - 20px);
    height: calc(100svh - 20px);
    max-height: calc(100svh - 20px);
  }
  .crop-modal .modal-header { padding: 14px 16px; }
  .crop-modal .modal-body { padding: 14px; }
  .crop-modal .modal-footer { padding: 12px 14px; }
}

@media (max-width: 760px) {
  .quote-page { padding-bottom: 82px; }
  .quote-topbar .topbar-right .status-pill,
  .quote-topbar .topbar-right #quote-download-stl { display: none; }
  .quote-shell {
    width: 100%;
    padding: 0 0 18px;
  }
  .quote-main {
    display: block;
  }
  .quote-preview-card {
    min-height: calc(100svh - 136px);
    border-radius: 0;
    border-left: none;
    border-right: none;
    background: transparent;
    box-shadow: none;
  }
  .quote-preview-header {
    padding: 0 4px;
    margin-bottom: 10px;
  }
  .quote-preview-header .eyebrow,
  .quote-preview-header h1,
  #quote-meta-link { display: none; }
  .quote-preview-frame {
    --quote-frame-height: calc(100svh - 136px);
    height: var(--quote-frame-height);
    min-height: 360px;
    border-radius: 0;
  }
  .quote-sidebar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 78px;
    z-index: 80;
    pointer-events: none;
  }
  .quote-price-card,
  .quote-cost-card,
  .quote-piece-card,
  .quote-profile-section {
    display: none;
    max-height: min(68svh, 520px);
    overflow: auto;
    pointer-events: auto;
    border-radius: 18px;
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.72);
  }
  body[data-mobile-panel="price"] .quote-price-card,
  body[data-mobile-panel="price"] .quote-cost-card,
  body[data-mobile-panel="price"] .quote-piece-card,
  body[data-mobile-panel="profiles"] .quote-profile-section {
    display: block;
  }
  .quote-metrics-column {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 78px;
    z-index: 81;
    pointer-events: none;
  }
  body[data-mobile-panel="price"] .quote-metrics-column {
    pointer-events: auto;
  }
  .quote-mobile-bar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 90;
    display: grid;
    grid-template-columns: 1fr 1fr 1.15fr;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line-strong);
    border-radius: 18px;
    background: rgba(13, 13, 16, 0.92);
    backdrop-filter: blur(16px);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  }
  .quote-mobile-bar button {
    min-width: 0;
    padding: 10px 8px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: #17171b;
    color: var(--text-2);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .quote-mobile-bar #quote-mobile-cta {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
  }
}

@media (max-width: 560px) {
  .brand-text { display: none; }
  .topbar { padding: 0 10px; }
  .topbar-right { gap: 6px; }
  .ghost-button { padding: 7px 9px; }
  .toolbar-action { font-size: 0; gap: 0; }
  .toolbar-action .icon { font-size: 13px; }
  .status-pill { max-width: 148px; overflow: hidden; }
  #preview-status-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .stage { height: calc(100svh - 126px); min-height: calc(100svh - 126px); padding: 42px 10px 72px; }
  .stage-canvas { width: 100%; height: 100%; max-height: none; }
  .preview-grid { width: auto; justify-content: center; }
  .preview-card { max-width: 100%; }
  .image-stage { max-width: none; max-height: none; }
  .stage.has-result .image-stage { max-width: none; }
  .view-side-by-side .preview-grid { align-items: center; }
  .view-side-by-side .image-stage { max-width: none; }
  .layer-ruler { height: 100%; }
  .tool-panel { max-height: min(76%, calc(100% - var(--mobile-rail-h))); }
  .size-row { align-items: stretch; }
  .size-row .icon-button { align-self: flex-end; }
  .palette-color-grid { grid-template-columns: repeat(6, 1fr); }
  .quote-shell { width: calc(100vw - 20px); padding: 14px 0 28px; }
  .quote-preview-card,
  .quote-price-card,
  .quote-cost-card,
  .quote-piece-card,
  .quote-profile-section { border-radius: 16px; }
  .quote-preview-header { flex-direction: column; }
  .quote-preview-frame { min-height: 300px; }
  .mode-switch { top: 10px; }
  .crop-modal {
    width: calc(100vw - 16px);
    height: calc(100svh - 16px);
    max-height: calc(100svh - 16px);
  }
  .crop-modal .modal-footer {
    display: grid; grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
