:root {
  color-scheme: dark;
  font: 14px "Segoe UI", system-ui, sans-serif;
  color: #e4eaf1;
  background: #080a0e;
  --surface: #151b23;
  --raised: #202832;
  --line: #303b49;
  --muted: #a7b3c2;
  --accent: #4FC3F7;
  --accent-surface: color-mix(in srgb, var(--accent) 18%, var(--surface));
  --accent-border: color-mix(in srgb, var(--accent) 45%, var(--line));
  --cut: #ff4848;
  --crease: #4c9cff;
  --perforation: #dd9d76;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; height: 100dvh; min-height: 420px; display: flex; flex-direction: column; }
header, .document-bar, .viewhead, .viewfoot, footer { padding-inline: clamp(12px, 2vw, 26px); }
header, .document-bar, .brand, .actions, .viewhead, .viewfoot, .settings, .setting, .toolhead, .inspector-head { display: flex; align-items: center; gap: 9px; }
header { justify-content: space-between; min-height: 55px; padding-block: 8px; background: #11161e; border-bottom: 1px solid var(--line); }
h1, h2, p { margin: 0; }
h1 { font-size: 17px; letter-spacing: -.025em; white-space: nowrap; }
h1 span { color: var(--muted); font-weight: 450; }
.mark { display: grid; place-items: center; width: 29px; height: 29px; color: var(--accent); background: var(--accent-surface); border: 1px solid var(--accent-border); border-radius: 6px; font-size: 19px; }
button, .button, select, input:not(.file):not([type="checkbox"]):not([type="range"]) {
  font: inherit; min-height: 32px; padding: 5px 10px; color: #e4eaf1; background: var(--raised); border: 1px solid #3a4859; border-radius: 5px;
}
button, .button, select { cursor: pointer; }
button:hover:not(:disabled), .button:hover { background: #2b3947; }
button:disabled { opacity: .48; cursor: default; }
button.primary { background: var(--accent-surface); border-color: var(--accent-border); color: var(--accent); }
#record-fold.recording { color: #ff958b; border-color: #e87268; background: #47272a; }
.button.primary { border-color: var(--accent-border); }
.button span { margin-left: 4px; font: 10px ui-monospace, monospace; color: var(--accent); }
.file { position: absolute; width: 1px; height: 1px; opacity: 0; }
:focus-visible, label:has(+ .file:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.document-bar { flex-wrap: wrap; min-height: 54px; padding-block: 7px; background: var(--surface); border-bottom: 1px solid var(--line); }
.drawing-title { flex: 1; min-width: 0; }
.drawing-title h2 { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#status { color: var(--muted); font: 11px ui-monospace, monospace; margin-top: 3px; overflow-wrap: anywhere; }
.view-switch { display: flex; flex-shrink: 0; padding: 3px; gap: 2px; background: #090d13; border: 1px solid #33404e; border-radius: 6px; }
.view-switch button { min-height: 28px; padding: 3px 11px; border-color: transparent; background: transparent; color: var(--muted); }
.view-switch button[aria-selected="true"] { background: var(--accent-surface); color: var(--accent); border-color: var(--accent-border); }
#inspector-toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.workspace { flex: 1; min-height: 0; position: relative; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.workspace:has(.tools:not([hidden])) { grid-template-columns: minmax(0, 1fr) min(380px, 46%); }
.view { grid-area: 1 / 1; display: grid; min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; }
.viewhead { min-height: 48px; padding-block: 7px; flex-wrap: wrap; background: #10151c; border-bottom: 1px solid #242d38; }
#share-dialog { width: min(480px, calc(100% - 24px)); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: inherit; }
#share-dialog::backdrop { background: #0009; }
#share-dialog form { display: grid; gap: 10px; }
.viewfoot { min-height: 31px; padding-block: 5px; justify-content: space-between; flex-wrap: wrap; border-top: 1px solid #242d38; background: #10151c; color: var(--muted); font-size: 11px; }
#flat, #volume { display: block; width: 100%; height: 100%; min-height: 0; touch-action: none; }
#flat { background: #0d1117; cursor: grab; }
.dieline-grid { fill: none; vector-effect: non-scaling-stroke; stroke-width: 1; pointer-events: none; }
.grid-minor { stroke: #202a35; }
.grid-major { stroke: #33414f; }
.grid-axis { stroke: #536575; }
#volume { overflow: hidden; background: radial-gradient(ellipse at 52% 49%, #202a36, #0a0e14 68%, #080a0e); position: relative; }
#volume canvas { display: block; }
#volume canvas.fold-draggable { cursor: grab; }
#volume canvas.fold-dragging { cursor: grabbing; }
.view-option { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.opacity-control { gap: 7px; }
#model-opacity { width: clamp(66px, 12vw, 108px); margin: 0; }
#model-opacity-value { min-width: 4ch; text-align: right; font: 11px ui-monospace, monospace; color: var(--accent); }
#panel-numbers { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.panel-number { position: absolute; translate: -50% -50%; min-width: 22px; padding: 2px 5px; border: 1px solid #718392; border-radius: 4px; background: #101922ee; color: #eef4fa; text-align: center; font: 600 11px ui-monospace, monospace; box-shadow: 0 1px 4px #0006; }
.panel-number.current { z-index: 1; border-color: #d1f1ff; background: var(--accent); color: #071924; }
.webgl-error { padding: 20px; }
footer { display: flex; flex-wrap: wrap; gap: 6px 17px; align-items: center; min-height: 30px; padding-block: 5px; background: #131923; border-top: 1px solid var(--line); }
.metric { color: var(--muted); font: 11px ui-monospace, monospace; white-space: nowrap; }
.metric strong { color: var(--accent); margin-right: 5px; }
.legend { display: flex; gap: 12px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend span::before { content: ""; width: 15px; border-top: 2px solid var(--cut); }
.legend .crease::before { border-color: var(--crease); }
.legend .perforation::before { border-top: 2px dotted var(--perforation); }
.panel { fill: #355975; fill-opacity: .27; cursor: pointer; }
.panel:hover, .panel.active { fill: var(--accent); fill-opacity: .38; }
.panel-label { font: 600 12px ui-monospace, monospace; fill: #d7edf2; pointer-events: none; paint-order: stroke; stroke: #0e151f; stroke-width: 3px; stroke-linejoin: round; }
.entity, .hinge-target, .loose { fill: none; vector-effect: non-scaling-stroke; }
.entity { stroke: var(--cut); stroke-width: 1.5; pointer-events: none; }
.entity.crease { stroke: var(--crease); }
.entity.perforation { stroke: var(--perforation); stroke-dasharray: 2 3; }
.entity.other { stroke: #96a6b9; opacity: .55; }
.loose { stroke: #ff9d6d; stroke-width: 2; stroke-dasharray: 2 3; pointer-events: none; }
.hinge-target { stroke: transparent; stroke-width: 11px; cursor: pointer; }
.hinge-target:hover, .hinge-target.active { stroke: var(--accent); stroke-opacity: .9; stroke-width: 4px; }
.tools { grid-area: 1 / 2; min-height: 0; overflow: auto; background: #151b23; border-left: 1px solid #3b4a5b; }
.inspector-head, .toolhead { justify-content: space-between; padding: 9px 13px; }
.inspector-head { position: sticky; top: 0; z-index: 1; background: #202832; border-bottom: 1px solid var(--line); }
.inspector-head h2, .toolhead h2 { font-size: 14px; }
.tools article { padding-bottom: 13px; border-bottom: 1px solid var(--line); }
#artwork-open[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.artwork-body { padding: 13px; }
#artwork-status { margin: 9px 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.artwork-help { margin: 10px 0; color: var(--muted); font-size: 12px; }
.artwork-fields { display: grid; gap: 6px; }
.artwork-body .setting { margin-inline: 0; }
.artwork-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.artwork-image { opacity: .75; pointer-events: none; }
.artwork-outline { fill: transparent; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; pointer-events: all; cursor: move; }
.artwork-handle { fill: var(--accent); stroke: #0d151d; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.artwork-handle[data-corner="0"], .artwork-handle[data-corner="2"] { cursor: nwse-resize; }
.artwork-handle[data-corner="1"], .artwork-handle[data-corner="3"] { cursor: nesw-resize; }
#flat.artwork-moving { cursor: grabbing; }
#flat.artwork-moving .artwork-outline { cursor: grabbing; }
.sequence-help { margin: 0 13px 7px; color: var(--muted); font-size: 11px; }
#sequence-message:empty { display: none; }
#fold-sequence { list-style: none; margin: 0 13px 8px; padding: 0; max-height: 245px; overflow: auto; }
.sequence-step { display: grid; grid-template-columns: 30px minmax(65px, 1fr) 57px 25px 25px; gap: 4px; align-items: center; padding: 4px; margin-bottom: 3px; border: 1px solid #303b49; border-radius: 5px; background: #1a232e; }
.sequence-step.active, .sequence-step.preview, .sequence-step.located { border-color: var(--accent); background: var(--accent-surface); }
.sequence-step.located .sequence-label strong { color: var(--accent); }
.sequence-step.dragging { opacity: .48; }
.sequence-step.drop-before { box-shadow: 0 -2px var(--accent); }
.sequence-step.drop-after { box-shadow: 0 2px var(--accent); }
.sequence-step button { min-height: 25px; padding: 1px 3px; }
.sequence-step .sequence-grip { color: var(--accent); cursor: grab; font: 11px ui-monospace, monospace; }
.sequence-step .sequence-grip:active { cursor: grabbing; }
.sequence-label { min-width: 0; }
.sequence-label strong, .sequence-label small { display: block; }
.sequence-label strong { font-size: 12px; }
.sequence-label small { font-size: 10px; color: var(--muted); }
#fold-sequence input { width: 100%; min-height: 25px; padding: 2px 4px; font: 12px ui-monospace, monospace; appearance: textfield; }
#fold-sequence input::-webkit-inner-spin-button { appearance: none; }
.tools .setting, .settings, #diagnostics, #hinges, #fold-results { margin-inline: 13px; }
.settings { display: grid; gap: 6px; }
.settings .setting { margin: 0; }
.setting { justify-content: space-between; color: var(--muted); font-size: 12px; }
.setting:has([type="checkbox"]) { justify-content: flex-start; }
.material-setting { gap: 8px; padding: 7px; border: 1px solid var(--line); border-radius: 5px; }
.material-setting strong { color: #e4eaf1; }
#material-caliper { margin-top: 3px; font: 11px ui-monospace, monospace; color: var(--accent); }
#current-finish { margin-top: 3px; }
#materials-dialog { width: min(500px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--accent-border); border-radius: 9px; color: inherit; background: var(--surface); box-shadow: 0 14px 52px #000b; }
#materials-dialog::backdrop { background: #06090dcc; }
.materials-heading { padding: 10px 15px; }
.materials-heading h2 { font-size: 16px; }
.materials-heading button { min-height: 28px; }
.finish-setting { margin: 12px 15px; padding: 9px; background: #1a232e; border: 1px solid var(--line); border-radius: 5px; }
.finish-setting label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.finish-setting select { width: min(230px, 66%); }
.finish-swatches { display: flex; flex-wrap: wrap; gap: 5px 13px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.finish-swatches span { display: flex; align-items: center; gap: 5px; }
.finish-swatches i { display: inline-block; width: 16px; height: 16px; border: 1px solid #69798a; border-radius: 3px; }
.flute-setting { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 15px 10px; padding: 6px 8px 8px; border: 1px solid var(--line); border-radius: 5px; }
.flute-setting legend { color: var(--accent); padding-inline: 4px; font-size: 12px; }
.flute-setting label { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 4px; font-size: 12px; cursor: pointer; }
.flute-setting label:has(:checked) { border-color: var(--accent); background: var(--accent-surface); }
#materials-note { margin: 10px 15px; color: var(--muted); font-size: 12px; }
#material-options { padding: 0 15px; }
.material-group { min-width: 0; margin: 10px 0; border: 0; padding: 0; }
.material-group legend { margin-bottom: 5px; color: var(--accent); font-weight: 600; font-size: 12px; }
.material-option { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 8px; margin: 3px 0; border: 1px solid var(--line); border-radius: 5px; background: #1a232e; cursor: pointer; }
.material-option:has(:checked) { border-color: var(--accent); background: var(--accent-surface); }
.material-option input { accent-color: var(--accent); }
.material-option small { display: block; color: var(--muted); font-size: 11px; }
.material-option output { font: 12px ui-monospace, monospace; color: var(--accent); }
.materials-actions { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 7px; background: var(--surface); padding-block: 8px; }
#flex-setting { margin-top: 7px; }
input[type="number"] { width: 82px; }
input[type="checkbox"], input[type="range"] { accent-color: var(--accent); }
#types { width: 150px; }
#hinges { display: grid; gap: 3px; margin-top: 10px; max-height: 212px; overflow: auto; }
.hinge-row { display: grid; grid-template-columns: minmax(115px, 1fr) minmax(56px, 1fr) 38px; align-items: center; gap: 5px; padding: 3px; border-radius: 4px; }
.hinge-row.active { background: var(--accent-surface); }
.hinge-row button { padding-inline: 3px; text-align: left; border-color: transparent; background: transparent; font-size: 12px; }
.hinge-row input { min-width: 0; width: 100%; }
.hinge-row output { font: 11px ui-monospace, monospace; text-align: right; }
#fold-stage { position: absolute; z-index: 1; left: 15px; bottom: 46px; background: #151d27; padding: 6px 11px; border: 1px solid #3b5460; border-radius: 4px; color: var(--accent); font-size: 12px; }
#diagnostics, #fold-results { margin-block: 9px; font-size: 12px; line-height: 1.45; color: var(--muted); }
#fold-results:empty { margin-block: 5px; }
#fold-results p { margin-block: 5px; }
#fold-results.ignore-collisions .collision-warning { display: none; }
#crease-editor { position: absolute; z-index: 3; top: 58px; left: clamp(8px, 2vw, 26px); width: min(256px, calc(100% - 16px)); padding: 10px 12px 12px; background: #151e29; border: 1px solid #43576a; border-left: 3px solid var(--accent); border-radius: 6px; box-shadow: 0 8px 24px #0007; }
.crease-heading, .crease-inputs, .crease-presets { display: flex; align-items: center; gap: 8px; }
.crease-heading { justify-content: space-between; }
.crease-heading h2 { font-size: 14px; }
#crease-close { min-height: 25px; padding: 0 8px; }
#crease-panels { color: var(--muted); font-size: 11px; }
.crease-inputs { margin-block: 9px; }
#crease-range { flex: 1; min-width: 0; width: 100%; margin: 0; }
.crease-degrees { position: relative; }
#crease-angle { width: 63px; padding-right: 17px; font: 13px ui-monospace, monospace; appearance: textfield; }
#crease-angle::-webkit-inner-spin-button { appearance: none; }
.crease-degrees span { position: absolute; right: 7px; top: 7px; pointer-events: none; color: var(--muted); }
.crease-presets button { flex: 1; min-height: 27px; padding: 3px; font: 11px ui-monospace, monospace; }
#fold-dial { position: absolute; z-index: 2; width: 76px; height: 76px; translate: -50% -50%; pointer-events: none; }
#fold-dial svg { width: 100%; height: 100%; fill: none; stroke: #1e3038; stroke-width: 3px; paint-order: stroke; filter: drop-shadow(0 0 2px #000); }
#fold-dial svg circle:first-child { stroke: var(--accent); stroke-dasharray: 3 4; stroke-width: 1.7px; }
#fold-dial svg path, #fold-dial .dial-center { stroke: var(--accent); stroke-width: 1.3px; }
#fold-grip { position: absolute; pointer-events: auto; translate: -50% -50%; width: 22px; min-height: 22px; height: 22px; padding: 0; border: 2px solid #11232e; border-radius: 50%; background: var(--accent); cursor: grab; touch-action: none; box-shadow: 0 1px 5px #0009; }
#fold-grip:hover:not(:disabled), #fold-grip:active { background: color-mix(in srgb, var(--accent) 78%, white); }
#fold-grip:active { cursor: grabbing; }
#diagnostics h3 { margin: 10px 0 3px; color: #e4eaf1; font-size: 12px; }
#diagnostics ul { margin: 5px 0; padding-left: 16px; }
@media (max-width: 520px) {
  .workspace:has(.tools:not([hidden])) { grid-template: minmax(0, 1fr) minmax(0, 44%) / minmax(0, 1fr); }
  .tools { grid-area: 2 / 1; border-left: 0; border-top: 1px solid #3b4a5b; }
  header { flex-wrap: wrap; }
  header .actions { width: 100%; }
  header select { flex: 1; min-width: 0; }
  .drawing-title { flex-basis: 100%; }
  .document-bar .view-switch { margin-right: auto; }
  .viewfoot { gap: 3px 8px; }
}
