/* The Precise Calculator: a chunky comic device, a thought bubble, a reasoning trace and a receipt. Tokens only. */
.calc { max-width: 1080px; margin: 0 auto; padding: 18px clamp(16px, 3vw, 28px) 48px; }
.calc__intro { margin: 4px 0 18px; }
.calc__grid { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 820px) { .calc__grid { grid-template-columns: 1fr; justify-items: center; } .side { width: 100%; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- the device ---------- */
.device-wrap { position: relative; width: min(400px, 100%); padding-top: 64px; }
.device { position: relative; box-sizing: border-box; padding: 18px 18px 20px; background: var(--yellow); border: 4px solid var(--ink); border-radius: 26px; box-shadow: 8px 8px 0 var(--ink); }
.device::before { content: ""; position: absolute; inset: 0; border-radius: 22px; background: radial-gradient(color-mix(in srgb, var(--ink) 14%, transparent) 1.3px, transparent 1.8px) 0 0 / 9px 9px; pointer-events: none; }
.device__brand { position: relative; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 4px 10px; color: #141210; }
.device__brand b { font: 26px/1 var(--font-display); letter-spacing: .06em; color: var(--red); -webkit-text-stroke: 1px #141210; }
.device__brand span { font: 600 10px var(--font-label); letter-spacing: .14em; }
.lcd { position: relative; box-sizing: border-box; min-height: 104px; padding: 10px 14px 12px; border: 4px solid #141210; border-radius: 12px; background: #b9d9c4; color: #142019;
  box-shadow: inset 0 4px 0 rgba(0,0,0,.12); display: grid; align-content: end; overflow: hidden; }
.lcd::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(0,0,0,.035) 0 2px, transparent 2px 4px); pointer-events: none; }
.lcd__sub { min-height: 18px; font: 14px/1.2 var(--font-type); text-align: right; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lcd__main { font: 600 44px/1.1 var(--font-label); text-align: right; letter-spacing: .02em; white-space: nowrap; overflow-x: auto; scrollbar-width: none; font-variant-numeric: tabular-nums; }
.lcd__main::-webkit-scrollbar { display: none; }
.lcd__main[data-size="m"] { font-size: 34px; }
.lcd__main[data-size="s"] { font-size: 26px; }
.lcd__main[data-size="xs"] { font-size: 19px; }
.rep { text-decoration: overline; text-decoration-thickness: 2px; text-underline-offset: 2px; }
.lcd__dots { display: none; gap: 8px; justify-content: flex-end; padding: 10px 2px 6px; }
.lcd__dots i { width: 12px; height: 12px; border-radius: 50%; background: #142019; animation: calc-dot 1s infinite ease-in-out; }
.lcd__dots i:nth-child(2) { animation-delay: .15s; } .lcd__dots i:nth-child(3) { animation-delay: .3s; }
.lcd.is-thinking .lcd__dots { display: flex; }
.lcd.is-thinking .lcd__main { font-size: 20px; }
:root[data-motion="off"] .lcd.is-thinking .lcd__dots { display: none; }
@keyframes calc-dot { 0%, 100% { transform: translateY(0); opacity: .35; } 50% { transform: translateY(-6px); opacity: 1; } }
.lcd.is-full { animation: calc-shake .25s; }
@keyframes calc-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
:root[data-motion="off"] .lcd.is-full { animation: none; }

.keys { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.key { min-height: 58px; border: 3px solid #141210; border-radius: 14px; background: #fffaf0; color: #141210; font: 600 24px/1 var(--font-label); cursor: pointer;
  box-shadow: 0 5px 0 #141210; transition: transform .05s, box-shadow .05s; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.key--fn { background: #e8ddc4; font-size: 18px; letter-spacing: .04em; }
.key--op { background: var(--cyan); color: #141210; font-size: 28px; }
.key--eq { background: var(--red); color: #fff; font-size: 30px; }
.key:active, .key.is-down { transform: translateY(4px); box-shadow: 0 1px 0 #141210; }
.key:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.is-busy .key { cursor: progress; }
.is-busy .key:not(:active) { filter: saturate(.7); }

.calc__sfx { position: absolute; right: -14px; top: 74px; font-size: 40px; opacity: 0; pointer-events: none; transform: rotate(-8deg) scale(.4); }
.calc__sfx.is-on { animation: calc-pop .9s ease-out forwards; }
@keyframes calc-pop { 0% { opacity: 0; transform: rotate(-8deg) scale(.4); } 18% { opacity: 1; transform: rotate(-8deg) scale(1.15); } 30% { transform: rotate(-8deg) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: rotate(-8deg) scale(1); } }

/* thought bubble while it "thinks" */
.bubble-think { position: absolute; left: 6px; right: 6px; top: -6px; z-index: 2; display: grid; place-items: center; min-height: 56px; padding: 8px 18px; background: var(--panel); color: var(--ink);
  border: 3px solid var(--panel-ink); border-radius: 30px; font: 15px/1.3 var(--font-type); text-align: center; box-shadow: 4px 4px 0 var(--panel-ink); }
.bubble-think i { position: absolute; border: 3px solid var(--panel-ink); background: var(--panel); border-radius: 50%; }
.bubble-think i:nth-of-type(1) { width: 16px; height: 16px; bottom: -20px; left: 36%; }
.bubble-think i:nth-of-type(2) { width: 9px; height: 9px; bottom: -32px; left: 31%; }

.express { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; margin-top: 20px; cursor: pointer; font: 600 14px var(--font-label); letter-spacing: .04em; }
.express input { width: 22px; height: 22px; accent-color: var(--accent); grid-row: span 2; }
.express small { font: 12px var(--font-body); color: var(--muted); letter-spacing: 0; }

/* ---------- side panels ---------- */
.side { display: grid; gap: 18px; }
.side__panel { padding: 16px 18px; display: grid; gap: 12px; }
.side__h { margin: 0; font: 600 13px var(--font-label); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.trace { margin: 0; padding-left: 1.4em; display: grid; gap: 6px; font: 15px/1.45 var(--font-type); min-height: 3em; }
.trace .t-hint { list-style: none; margin-left: -1.4em; color: var(--muted); }
.trace .t-q { font-weight: 700; }
.trace .t-a { color: var(--accent); font-weight: 700; }
.trace .t-m { color: var(--muted); font-size: 13px; }
.receipt, .float-note { border-top: 2px dashed var(--line); padding-top: 12px; }
.receipt h3, .float-note h3 { margin: 0 0 6px; font: 600 12px var(--font-label); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.receipt__dec { margin: 0; font: 600 22px/1.35 var(--font-label); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.receipt__frac { margin: 4px 0 0; font: 14px var(--font-type); color: var(--ink-2); overflow-wrap: anywhere; }
.float-note__val { margin: 0; font: 600 18px/1.35 var(--font-label); color: var(--muted); text-decoration: line-through; text-decoration-color: var(--accent); text-decoration-thickness: 2px; overflow-wrap: anywhere; }
.float-note__why { margin: 4px 0 0; font: 13.5px/1.45 var(--font-body); color: var(--ink-2); }
.examples { display: flex; flex-wrap: wrap; gap: 8px; }
.examples .chip { min-height: 40px; cursor: pointer; }
.side__fine { margin: 0; font: 13px/1.5 var(--font-body); color: var(--muted); }

/* ---------- editions ---------- */
:root[data-theme="hud"] .device { box-shadow: 8px 8px 0 var(--panel-ink); }
:root[data-skin="clean"] .device { background: var(--panel); border: 1px solid var(--line); box-shadow: 0 24px 50px -28px rgba(0,0,0,.45); }
:root[data-skin="clean"] .device::before { display: none; }
:root[data-skin="clean"] .device__brand { color: var(--ink); }
:root[data-skin="clean"] .device__brand b { color: var(--accent); -webkit-text-stroke: 0; font-weight: 800; font-size: 20px; }
:root[data-skin="clean"] .lcd { border-width: 1px; border-color: var(--line); box-shadow: none; }
:root[data-skin="clean"] .lcd::after { display: none; }
:root[data-skin="clean"] .key { border-width: 1px; border-color: var(--line); box-shadow: none; background: var(--paper-2); color: var(--ink); }
:root[data-skin="clean"] .key--fn { background: var(--paper); }
:root[data-skin="clean"] .key--op { background: color-mix(in srgb, var(--accent) 14%, var(--paper-2)); color: var(--ink); }
:root[data-skin="clean"] .key--eq { background: var(--accent); color: var(--accent-ink); }
:root[data-skin="clean"] .key:active, :root[data-skin="clean"] .key.is-down { transform: scale(.97); }
:root[data-skin="clean"] .bubble-think, :root[data-skin="clean"] .bubble-think i { border-width: 1px; box-shadow: none; }
:root[data-skin="clean"] .calc__sfx { display: none; }
:root[data-theme="hud"] .lcd { background: #10241a; color: #7cf2b0; }
:root[data-theme="hud"] .lcd__dots i { background: #7cf2b0; }
