/* Left inputs, right drawings. Both canvases share the available desktop viewport. */
body { padding: 10px 24px 28px; }
header { padding: 12px 24px; }
.content { padding: 14px 20px 20px; }
.workspace-grid { display: grid; grid-template-columns: 310px minmax(0,1fr); gap: 20px; align-items: start; }
.diagram-workbench, .diagram-column { display: block; }
.diagram-stage, .diagram-stage[data-view="3d"] { height: var(--drawing-height,clamp(280px,38vh,360px)); min-height: 0; border-radius: 12px; box-shadow: none; }
.diagram-stage #main-svg { max-width: none; }
.drawing-toolbar { min-height: 36px; padding-bottom: 6px; align-items: center; }
.material-summary { margin-top: 8px; padding: 7px 12px; gap: 8px; }
.material-summary > div { display: flex; align-items: baseline; gap: 5px; min-width: 0; }
.material-summary span { margin: 0 auto 0 0; white-space: nowrap; }
.material-summary strong { font-size: 17px; }
.material-summary small { margin: 0; }
.diagram-stage-footer { padding: 6px 0; min-height: 0; }
.capture-host-stage { width: 100%; }
.capture-toolbar { gap: 6px; }
.capture-toolbar > .capture-signature { display: flex; flex: 0 0 auto; width: auto; margin: 0 0 0 auto; gap: 6px; }
.capture-toolbar > .capture-signature input { width: 100px; min-height: 34px; font-weight: 400; }
.drawing-tools-menu { position: relative; }
.drawing-tools-menu > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.drawing-tools-menu > summary::after { content: '⌄'; color: var(--muted); }
.drawing-tools-menu[open] > summary { border-color: var(--border-strong); background: var(--surface-soft); }
.drawing-tools-menu > summary::-webkit-details-marker { display: none; }
.drawing-tools-popover { position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; display: grid; gap: 10px; width: 255px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: #fff; box-shadow: 0 10px 36px #24232224; }
.drawing-tools-popover p { margin: 0; font-size: 11px; line-height: 1.8; color: var(--muted); }
.drawing-hint { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.capture-status:not(:empty) { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 1500; width: max-content; max-width: calc(100vw - 32px); padding: 11px 18px; border: 1px solid #d3e9dc; border-radius: 9px; background: #f0f8f4; box-shadow: 0 4px 24px #24232218; font-size: 12px; }
.capture-status.error:not(:empty) { color: #a51f26; background: #fff5f4; border-color: #efcecb; }
.reference-panel { position: relative; margin-top: 4px; border-radius: 10px; }
.reference-panel > summary { padding: 8px 12px; min-height: 36px; box-sizing: border-box; font-weight: 650; }
.reference-panel > summary span { display: none; }
.reference-content { padding: 0 10px 8px; }
.reference-dropzone { height: var(--reference-height,200px); min-height: 0; box-sizing: border-box; background: #fafbfc; border-color: #e2dfdb; }
.reference-dropzone .reference-preview { width: 100%; height: 100%; max-height: none; object-fit: contain; }
.reference-placeholder { width: auto; height: auto; border: 0; background: none; max-width: 90%; font-size: 13px; gap: 8px; }
.reference-placeholder::before { display: none; }
.reference-placeholder small { font-size: 12px; }
.reference-actions { position: absolute; top: 3px; right: 10px; margin: 0; gap: 6px; flex-wrap: nowrap; }
.reference-actions .reference-btn { min-width: 0; min-height: 30px; padding: 5px 9px; font-size: 11px; }
.reference-status { font-size: 11px; margin: 0; }
.reference-status.success { position: absolute; bottom: 14px; left: 16px; pointer-events: none; max-width: calc(100% - 32px); color: var(--muted); padding: 3px 6px; background: #fffffff0; border-radius: 4px; }
.reference-status.error { margin-top: 6px; }
.reference-panel, .settings-panel { scroll-margin-top: 12px; }
body.reference-dock-open { padding-right: 24px; justify-content: center; }
body.reference-dock-open .container { max-width: 1380px; }
body.reference-dock-open .diagram-workbench { display: block; }
body.reference-dock-open .reference-panel { display: block; }
.reference-viewer { inset: 0; margin: auto; padding: 0; width: calc(100vw - 40px); height: calc(100dvh - 40px); max-width: none; max-height: none; background: #fff; box-shadow: 0 20px 80px #24232244; }
.reference-viewer:not([open]) { display: none; }
.reference-viewer[open] { display: block; }
.reference-viewer__viewport { flex: 1; min-height: 0; height: auto; width: 100%; border: 0; border-radius: 0; background: #eeece9; overscroll-behavior: contain; touch-action: none; }
.reference-viewer__viewport:focus { outline: 0; }
@media (max-width: 1100px) {
  body { padding: 10px 12px 24px; }
  header { padding: 12px 18px; }
  .content { padding: 14px; }
  .workspace-grid { grid-template-columns: 280px minmax(0,1fr); gap: 14px; }
  .material-summary span { font-size: 10px; }
  .material-summary div + div { padding-left: 8px; }
  .capture-toolbar > button, .drawing-tools-menu > summary { padding: 7px; font-size: 11px; }
  .capture-toolbar > .capture-signature input { width: 86px; }
  body.reference-dock-open { padding-right: 12px; }
}
@media (max-width: 800px) {
  body { padding: 0; }
  .workspace-grid { grid-template-columns: minmax(0,1fr); }
  .diagram-stage, .diagram-stage[data-view="3d"] { height: clamp(260px,44vw,340px); }
  .reference-dropzone { height: 220px; }
  .capture-status:not(:empty) { bottom: 78px; }
  .reference-viewer { inset: 0; width: calc(100vw - 16px); height: calc(100dvh - 16px); }
  body.reference-dock-open { padding-right: 0; }
}
@media (max-width: 480px) {
  .content { padding: 10px; }
  .material-summary { padding: 9px; }
  .material-summary > div { display: block; }
  .material-summary span { display: block; margin-bottom: 3px; }
  .material-summary small { margin-left: 4px; }
  .reference-panel > summary { min-height: 34px; padding-bottom: 6px; }
  .reference-actions { position: static; margin: 8px 0 0; flex-wrap: wrap; }
  .reference-status.success { position: static; padding: 0; margin-top: 6px; background: none; }
  .capture-toolbar > button, .drawing-tools-menu > summary { padding: 7px; font-size: 11px; }
  .drawing-tools-popover { position: fixed; top: auto; bottom: 76px; right: 12px; left: 12px; width: auto; z-index: 60; }
}

/* Completed actions disappear; validation warnings follow the current drawing. */
.capture-status:not(:empty) { line-height: 1.6; text-align: center; transition: opacity .18s ease, transform .18s ease; }
.capture-status.is-leaving:not(:empty) { opacity: 0; transform: translate(-50%, 6px); pointer-events: none; }
.diagram-warning:not([hidden]) { display: flex; align-items: center; gap: 10px; margin: 8px 0 0; padding: 10px 14px; box-sizing: border-box; border: 1px solid #eed6a3; border-radius: 8px; background: #fff8eb; color: #845718; font-size: 13px; line-height: 1.6; font-weight: 500; letter-spacing: 0; text-align: left; overflow-wrap: anywhere; }
.diagram-warning::before { content: '!'; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 20px; height: 20px; border-radius: 50%; background: #f8e5bc; color: #8c5a0b; font-size: 13px; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .capture-status:not(:empty) { transition: none; } }
