/* LensForge web: a desktop-style window (menu bar, toolbar, docks, status bar) like the Qt app. */
:root {
  --bg: #eef0f3;
  --panel: #ffffff;
  --border: #c4c9d0;
  --border-soft: #dde1e6;
  --text: #1d232a;
  --muted: #5f6b77;
  --accent: #1f5f99;
  --accent-soft: #dceaf7;
  --select: #cfe3f7;
  --current: #3d84c6;
  --solve-bg: #e1eeff;
  --var-bg: #fff6d6;
  --missing-bg: #ffcdcd;
  --na-bg: #f2f2f2;
  --error: #a00000;
  --menu-hover: #dceaf7;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
body { font: 13px/1.35 var(--ui); color: var(--text); background: var(--bg); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Pinned to the viewport, so touch browsers (iPad Safari) cannot scroll or rubber-band the menu bar off the
   top of the screen, e.g. after the on-screen keyboard opened for a cell edit. */
#app { display: flex; flex-direction: column; position: fixed; inset: 0; }

/* ---------------------------------------------------------------- menu bar */
#menubar { display: flex; background: var(--panel); border-bottom: 1px solid var(--border);
  -webkit-user-select: none; user-select: none; padding: 0 2px; flex: none; overflow-x: auto; scrollbar-width: none;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; position: relative; z-index: 10; }
#menubar::-webkit-scrollbar { display: none; }
.menu-top { padding: 4px 10px; cursor: default; border-radius: 3px; margin: 1px 0; flex: none; white-space: nowrap;
  -webkit-touch-callout: none; }
.menu-top.open, .menu-top:hover { background: var(--menu-hover); }
.menu-popup { position: fixed; z-index: 1000; background: var(--panel); border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0,0,0,.18); padding: 3px 0; min-width: 220px; max-height: calc(100vh - 20px);
  max-height: calc(100dvh - 20px); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  -webkit-user-select: none; user-select: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none; }
.menu-item { display: flex; align-items: center; gap: 8px; padding: 3px 14px 3px 6px; cursor: default;
  white-space: nowrap; position: relative; }
.menu-item:hover, .menu-item.active { background: var(--menu-hover); }
.menu-item.disabled { color: #9aa3ad; }
.menu-item.disabled:hover { background: none; }
.menu-item .mi-icon { width: 18px; height: 18px; flex: none; display: flex; align-items: center; justify-content: center; }
.menu-item .mi-icon img { width: 16px; height: 16px; }
.menu-item .mi-check { font-weight: bold; color: var(--accent); }
.menu-item .mi-label { flex: 1; }
.menu-item .mi-sc { color: var(--muted); margin-left: 24px; font-size: 12px; }
.menu-item .mi-arrow { color: var(--muted); margin-left: 12px; }
.menu-sep { height: 1px; background: var(--border-soft); margin: 3px 6px; }
/* Finger-sized menus on touch screens (iPad, tablets). */
@media (pointer: coarse) {
  .menu-top { padding: 9px 14px; }
  .menu-item { padding: 9px 16px 9px 8px; }
}

/* ---------------------------------------------------------------- toolbar */
#toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 1px; padding: 2px 4px; background: var(--panel);
  border-bottom: 1px solid var(--border); flex: none; }
.tb-btn { display: flex; align-items: center; gap: 4px; border: 1px solid transparent; background: none;
  border-radius: 3px; padding: 3px; cursor: default; min-height: 30px; }
.tb-btn:hover { background: var(--menu-hover); border-color: #b7cde3; }
.tb-btn:active { background: var(--select); }
.tb-btn img { width: 22px; height: 22px; }
.tb-btn.style-icons-text { flex-direction: column; gap: 0; font-size: 11px; padding: 2px 4px; }
.tb-btn .tb-text { white-space: nowrap; }
.tb-sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }

/* ---------------------------------------------------------------- workspace and docks */
/* The Lens Data Editor (#center) keeps a minimum size: when space runs out the docks shrink instead
   (flex-shrink 1 down to their own minimum), so a dock dragged or opened too large never covers it. */
