:root { color-scheme: dark; --bg:#0f141a; --panel:#18202a; --line:#2b3745; --text:#e6edf3; --accent:#2f81f7; --err:#f85149; }
* { box-sizing: border-box; }
html, body { margin:0; height:100%; overflow:hidden; background:var(--bg); color:var(--text); font-family:system-ui, "Segoe UI", sans-serif; font-size:14px; }
#app { height:100%; }
#app.loading { display:grid; place-items:center; }

/* Layout: panel + viewport fill the whole window; the canvas follows the viewport size. */
.layout { display:flex; height:100%; height:100dvh; width:100%; position:relative; }
.panel { flex:0 0 auto; width:340px; padding:16px; background:var(--panel); border-right:1px solid var(--line); overflow:auto; display:flex; flex-direction:column; gap:10px; }
.panel.collapsed { display:none; }
.panel h1 { margin:0; font-size:20px; }
.hint { margin:0 0 6px; color:#8b98a5; font-size:12px; }

.view { flex:1 1 0; min-width:0; min-height:0; position:relative; overflow:hidden; }
.view canvas { position:absolute; inset:0; width:100%; height:100%; display:block; touch-action:none; }

.panel { position:relative; }
.panel h1 { padding-right:36px; }
.panel-toggle { position:absolute; top:8px; right:8px; z-index:5; padding:6px 10px; background:rgba(24,32,42,.85); backdrop-filter:blur(4px); }

label { display:flex; flex-direction:column; gap:4px; font-size:12px; color:#9fb0c0; }
label.check { flex-direction:row; align-items:center; gap:8px; font-size:13px; color:var(--text); }
label.check.disabled { color:#6e7b88; }
input[type=text], input[type=number] { width:100%; padding:7px 9px; background:#0f141a; color:var(--text); border:1px solid var(--line); border-radius:6px; font:inherit; }
input[type=text] { font-family:Consolas, monospace; font-size:15px; }
textarea.formula { width:100%; min-height:90px; padding:8px 10px; background:#0f141a; color:var(--text); border:1px solid var(--line); border-radius:6px; font-family:Consolas, monospace; font-size:16px; line-height:1.4; resize:vertical; }
select { width:100%; padding:7px 9px; background:#0f141a; color:var(--text); border:1px solid var(--line); border-radius:6px; font:inherit; }
textarea:focus, select:focus { outline:2px solid var(--accent); outline-offset:-1px; }
input[type=range] { width:100%; }
input:not([type=range]):focus { outline:2px solid var(--accent); outline-offset:-1px; }
.grid2 { display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:8px; }
.grid3 { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:8px; }

button { font:inherit; cursor:pointer; border-radius:6px; border:1px solid var(--line); background:#222d3a; color:var(--text); padding:8px 12px; }
button:hover:not(:disabled) { background:#2b3948; }
button.primary { background:var(--accent); border-color:var(--accent); font-weight:600; padding:10px; }
button.primary:hover:not(:disabled) { background:#4893ff; }
button.active { border-color:var(--accent); box-shadow:inset 0 0 0 1px var(--accent); }
button:disabled { opacity:.65; cursor:default; }
.examples { display:flex; flex-wrap:wrap; gap:5px; }
.chip { padding:3px 8px; font-size:11px; font-family:Consolas, monospace; border-radius:12px; }

.msg { padding:8px 10px; border-radius:6px; background:#0f141a; border:1px solid var(--line); font-size:12px; color:#9fb0c0; }
.msg.error { border-color:var(--err); color:var(--err); }
details { font-size:12px; color:#9fb0c0; }
.mode-info summary { cursor:pointer; }
.mode-info .hint { margin:6px 0 0; }
code { background:#0f141a; padding:1px 4px; border-radius:4px; }

.constraints-summary code { word-break:break-all; }

/* Pseudo-modal dialog: dims and blocks the page until closed. */
.modal-backdrop { position:fixed; inset:0; z-index:100; background:rgba(0,0,0,.55); display:grid; place-items:center; padding:16px; }
.modal { width:min(620px, 100%); max-height:100%; overflow:auto; background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:18px; display:flex; flex-direction:column; gap:10px; box-shadow:0 12px 40px rgba(0,0,0,.5); }
.modal h2 { margin:0; font-size:17px; }
.modal .hint { line-height:1.5; }
.modal-buttons { display:flex; gap:8px; align-items:center; }
.modal-buttons .spacer { flex:1 1 auto; }

/* Boundary conditions dialog: the boundary drawn in math coordinates (y negated), parts clickable. */
.bc-modal { width:min(760px, 100%); }
.bc-modal:focus { outline:none; }
.bc-view { width:100%; max-height:46vh; background:#0d1218; border:1px solid var(--line); border-radius:8px; }
.bc-box { fill:none; stroke:#3a4654; stroke-width:1; stroke-dasharray:4 4; vector-effect:non-scaling-stroke; }
.bc-part { cursor:pointer; }
.bc-hit { fill:none; stroke:transparent; stroke-width:16; vector-effect:non-scaling-stroke; pointer-events:stroke; }
.bc-line { fill:none; stroke:#7f8ea0; stroke-width:2.5; stroke-linejoin:round; vector-effect:non-scaling-stroke; }
.bc-part:hover .bc-line { stroke:#c9d4df; stroke-width:4; }
.bc-part.dirichlet .bc-line { stroke:#ff5533; stroke-width:4; }
.bc-part.dirichlet:hover .bc-line { stroke:#ff8866; }
.bc-corner { fill:#c9d4df; pointer-events:none; }
.bc-label { fill:#e8eef5; stroke:#0d1218; stroke-width:3px; paint-order:stroke; vector-effect:non-scaling-stroke; text-anchor:middle; dominant-baseline:middle; pointer-events:none; font-weight:600; }
.bc-list { display:flex; flex-direction:column; gap:4px; max-height:26vh; overflow:auto; }
.bc-row { display:flex; flex-wrap:wrap; align-items:center; gap:4px 12px; }
.bc-row code { word-break:break-all; }
.bc-formula { display:flex; align-items:center; gap:6px; flex:1 1 220px; }
.bc-formula input { flex:1 1 auto; font-family:ui-monospace, Consolas, monospace; }

#blazor-error-ui { display:none; position:fixed; left:0; right:0; bottom:0; padding:10px 20px; background:#5a1d1d; z-index:1000; }
#blazor-error-ui .dismiss { cursor:pointer; position:absolute; right:12px; top:8px; }
#blazor-error-ui a { color:#fff; }

/* Narrow windows / phones: viewport on top, controls below it. */
@media (max-width: 760px) {
    .layout { flex-direction:column; }
    .panel { order:2; width:100%; max-height:48%; border-right:0; border-top:1px solid var(--line); }
    .view { order:1; }
}