/* Calculator panel (calc.js). Uses the tokens from style.css; nothing animates. */
#calc { position: fixed; z-index: 11; display: flex; flex-direction: column; min-width: 300px; min-height: 260px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); font: 13px/1.4 var(--font); touch-action: manipulation; }
#calc[hidden] { display: none !important; }
#calc .ch { display: flex; align-items: center; gap: 6px; padding: 7px 7px 7px 10px; border-bottom: 1px solid var(--line); cursor: move; user-select: none; touch-action: none; flex: none; }
#calc .grow { flex: 1; }
#calc select, #calc input[type=text], #calc textarea { font: 13px var(--font); color: var(--ink); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 7px; outline: none; min-width: 0; }
#calc select { height: 30px; padding: 0 6px; cursor: pointer; }
#calc input[type=text] { height: 30px; padding: 0 8px; width: 100%; }
#calc textarea { width: 100%; padding: 6px 8px; resize: vertical; font-family: var(--mono); font-size: 12px; }
#calc select:focus, #calc input[type=text]:focus, #calc textarea:focus { border-color: var(--accent); }
#calc input.bad { border-color: var(--bad); }
#calc .ch select.mode { font-weight: 600; }
#calc .ch button { height: 30px; min-width: 30px; padding: 0 8px; border-radius: 7px; color: var(--muted); font-size: 12px; font-weight: 600; }
#calc .ch button:hover { color: var(--ink); background: var(--surface-2); }
#calc .ch .ang { border: 1px solid var(--line-2); color: var(--ink); }
#calc .ch .x { padding: 0; display: grid; place-items: center; }
#calc .ch .x svg { width: 16px; height: 16px; }
#calc .cb { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#calc .pane { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; padding: 10px; gap: 8px; }
#calc .pane[hidden] { display: none; }
#calc .ball { position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); cursor: nwse-resize; touch-action: none; }
#calc .flash { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); padding: 5px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line-2); font-size: 12px; white-space: nowrap; }

/* shared bits */
#calc button.tb { flex: none; height: 22px; padding: 0 7px; border-radius: 6px; font-size: 11px; font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); white-space: nowrap; }
#calc button.tb:hover { background: var(--accent); color: #fff; }
#calc button.pri { height: 30px; padding: 0 12px; border-radius: 7px; font-weight: 600; color: #fff; background: var(--accent); flex: none; }
#calc .gbar button:not(.tb), #calc .step button, #calc .keys button, #calc .acts .sd { height: 26px; padding: 0 9px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--line-2); font-size: 12px; }
#calc .gbar button:not(.tb):hover, #calc .step button:hover, #calc .keys button:hover, #calc .acts .sd:hover { border-color: var(--accent); }
#calc .f { display: grid; gap: 3px; min-width: 0; flex: none; }
#calc .f > span { font-size: 11px; font-weight: 600; color: var(--muted); }
#calc .f > span:empty { display: none; }
#calc .prm, #calc .row { display: flex; gap: 6px; align-items: end; flex-wrap: wrap; }
#calc .prm > .f { flex: 1 1 70px; }
#calc .prm > .chk { flex: 1 1 100px; }
#calc .chk { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink); height: 30px; cursor: pointer; }
#calc .chk input { accent-color: var(--accent); margin: 0; }
#calc .res { display: grid; gap: 2px; }
#calc .res h4 { margin: 8px 0 2px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
#calc .rr { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 2px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
#calc .rl:empty { display: none; }
#calc .rl { flex: 0 0 auto; min-width: 74px; color: var(--muted); font-size: 12px; }
#calc .rv { flex: 1 1 auto; min-width: 0; overflow-x: auto; display: flex; align-items: baseline; gap: 8px; }
#calc .rv .full { color: var(--muted); font-family: var(--mono); font-size: 11px; }
#calc .rn { flex: 1 0 100%; order: 3; color: var(--muted); font-size: 11px; margin: -2px 0 2px; }
#calc .rr .tb { order: 2; }
#calc .tx .katex { font-size: 1.12em; }
#calc .muted { margin: 2px 0; color: var(--muted); font-size: 12px; }
#calc .err { margin: 2px 0; color: var(--bad); font-size: 12px; }
#calc .bad { color: var(--bad); }
#calc .concl { margin: 6px 0 0; font-weight: 600; }
#calc .dname { margin: 0 0 2px; }
#calc .all { display: flex; justify-content: flex-end; padding-top: 4px; }
#calc .tbl { border-collapse: collapse; font-family: var(--mono); font-size: 12px; width: 100%; }
#calc .tbl th { font: 600 11px var(--font); color: var(--muted); text-align: left; padding: 3px 4px; }
#calc .tbl td { padding: 3px 4px; border-bottom: 1px solid var(--line); }
#calc .tbl.in td { padding: 2px; border: 0; }
#calc .tbl.in input { height: 28px; text-align: center; padding: 0 4px; font-family: var(--mono); }
#calc .tbl.lin th { text-align: center; font-family: var(--mono); }
#calc .step { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); height: 30px; }
#calc .step button { width: 26px; padding: 0; }

