/* HUAHUI workbench: the established jsq red/black drawing language. */
:root {
  --bg: #f3f2f0; --surface: #fff; --surface-strong: #fff; --surface-soft: #f7f6f4;
  --text: #242322; --text-2: #393633; --muted: #78716c; --muted-2: #96908a;
  --border: #e5e2de; --border-strong: #c9c3bd;
  --primary: #b9232a; --primary-strong: #981b22; --accent: #242322; --accent-deep: #a51f26;
  --accent-soft: #fbefef; --panel-span-width: none;
  --wall-color: #34302d; --label-color: #34302d;
  --guide-color: #bf2930; --guide-text-color: #b9232a; --angle-color: #957248;
}
[hidden] { display: none !important; }
body { padding: 20px 24px 36px; background: var(--bg); background-attachment: initial; }
.container { max-width: 1380px; border: 1px solid var(--border); border-radius: 18px; background: #fff; box-shadow: 0 8px 35px #24232208; backdrop-filter: none; padding: 0; }
header { padding: 20px 24px; background: #fff; border-bottom: 1px solid var(--border); }
header::before { height: 3px; background: var(--primary); }
.brand-mark { width: 42px; height: 42px; flex-shrink: 0; border-radius: 0; background: #fff; box-shadow: none; }
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
header h1 { font-size: 19px; letter-spacing: .015em; }
header p { font-size: 12px; letter-spacing: .025em; margin-top: 5px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.status-pill { letter-spacing: 0; font-size: 12px; padding: 7px 10px; }
.status-pill.ok { color: #247258; background: #f0f8f4; border-color: #d3e9dc; }
.status-pill.ok::before { background: #247258; box-shadow: none; }
.content { padding: 20px; }
.workspace-grid { display: grid; grid-template-columns: 310px minmax(0,1fr); gap: 20px; align-items: start; }
.settings-panel { padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: #faf9f7; min-width: 0; }
.panel-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.panel-heading h2, .section-heading h2 { margin: 0; font-size: 15px; font-weight: 750; }
.eyebrow { color: var(--muted); font-size: 10px; letter-spacing: .12em; }
.panel-heading .eyebrow { margin: 4px 0 0; }
.section-number { color: var(--primary); font-size: 11px; font-weight: 700; margin-right: 7px; }
.form-group { min-width: 0; }
label { font-size: 12px; letter-spacing: 0; line-height: 1.5; margin-bottom: 5px; font-weight: 550; }
input, select { min-height: 40px; border-radius: 7px; padding: 8px 10px; font-size: 14px; box-shadow: none; }
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px #b9232a12; transform: none; }
input[aria-invalid="true"] { border-color: #c64040; background: #fff7f6; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
button, summary { -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .45; cursor: not-allowed; }
.filter-row { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.filter-row > .form-group { background: transparent; border: 0; padding: 0; box-shadow: none; }
.filter-row > .form-group:last-child { grid-column: 1 / -1; }
.filter-row select:disabled { opacity: 1; color: var(--text); background: #f1efec; }
.control-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; margin: 0 0 16px; }
.control-card { padding: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; min-width: 0; }
.control-card--mode, .control-card--direction { grid-column: 1 / -1; }
.control-card-label { font-size: 12px; font-weight: 550; color: var(--muted); letter-spacing: 0; margin-bottom: 6px; }
.mode-selector { display: flex; padding: 3px; gap: 3px; border-radius: 8px; background: #ece9e5; box-shadow: none; border: 0; }
.mode-btn { flex: 1; min-width: 0; padding: 8px 5px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); box-shadow: none; transform: none; min-height: 34px; }
.mode-btn-title { font-size: 12px; letter-spacing: 0; white-space: nowrap; }
.mode-btn.active { background: #fff; color: var(--primary-strong); box-shadow: 0 1px 4px #24232210; }
.mode-btn:hover:not(.active) { color: var(--text); background: #ffffff70; transform: none; }
.input-section { padding-top: 16px; border-top: 1px solid var(--border); }
.input-section-title { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 12px; font-size: 13px; font-weight: 700; }
.input-section-title span { color: var(--muted); font-size: 11px; font-weight: 400; }
.input-row { gap: 8px; margin-bottom: 12px; }
.input-row input { font-variant-numeric: tabular-nums; padding: 8px; }
.input-row label { font-size: 11px; }
.mode-help { margin: 0 0 12px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.draft-status { font-size: 11px; color: var(--muted); margin: 10px 0 0; }
.err { color: #a51f26; font-size: 12px; line-height: 1.6; text-align: left; margin: 0; }
.err:not(:empty) { border-left: 2px solid #b9232a; padding: 8px 10px; background: #fbefef; border-radius: 2px 6px 6px 2px; margin-bottom: 10px; }
.drawing-panel { min-width: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #fff; }
.drawing-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.toolbar-group { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.view-tabs { display: flex; gap: 4px; }
.tool-btn, .text-btn { font-size: 12px; font-weight: 550; font-family: inherit; border: 1px solid var(--border); border-radius: 6px; color: var(--text-2); padding: 7px 10px; min-height: 34px; background: #fff; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.tool-btn:hover, .text-btn:hover { background: #f5f3f0; border-color: var(--border-strong); }
.text-btn { border-color: transparent; background: transparent; }
.view-tabs .tool-btn { border: 0; color: var(--muted); }
.view-tabs .tool-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--primary-strong); font-weight: 700; }
.zoom-display { min-width: 43px; color: var(--muted); font-size: 11px; text-align: center; }
.diagram-workbench { display: block; margin: 0; }
.diagram-stage { height: 430px; margin: 0; border: 0; border-radius: 0; box-shadow: none; background: #fff; }
.diagram-stage #main-svg { height: 100%; width: 100%; transition: none; }
.diagram-stage.computing #main-svg { opacity: 1; }
.view-switcher { display: none; }
.diagram-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; padding: 10px 16px 0; color: var(--muted); font-size: 11px; }
.diagram-legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-line { display: inline-block; width: 17px; border-top: 2px solid var(--wall-color); }
.legend-line.guide { border-top-color: var(--guide-color); border-top-style: dashed; }
.legend-line.angle { border-top-color: var(--angle-color); }
.drawing-hint { margin: 0; padding: 8px 16px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--border); }
.material-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); padding: 14px 16px; gap: 12px; border-top: 1px solid var(--border); background: #faf9f7; }
.material-summary div + div { border-left: 1px solid var(--border); padding-left: 14px; }
.material-summary span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.material-summary strong { font-size: 20px; font-weight: 650; color: var(--primary-strong); font-variant-numeric: tabular-nums; }
.material-summary small { color: var(--muted); font-size: 10px; margin-left: 4px; }
.diagram-stage-footer { padding: 10px 14px; border-top: 1px solid var(--border); }
.capture-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 0; background: none; border: 0; box-shadow: none; }
.capture-btn, .btn-calc, .reference-btn { background: var(--primary); box-shadow: none; border-radius: 7px; border: 1px solid transparent; font-family: inherit; font-size: 12px; font-weight: 600; padding: 9px 12px; min-height: 36px; letter-spacing: 0; transform: none; }
.capture-btn:hover, .btn-calc:hover:not(:disabled), .reference-btn:hover { background: var(--primary-strong); box-shadow: none; transform: none; }
.capture-btn--edit, .reference-btn--ghost { background: #fff; color: var(--text-2); border: 1px solid var(--border); }
.capture-btn--edit:hover, .reference-btn--ghost:hover { background: #f5f3f0; }
.capture-signature { margin-left: auto; }
.capture-signature input { min-height: 34px; width: 86px; font-size: 12px; }
.capture-status { flex-basis: 100%; font-size: 11px; min-height: 0; }
.capture-status:empty { display: none; }
.reference-panel { display: block; padding: 0; margin: 0; border: 0; border-top: 1px solid var(--border); border-radius: 0; background: #fff; box-shadow: none; }
.reference-panel summary { padding: 12px 16px; font-size: 12px; color: var(--text); cursor: pointer; }
.reference-panel summary span { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: 10px; }
.reference-content { padding: 0 14px 14px; }
.reference-dropzone { height: 140px; min-height: 140px; border-radius: 8px; background: #faf9f7; border: 1px dashed var(--border-strong); }
.reference-placeholder { color: var(--muted); display: grid; place-content: center; font-size: 12px; gap: 7px; text-align: center; }
.reference-placeholder::before, .reference-placeholder::after { display: none; }
.reference-placeholder small { font-size: 11px; color: var(--muted-2); }
.reference-actions { margin-top: 8px; }
.reference-actions .reference-btn { flex: 0 1 auto; }
.reference-status { margin-top: 6px; }
.result-area { margin: 24px 0 0; padding: 0; border: 0; border-radius: 0; background: transparent; animation: none; }
.section-heading { padding: 0 0 12px; margin: 0 0 16px; border-bottom: 1px solid var(--border); }
.section-heading p { margin: 5px 0 0; font-size: 11px; color: var(--muted); }
.glass-input-row { grid-template-columns: 180px 1fr; align-items: center; }
.result-grid { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin-bottom: 20px; }
.result-cell { padding: 16px; gap: 6px; border-radius: 10px; animation: none; background: #fff; }
.result-cell:hover { transform: none; box-shadow: none; border-color: var(--border-strong); }
.result-cell.glass { background: #fff; }
.result-cell .k { font-size: 12px; letter-spacing: 0; }
.result-cell .v { font-size: 22px; font-weight: 650; color: var(--text); }
.result-cell .v small { font-size: 11px; font-weight: 400; color: var(--muted); }
.result-cell .formula { font-size: 11px; color: var(--muted); }
.result-cell.door { border-top: 3px solid var(--primary); padding-top: 14px; }
.details-grid { display: grid; grid-template-columns: 1.08fr 1fr; gap: 20px; align-items: start; }
.mid-post-preview-wrap { max-width: none; margin: 0; padding: 16px; border: 1px solid var(--border); background: #fff; border-radius: 12px; }
.mid-post-preview-title { text-align: left; letter-spacing: 0; font-size: 13px; margin-bottom: 14px; }
.mid-post-preview-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.mid-post-card { padding: 0; border: 0; border-radius: 0; box-shadow: none; }
.mid-post-card svg { height: 250px; border: 0; border-radius: 8px; background: #faf9f7; cursor: zoom-in; }
.mid-post-card-head strong { font-size: 12px; }
.mid-post-card-head span { font-size: 12px; color: var(--text-2); }
.mid-post-card-meta { font-size: 10px; font-weight: 400; color: var(--muted); margin: 8px 0 0; }
.post-actions { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.post-actions .btn-calc { margin: 0; width: 100%; }
#copy-hy055-post-image-info { font-size: 11px; min-height: 16px; margin-top: 7px; }
.glass-diagram-wrap { margin: 0; padding: 16px; border: 1px solid var(--border); border-radius: 12px; }
.glass-diagram-title { color: var(--text); text-align: left; font-size: 13px; letter-spacing: 0; margin-bottom: 10px; }
.glass-diagram-frame { border: 0; max-width: none; cursor: zoom-in; }
.glass-diagram-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.glass-diagram-header .glass-diagram-title { margin: 0; }
.glass-diagram-header .tool-btn { flex: none; }
.glass-diagram-frame svg { width: 100%; height: auto; max-height: clamp(340px, 52vh, 480px) !important; }
.glass-diagram-wrap, #glass-diag-dxf, #glass-diag-semantic { min-width: 0; }
.detail-hint { color: var(--muted); font-size: 11px; margin: 10px 0 0; }
text[data-force-editable="true"] { cursor: pointer; }
text[data-force-active="true"] { text-decoration: underline; text-decoration-style: dotted; }
.svg-field-active { fill: #a51f26; stroke: #fff0bd; stroke-width: 6px; }
.svg-direction-label { font-size: 20px; }
.force-edit-menu { border-color: var(--border); border-radius: 9px; box-shadow: 0 8px 32px #24232222; }
.force-edit-menu__item { font-size: 12px; padding: 10px 12px; }
.force-edit-menu__item:hover { color: var(--primary); background: var(--accent-soft); }
.workbench-dialog { width: min(1060px,calc(100vw - 32px)); height: min(820px,calc(100dvh - 40px)); padding: 0; border: 1px solid var(--border); border-radius: 14px; color: var(--text); box-shadow: 0 25px 90px #0003; }
.workbench-dialog::backdrop { background: #2228; backdrop-filter: blur(3px); }
.dialog-layout { display: flex; flex-direction: column; height: 100%; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 15px 20px; border-bottom: 1px solid var(--border); }
.dialog-header h2 { margin: 0; font-size: 16px; }
.dialog-canvas { flex: 1; min-height: 0; padding: 18px; background: #fff; }
.dialog-canvas svg { width: 100%; height: 100%; max-height: none !important; }
.dialog-footer { color: var(--muted); padding: 10px 20px; font-size: 11px; border-top: 1px solid var(--border); }
.value-dialog { width: min(420px,calc(100vw - 32px)); height: auto; padding: 24px; }
.value-dialog h2 { font-size: 17px; margin: 0 0 8px; }
.value-dialog p { color: var(--muted); font-size: 12px; line-height: 1.6; }
.value-dialog .dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.value-dialog .err { margin-top: 10px; }
.help-list { margin: 0; padding: 20px 28px; line-height: 2; font-size: 14px; }
.help-list li { margin-bottom: 14px; }
kbd { padding: 2px 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; font-size: 11px; font-family: inherit; }
.foot { margin: 0; padding: 16px; border-top: 1px solid var(--border); font-size: 10px; color: var(--muted-2); letter-spacing: .08em; }
@media (max-width: 1100px) {
  body { padding: 12px; } .content { padding: 14px; }
  .workspace-grid { grid-template-columns: 280px minmax(0,1fr); gap: 14px; }
  .details-grid { grid-template-columns: 1fr; }
  .mid-post-card svg { height: 300px; }
  .capture-signature { margin-left: 0; }
}
@media (max-width: 800px) {
  body { padding: 0; } .container { border: 0; border-radius: 0; }
  header { padding: 18px 14px; } header h1 { font-size: 17px; }
  .header-actions { gap: 3px; } .header-actions .tool-btn { padding: 6px 8px; }
  .header-actions .status-pill { display: none; }
  .workspace-grid { grid-template-columns: 1fr; }
  .settings-panel { padding: 14px; }
  .filter-row { grid-template-columns: 1fr 1fr 1.4fr; }
  .filter-row > .form-group:last-child { grid-column: auto; }
  .control-row { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .control-card--mode, .control-card--direction { grid-column: auto; }
  .diagram-stage { height: 370px; }
  .drawing-toolbar { padding: 10px; } .drawing-toolbar .tool-btn { padding: 6px 8px; }
  .material-summary strong { font-size: 18px; }
  .result-cell { padding: 12px; } .result-cell.door { padding-top: 10px; }
  .result-cell .v { font-size: 18px; }
  .section-heading { align-items: flex-start; }
  body.reference-dock-open { padding-right: 0; }
  body.reference-dock-open .container { max-width: none; }
  .reference-viewer { width: auto; left: 8px; right: 8px; top: 8px; bottom: 8px; }
}
@media (max-width: 480px) {
  .content { padding: 10px; } .brand-side { gap: 9px; }
  .brand-mark { width: 34px; height: 34px; font-size: 19px; }
  header p { font-size: 10px; } .header-actions .text-btn { font-size: 11px; padding: 6px; }
  .control-card--mode, .control-card--direction { grid-column: 1 / -1; }
  .input-row { flex-wrap: nowrap; } .input-row .form-group { flex: 1 1 0; }
  .filter-row select { padding: 8px 5px; font-size: 12px; }
  .result-grid { grid-template-columns: 1fr; gap: 8px; }
  .result-cell { display: grid; grid-template-columns: 1fr auto; align-items: center; }
  .result-cell .formula { grid-column: 1 / -1; }
  .glass-input-row { grid-template-columns: 130px 1fr; }
  .mid-post-preview-wrap { padding: 12px; }
  .mid-post-preview-grid { gap: 8px; } .mid-post-card svg { height: 205px; }
  .mid-post-card-meta { font-size: 9px; } .drawing-hint { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.settings-panel { padding: 14px; }
.panel-heading { margin-bottom: 12px; }
.filter-row { margin-bottom: 12px; }
.control-row { gap: 8px 10px; margin-bottom: 10px; }
.mode-help { margin-bottom: 10px; }
.input-section { padding-top: 10px; }
.input-section-title { margin-bottom: 8px; }
.input-row { margin-bottom: 8px; }
.drawing-title small { margin-left: 8px; color: var(--muted); font-size: 11px; font-weight: 400; }
.snapshot-workbench { width: min(1320px,calc(100vw - 24px)); height: calc(100dvh - 32px); }
.snapshot-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.snapshot-controls label { display: flex; align-items: center; gap: 5px; margin: 0; }
.snapshot-controls input { width: 60px; min-height: 32px; height: 32px; padding: 3px 6px; font-size: 12px; }
.snapshot-controls input[type="text"] { width: 195px; }
.snapshot-controls input[type="color"] { width: 36px; padding: 3px; }
.snapshot-controls [aria-pressed="true"] { background: var(--accent-soft); color: var(--primary-strong); border-color: var(--primary); }
.snapshot-zoom { margin-left: auto; }
.snapshot-zoom output { min-width: 40px; text-align: center; font-size: 12px; }
.snapshot-viewport { flex: 1; min-width: 0; min-height: 120px; overflow: auto; background: #eae8e5; }
.snapshot-canvas-wrap { display: flex; width: max-content; min-width: 100%; min-height: 100%; padding: 16px; box-sizing: border-box; align-items: center; justify-content: center; }
.snapshot-viewport canvas { display: block; flex: none; max-width: none; background: #fff; box-shadow: 0 3px 16px #24232218; cursor: crosshair; touch-action: none; }
.mobile-workbench-nav { display: none; }
@media (max-width: 800px) {
  .container { margin: 0; width: 100%; }
  .foot { padding-bottom: 78px; }
  .mobile-workbench-nav { position: fixed; display: flex; left: 10px; right: 10px; bottom: max(10px,env(safe-area-inset-bottom)); z-index: 50; padding: 5px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 4px 25px #24232222; }
  .mobile-workbench-nav a { flex: 1; padding: 9px 4px; text-align: center; color: var(--text); text-decoration: none; font-size: 12px; border-radius: 6px; }
  .mobile-workbench-nav a:hover, .mobile-workbench-nav a:focus { background: var(--accent-soft); color: var(--primary); }
  #measurement-panel, #drawing-panel, #result-area { scroll-margin-top: 10px; }
}
@media (max-width: 480px) {
  header { grid-template-columns: minmax(0,1fr); gap: 12px; }
  .brand-side { flex-basis: 100%; }
  .header-actions { width: 100%; justify-content: flex-end; }
  header h1 { white-space: nowrap; font-size: 17px; }
}
@media (max-width: 600px) {
  .snapshot-workbench .dialog-header { padding: 12px; gap: 8px; }
  .snapshot-workbench .dialog-header .tool-btn, .snapshot-workbench .dialog-header .capture-btn { padding: 6px 8px; }
  .snapshot-controls { gap: 8px; padding: 8px 12px; }
}
