:root {
  --bg: #ffffff; --panel: #ffffff; --line: #e4e4e4; --gutter: #f2f2f2; --text: #1f1f1f; --muted: #6f6f6f;
  --accent: #2d70b3; --accent2: #2f73c2; --chip: #f3f3f3; --chipb: #e0e0e0; --err: #e06a2b; --hole: #d4d4d4;
  --top: #2f2f33; --topt: #f2f2f2; --key: #e9eaed; --key2: #d6d8dd; --keyt: #222; --kbg: #f6f7f9;
  --math: "Cambria Math", "Times New Roman", "STIX Two Math", serif;
  --ui: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
body.dark {
  --bg: #1e1f24; --panel: #24262c; --line: #363841; --gutter: #2b2d34; --text: #e8e8ea; --muted: #a2a5ad;
  --chip: #30333b; --chipb: #41444e; --hole: #4b4e58; --key: #33363e; --key2: #3d414b; --keyt: #eee; --kbg: #26282e;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--ui); overflow: hidden; }
body { display: flex; flex-direction: column; }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ---------- topo */
.top { height: 48px; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--top); color: var(--topt); }
.brand { font-size: 18px; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.brand b { color: #8fc1ff; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--accent); font-family: var(--math); font-style: italic; }
.title { background: transparent; border: 1px solid transparent; color: inherit; font-size: 15px; padding: 5px 8px; border-radius: 6px; width: 220px; }
.title:hover, .title:focus { border-color: #555; outline: none; background: rgba(255,255,255,.06); }
.top button { white-space: nowrap; background: rgba(255,255,255,.08); color: inherit; border: 1px solid rgba(255,255,255,.12); border-radius: 6px; padding: 6px 11px; font-size: 13px; }
.top button:hover { background: rgba(255,255,255,.16); }
.tb { display: flex; gap: 6px; }
.seg { display: flex; border-radius: 6px; overflow: hidden; border: 1px solid rgba(255,255,255,.2); }
.seg button { border: 0; border-radius: 0; background: transparent; padding: 6px 10px; font-weight: 600; letter-spacing: .3px; }
.seg button.on { background: var(--accent); }
.pill.on { background: var(--accent) !important; border-color: var(--accent) !important; }
.top .icon { width: 32px; padding: 6px 0; font-size: 15px; }
.dd { position: relative; }
.menu { display: none; position: absolute; top: 36px; left: 0; z-index: 50; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.18); min-width: 260px; padding: 6px; }
.menu.open { display: block; }
.menu button { display: block; width: 100%; text-align: left; background: transparent !important; border: 0 !important; color: var(--text) !important; padding: 8px 10px; border-radius: 6px; }
.menu button:hover { background: var(--chip) !important; }
.menu small { color: var(--muted); display: block; font-size: 11.5px; }

/* ---------- layout */
.top { flex: none; }
main { display: flex; flex: 1; min-height: 0; }
#panel { width: 470px; min-width: 260px; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); }
#panel.collapsed { display: none; }
#splitter { width: 5px; cursor: col-resize; background: transparent; margin-left: -3px; z-index: 5; }
#splitter:hover { background: rgba(45,112,179,.25); }
#graphWrap { flex: 1; position: relative; min-width: 0; min-height: 120px; }
#right { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#anaSplit { height: 5px; cursor: row-resize; margin-top: -3px; z-index: 5; border-top: 1px solid var(--line); }
#anaSplit:hover { background: rgba(45,112,179,.25); }
#ana { height: 240px; display: flex; flex-direction: column; background: var(--panel); min-height: 36px; }
#ana.collapsed { height: 36px !important; }
#ana.collapsed .abody { display: none; }
.ahead { height: 36px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 8px; background: var(--gutter); border-bottom: 1px solid var(--line); }
.atitle { font-size: 13px; }
.acount { font-size: 12px; color: var(--muted); }
.aask { width: 240px; max-width: 30vw; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); font-size: 12px; }
.aprov { padding: 3px 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); font-size: 12px; max-width: 150px; }
.akeys { padding: 2px 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); font-size: 13px; cursor: pointer; }
.akeys:hover { border-color: var(--accent); }
.kprov { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.kprov h5 { margin: 0 0 6px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.kprov h5 .kst { font-size: 11px; font-weight: 400; padding: 1px 7px; border-radius: 10px; background: var(--chip); color: var(--muted); }
.kprov h5 .kst.ok { background: #388c46; color: #fff; }
.keyrow { display: grid; grid-template-columns: 70px 1fr; gap: 6px 8px; align-items: center; font-size: 12px; }
.keyrow input { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); font-size: 12px; font-family: Consolas, monospace; width: 100%; box-sizing: border-box; }
.kfoot { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 6px; }
.kfoot .amuted { margin-right: auto; font-size: 12px; }
.krm { font-size: 11px; color: var(--err); background: none; border: 0; cursor: pointer; padding: 0; }
.arun { padding: 4px 12px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font-size: 12px; cursor: pointer; white-space: nowrap; }
.arun.busy { background: var(--panel); color: var(--accent); }
.aauto { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 3px; white-space: nowrap; }
#aToggle { background: transparent; border: 0; color: var(--muted); font-size: 14px; width: 28px; height: 28px; border-radius: 6px; }
#ana.collapsed #aToggle { transform: rotate(180deg); }
.abody { flex: 1; display: flex; min-height: 0; }
/* o texto da IA chegando não força o navegador a recalcular a página inteira (gráfico, linhas) */
#aIA, #aLocal { contain: content; }
/* objetivo da aba (vai para a IA como filtro) */
.aobj { display: flex; align-items: flex-start; gap: 8px; padding: 4px 10px; border-bottom: 1px solid var(--line); }
.aobj label { font-size: 12px; font-weight: 600; white-space: nowrap; padding-top: 4px; color: #e8a33d; }
.aobj.vazio label { color: inherit; opacity: .7; }
.aobj textarea { flex: 1; resize: none; min-height: 22px; max-height: 96px; font: inherit; font-size: 13px; line-height: 1.35; padding: 2px 6px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: inherit; }
.aobj textarea:hover, .aobj textarea:focus { border-color: var(--line); outline: none; }
#ana.collapsed .aobj { display: none !important; }
.acol { flex: 1; overflow: auto; padding: 6px 10px 10px; min-width: 0; font-size: 13px; line-height: 1.45; }
.acol + .acol { border-left: 1px solid var(--line); flex: 1.4; }
.ahd { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin-bottom: 6px; position: sticky; top: -6px; background: var(--panel); padding: 2px 0; }
.ahd small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.af { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.af .tag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .04em; border-radius: 4px; padding: 1px 5px; margin-right: 6px; color: #fff; vertical-align: 1px; }
.k-padrao .tag { background: #388c46; } .k-lateral .tag { background: #6042a6; } .k-comportamento .tag { background: #2d70b3; }
.k-sugestao .tag { background: #e06a2b; } .k-aviso .tag { background: #9a8a3a; }
.af a, .amd a { color: var(--accent); cursor: pointer; font-size: 12px; margin-left: 4px; }
.amuted { color: var(--muted); }
.amd h4 { margin: 10px 0 3px; font-size: 13px; color: var(--accent); }
.amd h4:first-child { margin-top: 0; }
.amd ul { margin: 2px 0 6px; padding-left: 18px; }
.amd p { margin: 3px 0; }
.amd code { font-family: Consolas, monospace; font-size: 12px; background: var(--chip); border: 1px solid var(--chipb); border-radius: 4px; padding: 0 4px; }
.amd code.ins { cursor: copy; }
.amd code.ins:hover { border-color: var(--accent); color: var(--accent); }
.acaret::after { content: '▍'; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
#graph { display: block; touch-action: none; cursor: crosshair; }
#graph.dragging { cursor: grabbing; }
#ptabs { display: flex; gap: 0; background: var(--gutter); border-bottom: 1px solid var(--line); padding: 0 6px; overflow-x: auto; scrollbar-width: thin; flex: none; }
#ptabs button { background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 8px 12px 6px; font-size: 13px; cursor: pointer; white-space: nowrap; flex: none; }
#ptabs .stab { display: flex; align-items: center; gap: 4px; max-width: 170px; }
#ptabs .stl { overflow: hidden; text-overflow: ellipsis; }
#ptabs .sx { font-size: 14px; line-height: 1; width: 16px; height: 16px; border-radius: 4px; display: inline-grid; place-items: center; opacity: .5; }
#ptabs .sx:hover { opacity: 1; background: var(--chipb); }
#ptabs .stab.dirty .stl::before { content: '●'; color: #e8a33d; margin-right: 4px; font-size: 10px; vertical-align: 1px; }
#btnSaveAll.pend { box-shadow: inset 0 -2px 0 #e8a33d; }
#btnSaveAll.blink { animation: pmBlink .5s ease-in-out 4; }
@keyframes pmBlink { 50% { background: #e8a33d; color: #fff; } }
#ptabs .snew { font-size: 15px; padding: 6px 10px 4px; }
#ptabs .dtab { margin-left: auto; position: sticky; right: -6px; background: var(--gutter); border-left: 1px solid var(--line); }
#ptabs button:hover { color: var(--text); }
#ptabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
#panel.defs #lines { background: linear-gradient(var(--panel), var(--panel)), repeating-linear-gradient(45deg, transparent 0 8px, rgba(45,112,179,.04) 8px 16px); background-blend-mode: normal; box-shadow: inset 3px 0 0 var(--accent); }
.title:disabled { color: var(--accent); background: transparent; opacity: 1; }
.pbar { height: 44px; display: flex; align-items: center; gap: 2px; padding: 0 6px; border-bottom: 1px solid var(--line); background: var(--gutter); }
.pbar .icon { background: transparent; border: 0; color: var(--muted); font-size: 18px; width: 36px; height: 34px; border-radius: 6px; }
.pbar .icon:hover { background: var(--chip); color: var(--text); }
.pbar .icon.big { font-size: 22px; color: var(--text); }
#lines { overflow-y: auto; flex: 0 1 auto; }
#addArea { flex: 1; min-height: 60px; cursor: text; border-top: 1px solid var(--line); background: linear-gradient(90deg, var(--gutter) 46px, transparent 46px); }

/* ---------- linha */
.line { display: flex; border-bottom: 1px solid var(--line); position: relative; min-height: 58px; }
.line.active { box-shadow: inset 0 0 0 1px var(--accent); z-index: 1; }
.gutter { width: 46px; flex: none; background: var(--gutter); display: flex; flex-direction: column; align-items: center; padding-top: 4px; gap: 4px; user-select: none; }
.line.active .gutter { background: var(--accent); color: #fff; }
.gutter { cursor: grab; touch-action: none; }
.gutter .swatch { cursor: pointer; }
.line.dragging { z-index: 5; box-shadow: 0 6px 18px rgba(0,0,0,.25), inset 0 0 0 2px var(--accent); background: var(--bg, #fff); opacity: .95; }
body.dragging-line, body.dragging-line * { cursor: grabbing !important; user-select: none !important; }
.idx { font-size: 10.5px; color: var(--muted); align-self: flex-start; padding-left: 4px; }
.line.active .idx { color: #fff; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 3px solid var(--c); background: var(--c); padding: 0; }
.swatch.off { background: transparent; }
.swatch.none { visibility: hidden; }
.warn { color: var(--err); font-size: 19px; line-height: 1; cursor: help; }
.content { flex: 1; min-width: 0; padding: 8px 34px 6px 10px; }
.del { position: absolute; right: 4px; top: 6px; border: 0; background: transparent; color: #b5b5b5; font-size: 22px; width: 28px; height: 28px; border-radius: 4px; line-height: 1; }
.del:hover { color: var(--err); background: var(--chip); }
.src { width: 100%; resize: none; border: 0; outline: none; background: transparent; color: var(--text); font: 15px/1.45 "Cascadia Mono", Consolas, "Courier New", monospace; padding: 2px 0; overflow: hidden; display: none; }
.line.active .src { display: block; }
/* símbolo da derivada/integral fracionária: caixa com diagonal, d em cima, d^(x/y) embaixo */
.fdsym { display: inline-block; position: relative; width: 2.3em; height: 2.1em; vertical-align: -0.75em; margin: 0 .15em;
  border: 1px solid currentColor; box-sizing: border-box; font-style: normal; cursor: pointer;
  background: linear-gradient(to bottom right, transparent calc(50% - .6px), currentColor calc(50% - .6px), currentColor calc(50% + .6px), transparent calc(50% + .6px)); }
.fdsym .fd-top { position: absolute; left: .12em; top: -.02em; font-size: 1.05em; line-height: 1; font-family: Arial, sans-serif; }
.fdsym .fd-bot { position: absolute; right: .1em; bottom: .02em; font-size: 1.05em; line-height: 1; font-family: Arial, sans-serif; white-space: nowrap; display: flex; align-items: flex-start; }
.fdsym .fd-ord { display: inline-flex; align-items: center; margin-left: .04em; margin-top: -.35em; font-size: .58em; }
.fdsym .fd-fr { display: inline-flex; flex-direction: column; align-items: center; line-height: 1; }
.fdsym .fd-n { border-bottom: 1px solid currentColor; padding: 0 .05em; }
.fdsym .fd-v { line-height: 1; }
.fdsym.fd-neg { color: #6042a6; }
.fdsym:hover { outline: 2px solid rgba(45,112,179,.35); }
/* editor matemático (MathQuill): a fórmula é o próprio campo de digitação */
.mqf { display: none; }
.line.mathmode .mqf { display: block; }
.line.mathmode .src, .line.mathmode.active .src, .line.mathmode .view { display: none !important; }
.line .mqf.mq-editable-field { border: 0; box-shadow: none; width: 100%; box-sizing: border-box; min-height: 34px; padding: 4px 0;
  font-size: 20px; color: var(--text); overflow-x: auto; overflow-y: hidden; white-space: nowrap; cursor: text; }
.line .mqf.mq-editable-field.mq-focused { box-shadow: none; border: 0; }
.line .mqf .mq-root-block { padding: 2px 0; }
.line .mqf .mq-empty { background: var(--hole); }
.line .mqf.mq-editable-field .mq-root-block.mq-empty { background: transparent; }
body.dark .line .mqf .mq-cursor { border-color: var(--text); }
body.dark .mq-math-mode .mq-selection, body.dark .mq-editable-field .mq-selection { background: #3a5a85 !important; }
.view { font-family: var(--math); font-size: 21px; line-height: 1.5; min-height: 30px; overflow-x: auto; overflow-y: hidden; white-space: nowrap; cursor: text; padding: 2px 0; }
.line.active .view { font-size: 18px; opacity: .9; border-top: 1px dashed var(--line); margin-top: 4px; padding-top: 4px; }
.line.active .view:empty { display: none; }
.line.note .view { font-family: var(--ui); font-size: 15px; white-space: normal; color: var(--muted); }
.result { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 5px; margin-top: 4px; }
.result:empty { display: none; }
.eqsign { color: var(--muted); font-family: var(--math); font-size: 19px; margin-right: 2px; }
.approx { color: var(--muted); font-family: var(--math); font-size: 16px; margin: 0 2px 0 6px; }
.chip { background: var(--chip); border: 1px solid var(--chipb); border-radius: 5px; padding: 2px 8px; font-family: var(--math); font-size: 19px; cursor: copy; max-width: 100%; overflow-x: auto; white-space: nowrap; }
.chip:hover { border-color: var(--accent); }
.chip.sec { font-size: 16px; color: var(--muted); }
.chip.lst { font-size: 16px; padding: 1px 6px; }
.chip.sub, .chip.txt { white-space: normal; overflow-wrap: anywhere; }
/* destaque do maior / menor da lista */
.chip.mx { border-color: #2e8b57; background: rgba(46, 139, 87, .12); }
.chip.mx::after { content: ' ▲'; color: #2e8b57; font-size: 10px; font-family: var(--ui); }
.chip.mn { border-color: #d9534f; background: rgba(217, 83, 79, .10); }
.chip.mn::after { content: ' ▼'; color: #d9534f; font-size: 10px; font-family: var(--ui); }
.listinfo .lmx { color: #2e8b57; } .listinfo .lmn { color: #d9534f; }
/* tabela */
.ptable { max-width: 100%; overflow-x: auto; margin: 2px 0; }
.ptable table { border-collapse: collapse; font-family: var(--math); font-size: 15px; }
.ptable th { font-family: var(--ui); font-size: 12px; color: var(--muted); font-weight: 600; text-align: right; padding: 2px 10px; border-bottom: 1px solid var(--chipb); }
.ptable td { text-align: right; padding: 1px 10px; white-space: nowrap; }
.ptable td.tn { color: var(--muted); font-size: 11px; font-family: var(--ui); }
.ptable tr:nth-child(even) td { background: var(--chip); }
.ptable .tvazio { color: var(--muted); }
/* fit: usar a fórmula como linha */
button.usefit { font-size: 12px; padding: 2px 8px; margin-left: 6px; border: 1px solid var(--accent); color: var(--accent); background: transparent; border-radius: 5px; cursor: pointer; }
button.usefit:hover { background: var(--accent); color: #fff; }
/* segundo plano */
.bgpend { color: var(--accent); font-style: italic; }
.bgpend a { cursor: pointer; text-decoration: underline; font-style: normal; }
/* relatório: só aparece na impressão */
#report { display: none; }
.repbtns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
/* conta */
/* logado: fundo azul de .pill.on — texto branco (antes era azul sobre azul e o nome sumia) */
#btnConta.on { color: #fff; font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cform label { display: block; margin: 8px 0; font-size: 13px; color: var(--muted); }
.cform input { display: block; width: 100%; box-sizing: border-box; margin-top: 4px; padding: 7px 9px; font-size: 15px; border: 1px solid var(--chipb); border-radius: 6px; background: var(--chip); color: inherit; }
.cform .cerro { color: #d9534f; min-height: 1.2em; margin: 4px 0; font-size: 13px; }
@media print {
  body.printing > *:not(#report) { display: none !important; }
  body.printing #report { display: block; color: #000; background: #fff; font-family: 'Segoe UI', Arial, sans-serif; padding: 0 4mm; }
  #report h1 { font-size: 20px; margin: 0 0 2px; }
  #report .rdata { color: #666; font-size: 11px; margin-bottom: 8px; }
  #report .robj { border-left: 3px solid #2d70b3; padding: 4px 8px; margin: 6px 0 10px; font-size: 13px; }
  #report .rgraf { width: 100%; max-height: 95mm; object-fit: contain; border: 1px solid #ddd; margin-bottom: 8px; }
  #report .rline { padding: 5px 0; border-bottom: 1px solid #eee; break-inside: avoid; }
  #report .rn { display: inline-block; width: 22px; color: #888; font-size: 11px; vertical-align: top; }
  #report .rres { margin-left: 22px; font-family: 'Times New Roman', serif; font-size: 14px; overflow-wrap: anywhere; }
  #report .rerr { margin-left: 22px; color: #b33; font-size: 12px; }
  #report .rnote { padding: 6px 0; font-style: italic; color: #333; break-inside: avoid; }
  #report .rtab { margin-left: 22px; border-collapse: collapse; font-size: 12px; }
  #report .rtab th, #report .rtab td { border: 1px solid #ccc; padding: 1px 6px; text-align: right; }
}
.chip .undef { color: var(--muted); font-style: italic; font-family: var(--ui); font-size: 14px; }
.chip .idxn { font-size: 10px; color: var(--muted); vertical-align: super; margin-right: 2px; font-family: var(--ui); }
.chip .idxs { display: inline-flex; flex-direction: column; vertical-align: middle; font-size: 10px; line-height: 1.05; color: var(--muted); margin-right: 3px; font-family: var(--ui); text-align: right; }
.chip .idxs .idxo { color: var(--accent); }
.sd, .pol { border: 1px solid var(--chipb); background: var(--panel); color: var(--text); border-radius: 5px; font-size: 12.5px; padding: 3px 7px; font-weight: 600; }
.sd:hover, .pol:hover { border-color: var(--accent); color: var(--accent); }
.sd.d { background: var(--accent); color: #fff; border-color: var(--accent); }
.listinfo { font-size: 12px; color: var(--muted); text-align: right; }
/* quebra invisível: a informação da lista vai para a linha de baixo e o S⇔D fica ao lado dela (economiza uma linha) */
.result .fbreak { flex-basis: 100%; height: 0; }
.listinfo a { color: var(--accent); cursor: pointer; }
.err { color: var(--err); font-size: 12.5px; margin-top: 3px; font-family: var(--ui); }
.err:empty { display: none; }
.err button { margin: 3px 5px 0 0; border: 1px solid var(--chipb); background: var(--panel); color: var(--accent); border-radius: 12px; padding: 2px 10px; font-size: 12px; }
.kindtag { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; font-family: var(--ui); }
.slider { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.slider input[type=range] { flex: 1; accent-color: var(--c); }
.slider .lim { width: 52px; border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 12px; text-align: center; padding: 1px; border-radius: 4px; }
.slider .lim:hover, .slider .lim:focus { border-color: var(--chipb); outline: none; }
.slider .play { border: 0; background: var(--chip); color: var(--text); width: 26px; height: 26px; border-radius: 50%; font-size: 11px; }
.trange { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 4px; font-size: 12.5px; color: var(--muted); font-family: var(--math); }
.trange input { width: 60px; border: 1px solid var(--chipb); background: var(--panel); color: var(--text); border-radius: 4px; font-size: 12px; padding: 2px 4px; text-align: center; }

/* ---------- matemática renderizada */
.view .var, .fmath .var { font-style: italic; }
.view .const { font-style: normal; }
.view .fn, .view .numlit { font-style: normal; }
.view .fn { margin-right: 1px; }
.view .op { margin: 0 .22em; }
.view sub { font-size: .65em; vertical-align: -0.35em; font-style: normal; }
.view sup, .chip sup { font-size: .68em; vertical-align: .75em; line-height: 0; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 .12em; font-size: .9em; line-height: 1.15; }
.frac > .num { border-bottom: 1px solid currentColor; padding: 0 .15em .05em; }
.frac > .den { padding: .05em .15em 0; }
.sqrt { display: inline-flex; align-items: stretch; vertical-align: middle; position: relative; }
.sqrt .rad { font-size: 1.1em; line-height: 1; align-self: flex-end; margin-right: -1px; }
.sqrt .radicand { border-top: 1px solid currentColor; padding: .05em .1em 0 .1em; }
.sqrt .rootidx { font-size: .55em; position: relative; top: -.2em; margin-right: -.45em; z-index: 1; }
.pg, .absg, .piece { display: inline-flex; align-items: center; vertical-align: middle; }
.pl, .pr, .bar, .brace, .lst { display: inline-block; transform-origin: center; font-weight: 300; }
.pg > .pi { display: inline-block; }
.bigop { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 .15em; line-height: 1; }
.bigop .sym { font-size: 1.75em; line-height: 1; }
.bigop .lim { font-size: .62em; line-height: 1.2; min-height: 1em; }
.intg { display: inline-flex; align-items: center; vertical-align: middle; margin-right: .1em; }
.intg .sym { font-size: 2em; line-height: 1; font-style: italic; }
.ilim { display: inline-flex; flex-direction: column; justify-content: space-between; font-size: .62em; height: 2.6em; margin-left: -.15em; }
.ilim .lo { padding-left: .1em; }
.dx { font-style: italic; margin-left: .25em; }
.hole { display: inline-block; width: .65em; height: 1em; background: var(--hole); vertical-align: middle; margin: 0 .08em; border-radius: 1px; }
.raw { font-family: "Cascadia Mono", Consolas, monospace; font-size: 15px; color: var(--muted); }
.kw { font-family: var(--ui); font-size: .7em; color: var(--muted); }
.prime { margin-left: .05em; }
.times { margin: 0 .12em; }
.thin { display: inline-block; width: .22em; }
.imag { font-style: italic; margin-left: .05em; }
.angle { margin: 0 .15em; }

/* ---------- gráfico */
.gctl { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; }
.gctl button, .floating { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 18px; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.gctl button:hover, .floating:hover { border-color: var(--accent); color: var(--accent); }
.floating { position: absolute; left: 12px; top: 12px; }

/* ---------- teclado */
#kbdToggle { position: fixed; left: 12px; bottom: 12px; z-index: 30; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 8px; padding: 8px 12px; font-size: 13.5px; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
#keypad { flex: none; position: relative; z-index: 40; background: var(--kbg); border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgba(0,0,0,.08); padding: 6px 10px 10px; max-height: 46vh; overflow-y: auto; }
body.kbd #kbdToggle { display: none; }
.ktabs { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.ktabs button { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 6px; padding: 5px 14px; font-size: 13px; }
.ktabs button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.khint { font-size: 12px; color: var(--muted); }
.kgrid { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.kblock { display: grid; gap: 5px; }
.k { min-width: 52px; height: 42px; border: 0; border-radius: 6px; background: var(--key); color: var(--keyt); font-family: var(--math); font-size: 19px; box-shadow: 0 1px 0 rgba(0,0,0,.18); padding: 0 6px; }
.k:hover { background: var(--key2); }
.k:active { transform: translateY(1px); }
.k.act { background: var(--accent); color: #fff; font-family: var(--ui); font-size: 15px; }
.k.op2 { background: var(--key2); }
.k.ui { font-family: var(--ui); font-size: 14px; }
.k.sdk { background: #2f3640; color: #fff; font-family: var(--ui); font-size: 14px; font-weight: 600; }
.fcats { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 10px 18px; }
.fcat h4 { margin: 4px 0 5px; font: 600 11.5px var(--ui); color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.fcat .fk { display: flex; flex-wrap: wrap; gap: 4px; }
.fcat .k { min-width: 0; height: 34px; font-size: 15px; padding: 0 9px; }

/* ---------- modal / toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 60; display: grid; place-items: center; }
.mbox { background: var(--panel); color: var(--text); width: min(820px, 94vw); max-height: 86vh; overflow: auto; border-radius: 12px; box-shadow: 0 18px 60px rgba(0,0,0,.3); }
.mhead { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; position: sticky; top: 0; background: var(--panel); }
.mhead button { border: 0; background: transparent; color: var(--muted); font-size: 18px; }
#mBody { padding: 14px 20px 20px; font-size: 14px; line-height: 1.55; }
#mBody table { border-collapse: collapse; width: 100%; }
#mBody td { border-bottom: 1px solid var(--line); padding: 5px 8px; vertical-align: top; }
#mBody code { background: var(--chip); padding: 1px 5px; border-radius: 4px; font-family: "Cascadia Mono", Consolas, monospace; font-size: 13px; }
#mBody h3 { margin: 16px 0 6px; font-size: 15px; }
.setrow { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); gap: 16px; }
.setrow small { display: block; color: var(--muted); }
.setrow input[type=number] { width: 70px; }
.toast { position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%); background: #2f2f33; color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 70; }
.toast.show { opacity: 1; }

@media (max-width: 820px) {
  .title, .brand b, .tb #btnOpen { display: none; }
  main { flex-direction: column-reverse; }
  #panel { width: 100% !important; height: 55%; border-right: 0; border-top: 1px solid var(--line); }
  #splitter { display: none; }
  #right { height: 45%; flex: none; }
  #graphWrap { flex: 1; }
  #ana { height: 36px; } #ana .abody { display: none; } #ana:not(.collapsed) { height: 50%; } #ana:not(.collapsed) .abody { display: flex; }
  .aask, .aauto { display: none; }
  .abody { flex-direction: column; } .acol + .acol { border-left: 0; border-top: 1px solid var(--line); }
}
