:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --surface: #fffdfa;
  --surface-2: #f1ede6;
  --text: #1f1d1a;
  --muted: #57514a;
  --border: #e4ddd0;
  --border-strong: #c9bda9;
  --accent: #213f73;
  --accent-ink: #fffdfa;
  --accent-soft: #e7edf7;
  --cut: #213f73;
  --fold: #57514a;
  --error: #b91c1c;
  --ok: #16634b;
  --radius: 6px;
  --model: #c9bda9;
  --model-hinge: #b0a28c;
  --model-edge: #57514a;
  --board: #213f73;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { margin: 0; font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
.app-shell { display: flex; flex-direction: column; height: 100dvh; min-height: 620px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button, input, select, summary, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input, select { min-width: 0; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px; }
select { width: 100%; padding: 9px 10px; }
a { color: var(--accent); text-underline-offset: 3px; }
button svg { width: 17px; height: 17px; flex-shrink: 0; }
h1, h2, h3, p { margin: 0; }
summary { cursor: pointer; }
.eyebrow, .section-title { display: block; color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; }
.section-title { margin: 0 0 10px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-shrink: 0; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { display: block; width: 48px; height: 48px; flex-shrink: 0; object-fit: contain; }
.brand h1 { font-size: 16px; font-weight: 700; letter-spacing: -.025em; }
.tagline { color: var(--muted); font-size: 11px; }
.header-design-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.top-links { display: flex; align-items: center; gap: 8px; }
.topbar .ghost-btn { min-width: 96px; }
.top-links .unit-toggle { margin-left: 8px; }
.unit-toggle, .view-switch { display: inline-flex; padding: 3px; gap: 2px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); }
.unit-toggle button, .view-switch button { border: 0; padding: 6px 12px; border-radius: 4px; background: transparent; color: var(--muted); font-size: 12px; white-space: nowrap; }
.unit-toggle button[aria-pressed="true"], .view-switch button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px #1f1d1a12; font-weight: 650; }
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 348px minmax(0, 1fr); }
.panel { min-width: 0; overflow-y: auto; border-right: 1px solid var(--border); background: var(--surface); scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.settings-drawer > summary { display: none; }
.settings-content { padding: 22px 20px; }
.panel-heading { margin-bottom: 20px; }
.panel-heading h2 { font-size: 22px; font-weight: 550; letter-spacing: -.04em; margin-top: 2px; }
.card { padding: 18px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.model-card { padding-top: 0; }
.model-card > select { font-weight: 600; }
.model-about { margin-top: 8px; color: var(--muted); font-size: 12px; }
.desc { margin-top: 10px; }
.desc .ref { font-weight: 650; color: var(--accent); margin-right: 6px; }
.note { margin-top: 12px; padding: 10px 12px; background: var(--accent-soft); border-radius: 6px; font-size: 12px; }
.panel-footer { margin-top: 22px; color: var(--muted); font-size: 11px; line-height: 1.9; }
.params { display: flex; flex-direction: column; }
.card > summary { color: var(--text); font-size: 13px; font-weight: 600; }
.card > summary .section-title { display: inline; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 13px; }
details.card[open] > summary { margin-bottom: 14px; }
.field { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 5px 8px; padding: 9px 0; }
.field + .field { border-top: 1px solid var(--border); }
.field-label { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; }
.field-label .sym { color: var(--accent); font-size: 11px; font-weight: 650; }
.field-input { display: flex; align-items: center; gap: 6px; }
.field input[type="number"] { width: 78px; padding: 7px 8px; text-align: right; font-variant-numeric: tabular-nums; }
.field select { width: auto; max-width: 180px; padding: 7px 8px; }
.unit { font-size: 11px; color: var(--muted); }
.field-help, .field-limit { grid-column: 1 / -1; font-size: 11px; color: var(--muted); }
.field-limit.over { color: var(--error); }
.field-limit:empty { display: none; }
.field input[aria-invalid="true"] { border-color: var(--error); }
.dimensions-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.dimensions-grid .field { display: flex; flex-direction: column; align-items: stretch; border: 0; padding: 2px 0; }
.dimensions-grid .field-input { position: relative; }
.dimensions-grid .field input[type="number"] { width: 100%; padding: 10px 25px 10px 7px; text-align: left; appearance: textfield; }
.dimensions-grid input::-webkit-inner-spin-button, .dimensions-grid input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.dimensions-grid .unit { position: absolute; right: 8px; pointer-events: none; }
.dimensions-grid .field-limit { font-size: 10px; }
.fit-btn { float: right; border: 0; padding: 0; background: transparent; color: var(--accent); text-transform: none; letter-spacing: 0; font-size: 11px; }
.material-row { padding-top: 0; }
.material-row > .field-label { display: none; }
.material-row > .field-input { grid-column: 1 / -1; }
.material-row select { width: 100%; max-width: none; }
.material-info { grid-column: 1 / -1; font-size: 11px; color: var(--muted); }
.material-info p { margin-top: 7px; }
.material-info .ok { color: var(--ok); }
.material-info .warn { color: var(--error); }
.material-notes { margin-top: 8px; }
.material-notes summary { font-size: 11px; }
.advanced-fields { margin-top: 8px; }
.advanced-fields > summary { font-size: 12px; color: var(--accent); }
.advanced-fields[open] > summary { margin-bottom: 10px; }
.material-actions, .calib-actions, .save-row, .guide-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.save-row input { width: 100%; flex-basis: 100%; padding: 9px; }
.switch-input { appearance: none; position: relative; width: 36px; height: 22px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--border-strong); cursor: pointer; margin: 0; }
.switch-input::after { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: var(--muted); border-radius: 50%; }
.switch-input:checked { background: var(--accent); border-color: var(--accent); }
.switch-input:checked::after { background: var(--surface); left: 17px; }
.lid-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 0; margin: 0 0 12px; border: 0; }
.lid-options legend { font-size: 12px; margin-bottom: 8px; }
.lid-option { position: relative; display: flex; align-items: center; gap: 8px; padding: 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 11px; cursor: pointer; }
.lid-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.lid-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.lid-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.lid-option svg { width: 34px; height: 27px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.5; }
.calib-intro { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.calib-row { display: grid; grid-template-columns: minmax(0, 1fr) 112px; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.calib-row small { display: block; color: var(--muted); }
.calib-row select { font-size: 12px; padding: 7px; }
.calib-result { margin-top: 12px; padding: 12px; border-radius: 6px; background: var(--surface-2); font-size: 12px; }
.calib-result.error { color: var(--error); }
.calib-result ul { padding-left: 18px; }
.workspace { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.workspace-header { display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; grid-template-areas: "title views actions"; align-items: center; gap: 20px; padding: 24px 28px 16px; }
.workspace-title { grid-area: title; min-width: 0; }
#current-design-name { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; line-height: 1.4; }
.workspace-header h2 { font-size: 26px; font-weight: 550; letter-spacing: -.04em; margin-top: 3px; }
.workspace-actions { grid-area: actions; display: flex; align-items: center; justify-self: end; gap: 8px; }
.drawing-actions { display: flex; align-items: center; gap: 8px; }
.workspace-header .view-switch { grid-area: views; justify-self: start; }
.state-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.state-badge::before { content: ""; height: 5px; width: 5px; border-radius: 50%; background: currentColor; }
.state-badge[data-phase="ready"] { color: var(--ok); }
.state-badge[data-phase="invalid"] { color: var(--error); }
.viewer-wrap { position: relative; flex: 1; min-height: 220px; margin: 0 20px 18px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: radial-gradient(ellipse at 45% 25%, #fffdfa 0%, #f1ede6 100%); }
.viewer { position: absolute; inset: 0; }
.viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.hint { position: absolute; bottom: 76px; left: 12px; right: 12px; text-align: center; color: var(--muted); font-size: 10px; pointer-events: none; }
.preview-notice { position: absolute; top: 14px; left: 14px; right: 14px; width: fit-content; max-width: calc(100% - 28px); padding: 8px 12px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px; color: var(--muted); font-size: 12px; box-shadow: 0 2px 8px #1f1d1a08; }
.preview-notice[data-phase="invalid"] { color: var(--error); }
.toolbar { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 8px; max-width: calc(100% - 24px); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px #1f1d1a08; }
.fold-control { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 11px; color: var(--muted); white-space: nowrap; }
.fold-control input { width: clamp(70px, 12vw, 170px); min-width: 0; accent-color: var(--accent); }
.icon-btn, .ghost-btn, .primary-btn, .small-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--text); padding: 9px 13px; font-size: 12px; white-space: nowrap; }
.icon-btn { padding: 8px; width: 34px; height: 34px; flex-shrink: 0; }
.icon-btn svg { fill: currentColor; }
.primary-btn, .small-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.primary-btn:hover:not(:disabled), .small-btn.primary:hover:not(:disabled) { background: #142a50; }
.ghost-btn:hover:not(:disabled), .icon-btn:hover:not(:disabled), .small-btn:hover:not(:disabled) { border-color: var(--accent); }
.small-btn { padding: 7px 10px; font-size: 11px; }
.small-btn.danger { color: var(--error); }
.export-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 17px 28px; background: var(--surface); border-top: 1px solid var(--border); }
.export-info { min-width: 0; }
.status { font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.status.error { color: var(--error); }
.footnote { font-size: 11px; color: var(--muted); margin-top: 4px; }
.footnote .ok { color: var(--ok); }
.footnote .warn { color: var(--error); }
.export-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.export-actions button { min-height: 40px; }
.mobile-only { display: none; }
dialog { width: min(620px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); padding: 26px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: var(--surface); box-shadow: 0 24px 80px #0f172a26; }
dialog::backdrop { background: #0f172a55; backdrop-filter: blur(3px); }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.dialog-header h2 { font-size: 24px; font-weight: 550; letter-spacing: -.035em; }
dialog section + section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
dialog h3 { font-size: 14px; margin-bottom: 8px; }
dialog p, dialog li { font-size: 13px; color: var(--muted); }
dialog p + p { margin-top: 10px; }
dialog ul { padding-left: 20px; }
dialog li + li { margin-top: 6px; }
.drawing-dialog { width: min(850px, calc(100vw - 32px)); }
.dieline { width: 100%; height: min(55dvh, 500px); display: block; margin: 18px 0; }
.dieline .cut { fill: var(--accent-soft); stroke: var(--cut); stroke-width: 1.2; fill-rule: evenodd; }
.dieline .fold { stroke: var(--fold); stroke-width: 1; stroke-dasharray: 4 3; }
.dieline .band { fill: var(--fold); fill-opacity: .12; stroke: none; }
.dieline .dim { stroke: var(--text); stroke-width: 1; }
.dieline .dim-label { fill: var(--text); font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.dieline * { vector-effect: non-scaling-stroke; }
.legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); }
.sw { display: inline-block; width: 18px; margin-right: 6px; vertical-align: middle; }
.sw.cut { border-top: 2px solid var(--cut); }
.sw.fold { border-top: 2px dashed var(--fold); }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 318px minmax(0, 1fr); }
  .export-bar { flex-wrap: wrap; padding: 14px 20px; }
  .export-actions { margin-left: auto; }
  .workspace-header { grid-template-columns: minmax(160px, 1fr) auto; grid-template-areas: "title views" "actions actions"; gap: 10px 16px; padding: 20px 20px 14px; }
  .fold-control span { display: none; }
}
@media (max-width: 800px) {
  html, body { height: auto; min-height: 100%; }
  .app-shell { height: auto; min-height: 0; }
  .topbar { padding: 12px 16px; }
  .brand { gap: 8px; }
  .logo { width: 40px; height: 40px; }
  .brand h1 { font-size: 14px; }
  .tagline { display: none; }
  .top-links { gap: 8px; }
  .top-links .ghost-btn { padding: 8px; font-size: 11px; }
  .unit-toggle button { padding: 6px 8px; }
  .layout { display: flex; flex-direction: column; }
  .workspace { order: 0; }
  .panel { order: 1; border-right: 0; border-top: 1px solid var(--border); overflow: visible; }
  .settings-drawer > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 20px; color: var(--accent); font-weight: 600; }
  .settings-drawer > summary::after { content: "+"; font-size: 20px; }
  .settings-drawer[open] > summary::after { content: "−"; }
  .settings-drawer > summary span { margin-left: auto; color: var(--muted); font-size: 10px; font-weight: 400; }
  .panel-heading { display: none; }
  .settings-content { padding: 6px 20px 24px; }
  .workspace-header { grid-template-columns: minmax(0, 1fr) auto; padding: 18px 16px 14px; }
  .workspace-header h2 { font-size: 23px; }
  .workspace-actions { gap: 6px; }
  .workspace-actions .ghost-btn { font-size: 11px; padding: 8px; }
  .view-switch button { padding: 6px 9px; font-size: 11px; }
  .state-badge { font-size: 10px; }
  .viewer-wrap { flex: none; height: clamp(310px, 44dvh, 480px); min-height: 0; margin: 0 12px 14px; }
  .toolbar { gap: 8px; bottom: 12px; }
  .fold-control input { width: min(30vw, 180px); }
  .hint { bottom: 65px; font-size: 9px; }
  .export-bar { padding: 14px 16px; gap: 12px; }
  .export-info { width: 100%; }
  .export-actions { width: 100%; }
  .export-actions .primary-btn { flex: 1; }
  .mobile-only { display: inline-flex; }
  dialog { padding: 20px; }
}
@media (max-width: 560px) {
  .workspace-header { grid-template-areas: "title actions" "views views"; column-gap: 10px; }
  .workspace-actions { flex-direction: column; align-items: flex-end; }
  .drawing-actions { gap: 6px; }
}
@media (max-width: 370px) {
  .settings-drawer > summary span { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }

/* Portable designs and the browser-local library. */
.design-feedback { padding: 9px 12px; margin: 0 28px 14px; color: var(--ok); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; overflow-wrap: anywhere; font-size: 12px; }
.design-feedback.error { color: var(--error); }
.design-save-form { display: grid; gap: 8px; margin-top: 20px; }
.design-save-form label, .share-label { font-size: 12px; font-weight: 600; }
.design-save-form input, #share-link { width: 100%; padding: 10px; }
.design-file-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.design-save-form .design-file-actions { margin-top: 0; }
.design-library { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.saved-designs { list-style: none; padding: 0; margin: 8px 0; }
.saved-design { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.saved-design > div:first-child { min-width: 0; }
.saved-design strong { color: var(--text); font-size: 13px; overflow-wrap: anywhere; }
.saved-design p { font-size: 11px; margin-top: 3px; }
.saved-design-actions { display: flex; gap: 6px; flex-shrink: 0; }
#designs-dialog .design-feedback { margin: 14px 0 0; }
.share-label { display: block; margin: 18px 0 6px; }
#share-status { margin-top: 12px; }
@media (max-width: 800px) {
  .topbar { flex-wrap: wrap; }
  .top-links { margin-left: auto; gap: 6px; }
  .header-design-actions { gap: 6px; }
  .header-design-actions .ghost-btn { padding: 8px 10px; font-size: 11px; }
  .topbar .ghost-btn { min-width: 0; }
  .top-links .unit-toggle { margin-left: 0; }
  .design-feedback { margin: 0 16px 12px; }
}
@media (max-width: 420px) {
  .saved-design { align-items: flex-start; flex-direction: column; }
}

/* Readable, server-delivered content lives below the full-height modeling workspace. */
.site-info { max-width: 1240px; margin: 0 auto; padding: 72px 40px 56px; }
.info-intro { max-width: 730px; }
.info-intro h2, .guide-title { font-size: clamp(28px, 3vw, 42px); line-height: 1.16; font-weight: 600; letter-spacing: -.04em; margin: 12px 0 20px; }
.site-info p, .guide-main p, .guide-main li { color: var(--muted); line-height: 1.8; }
.info-intro > p { font-size: 16px; }
.text-link { display: inline-block; margin-top: 18px; font-weight: 600; }
.info-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px; padding: 44px 0; }
.site-info h3 { font-size: 16px; letter-spacing: -.02em; margin-bottom: 12px; }
.info-grid p + p { margin-top: 12px; }
.info-grid ol { padding-left: 20px; color: var(--muted); line-height: 1.8; }
.info-grid li + li { margin-top: 8px; }
.info-faq { border-top: 1px solid var(--border); padding-top: 36px; }
.info-faq h2 { font-size: 25px; font-weight: 550; letter-spacing: -.03em; margin-bottom: 28px; }
.faq-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px 56px; }
.site-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px; padding: 24px 40px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.site-footer nav { display: flex; gap: 20px; }
.brand-link { color: var(--text); text-decoration: none; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -.025em; }
.guide-main { max-width: 900px; margin: 0 auto; padding: 56px 36px 72px; }
.guide-lede { font-size: 18px; max-width: 720px; }
.guide-toc { display: flex; flex-wrap: wrap; gap: 12px 24px; margin: 32px 0 44px; padding: 22px 0; border-block: 1px solid var(--border); }
.guide-main section + section { margin-top: 38px; }
.guide-main h2 { font-size: 25px; font-weight: 550; letter-spacing: -.03em; margin-bottom: 16px; }
.guide-main h3 { font-size: 17px; margin: 24px 0 12px; }
.guide-main p + p { margin-top: 12px; }
.guide-main li + li { margin-top: 10px; }
.guide-main .note { color: var(--text); line-height: 1.7; }
.guide-cta { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
@media (max-width: 800px) {
  .site-info { padding: 44px 24px; }
  .info-grid { grid-template-columns: 1fr; gap: 28px; padding: 32px 0; }
  .faq-grid { grid-template-columns: 1fr; gap: 24px; }
  .site-footer { padding: 22px 24px; }
  .guide-main { padding: 36px 24px 48px; }
  .guide-lede { font-size: 16px; }
  .guide-toc { gap: 12px 20px; }
}
