:root {
    --navy-950: #03101e;
    --navy-900: #06182a;
    --navy-850: #092138;
    --navy-800: #0b2945;
    --navy-700: #123b60;
    --blue-600: #17659c;
    --blue-500: #2482be;
    --blue-300: #8ec5e8;
    --ice-100: #f5f9fc;
    --ice-150: #eef5f9;
    --ice-200: #e5eef5;
    --ice-300: #d3e1eb;
    --line: #b9cad7;
    --ink: #06182a;
    --muted: #557085;
    --green: #2ba84a;
    --green-dark: #178637;
    --orange: #f4a21d;
    --red: #d64034;
    --shadow: 0 8px 24px rgba(0, 24, 46, .12);
    --radius: 7px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    color: var(--ink);
    background: #eaf2f7;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
}
button, input, select, textarea { font: inherit; }
button, select, input[type="range"] { accent-color: var(--blue-600); }
a { color: inherit; }
img, svg, canvas { display: block; }
.hidden { display: none !important; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.site-shell { min-width: 320px; min-height: 100vh; }
.site-header {
    height: 58px;
    display: grid;
    grid-template-columns: 236px minmax(450px, 1fr) minmax(400px, 610px) 118px;
    align-items: stretch;
    background: #fff;
    border-bottom: 1px solid #cbd8e2;
    position: sticky;
    top: 0;
    z-index: 50;
}
.brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 5px 15px;
    text-decoration: none;
    color: #fff;
    background:
        radial-gradient(circle at 8% 90%, rgba(25,104,151,.35), transparent 35%),
        linear-gradient(135deg, #06182a, #03101e 62%, #071d31);
    border-bottom-right-radius: 7px;
}
.brand img { width: 42px; height: 42px; flex: 0 0 auto; }
.brand-copy { min-width: 0; display: grid; letter-spacing: .15em; line-height: 1; }
.brand-copy strong { font-family: Georgia, serif; font-size: 16px; font-weight: 500; white-space: nowrap; }
.brand-copy small { margin-top: 6px; font-size: 9px; letter-spacing: .28em; }
.primary-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 28px;
    padding: 0 18px;
    font-size: 12px;
    white-space: nowrap;
}
.primary-nav a {
    height: 100%;
    display: grid;
    place-items: center;
    text-decoration: none;
    border-bottom: 2px solid transparent;
}
.primary-nav a:hover, .primary-nav a.active { color: #0c3559; border-bottom-color: #0c3559; }
.header-title { min-width: 0; display: grid; place-content: center; text-align: center; padding: 3px 14px 4px; }
.header-title h1 { margin: 0; font-size: clamp(18px, 1.55vw, 25px); line-height: 1.05; letter-spacing: -.03em; }
.header-title p { margin: 3px 0 0; font-family: Georgia, serif; font-size: 13px; color: #23425c; }
.header-tools { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding-right: 12px; }
.header-tools a {
    width: 29px; height: 29px; display: grid; place-items: center;
    border-radius: 50%; border: 1px solid transparent; text-decoration: none;
    font-family: Georgia, serif; font-weight: 700; font-size: 16px;
}
.header-tools a:hover { border-color: var(--line); background: var(--ice-100); }
.nav-toggle { display: none; }

.tool-layout {
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr) 268px;
    min-height: calc(100vh - 89px);
}
.control-rail {
    min-width: 0;
    padding: 13px 11px 18px;
    background:
        linear-gradient(180deg, rgba(6,24,42,.98), rgba(2,24,41,.99)),
        radial-gradient(circle at 50% 0, rgba(26,104,152,.35), transparent 38%);
    border-right: 1px solid #071525;
}
.control-card {
    overflow: hidden;
    border: 1px solid #b4c7d6;
    border-radius: var(--radius);
    background: rgba(247,251,253,.97);
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    margin-bottom: 11px;
}
.control-card-heading {
    width: 100%; min-height: 27px;
    display: flex; justify-content: space-between; align-items: center;
    padding: 5px 8px;
    border: 0;
    border-bottom: 1px solid #bdcedb;
    background: linear-gradient(#f7fbfe, #dce9f2);
    color: #0a2946;
    font-size: 10px; font-weight: 800;
    cursor: pointer;
}
.control-card-heading .chevron { color: var(--muted); }
.control-card.collapsed .control-card-body { display: none; }
.control-card.collapsed .control-card-heading { border-bottom: 0; }
.control-card.collapsed .chevron { transform: rotate(180deg); }
.control-card-body { padding: 7px; }
.field-label { margin: 0 0 5px; font-size: 9px; font-weight: 700; }
.button-row { display: grid; grid-template-columns: .95fr 1.15fr; gap: 5px; margin-bottom: 6px; }
.button, select, input, textarea {
    border: 1px solid #b5c6d3;
    border-radius: 4px;
    background: #fff;
    color: var(--ink);
}
.button {
    min-height: 27px;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 5px 10px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 700;
    font-size: 10px;
}
.button:hover { filter: brightness(.98); }
.button-secondary { color: #fff; border-color: #0b385d; background: linear-gradient(#24577d,#123c5e); }
.button-dark { color: #fff; border-color: #031426; background: linear-gradient(#102f4c,#061a2d); }
.button-run { min-height: 39px; margin-top: 7px; color: #fff; border: 0; background: linear-gradient(135deg, var(--green), var(--green-dark)); font-size: 12px; }
.button-run b { margin-left: auto; font-size: 14px; }
.file-button { user-select: none; }
.full-width { width: 100%; }
.compact-select { min-width: 0; width: 100%; }
.field-row {
    min-height: 26px;
    display: grid;
    grid-template-columns: 75px minmax(0, 1fr);
    align-items: center;
    gap: 5px;
    font-size: 9px;
}
.field-row > span:first-child { font-weight: 600; }
.field-row input[type="text"], .field-row input[type="number"], .field-row select,
.form-grid input, .form-grid select, .annotation-panel textarea {
    width: 100%; min-width: 0; height: 24px; padding: 3px 6px; font-size: 9px;
}
.input-with-unit, .range-control { min-width: 0; display: grid; align-items: center; gap: 4px; }
.input-with-unit { grid-template-columns: minmax(0, 1fr) 18px; }
.input-with-unit em, .range-control em { font-style: normal; font-size: 8px; color: var(--muted); }
.range-control { grid-template-columns: 44px 25px minmax(34px, 1fr); }
.range-control input[type="range"] { min-width: 0; width: 100%; height: 15px; }
.readout-row { min-height: 22px; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 9px; }
.readout-row strong { font-weight: 650; white-space: nowrap; }
.compare-capture { display:grid; grid-template-columns:1fr 1fr; gap:5px; margin-top:6px; }
.compare-capture .button { min-height:25px; }
.micro-status { margin-top: 5px; padding: 5px 6px; border-radius: 4px; color: #27475f; background: #e8f2f8; font-size: 8px; line-height: 1.35; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid #aebfcb; border-radius: 4px; overflow: hidden; margin: 6px 0; }
.mode-button { min-height: 25px; border: 0; background: #fff; color: #1e4059; font-size: 8px; cursor: pointer; }
.mode-button + .mode-button { border-left: 1px solid #aebfcb; }
.mode-button.active { color: #fff; background: linear-gradient(#3eb75a,#229244); }
.solver-progress { margin-top: 6px; }
.solver-progress-bar { height: 5px; overflow: hidden; border-radius: 99px; background: #d9e4eb; }
.solver-progress-bar span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #24a94b, #68ca7a); transition: width .2s ease; }
.solver-progress small { display: block; margin-top: 4px; color: #587286; font-size: 8px; }

.workspace { min-width: 0; padding: 16px 10px 24px; background: linear-gradient(180deg,#f4f8fb 0,#eef5f9 48%,#f7fafc 100%); }
.visualizer-panel { overflow: hidden; border: 1px solid #9cafbd; border-radius: 6px; background: #020b13; box-shadow: var(--shadow); }
.visualizer-toolbar { padding: 7px 9px 0; background: #06131f; color: #fff; }
.toolbar-title { display: block; margin-bottom: 6px; font-size: 9px; font-weight: 800; }
.layer-buttons { display: flex; overflow-x: auto; scrollbar-width: thin; border: 1px solid #183b56; border-radius: 4px 4px 0 0; }
.layer-button {
    flex: 0 0 72px; min-height: 42px;
    display: grid; place-items: center; align-content: center; gap: 2px;
    border: 0; border-right: 1px solid #17374f;
    color: #c8d9e5; background: #071626; cursor: pointer; font-size: 7px;
}
.layer-button span { font-size: 15px; line-height: 1; }
.layer-button sub { font-size: 5px; }
.layer-button.active { color: #fff; background: linear-gradient(#173d60,#0d2b48); box-shadow: inset 0 -2px 0 #418bc1; }
.canvas-stage { position: relative; height: clamp(390px, 47vw, 630px); min-height: 390px; background: #020b13; overflow: hidden; }
#flow-canvas { width: 100%; height: 100%; cursor: grab; touch-action: none; }
#flow-canvas:active { cursor: grabbing; }
.drop-overlay[hidden] { display: none !important; }
.drop-overlay { position: absolute; inset: 20px; z-index: 10; display: grid; place-content: center; text-align: center; border: 2px dashed #58b6e8; border-radius: 8px; color: #fff; background: rgba(3,26,44,.88); }
.drop-overlay strong { font-size: 22px; }
.drop-overlay span { margin-top: 6px; color: #b8d8ea; }
.axis-widget { position: absolute; top: 16px; right: 18px; width: 74px; height: 74px; pointer-events: none; }
.axis-widget span { position: absolute; left: 31px; top: 31px; width: 18px; height: 18px; transform: rotate(30deg) skewY(-10deg); background: linear-gradient(135deg,#8799a7,#d0d9df); border: 1px solid #425567; }
.axis-widget i { position: absolute; font-style: normal; font-weight: 800; font-size: 10px; }
.axis-x { left: 3px; top: 39px; color: #ff3c32; }
.axis-y { left: 37px; top: 0; color: #41ff4c; }
.axis-z { right: 0; bottom: 4px; color: #286eff; }
.viewport-badge { position: absolute; left: 16px; top: 14px; display: grid; gap: 3px; pointer-events: none; }
.viewport-badge span { width: max-content; padding: 4px 7px; border-radius: 3px; color: #cdeafe; background: rgba(4,30,49,.76); border: 1px solid rgba(93,169,215,.35); font-size: 8px; letter-spacing: .08em; }
.viewport-badge small { color: #7fa4bb; font-size: 8px; }
.stage-help { position: absolute; right: 16px; bottom: 12px; color: rgba(213,233,245,.7); font-size: 8px; pointer-events: none; }
.viewport-controls {
    min-height: 39px;
    display: grid;
    grid-template-columns: minmax(220px,1fr) auto minmax(185px,.65fr) auto;
    gap: 8px; align-items: center;
    padding: 5px 9px 8px;
    color: #dcecf6; background: #06131f;
}
.viewport-controls label { min-width: 0; display: grid; grid-template-columns: auto minmax(40px,1fr) auto; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid #16364e; border-radius: 4px; font-size: 8px; background: #071a2b; }
.viewport-controls input[type="range"] { min-width: 0; width: 100%; }
.viewport-button-group { display: flex; gap: 4px; }
.viewport-button-group button { width: 31px; height: 29px; border: 1px solid #17374f; border-radius: 4px; color: #fff; background: #071a2b; cursor: pointer; }
.viewport-button-group button:hover { background: #123757; }
.legend-panel {
    min-height: 83px;
    display: grid; grid-template-columns: 1fr 1px 1fr; gap: 32px; align-items: center;
    padding: 12px 42px;
    border: 1px solid #b5c7d3; border-top: 0; border-radius: 0 0 6px 6px;
    background: rgba(255,255,255,.78);
}
.legend-block { min-width: 0; }
.legend-block > span { display: block; margin-bottom: 7px; font-size: 9px; }
.legend-gradient { height: 14px; border: 1px solid #aab9c3; }
.pressure-gradient { background: linear-gradient(90deg,#0816c7,#0e55f0,#02d9f7,#5fe97a,#fff331,#ff8a00,#d40000); }
.velocity-gradient { background: linear-gradient(90deg,#1800bd,#005fff,#02e4ee,#3fe47b,#fff241,#ff8400,#d80000); }
.legend-values { display: flex; justify-content: space-between; margin-top: 5px; font-size: 7px; }
.legend-divider { width: 1px; height: 50px; background: #c5d3dc; }

.results-rail { min-width: 0; padding: 16px 11px 24px 0; background: linear-gradient(180deg,#f4f8fb,#eef5f9); }
.results-panel { overflow: hidden; border: 1px solid #aebfcb; border-radius: 6px; background: rgba(255,255,255,.8); }
.results-panel > header { padding: 7px 9px; border-bottom: 1px solid #aebfcb; background: linear-gradient(#f5fbff,#e2edf5); font-size: 9px; font-weight: 800; color: #0a3557; }
.results-group { padding: 8px 10px; border-bottom: 1px solid #c7d4dc; }
.results-group:last-child { border-bottom: 0; }
.results-group h2 { margin: 0 0 6px; color: #0a3557; font-size: 10px; }
.results-group dl { margin: 0; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px 7px; align-items: baseline; font-size: 8px; }
.results-group dt { min-width: 0; }
.results-group dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.score i { margin-left: 5px; color: var(--orange); font-style: normal; letter-spacing: 1px; }
.status-chip { display: inline-block; padding: 3px 5px; border-radius: 3px; background: #e8f0f5; color: #34536b; }
.status-chip.running { color: #665011; background: #fff2b7; }
.status-chip.converged { color: #136326; background: #bff0c9; }
.status-chip.warning { color: #8a351a; background: #ffd9c8; }
.diagram-panel, .comparison-panel, .run-actions { margin-top: 12px; border: 1px solid #bdcbd5; border-radius: 6px; background: rgba(255,255,255,.72); }
.diagram-panel { padding: 10px 12px 13px; }
.comparison-panel { overflow:hidden; border:1px solid #bdcbd5; border-radius:6px; background:rgba(255,255,255,.78); }
.comparison-panel header { display:flex; justify-content:space-between; align-items:center; padding:7px 9px; border-bottom:1px solid #bdcbd5; background:linear-gradient(#f5fbff,#e2edf5); color:#0a3557; font-size:9px; font-weight:800; }
.comparison-panel header button { border:0; background:transparent; color:#315a74; font-size:8px; cursor:pointer; }
.comparison-state { display:grid; grid-template-columns:1fr 1fr; gap:5px; padding:7px 9px; font-size:8px; color:#44657b; }
.comparison-panel table { width:100%; border-collapse:collapse; font-size:8px; }
.comparison-panel th,.comparison-panel td { padding:5px 7px; border-top:1px solid #d4dfe6; text-align:right; }
.comparison-panel th:first-child { text-align:left; }
.comparison-panel thead th { color:#2f5269; background:#f4f8fb; }
.comparison-panel td:last-child.positive { color:#9b2f24; }
.comparison-panel td:last-child.negative { color:#167136; }
.diagram-panel svg { width: 100%; height: auto; }
.diagram-panel p { margin: -3px 12px 0; text-align: center; color: #25465d; font-size: 9px; line-height: 1.45; }
.run-actions { display: grid; gap: 7px; padding: 10px; }

.lower-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 10px; margin-top: 26px; }
.content-panel { min-width: 0; overflow: hidden; border: 1px solid #afc0cc; border-radius: 5px; background: rgba(255,255,255,.82); }
.content-panel > header { min-height: 31px; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 9px; border-bottom: 1px solid #b7c8d4; background: linear-gradient(#f4faff,#e4eef5); }
.content-panel > header h2 { margin: 0; font-size: 9px; color: #0a3557; }
.content-panel > header h2 small { font-weight: 400; color: #567185; }
.content-panel > header a { font-size: 8px; color: #0d4d7a; }
.pdf-frame { height: 370px; background: #44515c; }
.pdf-frame iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.annotation-panel { padding-bottom: 10px; }
.annotation-tabs { min-height: 32px; display: flex; align-items: center; gap: 17px; padding: 0 9px; border-bottom: 1px solid #d1dce4; }
.annotation-tabs button { align-self: stretch; border: 0; border-bottom: 2px solid transparent; background: transparent; font-size: 8px; cursor: pointer; }
.annotation-tabs button.active { border-bottom-color: #0b4d78; color: #0b4d78; }
.annotation-tabs label { margin-left: auto; font-size: 8px; }
.annotation-tabs select { height: 22px; font-size: 8px; border: 0; background: transparent; }
.comment-list { max-height: 145px; overflow: auto; padding: 0 10px; }
.comment-item { padding: 9px 0; border-bottom: 1px solid #dce5eb; }
.comment-item:last-child { border-bottom: 0; }
.comment-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; font-size: 8px; }
.comment-meta strong { font-size: 9px; }
.comment-meta span { color: #5b7588; }
.comment-type { display: inline-block; padding: 2px 4px; border-radius: 3px; background: #e3eef5; color: #174664 !important; }
.comment-item p { margin: 5px 0 0; font-size: 9px; line-height: 1.4; white-space: pre-wrap; }
.comment-reference { margin-top: 5px; color: #527084; font-size: 8px; }
.empty-comments { padding: 17px 0; color: #627b8d; text-align: center; font-size: 9px; }
#comment-form { padding: 10px; }
.form-grid { display: grid; gap: 8px; }
.form-grid.two-col { grid-template-columns: 1fr 1fr; }
.form-grid label, #comment-form > label { display: grid; gap: 4px; font-size: 8px; font-weight: 600; }
.form-grid label small, #comment-form label small { color: #62798a; font-weight: 400; }
.annotation-panel textarea { height: auto; min-height: 74px; resize: vertical; padding: 7px; }
.citation-row { grid-template-columns: minmax(0,1fr) 150px; align-items: end; margin-top: 8px; }
.citation-row .button { height: 27px; }
.privacy-note { margin: 8px 0 0; color: #597287; font-size: 8px; line-height: 1.45; }
.form-message { min-height: 14px; margin-top: 5px; font-size: 8px; }
.form-message.success { color: #12722d; }
.form-message.error { color: #a1261b; }
.honeypot { position: absolute !important; left: -9999px !important; }

.equations-section { margin-top: 28px; padding: 28px 24px; border-radius: 7px; background: linear-gradient(145deg,#06192b,#0b2e4b); color: #fff; }
.section-heading { max-width: 850px; }
.section-heading span, .eyebrow { color: #73bde7; font-size: 9px; font-weight: 800; letter-spacing: .13em; }
.section-heading h2, .about-section h2 { margin: 8px 0 6px; font-family: Georgia, serif; font-size: 27px; font-weight: 500; }
.section-heading p { margin: 0; color: #bed3e2; line-height: 1.6; }
.equation-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-top: 23px; }
.equation-card { position: relative; min-width: 0; padding: 14px; border: 1px solid rgba(139,195,227,.24); border-radius: 5px; background: rgba(255,255,255,.055); }
.equation-card h3 { margin: 0 0 6px; font-size: 11px; }
.equation-number { position: absolute; top: 10px; right: 11px; color: rgba(169,210,233,.55); font-family: Georgia, serif; font-size: 16px; }
.equation { min-height: 67px; display: grid; place-items: center; overflow-x: auto; color: #fff; font-family: Georgia, serif; font-size: 16px; text-align: center; }
.equation .latex-source { display: block; margin-top: 8px; color: #90b5cc; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 7px; white-space: normal; }
.equation-card p { margin: 4px 0 0; color: #b7ccda; font-size: 9px; line-height: 1.5; }
.references-panel { margin-top: 18px; padding-top: 18px; border-top: 1px solid rgba(153,199,226,.24); }
.references-panel h3 { margin: 0 0 9px; font-family: Georgia, serif; font-weight: 500; }
.references-panel ol { margin: 0; padding-left: 19px; columns: 2; column-gap: 40px; color: #c2d5e2; font-size: 9px; line-height: 1.55; }
.references-panel li { break-inside: avoid; margin-bottom: 7px; }
.about-section { margin-top: 14px; display: grid; grid-template-columns: .8fr 1.2fr; gap: 35px; align-items: start; padding: 24px; border: 1px solid #b6c8d4; border-radius: 7px; background: #fff; }
.about-section h2 { color: #082b48; font-size: 23px; }
.about-section p { margin: 0; color: #35556c; line-height: 1.65; }

.site-footer {
    min-height: 31px;
    display: flex; justify-content: space-between; align-items: center; gap: 20px;
    padding: 6px 24px 6px 258px;
    color: #e6f1f7; background: #06182a;
    font-size: 8px;
}
.site-footer nav { display: flex; gap: 22px; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

@media (max-width: 1320px) {
    .site-header { grid-template-columns: 218px minmax(400px,1fr) minmax(360px,520px) 96px; }
    .primary-nav { gap: 18px; }
    .tool-layout { grid-template-columns: 218px minmax(0,1fr) 252px; }
    .equation-grid { grid-template-columns: repeat(2,1fr); }
    .site-footer { padding-left: 240px; }
}

@media (max-width: 1060px) {
    .site-header { grid-template-columns: 210px 1fr 70px; }
    .primary-nav {
        position: absolute; left: 0; right: 0; top: 58px;
        display: none; flex-wrap: wrap; gap: 0; padding: 0;
        background: #fff; border-bottom: 1px solid #bdcbd5; box-shadow: var(--shadow);
    }
    .primary-nav.open { display: flex; }
    .primary-nav a { min-width: 100px; height: 42px; flex: 1; }
    .header-title { grid-column: 2; grid-row: 1; }
    .header-tools { grid-column: 3; }
    .nav-toggle {
        position: absolute; left: 174px; top: 14px; z-index: 2;
        width: 30px; height: 30px; display: grid; place-content: center; gap: 4px;
        border: 1px solid #567185; border-radius: 4px; background: transparent;
    }
    .nav-toggle span:not(.sr-only) { width: 15px; height: 1px; background: #fff; }
    .tool-layout { grid-template-columns: 218px minmax(0,1fr); }
    .results-rail { grid-column: 2; display: grid; grid-template-columns: 1.4fr .8fr; gap: 10px; padding: 0 10px 22px; }
    .results-panel { grid-row: span 2; }
    .workspace { grid-column: 2; grid-row: 1; }
    .diagram-panel, .comparison-panel, .run-actions { margin-top: 0; }
    .site-footer { padding-left: 230px; }
}

@media (max-width: 790px) {
    .site-header { height: auto; min-height: 62px; grid-template-columns: 178px 1fr 56px; }
    .brand { padding: 7px 10px; }
    .brand img { width: 36px; height: 36px; }
    .brand-copy strong { font-size: 13px; }
    .brand-copy small { font-size: 7px; }
    .nav-toggle { left: 141px; top: 16px; }
    .header-title h1 { font-size: 17px; }
    .header-title p { font-size: 10px; }
    .header-tools { gap: 2px; padding-right: 4px; }
    .header-tools a { width: 24px; height: 24px; font-size: 13px; }
    .primary-nav { top: 62px; }
    .tool-layout { display: block; }
    .control-rail { padding: 10px; }
    .control-card { margin-bottom: 7px; }
    .control-card-heading { min-height: 34px; font-size: 11px; }
    .control-card-body { padding: 9px; }
    .field-row { grid-template-columns: 120px minmax(0,1fr); font-size: 11px; }
    .field-row input[type="text"], .field-row input[type="number"], .field-row select,
    .form-grid input, .form-grid select, .annotation-panel textarea { height: 32px; font-size: 11px; }
    .range-control { grid-template-columns: 55px 35px minmax(70px,1fr); }
    .readout-row { font-size: 11px; }
    .workspace { padding: 10px; }
    .canvas-stage { height: 58vw; min-height: 340px; }
    .viewport-controls { grid-template-columns: 1fr auto; }
    .viewport-controls > label:nth-of-type(2) { grid-column: 1; }
    .viewport-controls > .viewport-button-group:last-child { grid-column: 2; grid-row: 2; }
    .legend-panel { grid-template-columns: 1fr; gap: 12px; padding: 13px; }
    .legend-divider { display: none; }
    .results-rail { display: grid; grid-template-columns: 1fr; padding: 0 10px 20px; }
    .results-panel { grid-row: auto; }
    .lower-grid { grid-template-columns: 1fr; }
    .pdf-frame { height: 420px; }
    .equation-grid { grid-template-columns: 1fr; }
    .references-panel ol { columns: 1; }
    .about-section { grid-template-columns: 1fr; gap: 10px; }
    .site-footer { flex-direction: column; align-items: flex-start; padding: 12px; }
    .site-footer nav { flex-wrap: wrap; gap: 10px 18px; }
}

@media (max-width: 520px) {
    .site-header { grid-template-columns: 150px minmax(0,1fr) 34px; }
    .brand-copy strong { font-size: 11px; }
    .brand-copy small { letter-spacing: .16em; }
    .nav-toggle { left: 116px; }
    .header-title { padding-left: 4px; padding-right: 4px; }
    .header-title h1 { font-size: 14px; line-height: 1.1; }
    .header-title p { display: none; }
    .header-tools a:not(:last-child) { display: none; }
    .field-row { grid-template-columns: 100px minmax(0,1fr); }
    .range-control { grid-template-columns: 52px 31px minmax(55px,1fr); }
    .canvas-stage { min-height: 310px; height: 78vw; }
    .layer-button { flex-basis: 64px; }
    .viewport-controls { grid-template-columns: 1fr; }
    .viewport-controls > .viewport-button-group, .viewport-controls > .viewport-button-group:last-child { grid-column: 1; grid-row: auto; flex-wrap: wrap; }
    .stage-help { display: none; }
    .legend-values { font-size: 6px; }
    .lower-grid { margin-top: 16px; }
    .form-grid.two-col, .citation-row { grid-template-columns: 1fr; }
    .equations-section { padding: 22px 14px; }
    .section-heading h2 { font-size: 22px; }
}

@media print {
    .site-header, .control-rail, .viewport-controls, .annotation-panel, .site-footer, .run-actions { display: none !important; }
    .tool-layout { display: block; }
    .workspace, .results-rail { padding: 0; background: #fff; }
    .visualizer-panel { break-inside: avoid; }
    .canvas-stage { height: 500px; }
}
