:root { color-scheme: light; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #edf1f4; color: #1d2832; } * { box-sizing: border-box; } body { margin: 0; min-width: 320px; } button, input, select { font: inherit; } button { border: 1px solid #aab7c2; border-radius: 9px; padding: 9px 11px; background: #fff; color: #21303b; cursor: pointer; } button:hover:not(:disabled) { border-color: #236858; background: #eef7f3; } button:disabled { cursor: not-allowed; opacity: .52; } label { display: grid; gap: 7px; color: #42525f; font-size: 13px; font-weight: 650; } input, select { width: 100%; min-width: 0; padding: 8px; border: 1px solid #cad4dc; border-radius: 8px; background: #fff; color: #1d2832; } input[type="range"] { padding: 0; accent-color: #236858; } input[type="color"] { height: 37px; padding: 3px; }
.app-shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; } .topbar, .footer-bar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px clamp(20px, 4vw, 56px); background: #fff; border-bottom: 1px solid #d7e0e6; } .topbar h1, .panel h2, .canvas-panel h2 { margin: 0; font-size: clamp(19px, 2vw, 27px); letter-spacing: -.03em; } .eyebrow, .panel-kicker { margin: 0 0 6px; color: #657585; font-size: 11px; font-weight: 750; letter-spacing: .13em; } .mode-tabs { display: flex; gap: 6px; padding: 4px; border-radius: 11px; background: #eef2f4; } .mode-tab { padding: 8px 11px; border: 0; background: transparent; font-size: 13px; white-space: nowrap; } .mode-tab.active { background: #fff; box-shadow: 0 1px 3px rgb(29 40 50 / 15%); color: #175c4b; } .status-chip, .mode-label { margin: 0; padding: 7px 10px; border-radius: 999px; background: #e5f2ec; color: #246145; font-size: 12px; font-weight: 750; white-space: nowrap; }
.workspace { min-height: 0; display: grid; grid-template-columns: minmax(225px, .85fr) minmax(420px, 2fr) minmax(260px, .95fr); gap: 15px; padding: 15px clamp(20px, 4vw, 56px); } .panel, .canvas-panel { min-height: 0; background: #fff; border: 1px solid #d7e0e6; border-radius: 16px; padding: 19px; box-shadow: 0 5px 16px rgb(30 48 62 / 4%); } .panel { display: flex; flex-direction: column; gap: 14px; overflow: auto; } .upload-zone { display: grid; gap: 7px; margin-top: 7px; padding: 18px 14px; border: 1.5px dashed #90a5b4; border-radius: 12px; cursor: pointer; color: #23323d; } .upload-zone:hover { border-color: #236858; background: #f2f8f6; } .upload-zone small, .muted { color: #697988; font-size: 12px; font-weight: 450; line-height: 1.5; } .pattern-preview { display: none; min-height: 112px; border-radius: 11px; background-color: #fff; } .pattern-preview.visible { display: block; background-size: contain; background-position: center; background-repeat: no-repeat; } .processing-controls, .control-section { display: grid; gap: 12px; padding-top: 14px; border-top: 1px solid #e5ebef; } .processing-controls h3, .control-section h3 { margin: 0; font-size: 14px; } .privacy-note { margin-top: auto; padding: 13px; border-radius: 11px; background: #f3f7f8; font-size: 13px; } .privacy-note p { margin: 6px 0 0; color: #536472; line-height: 1.5; }
.canvas-panel { position: relative; display: grid; grid-template-rows: auto 1fr auto; gap: 14px; overflow: hidden; } .panel-heading { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; } .canvas-stage { position: relative; min-height: 460px; display: grid; place-items: center; overflow: hidden; border-radius: 12px; background: #f2f5f6; } .empty-state { max-width: 260px; color: #627280; text-align: center; line-height: 1.55; } .canvas-view { position: relative; display: grid; transform-origin: center; box-shadow: 0 12px 28px rgb(32 48 60 / 18%); } #pattern-canvas { display: block; max-width: none; background: transparent; } .canvas-grid { position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(#7d8d99 1px, transparent 1px), linear-gradient(90deg, #7d8d99 1px, transparent 1px); background-size: 24px 24px; opacity: .33; } .canvas-tools, .control-actions { display: flex; flex-wrap: wrap; gap: 8px; } .controls-panel { gap: 17px; } .two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } .control-actions { margin-top: auto; padding-top: 4px; } .primary { border-color: #236858; background: #236858; color: #fff; } .primary:hover:not(:disabled) { background: #174f41; color: #fff; } .footer-bar { border-top: 1px solid #d7e0e6; border-bottom: 0; color: #536472; font-size: 12px; } .toast { position: fixed; z-index: 5; left: 50%; bottom: 28px; transform: translate(-50%, 12px); opacity: 0; pointer-events: none; padding: 9px 13px; border-radius: 9px; background: #1d2832; color: #fff; font-size: 13px; transition: opacity .18s, transform .18s; } .toast.visible { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 1120px) { .topbar { flex-wrap: wrap; } .workspace { grid-template-columns: minmax(215px, .8fr) minmax(380px, 1.6fr); } .controls-panel { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); } .control-actions, .controls-panel > .muted { grid-column: 1 / -1; } } @media (max-width: 820px) { .workspace { grid-template-columns: 1fr; } .canvas-stage { min-height: 360px; } .controls-panel { display: flex; } } @media (max-width: 600px) { .topbar, .footer-bar { align-items: flex-start; flex-direction: column; } .mode-tabs { overflow-x: auto; max-width: 100%; } .workspace { padding: 12px; } }

textarea { resize: vertical; min-height: 110px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.4; }
.local-server-warning { margin: 12px; padding: 12px 16px; border: 1px solid #d58a37; border-radius: 10px; background: #fff7e9; color: #704209; font-size: 14px; line-height: 1.55; }
.reference-upload { display: grid; gap: 12px; padding-top: 14px; border-top: 1px solid #e5ebef; }
.reference-upload h3 { margin: 0; font-size: 14px; }
.analysis-view { position: relative; width: min(100%, 860px); max-height: 100%; }
#analysis-canvas { display: block; width: 100%; max-height: 560px; object-fit: contain; background: #fff; box-shadow: 0 12px 28px rgb(32 48 60 / 18%); cursor: grab; touch-action: none; }
#analysis-canvas:active { cursor: grabbing; }
#analysis-canvas.is-adjusting { cursor: grabbing; }
.canvas-hint { margin: 9px 0 0; color: #536472; font-size: 12px; text-align: center; }

/* 视觉令牌：后续改变整体设计语言时，先替换这里的语义值，不需要触碰交互脚本。 */
:root { --pf-page: #edf1f4; --pf-surface: #ffffff; --pf-surface-subtle: #f2f5f6; --pf-border: #d7e0e6; --pf-text: #1d2832; --pf-text-muted: #536472; --pf-accent: #236858; --pf-accent-strong: #174f41; --pf-accent-soft: #e5f2ec; --pf-radius-panel: 16px; --pf-radius-control: 9px; --pf-shadow-panel: 0 5px 16px rgb(30 48 62 / 4%); --pf-space-panel: 19px; }
[hidden] { display: none !important; }
body { background: var(--pf-page); color: var(--pf-text); }
button { border-radius: var(--pf-radius-control); background: var(--pf-surface); color: var(--pf-text); }
button:hover:not(:disabled) { border-color: var(--pf-accent); background: color-mix(in srgb, var(--pf-accent-soft) 55%, var(--pf-surface)); }
input, select, textarea { background: var(--pf-surface); color: var(--pf-text); }
.topbar, .footer-bar, .panel, .canvas-panel { background: var(--pf-surface); border-color: var(--pf-border); }
.panel, .canvas-panel { border-radius: var(--pf-radius-panel); padding: var(--pf-space-panel); box-shadow: var(--pf-shadow-panel); }
.canvas-stage { background: var(--pf-surface-subtle); }
.status-chip, .mode-label { background: var(--pf-accent-soft); color: var(--pf-accent-strong); }
.primary { border-color: var(--pf-accent); background: var(--pf-accent); }
.primary:hover:not(:disabled) { background: var(--pf-accent-strong); }
.reference-upload:not([hidden]) { padding: 14px; border: 1px solid var(--pf-border); border-radius: 12px; background: color-mix(in srgb, var(--pf-accent-soft) 35%, var(--pf-surface)); }
.section-guide { margin: 0; color: var(--pf-text-muted); font-size: 12px; line-height: 1.55; }
.action-grid > div { display: grid; gap: 5px; }
.action-grid button { width: 100%; }
.button-hint, .control-hint { color: var(--pf-text-muted); font-size: 11px; font-weight: 450; line-height: 1.45; }
.workflow-bar { display: flex; align-items: baseline; gap: 10px; padding: 10px clamp(20px, 4vw, 56px); border-bottom: 1px solid var(--pf-border); background: var(--pf-surface-subtle); color: var(--pf-text-muted); font-size: 13px; }
.workflow-bar strong { color: var(--pf-accent-strong); font-size: 12px; }
.three-column { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.action-grid > div, .button-with-hint { position: relative; }
.button-hint { position: absolute; z-index: 3; left: 50%; bottom: calc(100% + 7px); width: max-content; max-width: 220px; transform: translate(-50%, 4px); padding: 7px 9px; border: 1px solid var(--pf-border); border-radius: 7px; background: var(--pf-text); color: var(--pf-surface); box-shadow: var(--pf-shadow-panel); opacity: 0; pointer-events: none; transition: opacity .14s, transform .14s; }
.action-grid > div:hover .button-hint, .action-grid > div:focus-within .button-hint, .button-with-hint:hover .button-hint, .button-with-hint:focus-within .button-hint { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 600px) { .three-column { grid-template-columns: 1fr; } .workflow-bar { align-items: flex-start; flex-direction: column; gap: 3px; } }
.variant-list { display: grid; gap: 7px; max-height: 310px; overflow: auto; }
.variant-card { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; width: 100%; padding: 10px; text-align: left; }
.variant-card strong { font-size: 13px; }
.variant-card small { grid-column: 1 / -1; color: var(--pf-text-muted); font-weight: 450; line-height: 1.4; }
.variant-card.is-selected { border-color: var(--pf-accent); background: var(--pf-accent-soft); }
.variant-score { align-self: start; color: var(--pf-accent-strong); font-size: 12px; font-weight: 750; }
.variant-editor { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--pf-border); border-radius: 10px; background: var(--pf-surface-subtle); }
.variant-editor h4 { margin: 0; font-size: 13px; }
.case-view { width: min(100%, 860px); max-height: 100%; display: grid; place-items: center; gap: 9px; }
#case-image { display: block; max-width: 100%; max-height: 560px; object-fit: contain; background: #fff; box-shadow: 0 12px 28px rgb(32 48 60 / 18%); }
.case-node-preview { width: min(100%, 860px); max-height: 560px; min-height: 360px; padding: 14px; overflow: auto; border: 1px solid var(--pf-border); border-radius: 12px; background: #202a35; box-shadow: 0 12px 28px rgb(32 48 60 / 18%); }
.case-node-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.case-node-toolbar > div { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.case-node-toolbar button { padding: 7px 9px; font-size: 12px; }
.case-node-toolbar .mode-label { background: #e5f2ec; }
.case-node-preview > .control-hint { margin: 10px 0; color: #cbd9e2; }
.case-node-graph { display: flex; align-items: center; gap: 8px; min-width: max-content; padding: 24px 8px; }
.case-node { display: grid; gap: 5px; width: 122px; min-height: 70px; padding: 11px; border: 1px solid #7d8d9b; border-radius: 8px; background: #344454; color: #f4f8fa; box-shadow: 0 4px 10px rgb(0 0 0 / 20%); }
.case-node.blender { border-color: #ec8b45; background: #31485a; }
.case-node.grasshopper { border-color: #80b33f; background: #3d5038; }
.case-node strong { font-size: 12px; }
.case-node small { color: #d2dee6; font-size: 11px; line-height: 1.3; }
.case-node-wire { width: 38px; height: 2px; background: #a7b8c5; position: relative; }
.case-node-wire::after { content: ''; position: absolute; right: -1px; top: -4px; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 7px solid #a7b8c5; }
.case-report { display: grid; gap: 10px; }
.case-confidence { margin: 0; padding: 9px 10px; border-radius: 8px; background: var(--pf-accent-soft); color: var(--pf-accent-strong); font-size: 12px; font-weight: 750; }
.case-report-section { padding: 10px; border: 1px solid var(--pf-border); border-radius: 9px; background: var(--pf-surface-subtle); }
.case-report-section h4 { margin: 0 0 7px; font-size: 12px; }
.case-report-section ul { display: grid; gap: 5px; margin: 0; padding-left: 18px; color: var(--pf-text-muted); font-size: 12px; line-height: 1.45; }
.case-report-section.observed { border-left: 3px solid #236858; }
.case-report-section.inferred { border-left: 3px solid #4e75ad; }
.case-report-section.unknown { border-left: 3px solid #b46e3c; }
.design-preview-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.design-preview-controls .mode-label { margin-right: auto; }
.three-view { width: 100%; height: 100%; min-height: 420px; display: grid; grid-template-rows: minmax(0, 1fr) auto auto; overflow: hidden; border-radius: 12px; background: radial-gradient(circle at 50% 32%, #f7f3eb, #cfd7d9); box-shadow: 0 12px 28px rgb(32 48 60 / 18%); }
#three-canvas { display: block; width: 100%; height: 100%; min-height: 0; cursor: grab; touch-action: none; }
#three-canvas:active { cursor: grabbing; }
.three-view .canvas-hint { padding: 0 12px 10px; }
.three-shape-picker { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 7px; padding: 10px 12px; border-top: 1px solid rgb(85 103 113 / 18%); background: rgb(255 255 255 / 48%); }
.three-shape-picker span { margin-right: 4px; color: var(--pf-text-muted); font-size: 12px; font-weight: 700; }
.three-shape-picker button { padding: 6px 9px; font-size: 12px; }
.three-shape-picker button.selected { border-color: #d7953d; background: #fff4df; color: #75470e; box-shadow: inset 0 0 0 1px rgb(215 149 61 / 28%); }
#three-controls input[type="number"].is-scrubbing { cursor: ew-resize; border-color: var(--pf-accent); background: var(--pf-accent-soft); }
.part-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.part-picker .selected { border-color: #d7953d; background: #fff4df; color: #75470e; box-shadow: inset 0 0 0 1px rgb(215 149 61 / 28%); }
.uv-report { display: grid; gap: 5px; padding: 11px; border: 1px solid var(--pf-border); border-radius: 10px; background: var(--pf-surface-subtle); }
.uv-report h4, .uv-report p { margin: 0; }
.manufacturing-controls { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--pf-border); border-radius: 10px; background: var(--pf-surface-subtle); }
.manufacturing-controls h4 { margin: 0; font-size: 13px; }
.manufacturing-report { display: grid; gap: 8px; }
.manufacturing-status { margin: 0; padding: 9px; border-radius: 8px; font-size: 12px; font-weight: 750; }
.manufacturing-status.screening { background: var(--pf-accent-soft); color: var(--pf-accent-strong); }
.manufacturing-status.review { background: #fff2e8; color: #8a4820; }
.manufacturing-metrics, .manufacturing-warnings { display: grid; gap: 4px; margin: 0; padding-left: 18px; color: var(--pf-text-muted); font-size: 12px; line-height: 1.45; }
.manufacturing-warnings { color: #8a4820; }
.three-active .workspace { grid-template-columns: minmax(215px, .55fr) minmax(520px, 2.55fr) minmax(280px, 1fr); }
@media (max-width: 1120px) { .three-active .workspace { grid-template-columns: minmax(215px, .8fr) minmax(380px, 1.6fr); } }
@media (max-width: 820px) { .three-active .workspace { grid-template-columns: 1fr; } }
.field-editor { display: grid; gap: 9px; padding: 11px; border: 1px solid var(--pf-border); border-radius: 10px; background: var(--pf-surface-subtle); }
.field-editor h4 { margin: 0; font-size: 13px; }
.field-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.field-actions button { padding: 7px 8px; font-size: 11px; }
.field-layer-list, .field-mapping-list { display: grid; gap: 8px; }
.field-layer, .field-mapping { display: grid; gap: 7px; padding: 9px; border: 1px solid var(--pf-border); border-radius: 8px; background: var(--pf-surface); }
.field-layer header, .field-mapping header { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.field-layer header strong, .field-mapping header strong { font-size: 12px; }
.field-layer button { padding: 5px 7px; color: #8b3e39; }
#field-draw-canvas { width: 100%; max-width: 192px; justify-self: center; border: 1px solid var(--pf-border); border-radius: 8px; background: #808080; cursor: crosshair; image-rendering: pixelated; touch-action: none; }
.button-file { display: grid; place-items: center; min-height: 34px; border: 1px solid var(--pf-border); border-radius: 7px; cursor: pointer; font-size: 12px; font-weight: 650; }
.field-introduction { position: fixed; z-index: 4; right: clamp(20px, 4vw, 56px); bottom: 16px; left: clamp(20px, 4vw, 56px); border: 1px solid var(--pf-border); border-radius: var(--pf-radius-panel); background: var(--pf-surface); box-shadow: var(--pf-shadow-panel); }
.field-introduction-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 48px; border: 0; border-radius: var(--pf-radius-panel); background: var(--pf-surface); color: var(--pf-accent-strong); text-align: left; }
.field-introduction-toggle span { font-weight: 750; }
.field-introduction-toggle small { color: var(--pf-text-muted); font-weight: 500; }
.field-introduction-content { display: none; grid-template-columns: 1.05fr 1fr 1fr; gap: 22px; padding: 0 22px 22px; }
.field-introduction.is-expanded .field-introduction-toggle { border-bottom: 1px solid var(--pf-border); border-radius: var(--pf-radius-panel) var(--pf-radius-panel) 0 0; }
.field-introduction.is-expanded .field-introduction-content { display: grid; }
.field-active .canvas-stage { display: flex; align-items: center; justify-content: center; }
.field-active .canvas-view { flex: 0 0 auto; }
.field-introduction h2, .field-introduction h3, .field-introduction p { margin-top: 0; }
.field-introduction h2 { margin-bottom: 8px; }
.field-introduction h3 { font-size: 14px; }
.field-introduction p, .field-introduction li { color: var(--pf-text-muted); font-size: 13px; line-height: 1.6; }
.field-introduction ol { margin: 0; padding-left: 20px; }
@media (max-width: 900px) { .field-introduction-content { grid-template-columns: 1fr; gap: 12px; } }
@media (min-width: 821px) {
  .app-shell { height: 100vh; }
  .workspace { overflow: hidden; }
  .panel, .canvas-panel { height: 100%; overscroll-behavior: contain; }
  .canvas-panel { min-height: 0; overflow: hidden; }
  .analysis-active .canvas-panel { align-self: stretch; grid-template-rows: auto auto minmax(0, 1fr); }
  .analysis-active .canvas-stage { grid-row: 3; }
  .analysis-active .canvas-stage { min-height: 0; display: grid; place-items: center; overflow: hidden; }
  .analysis-active .analysis-view { width: 100%; height: calc(100% - 30px); max-height: none; display: grid; place-items: center; }
  .analysis-active #analysis-canvas { width: auto; height: auto; max-width: 100%; max-height: 100%; }
  .three-active .canvas-panel { align-self: stretch; grid-template-rows: auto minmax(0, 1fr) auto; }
  .three-active .canvas-stage { min-height: 0; }
  .three-active .three-view { min-height: 0; }
}
@media (max-width: 600px) { .case-node-toolbar { align-items: flex-start; flex-direction: column; } .case-node-toolbar > div { justify-content: flex-start; } }
.topbar-actions { display: flex; align-items: center; gap: 8px; } .star-artifact { min-width: 142px; } .star-artifact[aria-pressed="true"] { border-color: #b77a19; background: #fff4df; color: #75470e; }
.library-drawer { position: fixed; z-index: 10; top: 0; right: 0; bottom: 0; width: min(430px, 94vw); display: grid; align-content: start; gap: 14px; padding: 22px; overflow: auto; border-left: 1px solid var(--pf-border); background: var(--pf-surface); box-shadow: -18px 0 36px rgb(20 31 40 / 18%); } .library-drawer header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; } .library-drawer h2 { margin: 0; font-size: 20px; } .library-list { display: grid; gap: 10px; } .library-card { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--pf-border); border-radius: 10px; background: var(--pf-surface-subtle); } .library-card h3, .library-card p { margin: 0; } .library-card h3 { font-size: 14px; } .library-meta { color: var(--pf-text-muted); font-size: 12px; line-height: 1.45; } .library-actions { display: flex; flex-wrap: wrap; gap: 7px; } .library-actions button, .library-undo { padding: 7px 8px; font-size: 12px; } .library-undo { border-color: var(--pf-accent); color: var(--pf-accent-strong); }
.directory-consent { position: fixed; z-index: 12; inset: 0; display: grid; place-items: center; padding: 20px; background: rgb(12 22 30 / 42%); } .directory-consent-card { width: min(460px, 100%); display: grid; gap: 16px; padding: 22px; border-radius: 14px; background: var(--pf-surface); box-shadow: 0 18px 45px rgb(15 25 33 / 28%); } .directory-consent-card h2, .directory-consent-card p { margin: 0; } .directory-consent-card p { color: var(--pf-text-muted); line-height: 1.6; } .directory-consent-card > div { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 600px) { .topbar-actions { flex-wrap: wrap; } }

/* V3-S6: Nocturne Parametric Studio visual layer. Existing selectors remain intact for automation. */
:root {
  color-scheme: dark;
  --pf-page: #08090b;
  --pf-surface: #0f1115;
  --pf-surface-subtle: #151820;
  --pf-surface-raised: #1b1f28;
  --pf-canvas: #0b0d11;
  --pf-border: rgb(255 255 255 / 8%);
  --pf-border-strong: rgb(255 255 255 / 16%);
  --pf-text: #f4f2ed;
  --pf-text-muted: #a7abb4;
  --pf-text-subtle: #777d88;
  --pf-accent: #a78bfa;
  --pf-accent-strong: #c4b5fd;
  --pf-accent-soft: rgb(167 139 250 / 14%);
  --pf-local: #54c6a4;
  --pf-selection: #f0b35a;
  --pf-warning: #f2a65a;
  --pf-danger: #f17070;
  --pf-radius-panel: 12px;
  --pf-radius-control: 6px;
  --pf-shadow-panel: 0 16px 48px rgb(0 0 0 / 24%);
  --pf-space-panel: 16px;
}

body { overflow-x: hidden; background: var(--pf-page); }
button, input, select, textarea { border-color: var(--pf-border); }
button { min-height: 40px; background: var(--pf-surface-raised); color: var(--pf-text); font-weight: 600; }
button:hover:not(:disabled) { border-color: var(--pf-accent); background: var(--pf-accent-soft); color: var(--pf-text); }
button:disabled { opacity: 1; border-color: var(--pf-border); background: rgb(255 255 255 / 3%); color: var(--pf-text-subtle); }
input, select, textarea { min-height: 40px; border-color: var(--pf-border); background: var(--pf-surface-raised); color: var(--pf-text); }
input[type="range"] { min-height: 20px; accent-color: var(--pf-accent); }
input[type="color"] { min-height: 40px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--pf-accent-strong); outline-offset: 2px; }

.app-shell { background: radial-gradient(circle at 50% -25%, rgb(167 139 250 / 12%), transparent 38%), var(--pf-page); }
.topbar, .footer-bar { border-color: var(--pf-border); background: rgb(8 9 11 / 92%); }
.topbar { min-height: 64px; padding-block: 12px; }
.topbar h1, .panel h2, .canvas-panel h2 { font-size: clamp(18px, 1.8vw, 24px); letter-spacing: -.02em; }
.eyebrow, .panel-kicker { color: var(--pf-text-subtle); }
.mode-tabs { max-width: min(100%, 760px); overflow-x: auto; border: 1px solid var(--pf-border); border-radius: 8px; background: var(--pf-surface); scrollbar-width: thin; }
.mode-tab { min-height: 36px; padding: 7px 10px; color: var(--pf-text-muted); }
.mode-tab.active { border: 1px solid var(--pf-border-strong); background: var(--pf-accent-soft); box-shadow: inset 0 -1px 0 var(--pf-accent); color: var(--pf-text); }
.topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
.status-chip, .mode-label { border: 1px solid rgb(84 198 164 / 24%); background: rgb(84 198 164 / 12%); color: var(--pf-local); }
.count-badge { display: inline-grid; min-width: 18px; min-height: 18px; place-items: center; margin-left: 4px; padding: 0 5px; border-radius: 999px; background: var(--pf-accent); color: #08090b; font-size: 11px; }
.workflow-bar { border-color: var(--pf-border); background: rgb(255 255 255 / 2%); color: var(--pf-text-muted); }
.workflow-bar strong { color: var(--pf-accent-strong); }

.workspace { grid-template-columns: minmax(240px, 280px) minmax(0, 1fr) minmax(300px, 352px); gap: 12px; padding-block: 12px; }
.panel, .canvas-panel { min-width: 0; border-color: var(--pf-border); background: var(--pf-surface); box-shadow: none; }
.panel { gap: 16px; }
.canvas-panel { background: linear-gradient(145deg, rgb(255 255 255 / 3%), transparent 30%), var(--pf-surface); }
.canvas-stage { min-width: 0; min-height: 420px; border: 1px solid var(--pf-border); border-radius: 10px; background: radial-gradient(circle at 50% 30%, rgb(255 255 255 / 3%), transparent 52%), var(--pf-canvas); }
#pattern-canvas, #analysis-canvas, #case-image { max-width: 100%; height: auto; box-shadow: 0 18px 40px rgb(0 0 0 / 30%); }
.canvas-grid { background-image: linear-gradient(rgb(167 139 250 / 22%) 1px, transparent 1px), linear-gradient(90deg, rgb(167 139 250 / 22%) 1px, transparent 1px); }
.empty-state, .canvas-hint, .upload-zone small, .muted { color: var(--pf-text-muted); }
.upload-zone { border-color: var(--pf-border-strong); background: rgb(255 255 255 / 1%); color: var(--pf-text); }
.upload-zone:hover { border-color: var(--pf-accent); background: var(--pf-accent-soft); }
.privacy-note, .reference-upload:not([hidden]), .field-editor, .variant-editor, .uv-report, .manufacturing-controls, .field-layer, .field-mapping, .library-card { border-color: var(--pf-border); background: var(--pf-surface-subtle); }
.processing-controls, .control-section, .reference-upload { border-color: var(--pf-border); }
.primary { border-color: var(--pf-accent); background: #7653d6; color: #fff; }
.primary:hover:not(:disabled) { border-color: var(--pf-accent-strong); background: #8b6eeb; }
.range-number { width: 84px; justify-self: end; margin-top: -4px; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12px; }
.control-section > label:has(input[type="range"]) { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.control-section > label:has(input[type="range"]) > input[type="range"] { grid-column: 1 / -1; }
.control-section > label:has(input[type="range"]) > output { justify-self: end; color: var(--pf-accent-strong); font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }

.toast { z-index: 20; bottom: 44px; border: 1px solid var(--pf-border-strong); background: var(--pf-surface-raised); color: var(--pf-text); box-shadow: var(--pf-shadow-panel); }
.three-view { border: 1px solid var(--pf-border); background: radial-gradient(circle at 50% 30%, #29313a, #0b0d11 70%); box-shadow: none; }
.three-shape-picker { border-color: var(--pf-border); background: rgb(8 9 11 / 72%); }
.three-shape-picker button.selected, .part-picker .selected, .star-artifact[aria-pressed="true"] { border-color: rgb(240 179 90 / 65%); background: rgb(240 179 90 / 14%); color: var(--pf-selection); box-shadow: inset 0 0 0 1px rgb(240 179 90 / 12%); }
.case-node-preview { border-color: var(--pf-border-strong); background: #0b0d11; box-shadow: none; }
.case-node { border-color: var(--pf-border-strong); background: var(--pf-surface-raised); }
.case-report-section.observed { border-left-color: var(--pf-local); }
.case-report-section.inferred { border-left-color: #72a7f2; }
.case-report-section.unknown, .manufacturing-status.review { border-left-color: var(--pf-warning); background: rgb(242 166 90 / 12%); color: var(--pf-warning); }
.field-introduction { border-color: var(--pf-border-strong); background: var(--pf-surface); box-shadow: var(--pf-shadow-panel); }
.field-introduction-toggle { background: var(--pf-surface); color: var(--pf-accent-strong); }

.library-scrim { position: fixed; z-index: 9; inset: 0; background: rgb(0 0 0 / 56%); backdrop-filter: blur(2px); }
.library-drawer { z-index: 10; width: min(460px, 100vw); border-color: var(--pf-border-strong); background: var(--pf-surface); box-shadow: -18px 0 48px rgb(0 0 0 / 38%); }
.library-toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.library-toolbar label { font-size: 11px; color: var(--pf-text-muted); }
.directory-consent { z-index: 12; background: rgb(0 0 0 / 64%); backdrop-filter: blur(3px); }
.directory-consent-card { border: 1px solid var(--pf-border-strong); background: var(--pf-surface); box-shadow: var(--pf-shadow-panel); }
.has-blocking-layer .app-shell { user-select: none; }

@media (max-width: 1279px) {
  .topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .mode-tabs { grid-column: 1 / -1; max-width: 100%; }
  .workspace { grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); }
  .controls-panel { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .controls-panel > h2, .controls-panel > .panel-kicker, .controls-panel > .control-actions, .controls-panel > .muted { grid-column: 1 / -1; }
  .three-active .workspace { grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); }
}

@media (min-width: 821px) and (max-width: 1279px) {
  .app-shell { height: auto; }
  .workspace { overflow: visible; }
  .panel, .canvas-panel { height: auto; align-self: start; }
  .canvas-panel { overflow: hidden; }
  .three-active .canvas-panel { grid-template-rows: auto minmax(420px, 1fr) auto; }
  .three-active .canvas-stage, .three-active .three-view { min-height: 420px; }
  .analysis-active .canvas-panel { grid-template-rows: auto auto minmax(420px, 1fr); }
}

@media (max-width: 899px) {
  .topbar { grid-template-columns: 1fr; gap: 12px; }
  .topbar-actions { justify-content: flex-start; }
  .workspace { grid-template-areas: "canvas" "assets" "controls"; grid-template-columns: minmax(0, 1fr); padding-inline: 12px; }
  .assets-panel { grid-area: assets; }
  .canvas-panel { grid-area: canvas; }
  .controls-panel { grid-area: controls; display: flex; }
  .three-active .workspace { grid-template-columns: minmax(0, 1fr); }
  .canvas-stage, .three-view { min-height: 420px; }
  .field-introduction { right: 12px; bottom: 12px; left: 12px; }
}

@media (max-width: 600px) {
  .topbar, .footer-bar { padding: 12px; }
  .workspace { gap: 10px; }
  .panel, .canvas-panel { padding: 14px; }
  .canvas-stage { min-height: 420px; }
  .two-column, .library-toolbar { grid-template-columns: 1fr; }
  .design-preview-controls .mode-label { width: 100%; margin-right: 0; }
  .library-drawer { padding: 16px 14px; }
  .footer-bar { gap: 6px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
