:root {
  color-scheme: dark;
  --bg: #141617;
  --surface: #191c1d;
  --inset: #101314;
  --line: #2c3132;
  --text: #e3e8e6;
  --muted: #929d99;
  --green: #a2d7a4;
  --cyan: #79b9d5;
  --amber: #dfb578;
  --danger: #ed9494;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 12px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; color: inherit; }
button:disabled { opacity: .38; cursor: not-allowed; }
button, input, select { border-radius: 4px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
svg.lucide { width: 16px; height: 16px; stroke-width: 1.6; flex: none; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: transparent; min-height: 32px; }
button:hover:not(:disabled) { background: #293030; }
h1, h2, h3, p { margin: 0; }
h2, h3 { font-size: 12px; font-weight: 600; }
input, select { width: 100%; min-width: 0; height: 33px; border: 1px solid #353c3b; padding: 5px 9px; background: var(--inset); color: var(--text); }
input[type=number] { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
input[type=number]::-webkit-inner-spin-button { opacity: 0; }
input[type=number]:hover::-webkit-inner-spin-button { opacity: 1; }
input[type=range] { padding: 0; height: 16px; margin: 10px 0 5px; accent-color: var(--green); background: transparent; border: none; cursor: pointer; }
input[type=checkbox] { width: 14px; height: 14px; margin: 0; accent-color: var(--green); }
select { padding-right: 20px; cursor: pointer; }
.app-header { height: 72px; display: flex; align-items: center; gap: 26px; padding: 0 22px; border-bottom: 1px solid var(--line); background: #171a1b; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 254px; }
.brand-mark { font: 23px var(--mono); width: 39px; height: 39px; display: grid; place-items: center; border: 1px solid #768878; color: var(--green); border-radius: 4px; }
h1 { font: 600 21px/1.2 var(--mono); }
.brand-sub { font: 9px/1.8 var(--mono); color: var(--muted); }
.document-title { display: flex; gap: 10px; align-items: center; color: #c5ceca; font-size: 12px; flex: 1; min-width: 0; }
#headerName { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.related-apps { display: flex; gap: 18px; }
.related-apps a { color: var(--muted); text-decoration: none; font: 16px var(--mono); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.related-apps a:hover { color: var(--text); }
.related-apps span { font: 9px system-ui, sans-serif; }
.file-actions { display: flex; gap: 6px; border-left: 1px solid var(--line); padding-left: 18px; }
.icon-button { width: 30px; height: 30px; min-height: 30px; padding: 0; border: 1px solid transparent; flex: none; color: var(--muted); }
.icon-button.active, .icon-button[aria-pressed=true] { color: var(--green); background: #29362c; border-color: #455b49; }
.tag, .mini-tag { padding: 2px 6px; border: 1px solid #404943; color: #bac8bf; font: 10px/1.4 var(--mono); border-radius: 3px; white-space: nowrap; }
#dirtyTag { color: var(--amber); border-color: #635238; }
.workbench { display: grid; grid-template-columns: 282px minmax(0, 1fr) 320px; height: calc(100dvh - 100px); min-height: 640px; }
.setup { border-right: 1px solid var(--line); background: var(--surface); overflow-y: auto; }
.section-heading { min-height: 46px; display: flex; align-items: center; justify-content: space-between; padding: 8px 18px; border-bottom: 1px solid var(--line); font: 10px var(--mono); color: var(--muted); }
.control-section { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.control-section h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 13px; color: #cfd8d3; }
.control-section h2 svg { color: var(--muted); width: 14px; height: 14px; }
.stacked { display: grid; gap: 6px; }
label { color: var(--muted); font-size: 11px; }
.name-field { margin-top: 12px; }
#exampleNote { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.segmented { display: flex; margin-top: 14px; background: var(--inset); padding: 3px; border: 1px solid var(--line); border-radius: 5px; gap: 2px; }
.segmented button { width: 50%; border: 0; min-height: 29px; color: var(--muted); }
.segmented .active { background: #333c36; color: #daebdc; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 12px; }
.field-grid label { display: grid; gap: 5px; }
.unit-input { position: relative; min-width: 0; }
.unit-input input { padding-right: 35px; }
.unit-input span { position: absolute; right: 9px; top: 9px; font: 10px var(--mono); pointer-events: none; color: #7e8b84; }
.unit-input input[name=density] { padding-right: 45px; }
.pitch-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 13px; }
.pitch-label .unit-input { width: 92px; }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; min-height: 20px; cursor: pointer; }
.field-note { margin-left: auto; font-size: 9px; color: #78857d; }
#ductField { margin-top: 10px; }
.design-fields { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.design-fields > .stacked { margin-top: 10px; }
.advanced summary { list-style: none; display: flex; align-items: center; justify-content: space-between; cursor: pointer; color: #bec8c2; font-size: 11px; }
.advanced[open] summary { margin-bottom: 14px; }
.advanced[open] summary svg { transform: rotate(180deg); }
.solve-dock { padding: 16px 18px; position: sticky; bottom: 0; background: #191c1df5; border-top: 1px solid var(--line); display: flex; gap: 7px; }
.primary { background: var(--green); border-color: var(--green); color: #18271b; font-weight: 650; padding: 8px 15px; min-height: 36px; }
.primary:hover:not(:disabled) { background: #b9e6ba; }
.solve-dock .primary { flex: 1; }
.secondary { padding: 7px 12px; background: #252b28; }
.workspace { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.workspace-nav { height: 46px; flex: none; border-bottom: 1px solid var(--line); display: flex; align-items: stretch; justify-content: space-between; padding: 0 14px; }
.tabs { display: flex; align-items: stretch; gap: 12px; }
.tabs button { border: 0; border-radius: 0; color: var(--muted); font-size: 11px; padding: 0 7px; position: relative; white-space: nowrap; min-height: 40px; }
.tabs button.active { color: var(--text); }
.tabs button.active::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: -1px; height: 2px; background: var(--green); }
.engine-label { align-self: center; font: 9px var(--mono); color: #77847d; white-space: nowrap; }
.view { min-height: 0; flex: 1; }
#view-rotor { display: flex; flex-direction: column; }
.scene-wrap { position: relative; flex: 1; min-height: 300px; background: #111516; overflow: hidden; }
#rotorScene { position: absolute; inset: 0; }
#rotorScene canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.scene-top { position: absolute; top: 19px; left: 20px; right: 20px; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; }
.eyebrow { font: 9px/1.4 var(--mono); color: var(--muted); }
#sceneMeta { margin-top: 6px; font: 11px var(--mono); color: #bdc9c3; }
.scene-tools { position: absolute; left: 18px; top: 90px; display: flex; flex-direction: column; gap: 5px; }
.scene-tools .icon-button { background: #191f20eb; border-color: #333d3b; }
.scene-tools .icon-button.active { background: #2a3b2d; }
.scene-tools > span { height: 5px; }
.scene-bottom { position: absolute; bottom: 18px; left: 20px; right: 20px; display: flex; justify-content: space-between; color: var(--muted); font: 10px var(--mono); pointer-events: none; }
.color-dot { display: inline-block; width: 6px; height: 6px; background: var(--green); margin-right: 7px; border-radius: 50%; }
#webglFallback { position: absolute; top: 45%; left: 15%; right: 15%; text-align: center; color: var(--amber); }
.data-heading { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; padding: 0 18px; height: 41px; flex: none; }
.small-tabs { gap: 18px; }
.small-tabs button { min-height: 40px; padding: 0; font-size: 10px; }
.data-table-wrap, .history-panel { height: 220px; min-height: 145px; overflow: auto; flex: none; }
table { border-collapse: collapse; width: 100%; text-align: right; white-space: nowrap; font: 10px/1.45 var(--mono); }
th { color: #95a39b; font-weight: 400; background: #1a1f20; position: sticky; top: 0; z-index: 1; }
th, td { padding: 9px 12px; border-bottom: 1px solid #242b29; }
th:first-child, td:first-child { text-align: left; padding-left: 20px; color: #77867c; }
th small { color: #66766c; font-size: 9px; }
tbody tr:hover { background: #232d27; }
tbody tr.selected { background: #27362c; }
.history-panel { padding: 12px 18px; }
.history-panel canvas { width: 100%; height: 165px; }
#historyMeta { font: 10px var(--mono); color: var(--muted); }
.message-bar { min-height: 34px; padding: 7px 18px; display: flex; align-items: center; gap: 8px; background: #1c2420; color: #a8bfae; border-top: 1px solid #314035; font: 10px/1.5 var(--mono); flex: none; }
.message-bar.error { color: var(--danger); background: #2c2020; border-color: #543535; }
.message-bar.warning { color: var(--amber); background: #27241d; border-color: #4a4430; }
.message-bar svg { width: 13px; height: 13px; }
.message-bar > span { flex: 1; min-width: 0; }
.message-bar .icon-button { height: 20px; min-height: 20px; width: 20px; }
tbody tr.stalled td:nth-child(5) { color: var(--amber); }
.results { border-left: 1px solid var(--line); background: #181c1c; overflow-y: auto; }
.status-badge { padding: 3px 7px; border-radius: 3px; background: #28302b; color: #b5c6b9; font: 9px var(--mono); }
.status-badge.converged { background: #283b2c; color: var(--green); }
.status-badge.warning { background: #3d3223; color: var(--amber); }
.metrics { display: grid; grid-template-columns: 1fr 1fr; padding: 20px 20px 15px; gap: 22px 20px; }
.metric > span { font-size: 10px; color: var(--muted); }
.metric strong { display: flex; align-items: baseline; gap: 6px; font: 23px/1.5 var(--mono); white-space: nowrap; }
.metric strong small { font-size: 10px; color: #8b9990; font-weight: 400; }
.metric:nth-child(3) strong { color: var(--green); }
.coefficient-row { display: grid; grid-template-columns: 1fr 1fr 1fr; margin: 0 20px; padding: 11px 0 17px; border-bottom: 1px solid var(--line); }
.coefficient-row span { display: flex; gap: 8px; font: 10px var(--mono); color: #7c8a81; }
.coefficient-row strong { color: #c1cec5; font-weight: 400; }
.plot-section { padding: 16px 16px 7px; border-bottom: 1px solid var(--line); }
.chart-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.chart-heading h2, .chart-heading h3 { font-weight: 500; font-size: 11px; }
.chart-heading > span { font: 9px var(--mono); color: var(--muted); }
.chart-heading select { width: 110px; height: 26px; font-size: 10px; padding: 3px 6px; background: transparent; border-color: transparent; }
.plot-section canvas { width: 100%; height: 164px; display: block; }
.legend::before { content: ""; display: inline-block; width: 15px; height: 2px; background: var(--green); vertical-align: middle; margin-right: 6px; }
.case-section { padding: 15px 18px; border-bottom: 1px solid var(--line); }
.case-section .chart-heading { margin-bottom: 8px; }
#caseCount { color: #7f9083; margin-left: 5px; font: 10px var(--mono); }
.empty-state { color: #6f7f75; padding: 8px 0; font-size: 11px; }
.case-row { display: flex; align-items: center; gap: 4px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.case-row > button:first-child { min-width: 0; flex: 1; justify-content: space-between; border: 0; padding: 5px 0; font-size: 10px; }
.case-row .case-name { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; text-align: left; max-width: 150px; }
.case-row .case-value { color: var(--green); font: 10px var(--mono); white-space: nowrap; }
.solver-details { display: flex; gap: 10px; justify-content: space-between; padding: 12px 18px; color: #738278; font: 9px var(--mono); }
.solver-details > span:first-child { max-width: 190px; }
.statusbar { height: 28px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; background: #101313; border-top: 1px solid var(--line); color: #7d8b82; font: 9px var(--mono); }
.connection-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green); display: inline-block; margin-right: 7px; }
.analysis-view { padding: 20px; overflow-y: auto; }
.analysis-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.analysis-heading h2 { font-size: 19px; font-weight: 500; margin-top: 5px; }
.inline-form { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.inline-form label { flex: 1; min-width: 60px; display: grid; gap: 6px; }
.inline-form .primary { margin-left: 4px; }
.inline-form input { height: 36px; }
.noise-form label { position: relative; }
.noise-form label > span { position: absolute; top: 2px; right: 0; color: #67796c; }
.large-chart { padding: 20px 0 8px; border-bottom: 1px solid var(--line); }
.large-chart canvas { width: 100%; height: 185px; display: block; }
.view-status { font: 10px/1.6 var(--mono); color: var(--muted); padding-top: 14px; }
.acoustic-totals { display: flex; gap: 44px; padding: 20px 0 6px; }
.acoustic-totals > div { display: grid; gap: 5px; }
.acoustic-totals span { color: var(--muted); font-size: 10px; }
.acoustic-totals strong { font: 24px var(--mono); color: var(--cyan); }
.acoustic-totals small { color: var(--muted); font-size: 11px; }
.mobile-tabs { display: none; }
dialog { width: min(400px, calc(100% - 32px)); padding: 24px; background: #202624; border: 1px solid #46514b; border-radius: 6px; color: var(--text); }
dialog::backdrop { background: #0009; }
dialog h2 { font-size: 17px; margin-bottom: 12px; }
dialog p { color: var(--muted); margin-bottom: 20px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
body.busy #solve svg { animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .3; } }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: #414b44; border-radius: 3px; }
@media (min-width: 1650px) { .workbench { grid-template-columns: 310px minmax(0, 1fr) 360px; } .plot-section canvas { height: 190px; } .data-table-wrap, .history-panel { height: 260px; } }
@media (max-width: 1150px) {
  .workbench { grid-template-columns: 250px minmax(0, 1fr) 275px; }
  .brand { min-width: 215px; } .app-header { gap: 15px; padding: 0 16px; }
  .control-section { padding: 14px; } .section-heading { padding-left: 14px; padding-right: 14px; }
  .metrics { gap: 15px 12px; padding: 16px 14px; } .metric strong { font-size: 20px; }
  .engine-label { display: none; } .tabs { gap: 8px; } .tabs button { font-size: 10px; }
  .coefficient-row { margin: 0 14px; } .coefficient-row span { gap: 4px; font-size: 9px; }
  .plot-section { padding-left: 10px; padding-right: 10px; }
  .scene-top { left: 14px; right: 14px; } .scene-top .tag { display: none; }
  .related-apps span { display: none; }
}
@media (max-width: 900px) {
  .app-header { height: 64px; } .brand { min-width: 190px; }
  .workbench { height: calc(100dvh - 92px); grid-template-columns: 250px minmax(0, 1fr); min-height: 650px; }
  .results { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; overflow: visible; border-left: 0; border-top: 1px solid var(--line); }
  .results > .section-heading { grid-column: 1 / -1; }
  .results .coefficient-row { align-self: center; }
  .results .solver-details { grid-column: 1 / -1; }
  .workbench { height: auto; } .setup, .workspace { height: 760px; } .statusbar { position: relative; }
  .related-apps { gap: 12px; } .document-title { font-size: 10px; }
}
@media (max-width: 620px) {
  .app-header { height: 62px; padding: 0 12px; gap: 10px; }
  .brand { min-width: 0; gap: 8px; flex: 1; } .brand-mark { width: 32px; height: 32px; font-size: 19px; }
  h1 { font-size: 18px; } .brand-sub { font-size: 8px; }
  .document-title, .related-apps { display: none; } .file-actions { padding-left: 8px; gap: 3px; }
  .mobile-tabs { display: flex; height: 40px; border-bottom: 1px solid var(--line); padding: 0 12px; background: #191d1c; gap: 20px; }
  .mobile-tabs button { border: 0; border-radius: 0; font-size: 11px; color: var(--muted); padding: 0 7px; }
  .mobile-tabs .active { color: var(--green); border-bottom: 2px solid var(--green); }
  .workbench { display: block; min-height: calc(100dvh - 130px); }
  .workbench > .setup, .workbench > .workspace, .workbench > .results { display: none; }
  .workbench[data-panel=setup] > .setup { display: block; }
  .workbench[data-panel=workspace] > .workspace { display: flex; }
  .workbench[data-panel=results] > .results { display: block; }
  .setup, .workspace { height: calc(100dvh - 130px); min-height: 620px; }
  .setup { border-right: 0; } .setup .control-section { padding: 16px 22px; }
  .setup .field-grid { gap: 14px 20px; } .solve-dock { padding: 16px 22px; }
  .workspace-nav { padding: 0 9px; height: 44px; } .tabs { gap: 8px; } .tabs button { padding: 0 6px; font-size: 11px; gap: 6px; }
  .scene-wrap { min-height: 300px; } .scene-top { top: 15px; }
  .scene-tools { left: 12px; top: 75px; gap: 4px; }
  .scene-tools .icon-button { height: 29px; min-height: 29px; width: 29px; }
  .data-table-wrap, .history-panel { height: 190px; } .scene-bottom { left: 14px; right: 14px; font-size: 9px; }
  .history-panel canvas { height: 140px; }
  .results { min-height: calc(100dvh - 130px); }
  .metrics { padding: 22px; gap: 25px; } .metric strong { font-size: 26px; }
  .coefficient-row { margin: 0 22px; } .coefficient-row span { font-size: 11px; }
  .plot-section { padding: 20px; } .plot-section canvas { height: 180px; }
  .analysis-view { padding: 18px 14px; }
  .inline-form { gap: 9px; } .inline-form .primary { margin-left: 0; width: 100%; }
  .large-chart canvas { height: 160px; }
  .acoustic-totals { gap: 20px; } .acoustic-totals strong { font-size: 21px; }
  .statusbar { padding: 0 12px; font-size: 8px; } .footer-note { display: none; }
  .message-bar { font-size: 9px; padding: 7px 12px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; } }