#workspace { flex: 1; display: flex; min-height: 120px; }
#center { flex: 1; min-width: 240px; display: flex; flex-direction: column; min-height: 0; }
.dock { background: var(--bg); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#left-dock { width: 240px; flex: 0 1 auto; min-width: 120px; }
#right-dock { width: 48%; flex: 0 1 auto; min-width: 160px; }
#bottom-dock { height: 34%; flex: 0 1 auto; min-height: 80px; }
.splitter { background: var(--bg); flex: none; touch-action: none; }
.splitter.vertical { width: 5px; cursor: col-resize; }
.splitter.horizontal { height: 5px; cursor: row-resize; }
.splitter:hover { background: #c9d6e3; }
.dock-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; background: var(--panel);
  border: 1px solid var(--border); }
.dock-title { display: flex; align-items: center; gap: 6px; padding: 2px 4px 2px 8px; background: #e4e8ec;
  border-bottom: 1px solid var(--border); font-weight: 600; user-select: none; flex: none; min-height: 24px; }
.dock-title .dt-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-title button, .win-title button { border: none; background: none; width: 20px; height: 20px; padding: 0;
  border-radius: 3px; cursor: default; color: var(--muted); font-size: 14px; line-height: 20px; }
.dock-title button:hover, .win-title button:hover { background: #cdd5de; color: var(--text); }
.dock-tabs { display: flex; flex-wrap: wrap; background: #e4e8ec; border-bottom: 1px solid var(--border);
  flex: none; user-select: none; }
.dock-tab { padding: 4px 6px 4px 10px; border-right: 1px solid var(--border); cursor: default; white-space: nowrap;
  display: flex; align-items: center; gap: 4px; max-width: 260px; }
.dock-tab span { overflow: hidden; text-overflow: ellipsis; }
.dock-tab.active { background: var(--panel); font-weight: 600; margin-bottom: -1px; border-bottom: 1px solid var(--panel); }
.dock-tab button { border: none; background: none; width: 16px; height: 16px; padding: 0; line-height: 16px;
  font-size: 13px; color: var(--muted); border-radius: 2px; }
.dock-tab button:hover { background: #cdd5de; color: var(--text); }
.dock-body { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--panel); }
.dock-body > .pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- floating windows and modal dialogs */
#floating-layer { position: fixed; inset: 0; pointer-events: none; z-index: 500; }
#modal-layer { position: fixed; inset: 0; pointer-events: none; z-index: 800; }
#modal-layer.active { pointer-events: auto; background: rgba(20, 30, 40, .18); }
.window { position: absolute; pointer-events: auto; background: var(--panel); border: 1px solid #9aa6b2;
  box-shadow: 0 8px 28px rgba(0,0,0,.25); display: flex; flex-direction: column; min-width: 260px; min-height: 120px;
  border-radius: 4px; overflow: hidden; resize: both; }
.window.dialog { resize: none; }
.window.dialog.resizable { resize: both; }
.win-title { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; background: #e4e8ec;
  border-bottom: 1px solid var(--border); font-weight: 600; cursor: move; user-select: none; flex: none; }
.win-title .wt-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win-body { flex: 1; min-height: 0; overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.win-body.flush { padding: 0; gap: 0; }
.win-buttons { display: flex; justify-content: flex-end; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--border-soft);
  flex: none; background: #f7f8fa; }
.win-buttons .left { margin-right: auto; display: flex; gap: 6px; }

button.btn { border: 1px solid #aeb7c1; background: linear-gradient(#fdfdfd, #eceff2); border-radius: 3px;
  padding: 3px 12px; min-height: 26px; cursor: default; }
button.btn:hover:not(:disabled) { border-color: #7f9bb8; background: linear-gradient(#fff, #e3ebf3); }
button.btn:active:not(:disabled) { background: #dbe5ef; }
button.btn.primary { border-color: #3d73a8; }
button.btn:disabled { color: #9aa3ad; }
button.btn.small { padding: 1px 8px; min-height: 22px; }
input[type=text], input[type=number], input:not([type]), select, textarea { border: 1px solid #aeb7c1; border-radius: 3px;
  padding: 3px 5px; background: #fff; min-height: 24px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #8bb8e3; outline-offset: -1px; border-color: #5a8fc4; }
input[type=number] { width: 90px; }
textarea { resize: vertical; }
label.check { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
fieldset { border: 1px solid var(--border); border-radius: 4px; padding: 6px 10px 10px; margin: 0; }
legend { padding: 0 4px; font-weight: 600; }
.form { display: grid; grid-template-columns: max-content 1fr; gap: 6px 10px; align-items: center; }
.form > .full { grid-column: 1 / -1; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.error-text { color: var(--error); }
.note { color: var(--muted); font-size: 12px; }
pre.mono, textarea.mono, .mono { font-family: var(--mono); font-size: 12px; }
pre.mono { margin: 0; white-space: pre; overflow: auto; }

.tabs { display: flex; border-bottom: 1px solid var(--border); gap: 2px; flex: none; }
.tabs .tab { padding: 5px 12px; border: 1px solid transparent; border-bottom: none; border-radius: 4px 4px 0 0;
  cursor: default; background: #eef1f4; }
.tabs .tab.active { background: var(--panel); border-color: var(--border); margin-bottom: -1px; font-weight: 600; }
.tab-page { display: none; flex: 1; min-height: 0; flex-direction: column; gap: 8px; padding-top: 8px; }
.tab-page.active { display: flex; }

/* simple data tables (dialogs) */
table.grid { border-collapse: collapse; width: 100%; }
table.grid th, table.grid td { border: 1px solid var(--border-soft); padding: 2px 5px; text-align: left; white-space: nowrap; }
table.grid th { background: #eef1f4; font-weight: 600; position: sticky; top: 0; z-index: 1; }
table.grid tr.sel td { background: var(--select); }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td input { width: 100%; border: none; min-height: 20px; padding: 1px 3px; background: transparent; }
table.grid td input:focus { outline: 2px solid #8bb8e3; background: #fff; }
.table-wrap { overflow: auto; border: 1px solid var(--border); flex: 1; min-height: 80px; background: #fff; }

/* ---------------------------------------------------------------- spreadsheet editors (LDE, MFE, MCE) */
#lde-panel { border: 1px solid var(--border); }
#lde { flex: 1; overflow: auto; outline: none; background: #fff; position: relative; }
table.sheet { border-collapse: separate; border-spacing: 0; table-layout: fixed; font-variant-numeric: tabular-nums; }
table.sheet th { position: sticky; top: 0; z-index: 2; background: #eef1f4; border-right: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border); padding: 3px 6px; font-weight: 600; text-align: left; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; user-select: none; }
table.sheet td { border-right: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft);
  padding: 0 4px; height: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: cell;
  position: relative; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
table.sheet td.num { text-align: right; }
table.sheet td.center { text-align: center; }
table.sheet td.rowhead { background: #f5f6f8; text-align: center; cursor: default; color: var(--muted); }
table.sheet td.rowhead.stop { font-weight: bold; color: var(--text); }
table.sheet td.na { background: var(--na-bg); cursor: default; }
table.sheet td.solve { background: var(--solve-bg); }
table.sheet td.var { background: var(--var-bg); }
table.sheet td.missing { background: var(--missing-bg); }
table.sheet td.auto { color: #6e6e6e; }
table.sheet td.weight0 { color: #787878; }
table.sheet td.negw { background: #ffecec; }
table.sheet td.blank { background: #f5f5f5; }
table.sheet td.value { background: #f8f8fc; }
table.sheet td.current-config { background: #fff8d6; }
table.sheet td.mcvar { background: #deebff; }
table.sheet td.mcerr { background: #ffdede; }
table.sheet tr.selrow td:not(.rowhead) { box-shadow: inset 0 0 0 999px rgba(61, 132, 198, .14); }
table.sheet td.cur { outline: 2px solid var(--current); outline-offset: -2px; }
table.sheet td .mk { position: absolute; right: 2px; top: 3px; font-size: 10px; font-weight: bold; color: #1e50aa; }
table.sheet td .mk.u { color: #787878; }
table.sheet td.has-mk { padding-right: 14px; }
table.sheet td.editing { padding: 0; overflow: visible; }
table.sheet td.editing input, table.sheet td.editing select { width: 100%; height: 21px; border: none; border-radius: 0;
  outline: 2px solid var(--current); outline-offset: -2px; padding: 0 4px; min-height: 0; }
.mat-editor { display: flex; height: 21px; }
.mat-editor input { flex: 1; min-width: 0; }
.mat-editor button { border: 1px solid #aeb7c1; background: #eef1f4; padding: 0 5px; height: 21px; line-height: 18px; }
.complete-pop { position: fixed; z-index: 1100; background: #fff; border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,.18); max-height: 300px; overflow-y: auto; min-width: 160px; }
.complete-pop div { padding: 2px 8px; cursor: default; white-space: nowrap; }
.complete-pop div.active, .complete-pop div:hover { background: var(--menu-hover); }

.editor-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 2px 4px; border-bottom: 1px solid var(--border-soft);
  background: #f7f8fa; flex: none; align-items: center; }
.editor-bar button { border: 1px solid transparent; background: none; border-radius: 3px; padding: 2px 8px; cursor: default; }
.editor-bar button:hover { background: var(--menu-hover); border-color: #b7cde3; }
.editor-bar .sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.editor-sheet { flex: 1; overflow: auto; min-height: 0; background: #fff; outline: none; }
.editor-foot { padding: 3px 8px; border-top: 1px solid var(--border-soft); font-weight: 600; flex: none; }
.editor-foot.plain { font-weight: normal; }

/* ---------------------------------------------------------------- analysis windows */
.an-bar { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; padding: 3px 6px;
  border-bottom: 1px solid var(--border-soft); background: #f7f8fa; flex: none; }
.an-bar label { display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; }
.an-bar select, .an-bar input { min-height: 22px; padding: 1px 4px; }
.an-bar input[type=number] { width: 76px; }
.an-body { flex: 1; min-height: 0; position: relative; overflow: hidden; background: #fff; display: flex; }
.an-body img { width: 100%; height: 100%; object-fit: contain; display: block; }
.an-body pre { flex: 1; padding: 6px 8px; }
.an-body canvas.view3d { display: block; position: absolute; inset: 0; cursor: grab; touch-action: none; user-select: none; }
.an-body canvas.view3d:active { cursor: grabbing; }
.an-body img.zoomable { cursor: crosshair; touch-action: pinch-zoom; user-select: none; }
.an-zoombox { position: absolute; border: 1px dashed #1a73e8; background: rgba(26,115,232,.12); pointer-events: none; }
.an-busy { position: absolute; top: 6px; right: 8px; background: rgba(255,255,255,.9); border: 1px solid var(--border);
  border-radius: 3px; padding: 1px 8px; font-size: 12px; color: var(--muted); }
.an-error { color: var(--error); padding: 3px 8px; border-top: 1px solid var(--border-soft); flex: none; white-space: pre-wrap; }
.an-foot { display: flex; gap: 6px; justify-content: flex-end; padding: 3px 6px; border-top: 1px solid var(--border-soft);
  background: #f7f8fa; flex: none; }

/* ---------------------------------------------------------------- status bar */
#statusbar { display: flex; gap: 14px; align-items: center; padding: 2px 8px; background: #e4e8ec;
  border-top: 1px solid var(--border); min-height: 24px; flex: none; white-space: nowrap; overflow: hidden; }
#status-msg { flex: 1; overflow: hidden; text-overflow: ellipsis; }
#status-config { font-weight: bold; }
#status-lens.error { color: var(--error); font-weight: bold; }
#status-merit { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- misc widgets */
.undo-list { flex: 1; overflow: auto; background: #fff; }
.undo-list div { padding: 2px 8px; cursor: default; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.undo-list div.current { background: var(--select); font-weight: 600; }
.undo-list div.future { color: #9aa3ad; }
.undo-list div:hover { background: var(--menu-hover); }
.list { overflow: auto; border: 1px solid var(--border); background: #fff; flex: 1; min-height: 80px; }
.list > div { padding: 2px 8px; cursor: default; white-space: nowrap; }
.list > div.sel { background: var(--select); }
.list > div.sep-item { color: var(--muted); text-align: center; }
.list > div:hover:not(.sel) { background: #eef4fa; }
.list > div.group { font-weight: 600; background: #f2f4f6; }
.tree { overflow: auto; border: 1px solid var(--border); background: #fff; }
.tree .node { padding: 2px 6px; cursor: default; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.tree .node img { width: 16px; height: 16px; }
.tree .node.sel { background: var(--select); }
.tree .node:hover:not(.sel) { background: #eef4fa; }
.tree .node.branch { font-weight: 600; }
.help-page { overflow: auto; padding: 4px 14px 14px; line-height: 1.5; background: #fff; border: 1px solid var(--border); }
.help-page h2 { margin: .4em 0; }
.help-page code { font-family: var(--mono); background: #f2f4f6; padding: 0 3px; border-radius: 2px; }
.help-page table { border-collapse: collapse; }
.help-head { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.help-head img { width: 40px; height: 40px; }
.whats-this, .whats-this * { cursor: help !important; }
.tip-pop { position: fixed; z-index: 1200; max-width: 420px; background: #fffff2; border: 1px solid #b9b48a;
  box-shadow: 0 4px 14px rgba(0,0,0,.2); padding: 8px 10px; border-radius: 3px; line-height: 1.45; }
.ctx-check { width: 18px; display: inline-block; text-align: center; color: var(--accent); }
.glass-map { width: 100%; height: 100%; display: block; background: #fff; border: 1px solid var(--border); }
.glass-map circle { fill: #1f77b4; cursor: pointer; }
.glass-map circle.hl { fill: none; stroke: crimson; stroke-width: 2.5; }
.glass-map text { font-size: 9px; fill: #555; pointer-events: none; }
.glass-map .axis { stroke: #888; }
.glass-map .gridline { stroke: #e3e3e3; }
.glass-map .lab { font-size: 11px; fill: #333; }
.pupil-preview { width: 170px; height: 190px; flex: none; }
.pupil-preview.wizard-pupil { width: 180px; height: 212px; }
/* Merit Function Wizard: sections in two columns like the Qt dialog, stacked on narrow screens */
.wizard-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-items: start; }
.wizard-cols > div { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.wizard-cols .form > *, .wizard-cols .row > * { min-width: 0; }
.wizard-cols select { width: 100%; }
.wizard-cols .row { flex-wrap: wrap; }
.wizard-cols input[type=number] { width: 100%; max-width: 120px; box-sizing: border-box; }
@media (max-width: 720px) { .wizard-cols { grid-template-columns: minmax(0, 1fr); } }
.drop-hint { position: fixed; inset: 0; background: rgba(31, 95, 153, .15); border: 4px dashed var(--accent);
  z-index: 2000; display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--accent);
  pointer-events: none; }

/* ---------------------------------------------------------------- splash */
#splash { position: fixed; inset: 0; z-index: 3000; background: radial-gradient(circle at 50% 35%, #2a1a14, #120b08);
  display: flex; align-items: center; justify-content: center; color: #f7e9d7; }
#splash.gone { display: none; }
.splash-box { text-align: center; max-width: 480px; padding: 20px; }
.splash-box h1 { margin: 10px 0 6px; font-weight: 600; letter-spacing: .5px; }
#splash-msg { min-height: 1.4em; color: #ffcf7a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.splash-bar { height: 6px; background: rgba(255,255,255,.12); border-radius: 3px; overflow: hidden; margin: 10px 0; }
#splash-progress { height: 100%; width: 3%; background: linear-gradient(90deg, #e2541c, #ffb23a); transition: width .3s; }
.splash-note { font-size: 12px; color: #b9a99a; }
#splash.failed #splash-msg { color: #ff8a7a; white-space: normal; }

/* ---------------------------------------------------------------- Type cells: the operand menu */
table.sheet td.combo { padding-right: 18px; }
table.sheet td.combo::after { content: "▾"; position: absolute; right: 0; top: 0; width: 18px; height: 100%;
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; }
table.sheet td.combo:hover::after { background: var(--menu-hover); color: var(--text); }
table.sheet td.combo.editing::after { display: none; }
.combo-list { position: fixed; z-index: 1100; background: var(--panel); border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0,0,0,.2); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; padding: 2px 0; }
.combo-group { padding: 5px 8px 2px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: none;
  border-top: 1px solid var(--border-soft); position: sticky; top: -2px; background: #f5f7f9; }
.combo-group:first-child { border-top: none; }
.combo-item { display: flex; gap: 8px; padding: 3px 8px; cursor: default; white-space: nowrap; }
.combo-item b { font-family: var(--mono); font-weight: 600; flex: none; width: 3.6em; }
.combo-item span { overflow: hidden; text-overflow: ellipsis; color: #39434d; }
.combo-item:hover { background: #eef4fa; }
.combo-item.hi { background: var(--select); }
.combo-none { padding: 6px 8px; color: var(--muted); font-style: italic; }
@media (pointer: coarse) { .combo-item { padding: 7px 10px; } table.sheet td.combo { padding-right: 24px; }
  table.sheet td.combo::after { width: 24px; } }

/* ---------------------------------------------------------------- an editor in its own tab (popout.html) */
.win-extra { display: contents; }
.editor-bar button.pop-toggle { color: var(--accent); }
#popout-app { display: flex; flex-direction: column; position: fixed; inset: 0; }
#popout-root { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--panel); }
#popout-root > .pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.popout-bar { display: flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px; background: #e4e8ec;
  border-bottom: 1px solid var(--border); flex: none; min-height: 28px; user-select: none; }
.popout-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popout-msg { padding: 24px; max-width: 640px; }
.win-pop > .win-body { flex: 1; min-height: 0; }

/* solve dialog: formula preview and syntax */
.solve-preview { margin: 6px 0; padding: 4px 6px; background: #eef6ee; border: 1px solid var(--border-soft); }
.solve-preview.error { background: #fbeceb; color: #a1261d; }
.solve-help { margin-top: 6px; }
/* the solve dialog grows with its fields (Safari would squeeze the body of an auto-height window and hide
   them behind the buttons), up to the visible height, then scrolls */
.window.solve-dialog { max-height: calc(100% - 20px); }
.window.solve-dialog > .win-body { flex: 1 1 auto; }
.window.solve-dialog > .win-body > * { flex-shrink: 0; }
