/* Surdbox — design system. IBM Plex Sans, cool neutrals, one indigo accent, 34px controls, dark navigation rail. */
:root {
  --bg: #f4f5f8; --panel: #ffffff; --panel2: #f1f3f7; --text: #0f172a; --muted: #5b6577; --faint: #94a0b4; --border: #e3e7ee; --border-strong: #cdd4e0;
  --accent: #4338ca; --accent-fg: #ffffff; --accent-soft: #eceefe; --accent-line: #c3c8f7; --danger: #d92d20; --ok: #0e9f6e;
  --rail: #0f172a; --rail-text: #94a0b4; --rail-active: rgba(255, 255, 255, .1);
  --plot-bg: #ffffff; --plot-grid: #eef1f6; --plot-axis: #5b6577; --sel: #eceefe;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06); --shadow: 0 16px 48px rgba(15, 23, 42, .18);
  --r: 10px; --h: 34px;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0d14; --panel: #10141d; --panel2: #161b26; --text: #e6e9f0; --muted: #8e99ad; --faint: #596277; --border: #1c2230; --border-strong: #2a3244;
    --accent: #8b93ff; --accent-fg: #0a0d14; --accent-soft: #1a1e3d; --accent-line: #343c7a; --danger: #f87171; --ok: #34d399;
    --rail: #06080d; --rail-text: #6b7488; --rail-active: rgba(255, 255, 255, .08);
    --plot-bg: #0d1119; --plot-grid: #181e2b; --plot-axis: #8e99ad; --sel: #1a1e3d; --shadow-sm: none; --shadow: 0 20px 56px rgba(0, 0, 0, .6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0d14; --panel: #10141d; --panel2: #161b26; --text: #e6e9f0; --muted: #8e99ad; --faint: #596277; --border: #1c2230; --border-strong: #2a3244;
  --accent: #8b93ff; --accent-fg: #0a0d14; --accent-soft: #1a1e3d; --accent-line: #343c7a; --danger: #f87171; --ok: #34d399;
  --rail: #06080d; --rail-text: #6b7488; --rail-active: rgba(255, 255, 255, .08);
  --plot-bg: #0d1119; --plot-grid: #181e2b; --plot-axis: #8e99ad; --sel: #1a1e3d; --shadow-sm: none; --shadow: 0 20px 56px rgba(0, 0, 0, .6); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 14px/1.5 var(--sans); display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-line); }
input, select, textarea { background: var(--panel); border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 11px; height: var(--h); min-width: 0; transition: border-color .15s, box-shadow .15s; }
textarea { height: auto; padding: 8px 11px; }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=range] { accent-color: var(--accent); padding: 0; height: auto; box-shadow: none; }
input[type=checkbox] { width: 15px; height: 15px; }
input:disabled { opacity: .55; }
select { appearance: none; padding-right: 28px; background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%2394a0b4' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 10px center; }
h3, h4 { margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 15px; }
h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); font-weight: 600; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--panel2); padding: 2px 6px; border-radius: 5px; }
.muted { color: var(--muted); } .error { color: var(--danger); } .ok { color: var(--ok); }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; } ::-webkit-scrollbar-thumb:hover { background: var(--faint); border: 3px solid transparent; background-clip: padding-box; } ::-webkit-scrollbar-track { background: transparent; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: #fff; font: italic 600 17px/1 Georgia, "Times New Roman", serif; flex: none; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: var(--h); border: 1px solid var(--border-strong); background: var(--panel); border-radius: 8px; padding: 0 14px; cursor: pointer; transition: background .12s, border-color .12s, transform .05s; white-space: nowrap; font-weight: 500; box-shadow: var(--shadow-sm); }
.btn:hover { background: var(--panel2); border-color: var(--faint); }
.btn:active { transform: translateY(.5px); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; gap: 6px; box-shadow: none; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.btn.primary:hover { background: var(--accent); filter: brightness(1.12); }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn i { font-size: .9em; opacity: .75; } .btn.primary i { opacity: 1; }
button:disabled { opacity: .4; cursor: default; }
.icon { border: 0; background: transparent; cursor: pointer; color: var(--faint); font-size: 14px; line-height: 1; padding: 6px 7px; border-radius: 6px; transition: background .12s, color .12s; }
.icon:hover { background: var(--panel2); color: var(--text); }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; align-items: center; }

/* shell: dark rail + content */
.shell { flex: 1; min-height: 0; display: flex; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rail { width: 72px; flex: none; background: var(--rail); display: flex; flex-direction: column; align-items: center; padding: 14px 0 12px; gap: 4px; z-index: 6; }
.rail-logo { margin-bottom: 18px; } .rail-logo .logo { width: 36px; height: 36px; border-radius: 11px; font-size: 20px; }
.app-tab { width: 56px; padding: 9px 0 7px; border: 0; background: transparent; cursor: pointer; color: var(--rail-text); display: flex; flex-direction: column; align-items: center; gap: 5px; border-radius: 10px; transition: background .15s, color .15s; position: relative; }
.app-tab i { font-size: 17px; } .app-tab span { font-size: 10.5px; font-weight: 500; letter-spacing: .02em; }
.app-tab:hover { color: #fff; background: var(--rail-active); }
.app-tab.active { color: #fff; background: var(--rail-active); }
.app-tab.active::before { content: ""; position: absolute; left: -8px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); filter: brightness(1.5); }
.rail-btn { width: 38px; height: 38px; border: 0; background: transparent; color: var(--rail-text); border-radius: 10px; cursor: pointer; font-size: 15px; transition: background .15s, color .15s; }
.rail-btn:hover { background: var(--rail-active); color: #fff; }
.spacer { flex: 1; }

.topbar { display: flex; align-items: center; gap: 14px; padding: 0 22px; height: 52px; background: var(--panel); border-bottom: 1px solid var(--border); flex: none; }
.doc-title { display: flex; align-items: center; gap: 9px; border: 0; background: transparent; cursor: pointer; padding: 6px 10px; margin-left: -10px; border-radius: 8px; font-size: 15px; font-weight: 600; max-width: 380px; transition: background .12s; }
.doc-title:hover { background: var(--panel2); }
.doc-title i:first-child { color: var(--faint); font-size: 14px; font-weight: 400; }
.doc-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { font-size: 9px !important; color: var(--faint); }
.save-state { font-size: 12px; color: var(--faint); display: flex; align-items: center; gap: 6px; }
.save-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.save-state.dirty::before { background: #f59e0b; } .save-state.err::before { background: var(--danger); } .save-state.err { color: var(--danger); }
.user-btn { display: flex; align-items: center; gap: 9px; border: 0; background: transparent; padding: 4px 10px 4px 4px; border-radius: 20px; cursor: pointer; color: var(--text); font-weight: 500; transition: background .12s; }
.user-btn:hover { background: var(--panel2); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; font-weight: 600; font-size: 12.5px; }
.user-menu { position: fixed; top: 56px; right: 16px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); padding: 6px; z-index: 50; min-width: 220px; }
.menu-head { padding: 8px 10px 10px; display: flex; flex-direction: column; border-bottom: 1px solid var(--border); margin-bottom: 4px; } .menu-head small { color: var(--muted); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.menu-item i { width: 16px; text-align: center; color: var(--faint); }
.menu-item:hover { background: var(--panel2); }

main { flex: 1; min-height: 0; position: relative; }
.app { display: none; position: absolute; inset: 0; overflow: hidden; }
.app.active { display: flex; animation: appin .18s ease; }
@keyframes appin { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.site-footer { flex: none; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 0 22px; height: 30px; font-size: 11.5px; color: var(--faint); border-top: 1px solid var(--border); background: var(--panel); }
.site-footer .build { font-variant-numeric: tabular-nums; }

/* calculate — notebook */
.calc-main { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 0 32px 16px; max-width: 1000px; margin: 0 auto; width: 100%; }
.history { flex: 1; overflow-y: auto; padding: 14px 2px; }
.entry { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 16px 6px 18px; border-bottom: 1px solid var(--border); position: relative; }
.entry:last-child { border-bottom: 0; }
.entry .in { color: var(--muted); cursor: pointer; grid-column: 1 / -1; word-break: break-all; font-size: 14px; }
.entry .in.plain { font-family: var(--mono); font-size: 13px; }
.entry .in:hover { color: var(--accent); }
.entry .in .katex { font-size: 1.12em; }
.entry .out { grid-column: 1; text-align: right; overflow-x: auto; padding: 2px 0; }
.entry .out .main .katex-display { margin: .2em 0; } .entry .out .main .katex { font-size: 1.42em; }
.entry .out .approx { color: var(--faint); margin-top: 2px; } .entry .out .approx .katex { font-size: 1.05em; }
.entry .out.error { font-family: var(--mono); font-size: 13px; text-align: left; color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); padding: 9px 12px; border-radius: 8px; }
.entry-tools { grid-column: 2; align-self: center; display: flex; opacity: 0; transition: opacity .15s; } .entry:hover .entry-tools { opacity: 1; }
.empty { text-align: center; padding: 9vh 10px 20px; color: var(--muted); }
.empty h3 { color: var(--text); font-size: 28px; font-weight: 600; letter-spacing: -.025em; margin-bottom: 8px; }
.empty p { max-width: 540px; margin: 0 auto 24px; }
.chip { margin: 4px; border: 1px solid var(--border); background: var(--panel); border-radius: 10px; padding: 8px 14px; cursor: pointer; color: var(--text); transition: border-color .15s, box-shadow .15s, transform .15s; box-shadow: var(--shadow-sm); }
.chip:hover { border-color: var(--accent-line); box-shadow: 0 6px 16px rgba(67, 56, 202, .12); transform: translateY(-1px); }
.chip .katex { font-size: 1em; }
.entry-bar { display: flex; gap: 8px; align-items: flex-end; padding-top: 6px; }
.entry-wrap { flex: 1; min-width: 0; display: flex; }
.entry-wrap > * { flex: 1; min-width: 0; }
.entry-input { resize: none; font-family: var(--mono); font-size: 15px; padding: 12px 14px; border-radius: 12px; max-height: 140px; box-shadow: var(--shadow-sm); }
.entry-bar .btn { height: 50px; border-radius: 12px; }
.ptabs { display: flex; gap: 2px; margin-top: 14px; overflow-x: auto; }
.ptab { border: 0; background: transparent; padding: 0 12px; height: 30px; cursor: pointer; color: var(--muted); border-radius: 7px; white-space: nowrap; font-weight: 500; font-size: 13px; transition: background .12s, color .12s; }
.ptab:hover { color: var(--text); background: var(--panel2); }
.ptab.active { color: var(--accent); background: var(--accent-soft); }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 6px; padding: 10px 0 0; max-height: 178px; overflow-y: auto; }
.key { border: 1px solid var(--border); background: var(--panel); border-radius: 9px; padding: 6px 4px; cursor: pointer; font-size: 13px; color: var(--text); min-height: 38px; display: grid; place-items: center; transition: background .1s, border-color .1s, transform .05s; }
.key:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.key:active { transform: scale(.97); }
.key.small { min-height: 0; padding: 4px 9px; font-size: 12.5px; border-radius: 7px; }
.key .katex { font-size: 1.05em; }
.side { width: 280px; flex: none; border-left: 1px solid var(--border); background: var(--panel); overflow-y: auto; padding: 20px 18px; }
.side-sec { margin-bottom: 26px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 9px 0; color: var(--muted); } .row.check { justify-content: flex-start; }
.row select, .row input[type=number] { width: 140px; color: var(--text); }
.kv { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-family: var(--mono); font-size: 12.5px; border-bottom: 1px solid var(--border); }
.kv b { color: var(--accent); font-weight: 500; } .kvv { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

/* math input */
math-field.mf { display: block; width: 100%; font-size: 21px; padding: 8px 14px; min-height: 50px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s;
  --caret-color: var(--accent); --selection-background-color: var(--accent-line); --placeholder-color: var(--accent); --placeholder-opacity: .5; --contains-highlight-background-color: var(--accent-soft); }
math-field.mf:hover { border-color: var(--faint); }
math-field.mf:focus-within { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
math-field.mf::part(virtual-keyboard-toggle), math-field.mf::part(menu-toggle) { display: none; }
math-field.fn-mf { flex: 1; font-size: 17px; min-height: 38px; padding: 3px 10px; border-radius: 9px; box-shadow: none; }
.fn-sub math-field { margin-right: 4px; }

/* shared */
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }
.controls { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; margin: 8px 0 14px; }
.fld { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); } .fld.stack { margin: 12px 0; }
.fld > span { font-weight: 500; } .fld select, .fld input { color: var(--text); font-size: 14px; }
.tiny { width: 84px; } .tiny.wide { width: 112px; }
table.data { border-collapse: collapse; font-size: 13px; margin: 8px 0; }
.data th, .data td { text-align: left; padding: 7px 20px 7px 0; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.data th { color: var(--muted); font-weight: 500; } .data thead th { position: sticky; top: 0; background: var(--panel); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.striped tbody tr:hover { background: var(--panel2); } .striped td, .striped th { padding-left: 12px; }
.results { margin-top: 10px; }
.canvas-wrap { position: relative; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; background: var(--plot-bg); }
.canvas-wrap.short { height: 330px; } .plot-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.plot-note { color: var(--muted); font-size: 12.5px; margin-top: 8px; font-family: var(--mono); }
.pred-out { font-family: var(--mono); color: var(--accent); }
.table-wrap { overflow: auto; max-height: 280px; border: 1px solid var(--border); border-radius: 10px; padding: 0 14px; } .table-wrap.tall { max-height: 380px; }
.badge { color: var(--accent); font-weight: 700; }

/* spreadsheet */
#app-sheet { flex-direction: column; padding: 16px 22px 18px; gap: 10px; }
.sheet-status { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.formula-bar { display: flex; gap: 10px; align-items: center; }
.namebox { width: 92px; text-align: center; font-weight: 600; background: var(--panel2); border-color: transparent; }
.formula { flex: 1; font-family: var(--mono); font-size: 13px; }
.fx-label { font: italic 15px Georgia, serif; color: var(--faint); }
.grid-scroll { flex: 1; overflow: auto; border: 1px solid var(--border); border-radius: var(--r); background: var(--panel); min-height: 0; }
table.grid { border-collapse: separate; border-spacing: 0; outline: none; font-size: 13px; user-select: none; }
.grid th { background: var(--panel2); color: var(--muted); font-weight: 500; font-size: 11.5px; position: sticky; top: 0; z-index: 2; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px 8px; min-width: 92px; cursor: pointer; }
.grid th:hover { color: var(--text); background: var(--border); }
.grid th.rowh { position: sticky; left: 0; top: auto; min-width: 44px; z-index: 1; text-align: center; }
.grid th.corner { left: 0; z-index: 3; min-width: 44px; }
.grid td { border-right: 1px solid var(--plot-grid); border-bottom: 1px solid var(--plot-grid); padding: 0 9px; height: 28px; min-width: 92px; max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
.grid td.num { text-align: right; font-variant-numeric: tabular-nums; } .grid td.fx { color: var(--accent); } .grid td.err { color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.grid td.sel { background: var(--sel); } .grid td.active { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--panel); }
.cell-edit { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0; padding: 0 9px; outline: 2px solid var(--accent); box-shadow: none; font-family: var(--mono); background: var(--panel); user-select: text; }
.hint { color: var(--faint); font-size: 12.5px; margin: 0; }

/* statistics */
#app-stats { gap: 0; }
.stat-left { width: 38%; min-width: 280px; max-width: 540px; border-right: 1px solid var(--border); padding: 20px 14px 20px 22px; overflow: auto; background: var(--panel); }
.stat-right { flex: 1; min-width: 0; overflow: auto; padding: 14px 30px 30px; }
.stat-right .ptabs { margin-top: 2px; border-bottom: 1px solid var(--border); gap: 4px; }
.stat-right .ptab, .fin-tabs .ptab { border-radius: 7px 7px 0 0; position: relative; height: 34px; } .stat-right .ptab.active, .fin-tabs .ptab.active { background: transparent; } .stat-right .ptab.active::after, .fin-tabs .ptab.active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--accent); }
.lists-grid { display: flex; gap: 8px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }
.listcol { display: flex; flex-direction: column; min-width: 96px; width: 96px; }
.lhead { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 5px 2px; }
.lhead b { font-size: 12px; color: var(--muted); font-weight: 600; }
.link-in { border-radius: 7px 7px 0 0; font-size: 11.5px; padding: 0 7px; height: 26px; font-family: var(--mono); background: var(--panel2); border-color: transparent; }
.listcol.linked .link-in { background: var(--accent-soft); color: var(--accent); }
.lcell { border-radius: 0; border-color: var(--plot-grid); border-top: 0; padding: 0 7px; height: 28px; font-family: var(--mono); font-size: 12.5px; text-align: right; width: 100%; box-shadow: none !important; }
.lcell:focus { border-color: var(--accent); position: relative; z-index: 1; border-top: 1px solid var(--accent); }
.lcell.ro { background: var(--panel2); color: var(--muted); border: 1px solid var(--plot-grid); border-top: 0; overflow: hidden; line-height: 26px; }
.stat-panel-body { padding-top: 14px; }

/* graph */
.graph-left { width: 340px; flex: none; border-right: 1px solid var(--border); background: var(--panel); padding: 18px 16px; overflow-y: auto; }
.graph-right { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 14px 16px; gap: 10px; }
.graph-right .canvas-wrap { flex: 1; min-height: 240px; cursor: crosshair; }
.fn-row { margin-bottom: 10px; } .fn-main { display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; } .kind { width: 76px; padding: 0 20px 0 8px; font-size: 12px; flex: none; background-position: right 6px center; }
.fn-input { flex: 1; font-family: var(--mono); } .fn-sub { display: flex; gap: 6px; align-items: center; margin: 6px 0 0 30px; font-size: 12px; color: var(--muted); }
.fn-status { font-size: 12px; margin-left: 30px; } .fn-status.error { color: var(--danger); }
.params { margin: 14px 0; } .param { display: flex; align-items: center; gap: 6px; margin: 6px 0; } .param b { width: 34px; font-family: var(--mono); font-weight: 500; } .param input[type=range] { flex: 1; min-width: 40px; }
.param .tiny { width: 58px; height: 28px; padding: 0 6px; font-size: 12px; }
.tpl-bar { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 12px; }
.analysis { margin: 12px 0; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; } .analysis summary { cursor: pointer; font-weight: 500; }
.ana-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; font-size: 12px; color: var(--muted); } .ana-grid label { display: flex; flex-direction: column; gap: 4px; } .ana-grid input, .ana-grid select { width: 100%; }
.ana-out { font-family: var(--mono); font-size: 12.5px; color: var(--accent); word-break: break-word; }
.win { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--faint); } .win .tiny { width: 64px; height: 28px; padding: 0 6px; }
.table-pane { max-height: 230px; overflow: auto; border: 1px solid var(--border); border-radius: var(--r); background: var(--panel); padding: 10px 14px; }
.table-ctl { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }

/* finance */
#app-finance { flex-direction: column; padding: 10px 30px 30px; overflow: auto; align-items: center; }
#app-finance > * { width: 100%; max-width: 880px; }
.fin-tabs { border-bottom: 1px solid var(--border); margin-top: 4px; gap: 4px; }
.fin-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 24px 26px; margin-top: 20px; box-shadow: var(--shadow-sm); }
.tvm-row { display: grid; grid-template-columns: 170px 1fr auto; gap: 12px; align-items: center; margin: 10px 0; } .tvm-row label { color: var(--muted); font-weight: 500; }
.tvm-in { font-family: var(--mono); font-size: 15px; height: 40px; }
.flows { width: 100%; font-family: var(--mono); resize: vertical; }

/* sign-in: hero + right-hand panel (one third, full height) */
body.auth { flex-direction: row; background: #1e1b4b; overflow: hidden; }
.auth-hero { flex: 1; position: relative; overflow: hidden; color: #fff; display: flex; align-items: center; }
.auth-hero svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-copy { position: relative; padding: 0 clamp(32px, 7vw, 110px); max-width: 720px; }
.hero-brand { display: flex; align-items: center; gap: 10px; font-size: 17px; margin-bottom: 52px; }
.hero-brand .logo { background: #fff; color: #312e81; }
.hero-copy h2 { font-size: clamp(34px, 4.2vw, 58px); line-height: 1.06; letter-spacing: -.035em; font-weight: 600; margin: 0 0 18px; }
.hero-copy > p { font-size: 17px; line-height: 1.55; color: rgba(255, 255, 255, .78); max-width: 520px; margin: 0 0 36px; }
.hero-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.hero-points li { display: flex; align-items: center; gap: 14px; color: rgba(255, 255, 255, .88); font-size: 14.5px; }
.hero-points i { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18); backdrop-filter: blur(6px); font-size: 14px; flex: none; }
.auth-panel { flex: 0 0 33.333vw; min-width: 420px; max-width: 560px; height: 100vh; background: var(--panel); display: flex; flex-direction: column; position: relative; box-shadow: -24px 0 60px rgba(15, 12, 50, .35); }
.auth-inner { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 0 clamp(32px, 4.2vw, 64px); overflow-y: auto; }
.auth-logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; margin-bottom: 40px; }
.auth-inner h1 { margin: 0 0 6px; font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.auth-sub { margin: 0 0 28px; color: var(--muted); }
#authForm label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-size: 12.5px; font-weight: 500; color: var(--muted); } #authForm small { font-weight: 400; color: var(--faint); }
.field { position: relative; display: block; }
.field i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 13px; pointer-events: none; transition: color .15s; }
.field:focus-within i { color: var(--accent); }
#authForm input { width: 100%; height: 42px; padding: 0 13px 0 38px; font-size: 14.5px; color: var(--text); border-radius: 9px; }
#authForm .reg-only { display: none; } #authForm.registering .reg-only { display: flex; }
#authForm .primary { width: 100%; height: 44px; background: var(--accent); color: var(--accent-fg); border: 0; border-radius: 9px; font-weight: 600; font-size: 14.5px; cursor: pointer; margin-top: 4px; transition: filter .15s, transform .05s; } #authForm .primary:hover { filter: brightness(1.12); } #authForm .primary:active { transform: translateY(.5px); } #authForm .primary:disabled { opacity: .6; }
.switch-line { margin: 22px 0 0; color: var(--muted); }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-weight: 500; } .linkish:hover { text-decoration: underline; }
.msg { min-height: 20px; margin: 2px 0 8px; color: var(--danger); font-size: 13px; } .msg.ok { color: var(--ok); }
.site-footer.in-panel { padding: 0 clamp(32px, 4.2vw, 64px); height: 44px; }

/* modals */
.modal-back { position: fixed; inset: 0; background: rgba(8, 11, 20, .4); display: grid; place-items: center; z-index: 100; backdrop-filter: blur(6px); animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(460px, 94vw); max-height: 88vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); animation: pop .18s ease; } .modal.wide { width: min(780px, 95vw); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 6px; } .modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 10px 20px 20px; overflow: auto; }
.wide-in { width: 100%; }
.doc-list { max-height: 50vh; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.doc-item { display: flex; align-items: center; gap: 2px; border: 1px solid transparent; border-radius: 10px; padding: 1px 6px 1px 1px; } .doc-item:hover { background: var(--panel2); } .doc-item.current { border-color: var(--accent-line); background: var(--accent-soft); }
.doc-open { flex: 1; text-align: left; border: 0; background: transparent; padding: 9px 12px; cursor: pointer; display: flex; flex-direction: column; } .doc-open small { color: var(--muted); }
.acct { display: grid; grid-template-columns: 150px 1fr; gap: 24px; } .acct-nav { display: flex; flex-direction: column; gap: 2px; }
.acct-tab { text-align: left; border: 0; background: transparent; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; } .acct-tab:hover { background: var(--panel2); color: var(--text); } .acct-tab.active { background: var(--accent-soft); color: var(--accent); }
.sess { display: flex; flex-direction: column; padding: 10px 0; border-bottom: 1px solid var(--border); } .sess small { color: var(--muted); } .sess .ua { font-size: 11px; opacity: .8; word-break: break-all; }
.danger-h { color: var(--danger); margin-top: 26px; }
.help section { margin-bottom: 18px; } .help td { vertical-align: top; padding-right: 18px; }
.toast { position: fixed; bottom: 46px; left: 50%; transform: translate(-50%, 16px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; opacity: 0; transition: .25s; z-index: 200; max-width: 90vw; font-size: 13px; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); } .toast.ok { background: #065f46; color: #fff; } .toast.err { background: #991b1b; color: #fff; }

@media (max-width: 900px) {
  .auth-hero { display: none; } .auth-panel { flex: 1; max-width: none; min-width: 0; } body.auth { background: var(--panel); }
  .shell { flex-direction: column-reverse; }
  .rail { width: 100%; height: 58px; flex-direction: row; justify-content: space-around; padding: 4px 6px; } .rail-logo, .spacer { display: none; }
  .app-tab { width: auto; flex: 1; padding: 6px 0 4px; } .app-tab.active::before { left: 18px; right: 18px; top: -4px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .rail-btn { width: 34px; }
  .topbar { padding: 0 12px; } #userName, .save-state { display: none; }
  #app-calc, #app-stats, #app-graph { flex-direction: column; overflow: auto; } .side, .graph-left, .stat-left { width: 100%; max-width: none; border: 0; border-top: 1px solid var(--border); }
  .calc-main { padding: 0 14px 10px; } .graph-right .canvas-wrap { min-height: 320px; } .acct { grid-template-columns: 1fr; } .acct-nav { flex-direction: row; overflow-x: auto; } .tvm-row { grid-template-columns: 1fr; } .stat-right { padding: 10px 14px; }
}

/* verification + captcha */
.hp { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.captcha-box { margin: 2px 0 14px; }
.captcha-label { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.captcha-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.captcha-img { display: block; border: 1px solid var(--border-strong); border-radius: 9px; background: #fff; max-width: 100%; height: auto; }
.captcha-refresh { width: 36px; height: 36px; border: 1px solid var(--border-strong); background: var(--panel); border-radius: 9px; cursor: pointer; color: var(--muted); transition: background .12s, color .12s; }
.captcha-refresh:hover { background: var(--panel2); color: var(--accent); }
.cf-box { min-height: 65px; }
.status-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 22px; margin-bottom: 18px; }
.status-icon.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); } .status-icon.err { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.email-shown { color: var(--text); word-break: break-all; }
.notice { padding: 10px 14px; border-radius: 9px; font-size: 13.5px; margin: 0 0 16px; background: var(--accent-soft); color: var(--accent); }
.notice.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); } .notice.err { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
.primary-btn { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; height: 44px; border: 0; border-radius: 9px; background: var(--accent); color: var(--accent-fg); font-weight: 600; font-size: 14.5px; cursor: pointer; text-decoration: none; transition: filter .15s; }
.primary-btn:hover { filter: brightness(1.12); } .primary-btn:disabled { background: var(--panel2); color: var(--faint); cursor: not-allowed; filter: none; border: 1px solid var(--border); }
.hint-line { color: var(--faint); font-size: 12.5px; margin: 10px 0 22px; }
.linkish.block { display: block; margin: 0 0 12px; }
.change-form { border-top: 1px solid var(--border); padding-top: 16px; margin-bottom: 6px; }
.change-form label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.change-form input { width: 100%; height: 42px; padding: 0 13px 0 38px; font-size: 14.5px; color: var(--text); border-radius: 9px; }
.change-form .primary { width: 100%; height: 44px; background: var(--accent); color: var(--accent-fg); border: 0; border-radius: 9px; font-weight: 600; cursor: pointer; } .change-form .primary:disabled { opacity: .6; }
.captcha-box .field input { width: 100%; height: 42px; padding: 0 13px 0 38px; font-size: 15px; letter-spacing: .12em; text-transform: uppercase; border-radius: 9px; }
[hidden] { display: none !important; }

/* live field status */
#authForm .status { display: none; font-size: 12px; font-weight: 500; min-height: 16px; align-items: center; gap: 6px; color: var(--faint); }
#authForm .status[data-state] { display: flex; }
#authForm .status[data-state=available] { color: var(--ok); } #authForm .status[data-state=taken], #authForm .status[data-state=invalid], #authForm .status[data-state=error] { color: var(--danger); }
#authForm .status i { font-size: 11px; }
#authForm .field[data-state=available] input { border-color: var(--ok); } #authForm .field[data-state=taken] input, #authForm .field[data-state=invalid] input { border-color: var(--danger); }
#authForm .field[data-state=available] input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
#authForm .field[data-state=taken] input:focus, #authForm .field[data-state=invalid] input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 15%, transparent); }

/* spreadsheet point mode */
.grid td.rf0 { box-shadow: inset 0 0 0 2px #4338ca; background: color-mix(in srgb, #4338ca 9%, transparent); }
.grid td.rf1 { box-shadow: inset 0 0 0 2px #e11d48; background: color-mix(in srgb, #e11d48 9%, transparent); }
.grid td.rf2 { box-shadow: inset 0 0 0 2px #0d9488; background: color-mix(in srgb, #0d9488 9%, transparent); }
.grid td.rf3 { box-shadow: inset 0 0 0 2px #d97706; background: color-mix(in srgb, #d97706 9%, transparent); }
.grid td.rf4 { box-shadow: inset 0 0 0 2px #9333ea; background: color-mix(in srgb, #9333ea 9%, transparent); }
.grid td.rf5 { box-shadow: inset 0 0 0 2px #0284c7; background: color-mix(in srgb, #0284c7 9%, transparent); }
.fx-btn { height: var(--h); padding: 0 12px; border: 1px solid var(--border-strong); background: var(--panel); border-radius: 8px; cursor: pointer; font: italic 500 14px Georgia, serif; color: var(--muted); white-space: nowrap; transition: background .12s, color .12s; }
.fx-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.fx-btn i { display: none; }
#app-sheet { position: absolute; }
.fx-menu { position: absolute; z-index: 20; width: 260px; max-height: 340px; overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); padding: 5px; }
.fx-menu button { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%; border: 0; background: transparent; padding: 7px 10px; border-radius: 7px; cursor: pointer; text-align: left; }
.fx-menu button:hover { background: var(--panel2); } .fx-menu b { font-family: var(--mono); font-weight: 500; font-size: 13px; color: var(--accent); } .fx-menu small { color: var(--faint); font-size: 11.5px; }

/* palette keys: never let labels spill outside the button */
.palette { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
.key { min-width: 0; padding: 6px 8px; overflow: hidden; line-height: 1.15; }
.key.long { font-size: 11.5px; letter-spacing: -.01em; padding: 6px 4px; }
.key:not(:has(.katex)) { white-space: nowrap; text-overflow: ellipsis; }
/* fraction <-> decimal toggle on an answer */
.out { display: flex; flex-direction: column; align-items: flex-end; }
.out > .main, .out > .approx { align-self: stretch; }
.conv-chip { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; height: 24px; padding: 0 10px; border: 1px solid var(--border); background: var(--panel); border-radius: 12px; font-size: 11.5px; font-weight: 500; color: var(--muted); cursor: pointer; opacity: .55; transition: opacity .15s, background .12s, color .12s, border-color .12s; }
.entry:hover .conv-chip, .conv-chip:focus-visible { opacity: 1; }
.conv-chip:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); opacity: 1; }
.conv-chip i { font-size: 10px; }
.out.error { display: block; }

/* ================= Calculate: notebook | function catalog | keypad ================= */
.calc-main { max-width: none; margin: 0; padding: 0 28px 16px; }
.fn-panel { width: 310px; flex: none; display: flex; flex-direction: column; border-left: 1px solid var(--border); background: var(--panel); min-height: 0; }
.fn-head { display: flex; gap: 2px; padding: 10px 12px 0; border-bottom: 1px solid var(--border); }
.fn-tab { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border: 0; background: transparent; color: var(--muted); font-weight: 500; cursor: pointer; border-radius: 8px 8px 0 0; position: relative; transition: color .12s; }
.fn-tab:hover { color: var(--text); } .fn-tab.active { color: var(--accent); }
.fn-tab.active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--accent); }
.fn-tab i { font-size: 12px; }
.fn-search { position: relative; margin: 12px 12px 6px; } .fn-search > i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--faint); pointer-events: none; }
.fn-search input { width: 100%; padding-left: 32px; background: var(--panel2); border-color: transparent; }
.fn-body { flex: 1; overflow-y: auto; padding: 4px 12px 16px; min-height: 0; }
.fn-body.ws { padding-top: 16px; }
.fn-sec { border-bottom: 1px solid var(--border); }
.fn-sec:last-child { border-bottom: 0; }
.fn-sec-head { display: flex; align-items: center; gap: 10px; width: 100%; height: 42px; padding: 0 2px; border: 0; background: transparent; cursor: pointer; font-weight: 600; font-size: 13px; text-align: left; color: var(--text); }
.fn-sec-head > i:first-child { width: 18px; text-align: center; color: var(--accent); font-size: 13px; }
.fn-sec-head span { flex: 1; } .fn-sec-head small { color: var(--faint); font-weight: 500; font-size: 11px; }
.fn-sec-head > i:last-child { font-size: 10px; color: var(--faint); transition: transform .15s; } .fn-sec.open .fn-sec-head > i:last-child { transform: rotate(180deg); }
.fn-sec-head:hover { color: var(--accent); }
.fn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 2px 0 14px; }
.fn-grid .key { min-height: 36px; font-size: 12.5px; }
.pad { padding: 12px 2px; }
.fn-panel .side-sec { margin-bottom: 22px; }

.keypad { width: 352px; flex: none; display: flex; flex-direction: column; gap: 12px; padding: 14px; border-left: 1px solid var(--border); background: var(--panel2); overflow-y: auto; }
.kp-tabs { display: flex; gap: 2px; padding: 3px; background: var(--border); border-radius: 10px; }
.kp-tab { flex: 1; height: 30px; border: 0; background: transparent; border-radius: 8px; color: var(--muted); font-weight: 500; cursor: pointer; transition: background .12s, color .12s; }
.kp-tab.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(15, 23, 42, .1); }
.kp-grid { display: grid; grid-template-columns: repeat(var(--cols, 5), 1fr); gap: 6px; }
.kp-key { height: 46px; min-width: 0; border: 1px solid var(--border); background: var(--panel); border-radius: 10px; font-size: 16px; font-weight: 500; color: var(--text); cursor: pointer; display: grid; place-items: center; padding: 0 2px; box-shadow: var(--shadow-sm); transition: background .1s, border-color .1s, transform .05s, color .1s; }
.kp-key:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.kp-key:active { transform: translateY(1px) scale(.98); }
.kp-key.num { font-size: 18px; }
.kp-key.fn { color: var(--muted); font-size: 14px; background: var(--panel); }
.kp-key.op { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); font-size: 17px; }
.kp-key.clr { color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--panel)); border-color: color-mix(in srgb, var(--danger) 25%, var(--border)); font-size: 14px; }
.kp-key.nav { color: var(--faint); font-size: 12px; background: transparent; box-shadow: none; }
.kp-key.exe { background: var(--accent); color: var(--accent-fg); border-color: transparent; font-weight: 600; font-size: 14px; letter-spacing: .03em; }
.kp-key.exe:hover { filter: brightness(1.12); background: var(--accent); color: var(--accent-fg); }
.kp-key .katex { font-size: 1.02em; }
.kp-grid.abc { display: flex; flex-direction: column; }
.kp-row { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 5px; }
.kp-grid.abc .kp-key { height: 42px; padding: 0; font-size: 16px; }
.kp-row.greek .kp-key { height: 38px; font-size: 15px; font-family: Georgia, serif; }
.kp-status { display: flex; gap: 6px; margin-top: auto; }
.kp-chip { height: 26px; padding: 0 10px; border: 1px solid var(--border-strong); background: var(--panel); border-radius: 13px; font-size: 11.5px; font-weight: 600; letter-spacing: .03em; color: var(--muted); cursor: pointer; transition: background .12s, color .12s; }
.kp-chip:hover { background: var(--accent-soft); color: var(--accent); } .kp-chip.on { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.fn-toggle { display: none; }

/* narrower screens: the function catalog slides over the notebook */
@media (max-width: 1320px) {
  .fn-toggle { display: inline-flex; }
  .fn-panel { position: absolute; top: 0; bottom: 0; right: 352px; z-index: 6; box-shadow: -12px 0 32px rgba(15, 23, 42, .14); transform: translateX(calc(100% + 352px)); transition: transform .2s ease; visibility: hidden; }
  .fn-panel.open { transform: none; visibility: visible; }
}

/* ================= phones / small tablets: Calculate becomes a fixed, app-style screen ================= */
html, body { height: 100dvh; }
.fn-close { display: none; margin-left: auto; align-self: center; }
.kp-toggle { display: none; }
@media (max-width: 1320px) { .fn-close { display: inline-block; } }
@media (max-width: 900px) {
  .topbar { height: 46px; padding: 0 10px; gap: 8px; }
  .rail { height: calc(52px + env(safe-area-inset-bottom)); padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); }
  .site-footer { height: 22px; font-size: 10.5px; padding: 0 12px; }

  #app-calc { flex-direction: column; overflow: hidden; }
  .calc-main { flex: 1 1 0; min-height: 0; width: 100%; padding: 0 10px 6px; }
  .history { padding: 4px 0; }
  .entry { padding: 10px 2px 12px; }
  .entry .out .main .katex { font-size: 1.25em; }
  .empty { padding: 3vh 6px 8px; } .empty h3 { font-size: 20px; } .chip { padding: 6px 10px; font-size: 12px; }
  .entry-bar { gap: 6px; padding-top: 4px; }
  .entry-bar .btn { height: 44px; padding: 0 12px; } .entry-bar .btn .lbl { display: none; }
  .fn-toggle, .kp-toggle { display: inline-flex; }
  math-field.mf { font-size: 18px; min-height: 44px; padding: 5px 10px; }
  .entry-input { font-size: 14px; padding: 10px 12px; }

  /* keypad docked under the entry line — always on screen, no page scrolling */
  .keypad { flex: none; width: 100%; padding: 8px 8px 6px; gap: 6px; border: 0; border-top: 1px solid var(--border); overflow: visible; }
  .keypad.collapsed { display: none; }
  .kp-tabs { padding: 2px; } .kp-tab { height: 26px; font-size: 12.5px; }
  .kp-grid { gap: 5px; }
  .kp-key { height: clamp(30px, 5.2dvh, 44px); font-size: 15px; border-radius: 8px; }
  .kp-key.num { font-size: 16px; } .kp-key.fn, .kp-key.clr { font-size: 13px; } .kp-key.exe { font-size: 13px; }
  .kp-grid.abc .kp-key { height: clamp(30px, 5dvh, 42px); } .kp-row.greek .kp-key { height: clamp(28px, 4.6dvh, 38px); } .kp-row { gap: 4px; }
  .kp-status { display: none; }

  /* function catalog: bottom sheet over the notebook */
  .fn-panel { position: fixed; left: 0; right: 0; bottom: calc(52px + env(safe-area-inset-bottom)); width: 100%; height: 66dvh; max-height: none; z-index: 40; border: 0; border-top: 1px solid var(--border); border-radius: 16px 16px 0 0; box-shadow: 0 -12px 40px rgba(15, 23, 42, .22); transform: translateY(calc(100% + 80px)); visibility: hidden; transition: transform .22s ease, visibility 0s .22s; }
  .fn-panel.open { transform: none; visibility: visible; transition: transform .22s ease; }
  .fn-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fn-close { display: inline-block; }
}
@media (max-width: 400px), (max-height: 640px) {
  .kp-key { height: clamp(28px, 4.8dvh, 38px); font-size: 14px; } .kp-key.num { font-size: 15px; }
  .entry-bar .btn { height: 40px; padding: 0 10px; } math-field.mf { min-height: 40px; font-size: 17px; }
}