/* Calculate */
#calc .calc { padding: 0; gap: 0; overflow: hidden; position: relative; }
#calc .hist { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
#calc .hist > .muted { margin: auto 0 8px; text-align: center; }
#calc .ent { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; row-gap: 1px; padding: 6px 0; border-bottom: 1px solid var(--line); }
#calc .ent .out, #calc .ent .note { grid-column: 1 / -1; }
#calc .ent .note { justify-self: end; color: var(--muted); font-size: 11px; text-align: right; }
#calc .ent .in { justify-self: start; max-width: 100%; text-align: left; font-family: var(--mono); font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
#calc .ent .in:hover { color: var(--ink); }
#calc .ent .out { justify-self: end; max-width: 100%; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
#calc .ent .out .katex { font-size: 1.2em; }
#calc .acts { display: flex; align-items: start; justify-content: flex-end; gap: 6px; min-height: 22px; }
#calc .acts .sd { height: 22px; padding: 0 7px; font-size: 11px; font-weight: 600; }
#calc .keys { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; padding: 8px 10px 0; border-top: 1px solid var(--line); flex: none; }
#calc .keys button { padding: 0; font-family: var(--mono); }
#calc .entry { display: flex; gap: 6px; padding: 6px 10px 0; flex: none; }
#calc .entry .line { height: 36px; font: 14px var(--mono); }
#calc .entry .go { width: 40px; height: 36px; flex: none; border-radius: 8px; background: var(--accent); color: #fff; font-size: 18px; font-weight: 600; }
#calc .foot { display: flex; justify-content: flex-end; padding: 4px 10px 8px; flex: none; }
#calc .lnk { font-size: 11px; color: var(--muted); }
#calc .lnk:hover { color: var(--ink); }
#calc .help { position: absolute; left: 8px; right: 8px; top: 8px; bottom: 96px; overflow-y: auto; z-index: 2; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); padding: 4px; display: grid; align-content: start; }
#calc .help button { display: flex; gap: 10px; align-items: baseline; text-align: left; padding: 5px 8px; border-radius: 6px; }
#calc .help button:hover { background: var(--surface-2); }
#calc .help code { font: 12px var(--mono); color: var(--accent-ink); flex: none; }
#calc .help span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Graph */
#calc .fns { display: grid; gap: 4px; flex: none; }
#calc .fr { display: flex; align-items: center; gap: 6px; }
#calc .fr .yl { flex: none; font-size: 12px; color: var(--muted); width: 34px; }
#calc .fr .fx { font-family: var(--mono); }
#calc .sw { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--c); background: transparent; }
#calc .sw.on { background: var(--c); }
#calc .gwrap { position: relative; flex: 1 1 200px; min-height: 160px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
#calc .gc { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#calc .gc:active { cursor: grabbing; }
#calc .ro { position: absolute; right: 6px; top: 4px; font: 11px var(--mono); color: var(--muted); pointer-events: none; }
#calc .gbar, #calc .gtools { display: flex; gap: 6px; align-items: center; flex: none; flex-wrap: wrap; }
#calc .gtools select.gk { flex: 1 1 110px; }
#calc .gtools select.gf { flex: 0 0 58px; }
#calc .gtools .gv { flex: 1 1 60px; width: 60px; }
#calc .gres { display: grid; gap: 2px; flex: none; }

/* Statistics */
#calc .lists { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

/* Distributions */
#calc .dc { width: 100%; height: 96px; display: block; flex: none; }
#calc .coef > .f { flex: 1 1 48px; }
