/* Interface refinement using unslop by Damir Sokolovsky (@heydamir), CC BY 4.0.
   Direction: a precise, restrained, neutral modeling workbench. */
:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --page: #e4e5e7;
  --surface: #fcfcfd;
  --canvas: #f2f3f5;
  --border: #d9dce0;
  --ink: #131416;
  --secondary: #52565d;
  --muted: #666b73;
  --accent: #141517;
  --green: #268755;
  --red: #b85f64;
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; height: 100vh; overflow: hidden; }
main { height: 100vh; display: flex; flex-direction: column; padding: 20px 24px; }
header { display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-shrink: 0; padding: 0 0 20px; }
h1 { font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: 0; margin: 0; }
h2 { font-size: 16px; line-height: 24px; font-weight: 600; margin: 0 0 16px; }
p { font-size: 13px; line-height: 20px; color: var(--secondary); margin: 8px 0; }
header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.layout { display: grid; grid-template-columns: 288px minmax(0,1fr); gap: 20px; min-height: 0; flex: 1; }
.controls, .viewport { display: flex; flex-direction: column; gap: 16px; }
.layout > .controls, .viewport { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #b8bcc3 transparent; padding-right: 4px; }
section { background: var(--surface); border: 1px solid var(--border); border-radius: 28px; padding: 24px; }
.controls section { padding: 16px; }
.comparison, .design-row { display: grid; grid-template-columns: minmax(0,1fr); gap: 16px; }
.comparison > section, .design-row > section { min-width: 0; }
label { display: block; font-size: 12px; line-height: 18px; color: var(--secondary); margin: 12px 0; }
input, select, button { font: inherit; }
button, select, input[type=number] { border: 1px solid #dcdfe3; border-radius: 20px; background: var(--surface); color: var(--ink); }
button { min-height: 36px; padding: 8px 12px; font-size: 13px; line-height: 18px; font-weight: 500; cursor: pointer; transition: background-color 140ms ease-out, border-color 140ms ease-out, color 140ms ease-out; }
button:hover:not(:disabled), #language-toggle:hover { background: #f1f2f4; border-color: #9ba1aa; }
button:active:not(:disabled), #language-toggle:active { background: #e5e7ea; }
button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover:not(:disabled) { background: #32353a; border-color: #32353a; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
select, input[type=number] { width: 100%; min-height: 36px; padding: 8px 12px; margin-top: 8px; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0 6px 0 0; vertical-align: -3px; }
input[type=range] { appearance: none; -webkit-appearance: none; background: transparent; width: 100%; min-width: 0; height: 24px; margin: 0; cursor: pointer; accent-color: var(--accent); }
input[type=range]::-webkit-slider-runnable-track { height: 4px; background: #d9dce0; border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border: 2px solid #25282d; border-radius: 50%; background: #fc914a; box-shadow: 0 0 0 1px #34383e; }
input[type=range]::-moz-range-track { height: 4px; background: #d9dce0; border-radius: 2px; }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border: 2px solid #25282d; border-radius: 50%; background: #fc914a; box-shadow: 0 0 0 1px #34383e; }
input[type=range]:disabled { opacity: .4; cursor: default; }
output { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px 16px; }
.parameter-group { border: 0; border-top: 1px solid var(--border); margin: 24px 0 0; padding: 16px 0 0; min-width: 0; }
.parameter-group legend { padding: 0 8px 0 0; font-size: 12px; font-weight: 600; color: var(--ink); }
.parameter-group .grid { gap: 16px 16px; }
.parameter-group label { display: grid; grid-template-columns: minmax(0,1fr) auto; grid-template-rows: 32px 40px; gap: 4px 4px; margin: 0; min-width: 0; align-content: start; }
.parameter-name { line-height: 18px; }
.parameter-group .parameter-name { grid-column: 1; grid-row: 1; }
.parameter-group output { grid-column: 2; grid-row: 1; padding-top: 1px; }
.parameter-group input[type=range] { grid-row: 2; grid-column: 1/-1; align-self: start; }
.range-reference { position: relative; display: block; grid-column: 1/-1; grid-row: 2; height: 44px; --initial-position: 50%; }
.range-reference input[type=range] { display: block; width: 100%; height: 24px; margin: 0; }
.initial-dot { position: absolute; left: var(--initial-position); top: 12px; width: 6px; height: 6px; transform: translate(-50%,-50%); border-radius: 50%; background: #8c929a; box-shadow: 0 0 0 1px white; pointer-events: none; }
.initial-value { display: block; border: 0; background: transparent; color: var(--muted); font-size: 11px; line-height: 16px; min-height: 0; font-weight: 400; cursor: pointer; }
.range-reference .initial-value { position: absolute; top: 28px; left: clamp(36px,var(--initial-position),calc(100% - 36px)); transform: translateX(-50%); white-space: nowrap; margin: 0; padding: 0; }
#scan-dimension-help { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 24px; font-size: 12px; line-height: 20px; }
.export-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.export-actions button { min-height: 40px; padding-inline: 6px; }
#status { font-size: 12px; margin: 8px 0 0; }
#status:empty, #library-status:empty, #measurements:empty { display: none; }
.error { color: #a33535; }
#measurements, #dimensions { font-variant-numeric: tabular-nums; color: var(--secondary); font-size: 12px; }
canvas { display: block; width: 100%; height: 330px; border-radius: 16px; background: var(--canvas); touch-action: none; }
#scan { height: 330px; cursor: crosshair; }
#section { height: 330px; }
#model, .library-preview { height: 440px; cursor: grab; }
#model:active, .library-preview:active { cursor: grabbing; }
.scan-layout { display: flex; flex-direction: column; gap: 16px; }
#marking { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; align-items: start; padding: 0; }
.marking-instructions { display: grid; gap: 8px; min-width: 0; }
.landmark-reference { position: absolute; z-index: 1; left: 12px; top: 50%; transform: translateY(-50%); width: var(--reference-width); height: auto; pointer-events: none; color: var(--secondary); }
#marking h2 { font-size: 13px; font-weight: 500; width: 100%; margin: 0; }
#marking p { margin: 0; width: 100%; }
#marking #instruction { margin-bottom: 4px; }
#marking #measurements { margin-top: 4px; }
#marking .row { flex-wrap: wrap; gap: 8px; }
#marking button { min-height: 36px; }
.scan-frame, .model-frame { position: relative; }
.scan-frame { --reference-width: clamp(70px, 24%, 190px); display: grid; grid-template-columns: calc(var(--reference-width) + 16px) minmax(0, 1fr); background: var(--canvas); border-radius: 16px; overflow: hidden; }
.scan-frame > canvas { grid-column: 2; outline: none; }
.scan-frame:has(> canvas:focus-visible) { outline: 2px solid var(--highlight); outline-offset: 2px; }
.scan-guidance, .orientation-status { position: absolute; top: 14px; left: 16px; z-index: 1; max-width: calc(100% - 32px); white-space: pre-line; color: var(--secondary); font-size: clamp(15px, 1.05vw, 17px); font-weight: 500; line-height: 1.45; pointer-events: none; }
.point-help-badge { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; margin-right: 8px; background: currentColor; vertical-align: middle; font-size: 0; }
.point-help-badge::after { content: attr(data-number); color: white; font-size: 13px; font-weight: 600; }
.range { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-top: 12px; }
.range label { display: grid; grid-template-columns: auto 96px 32px; gap: 8px; align-items: center; margin: 0; }
.range output { text-align: right; }
.view-cube { position: absolute; top: 12px; right: 12px; width: 112px; z-index: 2; }
.view-cube canvas { width: 112px; height: 112px; background: transparent; border-radius: 0; cursor: pointer; }
.model-thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 4px; margin: -4px -4px 16px; }
.model-thumbs .model-choice, .model-thumbs .model-add { flex: 0 0 96px; padding: 8px; font-size: 12px; min-height: 88px; }
.model-thumbs .model-choice span { display: block; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
.model-thumbs canvas { width: 80px; height: 60px; border-radius: 4px; margin-bottom: 4px; }
.model-thumbs button[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: #ffeadc; }
.model-frame + .row { margin: 12px 0; justify-content: space-between; gap: 12px; }
.model-frame + .row p { margin: 0; font-size: 12px; color: var(--muted); }
.section-panel { --section-spacing: 16px; display: flex; flex-direction: column; gap: var(--section-spacing); padding-top: var(--section-spacing); }
.section-heading { display: flex; align-items: center; gap: 12px; margin: 0; }
.section-heading button { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; border: 2px solid #ff3030; }
.section-heading h2 { margin: 0; }
.section-panel > p { margin: 0; }
.section-chart .section-zoom { margin: 0; gap: 4px; pointer-events: auto; }
.section-zoom .mouse-wheel-icon { width: 30px; height: 26px; flex-basis: 30px; color: var(--secondary); }
.section-zoom output { min-width: 34px; text-align: center; font-size: 11px; }
#section-zoom-in, #section-zoom-out { width: 26px; height: 26px; min-height: 26px; padding: 0; font-size: 15px; }
.section-chart { position: relative; }
.section-legend { position: absolute; top: 16px; right: 16px; z-index: 1; display: flex; flex-direction: column; gap: 8px; font-size: 12px; line-height: 20px; pointer-events: none; }
.section-legend span { display: flex; align-items: center; gap: 8px; }
.section-legend span:has(.effective) { color: var(--green); }
.section-legend span:has(.contact) { color: var(--red); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend-dot.effective { background: var(--green); }
.legend-dot.contact { background: var(--red); }
#section-notice { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 32px; text-align: center; color: var(--secondary); pointer-events: none; }
.section-parameters { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px 40px; width: 100%; max-width: 800px; margin-top: 24px; }
.smoothing-control { display: grid; grid-template-columns: minmax(0,1fr) auto; grid-template-rows: 20px 44px; gap: 8px 12px; margin: 0; min-width: 0; align-content: start; }
.smoothing-control input { grid-column: 1/-1; grid-row: 2; align-self: start; }
.smoothing-control output { grid-column: 2; grid-row: 1; }
#scan-display-controls { padding: 12px 16px; margin: 12px 0; border: 1px solid var(--border); border-radius: 8px; gap: 24px; }
#scan-display-controls label { margin: 0; }
#scan-display { min-width: 144px; height: 36px; }
#scan-display-controls label:has(input[type=range]) { display: grid; grid-template-columns: auto 120px 40px; gap: 8px; min-height: 36px; align-items: center; }
#overlay-help { font-size: 12px; }
@media (min-width: 1600px) { main { max-width: 1600px; margin: auto; } }
@media (max-width: 1000px) { main { padding: 16px; }.layout { grid-template-columns: 264px minmax(0,1fr); gap: 16px; }.section-parameters { gap: 16px 24px; }.smoothing-control { grid-template-rows: 36px 44px; } }
@media (max-width: 720px) {
  body, main { height: auto; min-height: 100vh; overflow: auto; }
  main { padding: 16px; } header { align-items: flex-start; gap: 12px; } h1 { font-size: 20px; line-height: 28px; } header p { max-width: 220px; }
  .layout { grid-template-columns: minmax(0,1fr); } .layout > .controls, .viewport { overflow: visible; padding: 0; }
  section { padding: 16px; }.parameter-group label { grid-template-rows: 24px 44px; }
  .section-parameters { grid-template-columns: 1fr; gap: 12px; }.smoothing-control { grid-template-rows: 20px 44px; }
  .library-preview, #model { height: 400px; }.section-legend { top: 12px; right: 12px; }
  #scan-display-controls { gap: 16px; }.model-frame + .row { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) { button { transition: none; } }

.scan-navigation { justify-content: space-between; gap: 12px; margin-top: 12px; }
.scan-navigation p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.7; }
#scan { touch-action: none; }

.navigation-hints { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; }
.nav-gesture { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.mouse-icon { display: inline-block; width: 22px; height: 26px; flex: 0 0 22px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.mouse-icon .mouse-active { fill: var(--accent); stroke: var(--accent); }
.navigation-hints kbd { font-family: inherit; font-size: 11px; line-height: 18px; padding: 0 4px; border: 1px solid var(--border); border-radius: 3px; background: var(--surface); }

.mouse-wheel-icon { width: 30px; flex-basis: 30px; }
.preview-scale { position: absolute; bottom: 16px; left: 16px; pointer-events: none; color: var(--secondary); font-size: 12px; line-height: 20px; padding: 0; background: transparent; }
.preview-scale > span { display: block; }
.preview-scale .scale-bar { height: 6px; margin-top: 5px; border: solid currentColor; border-width: 0 1px 1px; }

#library-status:empty { display: none; }
#library-status { margin: 0 0 14px; overflow-wrap: anywhere; }


.section-chart .section-legend { top: 42px; }

.model-card { position: relative; flex: 0 0 96px; }
.model-card .model-choice { width: 96px; }
.model-thumbs .model-add { font-size: 32px; font-weight: 400; }
.model-card .model-delete { position: absolute; top: 4px; right: 4px; z-index: 1; width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 6px; display: grid; place-items: center; font-size: 0; line-height: 1; background: var(--surface); color: var(--red); opacity: 0; pointer-events: none; }
.model-card:hover .model-delete, .model-card:focus-within .model-delete { opacity: 1; pointer-events: auto; }
@media (hover: none) { .model-card .model-delete { opacity: 1; pointer-events: auto; } }

.model-card .model-delete::before { content: ""; width: 10px; height: 2px; border-radius: 1px; background: currentColor; }

#scan-complete { color: #139c46; font-weight: 600; margin-bottom: 5px; }

.section-tools { position: absolute; top: 12px; right: 16px; max-width: 53%; display: grid; justify-items: end; gap: 5px; z-index: 2; pointer-events: none; }
.section-chart .section-legend { left: 16px; right: auto; top: 42px; }
.parameter-heading { margin: 20px 0 12px; font-size: 14px; }
.orientation-guide { position: absolute; top: 16px; left: 16px; right: 124px; z-index: 2; display: grid; justify-items: start; gap: 8px; pointer-events: none; }
.orientation-guide button { pointer-events: auto; }
.completion-notice { color: #139c46; font-size: 14px; font-weight: 600; z-index: 2; pointer-events: none; }


/* Reference direction: cool grey, white panels, and soft apricot — a focused modeling workspace. */
:root { --highlight: #fc914a; }
body { background: #d9dce0; }
main { position: relative; height: calc(100vh - 32px); margin: 16px; padding: 20px 20px 20px 88px; border-radius: 32px; background-color: var(--page); border: 1px solid #ffffffb3; }
header { padding-bottom: 24px; }
h1 { font-size: 26px; line-height: 36px; font-weight: 600; }
header p { margin-top: 4px; }
.layout { grid-template-columns: 280px minmax(0,1fr); gap: 16px; }
.controls section { padding: 20px 16px; }
.fit-panel { border: 2px solid var(--highlight); }
#fit-parameters[inert] { position: relative; }
#fit-parameters[inert]::after { content: ""; position: absolute; inset: -2px; border-radius: inherit; background: rgb(120 125 132 / 30%); }
@media (min-width: 721px) {
  .controls > .fit-panel { flex-shrink: 0; min-height: 100%; }
}
section { border-color: #f5f6f8; box-shadow: none; }
button { border-radius: 20px; padding-inline: 16px; }
.primary { background: #08090a; border-color: #08090a; }
.primary:hover:not(:disabled) { background: #fc914a; border-color: #dc7736; color: #141517; }
#scale {
  box-sizing: border-box;
  height: 36px;
  border-radius: 18px;
}
#scale {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='m2 4 4 4 4-4' fill='none' stroke='%23131416' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-origin: border-box;
  background-position: right 12px center;
  background-size: 12px 12px;
  background-repeat: no-repeat;
}
select { background-color: #f4f5f7; }
#scan-display {
  appearance: none;
  height: 36px;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='m2 4 4 4 4-4' fill='none' stroke='%23495057' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-origin: border-box;
  background-position: right 12px center;
  background-size: 12px 12px;
  background-repeat: no-repeat;
}
@media (forced-colors: active) {
  #scan-display { appearance: auto; background-image: none; }
}
.parameter-group { margin-top: 24px; }
.parameter-group legend { font-size: 13px; }
output { font-weight: 500; }
.model-thumbs .model-choice { border-radius: 16px; }
.model-thumbs .model-add { border-radius: 16px; background: #f2f3f5; }
.model-thumbs button[aria-pressed="true"] { background: #ffeadc; border-color: #25282d; box-shadow: inset 0 0 0 1px #25282d; }
.model-thumbs canvas { border-radius: 8px; background: #f1f2f4; }
.section-parameters { max-width: none; gap: 16px 32px; margin-top: 16px; }
.parameter-heading { padding-top: 16px; border-top: 1px solid var(--border); }
#scan-complete, .completion-notice { color: #397b25; }
.workspace-rail { position: absolute; top: 16px; left: 12px; bottom: 16px; width: 56px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.rail-steps { display: grid; gap: 12px; padding: 6px; border-radius: 28px; background: #08090a; }
.workspace-rail > * { position: relative; }
.workspace-rail svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.rail-mark { color: #111; background: var(--highlight); width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 12px; }
.rail-mark svg { width: 28px; height: 28px; stroke-width: 1.7; }
.workspace-rail a { color: #d7dade; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; text-decoration: none; }
.workspace-rail a[aria-current="location"] { background: var(--highlight); background-clip: padding-box; border: 4px solid transparent; color: var(--ink); }
.workspace-rail a:hover, .workspace-rail a:focus-visible { color: white; outline-color: var(--highlight); }
.rail-caption { margin-top: auto; color: #666b73; font: 11px ui-monospace,monospace; writing-mode: vertical-rl; text-orientation: upright; letter-spacing: 2px; }
.rail-caption > [lang="en"] { letter-spacing: -2px; }
@media (min-width:1600px) { main { width: calc(100% - 32px); margin: 16px auto; } }
@media (max-width:1000px) { main { margin: 8px; height: calc(100vh - 16px); padding: 16px 12px 16px 76px; }.layout { grid-template-columns: 248px minmax(0,1fr); gap: 12px; }section { padding: 20px; } }
@media (max-width:720px) { main { height: auto; margin: 8px; padding: 16px; border-radius: 24px; }.workspace-rail { display:none; }.layout { grid-template-columns:minmax(0,1fr); }h1 { font-size: 22px; }header { gap: 8px; }section { padding: 16px; }.section-parameters { grid-template-columns:1fr; } }
/* Keep in-page navigation inside the workbench rather than scrolling its shell. */
body { display: flow-root; overflow: clip; }
@media (max-width:720px) { body { overflow: auto; } }

.scan-picker { display: flex; align-items: center; gap: 8px; }
.language-picker { position: relative; flex: none; z-index: 5; }
#language-toggle { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: white; cursor: pointer; }
#language-toggle::-webkit-details-marker { display: none; }
#language-toggle svg { width: 20px; height: 20px; }
#language-toggle:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }
.language-options { position: absolute; top: calc(100% + 6px); right: 0; width: 112px; padding: 4px; border: 1px solid var(--border); border-radius: 16px; background: white; }
.language-options button { border-radius: inherit; display: grid; place-items: center; width: 100%; height: 36px; padding: 0; text-align: center; border: 0; }
.language-options button[aria-pressed="true"] { background: #ffeadc; }
.scan-picker { margin-block: 8px; min-width: 0; }
#choose-scan { flex: none; height: 36px; border: 2px solid var(--highlight); border-radius: 18px; background: #f0f1f3; padding-inline: 18px; }
#scan-file-name { font-size: 12px; overflow-wrap: anywhere; min-width: 0; }

:lang(en) .parameter-group label { grid-template-rows: minmax(36px,auto) 40px; }

.project-actions { position:relative; margin-inline-start:auto; display:flex; flex-wrap:wrap; gap:6px; }
@media(max-width:600px){ header { flex-wrap:wrap; } .project-actions button { padding-inline:10px; } }

.title-group { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 8px; }
.byline { color: #61656c; font-size: 12px; font-weight: 400; white-space: nowrap; }

#account-dialog, #generation-dialog { width: min(360px,90vw); border: 1px solid var(--border); border-radius: 20px; padding: 24px; color: var(--ink); }
#account-dialog::backdrop, #generation-dialog::backdrop { background: rgb(0 0 0 / .25); }
#account-dialog form { margin-block: 14px; }
#account-dialog input { width: 100%; box-sizing: border-box; margin-block: 6px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; }

#generation-title { font-size: 24px; font-weight: 700; margin: 0 0 16px; }
#generation-quota { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: 14px; background: #ffeadc; font-size: 14px; }
#generation-count { font-size: 34px; line-height: 1.1; font-weight: 750; font-variant-numeric: tabular-nums; }
#generation-charge { margin: 16px 0 4px; color: var(--ink); font-size: 15px; font-weight: 600; }
#generation-note { margin: 0; font-size: 13px; line-height: 1.6; color: var(--muted); }
#generation-dialog form { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.purchase-dialog { width: min(390px, 90vw); max-height: 85vh; overflow: auto; padding: 24px; border: 1px solid var(--border); border-radius: 20px; color: var(--ink); }
.purchase-dialog::backdrop { background: rgb(0 0 0 / .25); }
.purchase-dialog form { display: flex; gap: 8px; margin-top: 18px; }
.download-choices { flex-direction: column; }
#plans-dialog { width: min(790px, 92vw); }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(185px,100%),1fr)); gap: 10px; }
.plan-grid section { padding: 16px; border: 1px solid var(--border); border-radius: 14px; }
.plan-grid .selected-plan { border-color: #fd914b; }
.plan-grid h3 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0; }
.plan-price { white-space: nowrap; }

.plan-grid section:not([hidden]) { display: flex; flex-direction: column; }
.plan-grid section > :is(a,button) { margin-top: auto; align-self: flex-start; }
.plan-grid section > a { padding: 8px 16px; border-radius: 999px; background: var(--ink); color: white; text-decoration: none; font-weight: 600; }
#scan-display-controls { flex-wrap: wrap; align-items: flex-end; }
.line-blue { color: #287bbf; }
.line-orange { color: #c07924; }
.line-red { color: #c57474; }
.line-green { color: #268755; }
.curve-step-note { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 0.25em; margin: 0; font-size: 12px; line-height: 18px; }
#scale-switch { vertical-align: middle; width: 30px; height: 18px; min-height: 0; border: 0; padding: 2px; background: #aaaeb3; }
#scale-switch::before { content: ""; display: block; background: white; width: 14px; height: 14px; border-radius: 50%; }
#scale-switch[aria-checked=true] { background: #b95317; }
#scale-switch[aria-checked=true]::before { transform: translateX(12px); }
.smoothing-control > span > label { display: inline; }
output[id$="-value"][tabindex] {
  align-self: start;
  justify-self: end;
  cursor: text;
  outline: none;
}
output[tabindex]:focus-visible:not([contenteditable]) {
  text-decoration: underline;
  text-underline-offset: 3px;
}
output[id$="-value"][contenteditable="plaintext-only"]:focus {
  min-width: 1ch;
  outline: 1px solid #89919a;
  outline-offset: 2px;
  border-radius: 2px;
  background: white;
  caret-color: var(--ink);
  white-space: nowrap;
}
.range-reference:has(input:disabled) { opacity: .5; }

.controls .section-parameters { grid-template-columns: minmax(0, 1fr); gap: 8px; }
.controls .smoothing-control { grid-template-rows: auto auto; row-gap: 6px; }
.fit-panel .parameter-group label { grid-template-rows: minmax(36px, auto) auto; }
.fit-panel .parameter-group .grid { row-gap: 12px; }
#curve-panel { padding-bottom: 12px; }
#pillow-output > .row:last-child { margin-bottom: 0; }
#pillow-output { padding-top: var(--section-spacing); border-top: 1px solid var(--border); }

.preview-heading { margin: 0 0 12px; }
.scan-overlay-toggle { position: absolute; top: 12px; left: 12px; z-index: 1; margin: 0; padding: 4px 8px; cursor: pointer; }
#pillow-output .model-frame { container-type: inline-size; }
#dimensions {
  position: absolute;
  bottom: 16px;
  inset-inline: 0;
  margin: 0;
  text-align: center;
  font-size: 12px;
  font-weight: 400;
  line-height: 20px;
  pointer-events: none;
}
@container (max-width: 520px) {
  #dimensions { bottom: 72px; }
}
#dimensions:empty { display: none; }

/* Guided workspace */
body { height:auto; min-height:100vh; overflow:auto; background:#f8f7f4; }
main { width:min(100%,1512px); height:auto; min-height:100svh; margin:0 auto; padding:0 clamp(20px,5vw,78px) 24px; border:0; border-radius:0; background:transparent; }
main > header { min-height:86px; padding:16px 0; border-bottom:1px solid #dcdcd5; gap:12px; }
header h1 { font-size:18px; line-height:1.25; }
.brand-symbol { display:block; width:48px; height:auto; flex:none; }
.title-group { align-items:center; }
.welcome { flex:1; display:grid; grid-template-columns:minmax(0,.85fr) minmax(0,1.15fr); align-items:center; column-gap:4vw; padding:clamp(38px,7vw,108px) 0; }
.welcome-copy h2 { max-width:7em; margin:0; font-size:clamp(40px,5.2vw,82px); line-height:1.18; letter-spacing:-.055em; font-weight:650; }
.welcome-copy p { margin:22px 0 36px; font-size:clamp(17px,1.6vw,25px); line-height:1.5; color:#585950; }
.start-button { display:inline-flex; align-items:center; gap:32px; padding:16px 25px; border-radius:999px; font-size:16px; }
.welcome-stage,.demo-stage { overflow:hidden; background:#edece6; border-radius:28px; }
#welcome-demo { width:100%; height:clamp(330px,44vw,620px); display:block; background:transparent; }
#wizard-progress { display:flex; width:min(800px,100%); margin:32px auto 12px; }
#wizard-progress button { flex:1; min-width:0; position:relative; display:grid; justify-items:center; gap:7px; padding:3px; border:0; border-radius:5px; background:transparent; color:#616158; font-size:12px; }
#wizard-progress button:not(:last-child)::after { content:""; position:absolute; width:calc(100% - 34px); height:1px; left:calc(50% + 17px); top:17px; background:#cacac3; }
#wizard-progress b { display:grid; place-items:center; width:28px; height:28px; background:#f8f7f4; border:1px solid #a4a59d; border-radius:50%; font:550 11px/1 ui-monospace,monospace; }
#wizard-progress button:is([aria-current="step"],.active,.complete,.completed) b,
#wizard-progress button:has(~ button[aria-current="step"]) b { background:#292b27; color:white; border-color:#292b27; }
#wizard-progress button[aria-current="step"] { color:#171915; font-weight:700; }
.wizard-screen { margin:12px 0; }
.screen-title { font-size:clamp(26px,3vw,43px); line-height:1.25; letter-spacing:-.04em; margin:18px 0 24px; }
.wizard-columns,.scan-layout,#pillow-library { display:grid; grid-template-columns:minmax(230px,.7fr) minmax(0,1.3fr); gap:20px; align-items:stretch; }
.wizard-screen section,.library-options,#marking { min-width:0; padding:clamp(18px,2vw,32px); background:white; border:1px solid #dedfd8; border-radius:22px; }
#scan-controls section { height:100%; padding-top:18px; }
#scan-controls label[for="file"] { margin-top:0; }
#scan-controls label:first-of-type { font-size:16px; line-height:1.5; color:var(--ink); }
.scan-picker { flex-wrap:wrap; margin:18px 0 26px; }
#choose-scan { background:#ffecde; border:1px solid #edab7c; }
.demo-stage { min-height:320px; display:grid; place-items:center; }
#scan-preview,#pillow-library { background:transparent; border:0; padding:0; }
#marking { align-content:start; }
#marking h2,.wizard-screen h3 { font-size:18px; line-height:1.5; margin:0 0 14px; }
.library-work,.scan-layout > div { min-width:0; }
.library-options .model-thumbs { flex-wrap:wrap; overflow:visible; }
.fit-columns { grid-template-columns:minmax(290px,.76fr) minmax(0,1.24fr); align-items:start; }
.fit-columns > .viewport { padding:0; overflow:visible; }
#scan,#library-preview { height:clamp(320px,43vh,580px); }
#final-preview #model { height:clamp(280px,36vh,490px); }
#final-preview #pillow-output { border:0; padding:0; }
.export-panel .export-actions { display:grid; gap:12px; }
.step-actions { position:relative; display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:24px; }
.step-actions button { min-width:94px; }
#status { margin:0; }
#status:not(:empty) { margin-top:12px; }
@media(max-width:760px) {
 main > header { min-height:68px; flex-wrap:wrap; }
 .welcome { grid-template-columns:1fr; gap:28px; align-content:center; }
 .welcome-copy h2 { max-width:none; }
 #welcome-demo { height:clamp(240px,57vw,380px); }
 .wizard-columns,.scan-layout,#pillow-library { grid-template-columns:minmax(0,1fr); }
 #wizard-progress { margin-top:20px; }
 #wizard-progress button { font-size:11px; }
 .demo-stage { min-height:220px; }
}
.welcome-overview { display:flex; flex-wrap:wrap; align-items:center; gap:10px 15px; margin:0 0 32px; padding:0; list-style:none; color:#51524c; font-size:13px; }
.welcome-overview li:not(:last-child)::after { content:"→"; margin-left:15px; color:#afaea5; }
#marking .landmark-reference { position:static; transform:none; width:100%; justify-self:center; margin:8px 0; }
.scan-frame { display:block; }
#final-preview { width:100%; box-sizing:border-box; display:grid; grid-template-columns:clamp(84px,14vw,164px) minmax(0,1fr); gap:16px; align-items:start; }
#final-preview > h2 { grid-column:1/-1; margin:0; font-size:18px; }
#final-preview #pillow-output { min-width:0; }
.step-actions > #save-action { margin-inline-start:auto; }
@media(max-width:400px) { .step-actions button { min-width:0; } }
#final-preview .preview-heading { display:none; }
.export-footer > button { flex:none; }
.final-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; align-items:center; gap:8px 12px; }
@media(max-width:600px) { .export-footer { align-items:flex-start; } }
.final-actions button { padding:10px 22px; min-height:40px; }
.section-heading button { border:1px solid var(--border); }

#scan-dimensions { margin-top:18px; padding-top:16px; border-top:1px solid var(--border); }
#scan-dimensions summary { cursor:pointer; font-weight:600; }

.welcome {
  flex: 0 0 auto;
  grid-template-columns: minmax(0,.83fr) minmax(0,1.17fr);
  gap: clamp(12px,2vw,32px);
  padding: clamp(42px,7vh,82px) 0 40px;
  align-items: start;
}
.welcome-copy { padding-top:clamp(16px,4vh,48px); }
.welcome-copy h2 {
  max-width: none; font-size: clamp(39px,4.25vw,68px); line-height:1.16;
  letter-spacing:-.05em; font-weight:680; text-wrap:balance;
}
.welcome-copy p { margin:18px 0 24px; color:#425553; font-size:clamp(18px,1.8vw,27px); line-height:1.5; }
.welcome-overview { font-size:14px; line-height:1.6; margin:0 0 32px; gap:8px 12px; }
.welcome-overview li:not(:last-child)::after { margin-left:12px; }
.start-button { display:grid; place-items:center; min-width:196px; min-height:58px; padding:12px 28px; font-size:18px; font-weight:600; }
.welcome-stage { display:grid; place-items:center; min-width:0; min-height:0; overflow:visible; border:0; border-radius:0; background:transparent; }
#welcome-demo { width:100%; height:auto; aspect-ratio:3/2; object-fit:contain; }
#scan-demo { --scan-progress:.5; position:relative; isolation:isolate; min-height:0; align-self:stretch; background:#f4efeb; container-type:size; min-height:clamp(290px,30vw,500px); }
#scan-demo .scan-scene > img { display:block; width:100%; height:auto; aspect-ratio:3/2; object-fit:cover; }
#scan-demo .scan-highlight {
  position:absolute; inset:0; width:100%; height:100%; pointer-events:none;
  clip-path:polygon(49% 2.5%,53% 3%,57% 6%,60% 11%,62% 18%,62.5% 26%,61.5% 32%,59% 38%,59% 47%,60% 53%,63% 57%,70% 62%,76% 65%,80% 72%,83% 83%,84% 94%,85% 100%,17% 100%,17.5% 94%,18.5% 82%,20% 73%,24% 66%,29% 63%,36% 60%,43% 55%,43% 50%,39.5% 49.5%,38% 47%,37% 40%,36% 34%,36% 29%,35.3% 25%,36% 18%,38% 11%,41% 6%,45% 3.5%);
}
.scan-contour-position { fill:none; stroke:url(#scan-reflection); stroke-linecap:round; }
.scan-contour-glow { stroke-width:3.6; opacity:.65; filter:blur(1.65px); }
.scan-contour-core { stroke-width:1; }
.scan-phone {
  position:absolute; top:46%; left:calc(12% + 63% * var(--scan-progress)); width:15%; aspect-ratio:10/19;
  padding:0.6%; box-sizing:border-box; border-radius:17% / 9%;
  background:linear-gradient(110deg,#989d9a,#1a2223 14%,#131819 77%,#767b79);
  box-shadow:0 4px 8px #31291d45,inset 0 0 0 1px #303434;
  transform:rotate(calc(-8deg + 16deg * var(--scan-progress)));
}
.scan-screen {
  position:relative; display:block; height:100%; overflow:hidden; border-radius:13% / 7%;
  background:linear-gradient(#004b4b,#006865),url("scan-guide.webp") calc(34% + 32% * var(--scan-progress)) 20% / auto 145% no-repeat;
  background-blend-mode:color;
}
.scan-screen::before {
  content:""; position:absolute; inset:0;
  background:repeating-linear-gradient(0deg,transparent 0 2px,#9ff7e744 2px 3px),linear-gradient(0deg,#00373499,transparent 44%);
}
.scan-screen::after { content:""; position:absolute; top:4%; left:36%; width:28%; height:4%; border-radius:99px; background:#131819; }
@media(max-width:760px) {
  .welcome { grid-template-columns:1fr; gap:18px; padding:28px 0 0; }
  .welcome-copy { padding:0; }
  .welcome-copy p { margin:12px 0 16px; }
  .welcome-overview { margin-bottom:20px; }
  .start-button { min-width:176px; min-height:52px; }
  #welcome-demo { width:min(100%,54svh); }
}

#fit-parameters, #curve-panel { padding:16px 20px; }
#fit-parameters #scan-dimensions { border:0; margin:0; padding:0; }
#fit-parameters .section-parameters { margin-top:8px; gap:6px; }
#fit-parameters .smoothing-control { row-gap:1px; }
#fit-parameters .parameter-group { margin-top:15px; padding-top:8px; }
#fit-parameters .parameter-group label { grid-template-rows:auto auto; }
#fit-parameters .parameter-group .grid { row-gap:5px; }
#confirm-handles { grid-column:2; justify-self:start; margin-top:3px; min-height:24px; padding:2px 14px; }
#curve-panel { --section-spacing:8px; }
#curve-panel #section { height:clamp(195px,21vh,265px); }
#curve-panel #model { height:clamp(225px,25vh,320px); }
#curve-panel .preview-heading { margin-bottom:6px; }
#curve-panel .section-legend { top:10px; }
.curve-legend { display:grid; gap:1px; font-size:12px; line-height:1.4; }
#handle-pulses { position:absolute; inset:0; pointer-events:none; overflow:hidden; }
#handle-pulses i { position:absolute; width:14px; height:14px; border:1px solid #a8673b; border-radius:50%; animation:handle-pulse 1.8s ease-in-out infinite; }
@keyframes handle-pulse { 0%,100% {transform:translate(-50%,-50%) scale(.8);opacity:.3} 50% {transform:translate(-50%,-50%) scale(1.3);opacity:.85} }
@media(prefers-reduced-motion:reduce){ #handle-pulses i { animation:none; transform:translate(-50%,-50%); } }

.capture-help { margin-top:20px; }
.capture-help summary { cursor:pointer; font-weight:600; }
.capture-help ol { padding-inline-start:1.4em; }
.capture-help li { margin-block:.45em; }
#welcome-demo {
  mask-image: linear-gradient(to right,#000 77%,rgb(0 0 0 / .84) 84%,rgb(0 0 0 / .42) 91%,rgb(0 0 0 / .08) 97%,transparent),linear-gradient(to bottom,#000 86%,transparent);
  mask-composite:intersect;
}
[data-screen="4"] .screen-title { margin:8px 0 12px; }
[data-screen="4"] .step-actions { margin-top:12px; }
#curve-panel #scan-display-controls { padding:4px 8px; margin:4px 0; gap:8px; }
#curve-panel #scan-display-controls output { align-self:center; }
#curve-panel #scan-display { display:block; width:auto; min-width:0; }
@media (min-width:761px) {
  #fit-parameters .smoothing-control { grid-template-columns:minmax(0,1fr) minmax(54px,.72fr) auto; align-items:center; grid-template-rows:auto; column-gap:8px; }
  #fit-parameters .smoothing-control > input, #fit-parameters .smoothing-control .range-reference { grid-column:2; grid-row:1; }
  #fit-parameters .smoothing-control > output { grid-column:3; grid-row:1; min-width:3ch; align-self:center; text-align:right; }
  #fit-parameters .section-parameters { gap:12px; }
}
.curve-legend > span { display:flex; gap:6px; align-items:baseline; }
.curve-legend b { display:inline-flex; align-items:center; flex:none; }
.curve-legend b::before { content:""; width:13px; height:2px; margin-right:6px; background:currentColor; }



.scan-scene { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); width:min(100cqw,150cqh); aspect-ratio:3/2; }
@media(max-width:760px){ #scan-demo { min-height:0; aspect-ratio:3/2; } }
.gesture-help summary,#curve-panel details summary { cursor:pointer; font-size:13px; color:var(--secondary); }
#fit-parameters .comfort-controls { margin-bottom:20px; gap:16px; }

#scan-file-name { flex-basis:100%; list-style:none; margin:0; padding:0; }
#scan-file-name li { display:flex; align-items:center; gap:9px; padding:3px 0; }
#scan-file-name li > :first-child { flex:none; width:32px; height:32px; border-radius:5px; object-fit:cover; background:#eef0f1; display:grid; place-items:center; color:#53595e; font:600 10px system-ui; }
.orientation-guide { display:flex; top:auto; left:auto; bottom:14px; right:14px; justify-items:end; }
#fit-parameters .parameter-group:first-child { margin-top:0; }
.section-heading { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:8px; }
.section-heading h2 { margin:0; }
#curve-panel .curve-legend { display:flex; flex-wrap:wrap; gap:5px 16px; }


#marking { align-content:center; }
.orientation-status { color:#a7490d; }
.orientation-status strong { font-weight:600; }
.orientation-status .completion-notice { font-size:inherit; }
.orientation-status:has(#base-status[data-picking="true"]) strong,
.orientation-status:has(#model-applied:not([hidden])) strong { display:none; }
#dimensions { inset-inline:auto 16px; bottom:16px; text-align:right; }
@media(min-width:761px){
  .fit-columns { align-items:stretch; }
  .fit-columns > .controls > section, .fit-columns > .viewport > section { flex:1; }
  #fit-parameters .parameter-group .smoothing-control { grid-template-rows:auto; }
  #fit-parameters .parameter-group input[type=range] { align-self:center; }
}

#point-help { font-weight:600; }
#point-help:empty { display:none; }

.scan-frame #measurements { position:absolute; left:16px; bottom:14px; max-width:calc(100% - 32px); margin:0; pointer-events:none; }

#wizard-progress button:has(~ button[aria-current="step"])::after {
  height: 3px;
  top: 16px;
  background: #292b27;
  border-radius: 2px;
}
#marking h3 { margin: 0; }

@media (min-width: 761px) {
  .scan-layout > div, #pillow-library .library-work { display: contents; }
  .scan-layout, #pillow-library { row-gap: 0; }
  .scan-layout .scan-navigation, .library-work > .row { grid-column: 2; }
  .scan-layout .scan-frame, .library-work > .model-frame { min-height: clamp(320px,43vh,580px); }
  #scan, #library-preview { position: absolute; inset: 0; width: 100%; height: 100%; }
  #fit-parameters { display: flex; flex-direction: column; gap: 10px; }
  #fit-parameters > fieldset.parameter-group { margin-top:4px; }
  #fit-parameters > .parameter-group, #fit-parameters > #scan-dimensions {
    display: flex;
    flex-direction: column;
    flex: 4;
  }
  #fit-parameters .section-parameters { flex: 1; align-content: space-around; }
  #fit-parameters > .comfort-controls { flex: 2; margin: 0; }
}

#fit-parameters .parameter-group legend, #fit-parameters #scan-dimensions h3 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.5;
}
#fit-parameters #scan-dimensions h3 { display: flex; align-items: center; gap: 8px; margin: 0; }
#fit-parameters #scan-dimensions h3::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

#fit-parameters .smoothing-control > span:first-child { font-size: 14px; line-height: 1.45; }

#model-measurement { font-size: 12px; font-weight: 500; color: var(--secondary); }

.brand-home { display:inline-flex; align-items:center; gap:8px; color:inherit; text-decoration:none; border-radius:8px; vertical-align:middle; }
@media (min-width:761px) {
  main {
    --panel-height:clamp(320px,43vh,580px);
    --intro-columns:minmax(230px,.7fr) minmax(0,1.3fr);
    --intro-title-size:clamp(26px,3vw,43px);
    --progress-height:59px;
  }
  #wizard-progress { height:var(--progress-height); }
  .welcome, [data-screen="1"] .wizard-columns, .scan-layout, #pillow-library {
    grid-template-columns:var(--intro-columns);
    grid-template-rows:var(--panel-height);
    column-gap:20px;
  }
  .welcome {
    /* Match the space occupied by progress, screen margins, and the step title. */
    margin-top:calc(32px + var(--progress-height) + 12px + 12px + 18px + var(--intro-title-size)*1.25 + 24px);
    padding:0;
    align-items:stretch;
  }
  .welcome-copy { align-self:center; padding:0; }
  .welcome-stage { container-type:size; }
  #welcome-demo { width:min(100cqw,150cqh); }
  #scan-demo, .scan-layout .scan-frame, .library-work > .model-frame { min-height:0; }
  #scan-controls, #marking, .library-options { min-height:0; }
  #scan-controls section, #marking, .library-options { overflow-y:auto; }
}

.welcome-heading { display:grid; width:fit-content; max-width:100%; }
.welcome-heading .welcome-overview { margin-block:clamp(12px, 1.5vw, 18px); contain:inline-size; flex-wrap:nowrap; gap:8px; letter-spacing:.08em; }
.welcome-overview li { display:flex; align-items:center; }
.welcome-overview li:not(:last-child) { flex:1; }
.welcome-heading .welcome-overview li:not(:last-child)::after {
  content:""; flex:1; min-width:10px; height:9px; margin-left:8px; background:#989990;
  clip-path:polygon(0 44%,calc(100% - 5px) 44%,calc(100% - 8px) 8%,calc(100% - 6px) 8%,100% 50%,calc(100% - 6px) 92%,calc(100% - 8px) 92%,calc(100% - 5px) 56%,0 56%);
}
#marking { align-content:stretch; align-items:stretch; }
.marking-instructions { display:flex; flex-direction:column; }
#marking .landmark-reference { flex:none; align-self:center; width:91%; height:auto; aspect-ratio:126 / 110; margin:clamp(12px, 2vh, 24px) 0 0; }
#marking .row { margin:auto 0 0; min-height:36px; }
#undo { margin-inline-start:auto; }

output[id$="-value"][contenteditable="plaintext-only"]:focus {
  min-width:5ch; padding:3px 6px; border-radius:5px; border:1px solid #89919a;
  outline:2px solid #f6c7a7; outline-offset:0; text-align:right;
}


#project-feedback:not(:empty) { position:absolute; z-index:6; inset-block-end:calc(100% + 5px); inset-inline-end:0; width:max-content; max-width:100%; padding:6px 12px; border:1px solid var(--border); border-radius:8px; background:var(--surface); font-size:13px; }
#base-status { color:#b02e27; font-size:14px; }
#base-status[data-grounded="true"] { color:#237446; }

.printer-setup { margin:0; padding:0; border:0; min-width:0; }
.printer-setup legend { font-size:17px; font-weight:650; }
.bed-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)) auto; align-items:center; gap:8px; margin:10px 0; }
#fit-parameters .bed-fields label { display:flex; align-items:center; gap:4px; min-width:0; white-space:nowrap; font-size:12px; }
.bed-fields label span:last-child { display:flex; align-items:center; gap:2px; min-width:0; }
.bed-fields #use-bed { margin:0; white-space:nowrap; }
.bed-fields input[type=number] { margin:0; min-width:0; width:8ch; max-width:100%; padding:5px; text-align:right; appearance:textfield; border:1px solid var(--border); border-radius:6px; }
.bed-fields input::-webkit-inner-spin-button, .bed-fields input::-webkit-outer-spin-button { appearance:none; margin:0; }
.preview-title-row { display:flex; align-items:baseline; flex-wrap:wrap; gap:2px 12px; margin-bottom:6px; }
#curve-panel .preview-title-row h2 { margin:0; }
#bed-feedback {
  position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); z-index:1;
  width:max-content; max-width:92%; margin:0; padding:6px 12px; border-radius:8px;
  font-size:15px; font-weight:650; color:#235f43; background:rgba(255,255,255,.94);
  text-align:center; pointer-events:none;
}
#bed-feedback:empty, #final-preview #bed-feedback { display:none; }
#final-preview .preview-title-row { display:none; }
#bed-feedback[data-over=true] {color:#a53524;}
#use-bed.pending {background:#ff994f;border-color:#ed8539;color:#20160f;}
#fit-parameters > [inert] {opacity:.55;}

#fit-parameters .feel-control label { display:block; font-size:14px; }
.feel-control input { display:block; width:100%; }
.feel-ticks { display:flex; justify-content:space-between; margin:0 9%; color:var(--secondary); font-size:12px; }

#fit-parameters #cradle-group { margin:12px 0 0; padding:0; border:0; min-width:0; }
#fit-parameters #cradle-group legend { font-size:15px; font-weight:600; background:none; padding:0; }
#fit-parameters #cradle-group legend::after { display:none; }
@media (min-width:761px) {
  #fit-parameters .smoothing-control, #fit-parameters .feel-control {
    display:grid; grid-template-columns:minmax(0,1fr) minmax(54px,.72fr) 24px;
    column-gap:8px; align-items:center;
  }
  #fit-parameters .feel-control input { grid-column:2; grid-row:1; }
  .feel-control .feel-ticks { grid-column:2; margin:0; justify-content:space-around; white-space:nowrap; }
}

#open-bambu { background:#00ae42; border-color:#00ae42; color:white; }
#open-bambu:hover { background:#008f36; border-color:#008f36; }

#projects-list { display:grid; gap:8px; max-height:52vh; overflow:auto; }
#projects-list button { width:100%; text-align:start; overflow-wrap:anywhere; }
.project-dialog-actions { display:flex; align-items:center; flex-wrap:wrap; gap:8px; margin-top:18px; }
#projects-close { margin-inline-start:auto; }

.contour-tip { margin: 8px 0 0; color: #565c62; font-size: 12px; line-height: 1.5; }

#fit-parameters input[type=range] { touch-action: pan-y; }

.density-panel{background:#fff;border:1px solid #dadbd7;border-radius:20px;padding:22px;margin:14px 0}
.density-panel h2{font-size:18px;margin:0 0 16px}.density-panel h3{font-size:14px;margin:0}
 .density-layout{display:grid;grid-template-columns:185px minmax(0,1fr);gap:16px;align-items:center}
.density-controls{padding:24px 0 24px 52px}
#density-track{position:relative;height:190px;width:24px;border-radius:5px;box-shadow:0 0 0 1px #969a9c}
.density-band{position:absolute;left:0;right:0;pointer-events:none}
.density-band:first-child{border-radius:5px 5px 0 0}.density-band:nth-child(3){border-radius:0 0 5px 5px}
.density-band span{position:absolute;right:calc(100% + 8px);top:50%;transform:translateY(-50%);font:12px/1.1 system-ui;white-space:nowrap;font-variant-numeric:tabular-nums}
.density-divider{position:absolute;left:0;width:100%;height:0}
.density-divider button{position:absolute;left:-7px;top:-10px;width:38px;height:20px;padding:0;border:0;background:transparent;touch-action:none;cursor:ns-resize}
.density-divider button:after{content:'';display:block;border:1px solid #373c40;background:white;height:5px;border-radius:4px}
.density-divider label{position:absolute;left:44px;top:var(--label-offset,0px);transform:translateY(-50%);display:flex;align-items:center;gap:3px;font-size:13px}
.density-divider input[type=number]{width:40px;height:24px;min-height:24px;margin:0;padding:1px 4px;border-radius:6px;text-align:right;appearance:textfield;font-variant-numeric:tabular-nums}
.density-divider input::-webkit-inner-spin-button{appearance:none}
#density-section{display:block;width:100%;height:200px;background:#f4f5f4;border-radius:10px;margin-top:8px}
@media(max-width:600px){.density-layout{grid-template-columns:123px minmax(0,1fr);gap:6px}.density-controls{padding-left:36px}.density-divider label{left:30px}.density-divider input[type=number]{width:40px}.density-panel{padding:14px}}
.density-divider button,.density-divider button:hover:not(:disabled){min-height:0;min-width:0;background:transparent}
.surface-layout{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:34px;align-items:center}
#surface-plan{width:100%;max-height:220px}.plan-labels{paint-order:stroke fill;stroke:#d9edeb;stroke-width:3px;stroke-linejoin:round;fill:#173b45;font:600 12px system-ui;pointer-events:none}
.zone-slider{display:grid;grid-template-columns:4em minmax(0,1fr) 4em;gap:10px;align-items:center;margin:16px 0;font-size:14px}
.zone-slider output{text-align:right;font-variant-numeric:tabular-nums}
@media(max-width:650px){.surface-layout{grid-template-columns:1fr;gap:6px}}
.density-band:nth-child(3) span{max-width:55px;white-space:normal;text-align:right}

#fit-parameters output[id$="-value"][tabindex] { border:1px solid #cbd0d5; border-radius:5px; padding:3px 5px; min-width:3.3em; box-sizing:border-box; text-align:center; background:white; align-self:center }
@media(min-width:761px){ #fit-parameters .smoothing-control,#fit-parameters .feel-control { grid-template-columns:minmax(0,1fr) minmax(54px,.72fr) 3em } }
.density-panels { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; margin-bottom:16px }
.density-panels .density-panel { margin:0; min-width:0 }
.density-panels .density-layout,.density-panels .surface-layout { display:flex; flex-direction:column; align-items:stretch; gap:12px }
.density-layout .density-controls { order:1; padding:38px 34px 42px }
#density-track { height:18px; width:100% }
.density-band { top:0; bottom:0; right:auto; }
.density-band:first-child {border-radius:5px 0 0 5px}
.density-band:nth-child(3) {border-radius:0 5px 5px 0}
.density-band span,.density-band:nth-child(3) span { top:-19px; left:50%; right:auto; transform:translateX(-50%); white-space:nowrap; max-width:none }
#density-track .density-band:nth-child(3) span {top:auto;bottom:calc(100% + 4px);white-space:pre;text-align:center}
.density-divider {top:0; width:0; height:100%}
.density-divider button {top:-5px; left:-15px; width:30px; height:28px; cursor:ew-resize}
.density-divider button:after {width:5px; height:26px; margin:auto}
.drag-arrows {position:absolute;inset:0;display:flex;align-items:center;justify-content:space-between;pointer-events:none;filter:drop-shadow(0 0 1px white)}
.drag-arrows::before,.drag-arrows::after {content:"";border-block:4px solid transparent}
.drag-arrows::before {border-right:6px solid #303e49}
.drag-arrows::after {border-left:6px solid #303e49}
.density-divider label {left:var(--label-offset,0px); top:calc(100% + 9px); margin:0; transform:translateX(-50%)}
#surface-plan {height:208px}
.surface-heading {display:flex; align-items:center; gap:10px}
.surface-heading {justify-content:space-between; margin-bottom:16px}
.surface-heading h2 {margin:0;font-size:18px}
:is(#surface-enabled,#shell-enabled) {appearance:none;width:38px;height:22px;border:1px solid #a6acab;border-radius:20px;background:#d5d9d7;cursor:pointer}
:is(#surface-enabled,#shell-enabled):before {content:'';display:block;width:16px;height:16px;margin:2px;border-radius:50%;background:white}
:is(#surface-enabled,#shell-enabled):checked {background:#216374} :is(#surface-enabled,#shell-enabled):checked:before {transform:translateX(16px)}
.density-panel:has(#surface-enabled:not(:checked)) .surface-layout {opacity:.5}
.cut-controls {display:grid; gap:10px}
.cut-controls [hidden]{display:none}.cut-controls select {padding:5px;border:1px solid #cbd0d5;border-radius:5px;background:white}
.cut-controls output {min-width:5em;font-variant-numeric:tabular-nums}
@media(max-width:700px){.density-panels{grid-template-columns:1fr}}
.cut-controls label { display:grid; gap:6px; white-space:nowrap; margin:0 }
.cut-controls select,.cut-controls input {width:100%; min-width:0; box-sizing:border-box}

.contour-tip::before {content:"★"; color:#c33434; margin-right:.4em}

#fit-parameters .feel-control #loft-entry {border:1px solid #cbd0d5;border-radius:5px;padding:3px 2px;background:white;box-sizing:border-box;text-align:center;appearance:textfield;grid-column:3;grid-row:1;white-space:nowrap;font:12px system-ui}
#density-loading {color:var(--muted);font-size:14px}

.section-stage{position:relative}
#scan-overlay-loading,#density-loading{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);margin:0;text-align:center;border-radius:12px;background:#fffffff2;padding:9px 13px}
#scan-overlay-loading{z-index:2;pointer-events:none;font-size:14px;color:var(--muted)}
#scan-overlay-loading:before,#density-loading.calculating:before{content:'';display:block;margin:0 auto 6px;width:22px;height:22px;border:3px solid #d9dfdf;border-top-color:#287480;border-radius:50%;animation:section-spin .85s linear infinite}
@keyframes section-spin{to{transform:rotate(360deg)}}
@media(prefers-reduced-motion:reduce){#scan-overlay-loading:before,#density-loading.calculating:before{animation:none}}
.density-panels[data-loading=true] :is(.density-controls,.surface-layout,.surface-heading input){visibility:hidden}
.density-panels[data-loading=true] ~ #final-preview .model-frame{visibility:hidden}

#surface-plan [data-zone-edge] {cursor:ew-resize;touch-action:none}
#surface-plan [data-zone-edge="neck"] {cursor:ns-resize}
#surface-plan [data-zone-edge] circle {fill:white;stroke:#476170;stroke-width:1}
#surface-plan [data-zone-edge] path {fill:none;stroke:#304b5a;stroke-width:1.3;pointer-events:none}
#surface-plan [data-zone-edge]:focus-visible circle {stroke:#176daa;stroke-width:2}

#feel-loft ~ .feel-ticks {position:relative;justify-content:space-between;margin-inline:7px}
#feel-loft ~ .feel-ticks span:nth-child(2) {position:absolute;left:35.714%;transform:translateX(-50%)}
#cut-depth::-webkit-slider-runnable-track {background:radial-gradient(circle at center,#858b92 2px,transparent 3px),#d7dadf}
#cut-depth::-moz-range-track {background:radial-gradient(circle at center,#858b92 2px,transparent 3px),#d7dadf}

.cut-controls #scan-display-controls {display:grid;grid-template-columns:minmax(0,1fr);gap:10px;padding:0;margin:0;border:0;min-width:0}
.cut-controls #scan-display-controls[hidden] {display:none}
#final-preview #scan-display-controls label {min-width:0;display:grid;grid-template-columns:minmax(0,1fr);gap:4px}
#final-preview #scan-display {min-width:0;width:100%;appearance:auto;background-image:none;padding:5px}
label:has(> #shell-enabled) {display:flex;align-items:center;gap:8px}
