:root {
  color-scheme: dark;
  --page: #0c111a;
  --navy: #101724;
  --case: #1b2535;
  --display: #0a101a;
  --paper: #18212e;
  --ink: #f2f3f5;
  --muted: #b7c1d0;
  --rule: #3b4658;
  --key: #424242;
  --control: #525252;
  --operator: #606060;
  --equals: #c6c6c6;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 1rem; }
body { margin: 0; min-width: 280px; color: var(--ink); background: var(--page); font: 1rem/1.5 var(--sans); }
button, input { font: inherit; }
button, summary { cursor: pointer; }
a { color: inherit; text-underline-offset: .22em; }
:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
button:disabled { opacity: .58; cursor: default; }
.wrap { width: min(980px, calc(100% - 3rem)); margin-inline: auto; }
header { background: var(--navy); border-bottom: 1px solid #2c3646; }
.bar { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.bar > a:last-child { color: var(--muted); font-size: .92rem; font-weight: 600; }
.tool-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1.15rem; font-size: .94rem; font-weight: 600; }
.tool-nav a { padding-block: .35rem; }
.tool-nav a[href="#ayuda"] { color: var(--muted); }
@media (max-width: 470px) {
  .bar:has(.tool-nav) { flex-wrap: wrap; gap: 0 .75rem; padding-block: .5rem; }
  .tool-nav { column-gap: 1.1rem; }
}
.brand { display: inline-flex; align-items: center; gap: .65rem; text-decoration: none; font-size: 1.16rem; font-weight: 720; letter-spacing: -.04em; }
.mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; background: #d7d7d7; color: #141414; font: 800 1.65rem/.8 var(--mono); }
.intro { padding: 2rem 0 1.45rem; }
.intro h1, h2, p { margin: 0; }
.intro h1 { font-size: clamp(2.35rem, 5.25vw, 3.8rem); font-weight: 740; letter-spacing: -.055em; line-height: 1.07; text-wrap: balance; }
.intro p { margin-top: .65rem; color: var(--muted); font-size: 1.05rem; }
.desk { display: grid; align-items: start; grid-template-columns: minmax(0, 1.07fr) minmax(0, 1fr); gap: clamp(1rem, 3vw, 2rem); }
.machine { padding: clamp(.85rem, 2.4vw, 1.35rem); background: var(--case); border: 1px solid #485467; border-radius: 18px; box-shadow: inset 0 1px 0 #ffffff0d, 0 5px 0 #070b12; }
.display { margin-bottom: .95rem; padding: .8rem 1rem; overflow: hidden; color: var(--ink); background: var(--display); border: 1px solid #445063; border-radius: 9px; }
.display-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font: 650 .85rem/1.4 var(--sans); }
.lamp { display: none; }
.expression { display: block; min-height: 1.3rem; overflow-x: auto; white-space: nowrap; text-align: right; color: var(--muted); font: 500 .9rem/1.45 var(--mono); }
#visor { display: block; overflow-x: auto; white-space: nowrap; text-align: right; font: 600 clamp(2.2rem, 4.6vw, 3.55rem)/1.16 var(--mono); letter-spacing: -.065em; font-variant-numeric: tabular-nums; }
#visor.long { font-size: clamp(1.3rem, 3.3vw, 2rem); }
.keys { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .48rem; }
.keys button { display: grid; place-items: center; min-height: clamp(46px, 6.3vw, 58px); padding: .3rem; border: 1px solid #727272; border-radius: 8px; background: var(--key); color: #fff; font: 560 1.45rem/1 var(--mono); box-shadow: 0 2px 0 #101010; }
.keys .ctl { background: var(--control); font-size: 1.22rem; }
.keys .ctl svg { width: 23px; height: 23px; }
.keys .op { background: var(--operator); font-size: 1.65rem; }
.keys .equals { color: #161616; background: var(--equals); border-color: #dedede; font-size: 1.8rem; font-weight: 750; }
.keys button.chosen { color: #111; background: #ddd; border-color: #fff; box-shadow: inset 0 0 0 1px #111, 0 2px 0 #101010; }
@media (hover: hover) {
  .keys button:hover { filter: brightness(1.18); }
  .paper-actions button:not(:disabled):hover, .dialog-actions button:hover { border-color: #e0e0e0; }
  .term button:hover { background: #353535; }
}
.keys button:active { transform: translateY(1px); box-shadow: none; }
#aviso:empty { display: none; }
#aviso { margin: .75rem .1rem 0; color: var(--ink); font-size: .9rem; }
.paper { position: relative; margin-bottom: 7px; padding: clamp(1rem, 3vw, 1.7rem); background: var(--paper); border: 1px solid var(--rule); border-bottom: 0; border-radius: 4px 4px 0 0; }
.paper::after { content: ""; position: absolute; top: 100%; left: -1px; right: -1px; height: 8px; background: linear-gradient(135deg, var(--paper) 25%, transparent 25%) -7px 0/14px 14px repeat-x, linear-gradient(225deg, var(--paper) 25%, transparent 25%) -7px 0/14px 14px repeat-x; }
.paper-head { display: flex; align-items: center; gap: .6rem; padding-bottom: 1.1rem; border-bottom: 1px dashed #626c79; }
.ticket-icon { display: grid; place-items: center; height: 29px; width: 25px; border-radius: 2px; color: #171717; background: #c6c6c6; font: 1.4rem/1 var(--mono); }
h2 { font-size: 1.48rem; line-height: 1.2; letter-spacing: -.045em; }
.empty { padding: 2rem .1rem 1.8rem; color: var(--muted); max-width: 30ch; }
.empty b { display: block; color: var(--ink); margin-bottom: .35rem; }
.paper-actions, .dialog-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; }
.paper-actions { border-top: 1px dashed #626c79; padding-top: 1rem; }
.paper-actions button, .dialog-actions button { min-height: 40px; padding: .49rem .85rem; border: 1px solid #858585; border-radius: 7px; color: #fff; background: #484848; font-size: .9rem; font-weight: 650; }
.paper-actions button:last-child, .dialog-actions .secondary { background: #303030; border-color: #737373; }
.privacy { margin-top: .8rem; color: var(--muted); font-size: .86rem; }
#historial { max-height: 34rem; overflow-y: auto; scrollbar-color: #687281 transparent; }
.sheet { padding: .8rem 0; }
.sheet + .sheet { border-top: 1px dashed var(--rule); }
.sheet h3 { margin: 0 0 .45rem; color: var(--muted); font-size: .88rem; font-weight: 650; }
.term, .subtotal { display: flex; align-items: center; justify-content: space-between; gap: .7rem; }
.term { padding: .1rem .05rem; font: 1.02rem/1.4 var(--mono); }
.term button { max-width: 90%; min-height: 30px; padding: .1rem .25rem; border: 0; border-bottom: 1px dotted #a7a7a7; color: #ededed; background: transparent; font: inherit; overflow-wrap: anywhere; }
.subtotal { margin-top: .35rem; padding: .45rem 0 .1rem; border-top: 1px solid var(--rule); font-weight: 650; }
.subtotal output { text-align: right; font: 700 1.15rem/1.45 var(--mono); overflow-wrap: anywhere; }
#ayuda { margin: 1.8rem 0 3rem; padding: .9rem .15rem; border-block: 1px solid var(--rule); }
summary { font-weight: 650; }
summary::marker { color: #aeb8c7; }
.help { padding: .35rem 0; max-width: 76ch; color: var(--muted); }
.help p { margin-top: .55rem; }
dialog { width: min(365px, calc(100% - 2rem)); padding: 1.5rem; border: 1px solid #627083; border-radius: 13px; color: var(--ink); background: var(--paper); }
dialog::backdrop { background: #05070bbd; }
dialog h2 { margin-bottom: 1rem; }
dialog label { display: block; margin-bottom: .3rem; font-weight: 650; }
dialog input { width: 100%; padding: .55rem; border: 1px solid #8993a1; border-radius: 6px; color: var(--ink); background: var(--display); font: 1.1rem var(--mono); }
.dialog-actions { justify-content: flex-end; margin-top: 1rem; }
#errorEdicion { margin-top: .5rem; color: #ffd2d2; font-size: .9rem; }
@media (max-width: 680px) {
  .wrap { width: calc(100% - 2rem); }
  .bar { min-height: 54px; }
  .intro { padding: 1.4rem 0 1.05rem; }
  .intro h1 { font-size: clamp(2.15rem, 7.5vw, 2.8rem); }
  .intro p { font-size: 1rem; }
  .desk { grid-template-columns: minmax(0, 1fr); gap: 1.45rem; }
  .machine, .paper { width: 100%; }
  .keys button { min-height: 48px; }
  .display { padding: .6rem .8rem; }
  .expression { min-height: 1.15rem; }
  .empty { padding: 1.2rem 0; }
  .paper-head { padding-bottom: .8rem; }
  .privacy { margin-top: .55rem; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