.ws-clear { display: none; margin-bottom: 18px; }
@media (max-width: 900px) { .clear-btn { display: none !important; } .ws-clear { display: inline-flex; } .entry-bar .btn { height: 42px; padding: 0 10px; min-width: 42px; } .entry-bar { gap: 5px; } .entry-wrap { min-width: 110px; } }
@media (max-width: 900px) { .fn-panel { bottom: calc(74px + env(safe-area-inset-bottom)); height: 64dvh; } }
@media (max-width: 900px) { .fn-panel { top: auto; } }

/* ================= public share page (read-only snapshot) ================= */
body.share-body { height: auto; min-height: 100dvh; }
.share-top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 56px; padding: 0 24px; background: var(--panel); border-bottom: 1px solid var(--border); }
.share-brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 15px; }
.share-pill { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; height: 24px; padding: 0 10px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 600; }
.share-pill i { font-size: 10.5px; }
.share-actions { display: flex; gap: 8px; align-items: center; } .share-actions .btn { text-decoration: none; }
.share-main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 30px 22px 56px; }
.share-state { display: flex; align-items: center; gap: 14px; padding: 80px 10px; justify-content: center; color: var(--muted); }
.share-state.err { flex-direction: column; text-align: center; } .share-state.err > i { font-size: 34px; color: var(--faint); } .share-state h2 { color: var(--text); margin: 0 0 4px; }
.share-hero h1 { margin: 0 0 10px; font-size: 30px; letter-spacing: -.025em; font-weight: 600; word-break: break-word; }
.share-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; color: var(--muted); margin-bottom: 14px; }
.share-meta i { margin-right: 4px; color: var(--faint); font-size: 12px; }
.share-author { display: inline-flex; align-items: center; gap: 8px; color: var(--text); } .share-author .avatar { width: 26px; height: 26px; font-size: 12px; }
.share-hero .notice { display: block; margin: 0; }
.share-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.share-nav a { padding: 5px 13px; border: 1px solid var(--border); border-radius: 16px; background: var(--panel); color: var(--muted); text-decoration: none; font-size: 12.5px; font-weight: 500; }
.share-nav a:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.share-sec { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 22px 26px; margin-top: 20px; box-shadow: var(--shadow-sm); }
.share-sec h2 { margin: 0 0 16px; font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.share-block + .share-block { margin-top: 24px; }
.share-block h3 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 600; }
.share-scroll { overflow: auto; max-height: 540px; border: 1px solid var(--border); border-radius: 10px; }
.share-table { margin: 0; width: 100%; } .share-table th, .share-table td { padding: 6px 12px; border-right: 1px solid var(--plot-grid); white-space: nowrap; }
.share-table thead th { position: sticky; top: 0; background: var(--panel2); } .share-table th.rh { background: var(--panel2); color: var(--faint); text-align: center; position: sticky; left: 0; }
.share-table td.num { text-align: right; font-variant-numeric: tabular-nums; } .share-table td.fx { color: var(--accent); }
.share-kv { width: auto; min-width: 260px; } .share-kv th { min-width: 160px; }
.share-fig { margin: 0; } .share-fig img { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 10px; background: #fff; } .share-fig figcaption { margin-top: 8px; color: var(--muted); font-size: 12.5px; font-family: var(--mono); }
.share-text { margin: 0; color: var(--muted); white-space: pre-wrap; }
.share-entries .entry { grid-template-columns: 1fr; }
@media (max-width: 700px) { .share-top { padding: 0 12px; } .share-actions .btn:first-child { display: none; } .share-sec { padding: 16px; } .share-hero h1 { font-size: 24px; } }
@media print {
  body.share-body { background: #fff; }
  .share-top, .site-footer, .share-nav { display: none !important; }
  .share-main { max-width: none; padding: 0; }
  .share-sec { box-shadow: none; border-color: #ddd; break-inside: auto; }
  .share-scroll { max-height: none; overflow: visible; }
  .share-block { break-inside: avoid; }
}

/* share dialog */
.share-btn { margin-right: 4px; } .share-btn i { color: var(--accent); opacity: 1; }
.share-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.share-check { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--panel); cursor: pointer; color: var(--text); font-size: 13.5px; }
.share-check:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.share-check.off { opacity: .5; cursor: default; } .share-check small { color: var(--faint); }
.share-check i { font-size: 12px; }
.share-disclose { display: flex; gap: 8px; color: var(--muted); font-size: 12.5px; margin: 4px 0 12px; } .share-disclose i { margin-top: 3px; color: var(--faint); }
.share-result { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel2); } .share-result p { margin: 0 0 8px; }
.share-link-row { display: flex; gap: 8px; } .share-link { flex: 1; font-family: var(--mono); font-size: 12.5px; }
.snap-list { margin-top: 22px; } .snap-item { display: flex; align-items: center; gap: 2px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.snap-info { flex: 1; min-width: 0; display: flex; flex-direction: column; } .snap-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .snap-info small { color: var(--muted); }
.snap-item a.icon { text-decoration: none; display: inline-grid; place-items: center; }
@media (max-width: 900px) { .share-btn span { display: none; } }

/* logo mark (SVG) */
.logo { display: block; width: 30px; height: 30px; flex: none; border-radius: 9px; background: none; object-fit: contain; }
.rail-logo .logo { width: 38px; height: 38px; border-radius: 11px; }
.auth-logo .logo { width: 34px; height: 34px; }
.hero-brand .logo { width: 36px; height: 36px; background: none; box-shadow: 0 6px 18px rgba(15, 12, 50, .35); }
.share-brand .logo { width: 28px; height: 28px; }
