body { --bg: #f4f2ed; --tint: #fff1e9; --danger: #a92e2d; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { cursor: default; opacity: .38; }
svg.glyph { width: 1em; height: 1em; display: block; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.board-bar { min-height: 65px; padding: 0 var(--site-layout-gutter); background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand, .board-bar-actions, .panel-title, .editor-heading, .history, .toolbar { display: flex; align-items: center; }
.brand { gap: 13px; flex: none; }
.brand-mark { display: grid; place-items: center; background: var(--accent-soft); color: #9f2a16; width: 40px; height: 40px; border-radius: 10px; font-size: 26px; }
.brand h1 { font-size: 19px; line-height: 1.35; letter-spacing: .04em; }
.board-bar-actions { gap: 10px; }
.save-status { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); font-size: .81rem; margin-right: 8px; white-space: nowrap; }
.save-status .glyph { color: var(--ok); }
.button { border: 1px solid transparent; background: none; border-radius: 7px; padding: 7px 12px; min-height: 38px; font-size: .875rem; font-weight: 600; display: inline-flex; justify-content: center; align-items: center; gap: 7px; white-space: nowrap; }
.button [data-icon] { font-size: 17px; }
.header-button { color: var(--ink); border-color: var(--line); }
.header-button:hover { background: var(--paper); border-color: var(--ink); }
.button.primary { background: #c53620; color: #fff; border-color: #c53620; }
.button.primary:hover { background: #aa2d1a; border-color: #aa2d1a; }
.outline-button { background: #fff; border-color: var(--line); }
.outline-button:hover { border-color: #88afb9; background: #f2f8fa; }
.workbench { max-width: 1920px; margin: auto; display: grid; grid-template-columns: 264px minmax(350px, 1fr) 286px; align-items: stretch; gap: 16px; min-height: calc(100svh - 130px); padding: 18px; }
.card { background: #fff; min-width: 0; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 2px 5px #142b4510; }
.settings, .operations { align-self: start; }
.panel-title { padding: 15px 16px; gap: 9px; border-bottom: 1px solid var(--line); min-height: 62px; }
.panel-title h2, .editor h2 { font-size: 1rem; font-weight: 700; }
.panel-icon { background: #eef4f8; color: #47637b; border-radius: 7px; padding: 6px; font-size: 17px; }
.setting-section { padding: 15px 16px; border-bottom: 1px solid #e6ecf2; }
.setting-section:last-child { border-bottom: 0; }
.section-label { font-size: .875rem; font-weight: 700; margin-bottom: 9px; display: flex; align-items: center; justify-content: space-between; }
.section-label span { font-family: ui-monospace, monospace; font-size: .75rem; font-weight: 500; color: var(--muted); }
.field { display: grid; gap: 4px; min-width: 0; font-size: .875rem; color: var(--muted); }
.field + .field { margin-top: 8px; }
.field input, .field select, .field textarea { display: block; background: #f8fafc; width: 100%; border: 1px solid #d5e0eb; border-radius: 6px; min-height: 35px; color: var(--ink); padding: 6px 8px; }
.field input[type=number] { font-variant-numeric: tabular-nums; appearance: textfield; }
.field input::-webkit-inner-spin-button { appearance: none; }
.field textarea { resize: vertical; min-height: 102px; font-family: ui-monospace, monospace; }
.field select { appearance: none; padding-right: 24px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='m3 5 4 4 4-4' fill='none' stroke='%2356677a' stroke-width='1.4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-size: 14px; background-position: right 7px center; }
.field + .section-label { margin-top: 13px; }
.size-fields, .property-grid, .corners-grid { display: grid; gap: 8px; }
.size-fields { grid-template-columns: repeat(3, 1fr); }
.property-grid, .corners-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
.size-fields .field, .property-grid .field, .corners-grid .field { margin: 0; }
.shape-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.shape { min-width: 0; min-height: 52px; display: grid; gap: 3px; justify-items: center; align-content: center; border: 1px solid var(--line); background: #fff; border-radius: 7px; font-size: .81rem; padding: 5px 2px; color: #476079; white-space: nowrap; }
.shape > span:first-child { font-size: 19px; }
.shape:hover, .tool:hover { background: #f0f7f9; color: var(--accent); }
.shape[aria-pressed=true], .tool[aria-pressed=true] { color: #9f2a16; background: var(--tint); border-color: #e0a998; font-weight: 700; }
.shape[data-shape=polygon] { grid-column: 1 / -1; min-height: 34px; display: flex; align-items: center; justify-content: center; gap: 6px; }
#shape-options:not(:empty) { margin-top: 11px; }
.helper { color: var(--muted); font-size: .8125rem; margin: 6px 0 0; }
.check-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: .875rem; min-height: 29px; }
.check-row:first-of-type { margin-top: 9px; }
.radius-toggle { margin-top: 4px; }
.switch { appearance: none; margin: 0; cursor: pointer; width: 32px; height: 18px; border-radius: 12px; border: 1px solid #aabacb; background: #e7edf3; display: grid; align-items: center; padding: 2px; flex: none; }
.switch::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: #607991; transition: transform .12s ease; }
.switch:checked { background: #d4f2f2; border-color: #3c99a6; }
.switch:checked::after { background: #0d7187; transform: translateX(14px); }
.editor { display: flex; flex-direction: column; min-height: 705px; }
.editor-head { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); min-height: 69px; }
.editor-heading { gap: 8px; }
.view-label { font-size: .75rem; font-weight: 600; background: #edf3f7; color: #4b6279; border-radius: 4px; padding: 1px 6px; }
#board-summary { color: var(--muted); font-size: .8125rem; font-variant-numeric: tabular-nums; margin-top: 4px; }
.history { gap: 4px; }
.icon-button { border: 1px solid transparent; background: transparent; border-radius: 6px; display: grid; place-items: center; color: #4b6279; padding: 0; width: 32px; height: 32px; }
.icon-button:hover:not(:disabled) { background: #e9f1f5; color: #105b70; }
.toolbar { min-height: 55px; padding: 8px 12px; gap: 5px; flex-wrap: wrap; }
.tool { display: flex; align-items: center; gap: 5px; border: 1px solid transparent; background: #fff; border-radius: 6px; color: #3f556c; font-size: .875rem; padding: 6px 7px; white-space: nowrap; }
.tool [data-icon] { font-size: 17px; }
.stage { min-height: 400px; flex: 1; position: relative; display: grid; overflow: hidden; background-color: #f0f5f9; }
.stage svg#drawing { width: 100%; height: 100%; position: absolute; inset: 0; touch-action: pan-y; }
.stage .is-placing { cursor: crosshair; touch-action: none !important; }
.stage [data-op] { cursor: grab; touch-action: none; }
.stage.is-dragging, .stage.is-dragging [data-op] { cursor: grabbing; }
.stage-hint { position: absolute; top: 12px; left: 12px; right: 12px; width: fit-content; max-width: calc(100% - 24px); pointer-events: none; font-size: .8125rem; padding: 5px 8px; border-radius: 5px; background: #ffffffed; border: 1px solid #d8e4ec; color: #395269; }
.stage-hint:empty { display: none; }
.zoom-controls { position: absolute; right: 12px; bottom: 12px; display: flex; align-items: center; background: #fff; border: 1px solid #d3e0e9; border-radius: 7px; padding: 2px; box-shadow: 0 2px 4px #19314412; }
#zoom-label { width: 45px; text-align: center; font: .78rem ui-monospace, monospace; color: #354f65; }
.fit { border-left: 1px solid var(--line); border-radius: 0 4px 4px 0; }
.editor-footer { min-height: 43px; padding: 8px 13px; display: flex; gap: 7px 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; color: var(--muted); font-size: .8125rem; }
.editor-footer span { display: inline-flex; align-items: center; gap: 5px; }
.editor-footer output { font-variant-numeric: tabular-nums; white-space: nowrap; }
.count { margin-left: auto; min-width: 24px; text-align: center; background: #ecf1f6; color: #496179; font: 600 .8125rem/23px ui-monospace, monospace; border-radius: 6px; }
.empty { text-align: center; margin: 15px; padding: 22px 12px; border: 1px dashed #cedce8; border-radius: 9px; color: var(--muted); background: #fafcfe; }
.empty-symbol { font-size: 23px; background: #e9f2f7; width: 39px; height: 39px; border-radius: 9px; display: grid; place-items: center; margin: 0 auto 11px; color: #517087; }
.empty strong { color: var(--ink); display: block; font-size: .875rem; margin-bottom: 5px; }
.empty p { font-size: .8125rem; }
.operation-rows { padding: 10px; display: grid; gap: 5px; max-height: 252px; overflow-y: auto; }
.operation-row { padding: 7px 8px; min-width: 0; border: 1px solid transparent; background: #f7f9fb; border-radius: 7px; display: flex; align-items: center; gap: 8px; text-align: left; }
.operation-row:hover { background: #eef6f8; }
.operation-row[aria-pressed=true] { background: var(--tint); border-color: #e0a998; }
.operation-row .row-icon { font-size: 19px; color: var(--accent); }
.operation-row .row-text { min-width: 0; flex: 1; }
.row-text strong, .row-text small { display: block; }
.row-text strong { font-size: .875rem; }
.row-text small { font-size: .75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.operation-row.invalid .row-icon { color: var(--danger); }
.properties { border-top: 1px solid var(--line); padding: 14px 15px; }
.properties h3 { font-size: .9rem; margin-bottom: 10px; }
.properties .property-grid { margin-top: 8px; }
.property-actions { display: flex; justify-content: space-between; gap: 6px; margin-top: 11px; }
.property-actions .button { padding-inline: 8px; min-height: 33px; }
.delete { color: var(--danger); }
.check-panel { border-top: 1px solid var(--line); padding: 14px 15px; }
.check-heading { display: flex; align-items: center; gap: 6px; font-size: .875rem; font-weight: 700; color: #176253; }
.check-panel p { margin-top: 4px; font-size: .8125rem; color: var(--muted); }
.check-panel ul { margin: 7px 0 0; padding-left: 18px; font-size: .8125rem; color: #8b3131; max-height: 146px; overflow: auto; }
.check-panel.invalid .check-heading { color: var(--danger); }
.polygon-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.polygon-actions .button { min-height: 33px; padding-inline: 7px; }
dialog { border: 1px solid var(--line); border-radius: 12px; max-width: min(91vw, 380px); padding: 22px; color: var(--ink); }
dialog::backdrop { background: #12304966; }
dialog h2 { font-size: 1.14rem; }
dialog p { color: var(--muted); margin: 8px 0 16px; }
.dialog-actions { display: flex; justify-content: end; gap: 8px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); border-radius: 8px; color: white; background: #173347; padding: 9px 15px; max-width: calc(100vw - 32px); box-shadow: 0 4px 20px #18334a30; z-index: 2; font-size: .875rem; }
#toast:empty { display: none; }
@media (min-width: 1450px) {
  .workbench { grid-template-columns: 280px minmax(350px, 1fr) 300px; gap: 18px; padding: 21px; }
}
@media (max-width: 1090px) {
  .workbench { grid-template-columns: 218px minmax(310px, 1fr) 228px; gap: 10px; padding: 12px; }
  .shape { font-size: .75rem; }
  .setting-section { padding-inline: 11px; }
  .toolbar { padding-inline: 6px; }
}
@media (max-width: 820px) {
  .workbench { grid-template-columns: 230px minmax(0, 1fr); align-items: start; }
  .settings { grid-row: 1 / span 2; }
  .editor { min-height: 575px; }
  .operations { grid-column: 2; }
}
@media (max-width: 565px) {
  .board-bar { height: 64px; padding-inline: 10px; gap: 8px; }
  .brand { gap: 6px; }
  .brand-mark { width: 30px; height: 30px; font-size: 20px; }
  .brand h1 { font-size: 16px; }
  .save-status { display: none; }
  .board-bar-actions { gap: 5px; }
  .board-bar-actions .button { padding: 5px 7px; min-height: 33px; }
  .workbench { display: flex; flex-direction: column; }
  .editor, .operations, .settings { width: 100%; }
  .editor { order: -2; min-height: 485px; }
  .stage { min-height: 325px; }
  .operations { order: -1; }
}
.stage-hint:has(button) { pointer-events: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.stage-hint .button { min-height: 26px; padding: 2px 6px; font-size: .8125rem; }
.text-button { color: var(--accent); background: none; border: 0; padding: 0; font-size: .8125rem; font-weight: 600; }
a.text-button { display: inline-block; margin-top: 5px; }
.text-button:hover:not(:disabled) { text-decoration: underline; }
.field input[readonly], .field select:disabled { color: #647589; background-color: #edf2f7; }
.color-label { display: flex; align-items: center; justify-content: space-between; }
#material-swatch { height: 12px; width: 19px; border: 1px solid #8294a5; border-radius: 3px; }
.warning { color: var(--danger); }
.material-section .check-row { margin-top: 5px; }
.diy-library-dialog { max-width: min(780px,calc(100vw - 24px)); }

.side-rail { align-self: start; min-width: 0; display: grid; gap: 12px; }
.cost-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; background: #fcf0e9; }
.cost-summary span, .cost-summary strong { display: block; }
.cost-summary span { font-size: .8125rem; color: var(--ink-soft); }
.cost-summary strong { margin-top: 3px; font: 700 1.15rem/1.24 ui-monospace, sans-serif; color: #8b2c1c; overflow-wrap: anywhere; }
.cost-details { padding: 7px 12px 12px; }
.cost-list { margin: 0; font-size: .875rem; }
.cost-list > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; column-gap: 7px; padding: 5px 0; }
.cost-list dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 620; text-align: right; }
.cost-list small { display: block; color: var(--muted); font-size: .75rem; }
.cost-list small:empty, #cost-status:empty { display: none; }
.cost-weight { border-block: 1px solid var(--line); padding-block: 4px; margin: 4px 0; }
.cost-method { margin: 8px 0 0; color: var(--muted); font-size: .8125rem; }
.cost-method summary { cursor: pointer; }
.cost-method p { margin-top: 6px; }
@media (max-width: 820px) {
  .side-rail { grid-column: 2; }
}
@media (max-width: 565px) {
  .side-rail { width: 100%; order: -1; }
  .side-rail .operations { order: 0; }
}
@media (max-width: 360px) {
  .board-bar .brand-mark { display: none; }
}

.editor-actions { display: flex; align-items: center; justify-content: end; flex-wrap: wrap; gap: 6px; }
.view-switch { display: flex; gap: 2px; padding: 3px; background: #f3f1ec; border: 1px solid var(--line); border-radius: 8px; }
.view-switch button, .preview-angle { border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--ink-soft); font-weight: 620; font-size: .8125rem; padding: 5px 9px; white-space: nowrap; }
.view-switch button:hover, .preview-angle:hover { background: #fff; color: #9f2a16; }
.view-switch button[aria-pressed=true] { background: #fff; border-color: #ead4c9; color: #9f2a16; }
#preview-3d { position: absolute; inset: 0; background: #eff3f6; }
#preview-3d canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#preview-3d canvas:active { cursor: grabbing; }
.preview-angle { height: 32px; padding-inline: 7px; }
.preview-angle:hover { background: #e9f1f5; }
@media (max-width: 565px) {
  .editor-head { flex-wrap: wrap; }
  .editor-actions { justify-content: space-between; flex: 1 0 100%; }
}

.editor.preview-active { align-self: start; min-height: 0; }
.preview-active .stage { flex: none; height: clamp(340px, calc(100svh - 310px), 760px); min-height: 0; }
@media (max-width: 565px) {
  .preview-active .stage { height: clamp(290px, calc(100svh - 395px), 620px); }
}
