:root{color-scheme:light;--ink:#2a342d;--muted:#4c554e;--ground:#f8f0e5;--paper:#fffefa;--line:#d7c5b5;--accent:#963f2b;--green:#324f40;--mono:ui-monospace,'SFMono-Regular',Consolas,monospace}
*{box-sizing:border-box}
body{margin:0;background:radial-gradient(ellipse at 12% 5%,#ffe6c9 0,transparent 44rem),var(--ground);color:var(--ink);font:1rem/1.5 system-ui,sans-serif}
main{max-width:72rem;margin:auto;padding:clamp(.85rem,4vw,3rem)}
h1,h2,h3,p{margin:0}header{padding-bottom:clamp(1.35rem,3.5vw,2.65rem)}
.mast{display:flex;align-items:center;justify-content:space-between;gap:.5rem;border-bottom:1px solid var(--line);padding-bottom:.7rem}
.mast strong{font-size:.83rem;letter-spacing:.11em;text-transform:uppercase}.mast span{font-size:.82rem;color:var(--muted)}
h1{max-width:14ch;font:500 clamp(2.45rem,7vw,5.45rem)/.98 Georgia,serif;letter-spacing:-.055em;margin:clamp(1.2rem,4vw,2.4rem) 0 .8rem}
h1 em{font-weight:400;color:var(--accent)}header p{max-width:39ch;font-size:clamp(1rem,2vw,1.18rem);color:var(--muted)}
.layout{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.04fr);gap:clamp(.65rem,4vw,3.75rem);align-items:start}
.choices{position:sticky;top:.75rem}.choices h2,.next h2{font:500 clamp(1.4rem,3vw,2rem)/1.08 Georgia,serif;letter-spacing:-.018em}.choices h2{margin:0 0 .85rem}
.cards{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.58rem}
.topic{display:flex;align-items:center;gap:.58rem;text-align:left;padding:.68rem;min-height:3.7rem;border:1px solid var(--line);background:#fffaf2;color:var(--ink);border-radius:.7rem;font:650 1rem/1.18 system-ui,sans-serif;cursor:pointer;overflow-wrap:anywhere;transition:background .15s,border-color .15s}
.topic:hover{border-color:var(--accent)}.topic[aria-pressed=true]{background:#f7dfcf;border-color:var(--accent);color:#76321f}
.mark{display:grid;place-items:center;flex:none;width:1.3rem;height:1.3rem;border:1px solid currentColor;border-radius:50%;color:var(--accent)}
.receipt{min-width:0;min-height:calc(29rem + var(--extra,0rem));display:flex;flex-direction:column;position:relative;padding:clamp(.75rem,3vw,2rem);background:repeating-linear-gradient(0deg,#53442c03 0 1px,transparent 1px 4px),var(--paper);color:#292923;box-shadow:0 14px 28px -12px #69483054,0 1px 3px #60483137;overflow-wrap:anywhere;font: .94rem/1.47 var(--mono)}
.receipt:before,.receipt:after{position:absolute;left:0;right:0;content:"";height:6px;background:conic-gradient(from 45deg at bottom,transparent 0deg 270deg,var(--paper) 270deg 360deg) 0 0/12px 6px repeat-x}
.receipt:before{top:-5px}.receipt:after{bottom:-5px;transform:rotate(180deg)}
.receipt-head{text-align:center;padding:0 0 1.05rem}.brand-mark{display:block;width:clamp(2.35rem,6vw,3.65rem);height:auto;aspect-ratio:1;margin:.05rem auto .4rem;color:var(--accent)}
.brand-name{font:700 clamp(1.15rem,3.1vw,2.3rem)/1 Georgia,serif;letter-spacing:-.03em}
.receipt-head h2{font:600 .73rem/1.4 var(--mono);letter-spacing:.12em;text-transform:uppercase;margin-top:.4rem;color:#514f43}
.receipt-columns,.receipt li{display:grid;grid-template-columns:2.6rem minmax(0,1fr);gap:.23rem}
.receipt-columns{padding:.48rem 0;border-block:1px dashed #817c6b;font-size:.79rem;font-weight:700}
.receipt ul{list-style:none;padding:0;margin:0}.receipt li{padding:.62rem 0;border-bottom:1px dotted #aaa091}.receipt li strong{display:block}.position{color:var(--accent);font-weight:700;font-variant-numeric:tabular-nums}
.receipt-bottom{margin-top:auto;border-top:1px dashed #817c6b;padding-top:.6rem}.receipt-bottom h3{font:750 .98rem/1.23 var(--mono)}
#reset{margin-top:.25rem;min-height:44px;padding:0;border:0;background:none;text-decoration:underline;color:#753a2a;font:inherit;cursor:pointer;text-align:left}
.receipt-end{text-align:center;margin-top:.85rem;color:#514d42;font-size:.72rem;letter-spacing:.08em;text-transform:uppercase}
.barcode{display:block;width:min(100%,6rem);height:1.1rem;margin:0 auto .3rem;background:repeating-linear-gradient(90deg,#36342c 0 1px,transparent 1px 3px,#36342c 3px 6px,transparent 6px 8px,#36342c 8px 9px,transparent 9px 12px,#36342c 12px 14px,transparent 14px 15px)}
.next{margin-top:2.55rem;padding:1.15rem 0;border-top:1px solid var(--line)}.next p{margin:.48rem 0 .8rem;color:var(--muted)}
.links{display:flex;gap:.55rem;flex-wrap:wrap}.links a{border:1px solid var(--green);border-radius:.4rem;padding:.61rem .8rem;color:var(--green);text-decoration:none;font-weight:650}.links a:first-child{background:var(--green);color:#fff}.links a:hover{text-decoration:underline}
footer{font-size:.86rem;color:var(--muted)}[hidden]{display:none!important}:focus-visible{outline:3px solid var(--accent);outline-offset:3px}
.sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
@media(max-width:40rem){
.layout{grid-template-columns:minmax(0,.89fr) minmax(0,1.11fr);gap:.56rem}.cards{grid-template-columns:1fr;gap:.35rem}
.topic{min-height:44px;font-size:.87rem;padding:.37rem;gap:.33rem}.mark{width:1.02rem;height:1.02rem;font-size:.8rem}.choices h2{font-size:1.16rem}
.receipt{min-height:calc(22rem + var(--extra,0rem));padding:.67rem;font-size:.8rem}.receipt-head{padding-bottom:.72rem}.receipt-head h2{font-size:.64rem}.receipt-columns,.receipt li{grid-template-columns:1.56rem minmax(0,1fr);gap:.18rem}.receipt-columns{font-size:.65rem}.receipt-bottom h3{font-size:.84rem}.receipt li{padding:.5rem 0}
}
@media(max-height:40rem){.choices{position:static}}
@media(prefers-reduced-motion:reduce){.topic{transition:none}}

.receipt-columns,.receipt li{grid-template-columns:2.6rem minmax(0,1fr) 3ch}
.amount-label,.amount{text-align:right;font-variant-numeric:tabular-nums}
.amount{color:#292923}
.receipt-total{display:flex;justify-content:space-between;gap:.25rem;align-items:baseline;font-variant-numeric:tabular-nums;font-weight:750;color:#292923}
#total-amount{font-size:clamp(1.06rem,2.75vw,1.65rem);white-space:nowrap}
.receipt-unit{font-size:.76rem;color:#514f43;margin:.1rem 0 .72rem}
@media(max-width:40rem){.receipt-columns,.receipt li{grid-template-columns:1.25rem minmax(0,1fr) 2.15ch}.receipt-unit{font-size:.68rem}}

/* Two sides of one running balance */
.choice-switch{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.45rem;margin-bottom:.75rem}
.choice-switch button{min-height:44px;padding:.46rem .55rem;border:1px solid var(--line);border-radius:.55rem;background:#fffaf2;color:var(--ink);font:700 .91rem/1.12 system-ui,sans-serif;cursor:pointer;text-align:left}
.choice-switch button span{font:800 1rem/1 var(--mono);margin-right:.19rem}
#cost-mode[aria-pressed=true]{border-color:var(--accent);color:#76321f;background:#f7dfcf}
#gain-mode[aria-pressed=true],.gain-topic[aria-pressed=true]{border-color:#4b7458;color:#264933;background:#e4f0e1}
.gain-topic .mark,.credit .amount,.credit .position,#total-amount[data-tone=gain]{color:#275b3d}
.charge .amount,#total-cost[data-tone=cost],#total-amount[data-tone=cost]{color:#a31b27;font-weight:800}
.gain-topic:hover{border-color:#4b7458}
.receipt{min-height:32rem}
.receipt li,.receipt-columns{grid-template-columns:2.15rem minmax(0,1fr) 3.2ch}
.subtotals{margin:0 0 .45rem;font-size:.83em}
.subtotals div{display:flex;justify-content:space-between;gap:.35rem}
.subtotals dd{margin:0;white-space:nowrap}
#total-cost{color:#843725}#total-gain{color:#275b3d}
#receipt-title{scroll-margin-top:1rem}
.jump{display:inline-block;color:var(--green);font-size:.85rem;margin-top:.55rem}
.choices{position:static}
@media(max-width:40rem){
 .choice-switch{grid-template-columns:1fr;gap:.25rem}
 .choice-switch button{font-size:.78rem;padding:.37rem}
 .receipt{min-height:25.5rem}
 .brand-name{font-size:clamp(.88rem,3.45vw,1.38rem)}
 .receipt li,.receipt-columns{grid-template-columns:1.05rem minmax(0,1fr) 3.1ch}
}

header h1{max-width:23ch;font-size:clamp(2.2rem,5.8vw,4.85rem)}

/* Thermal paper: shallow creases, a turned corner and soft cast shadow. */
.receipt{
 --paper:#fcf3dc;
 background:
  url('receipt-folds.svg') center top / 100% clamp(9.5rem,23vw,19rem) no-repeat,
  linear-gradient(149deg,transparent 74%,#bf9e6338 99%) right bottom / 54% 6rem no-repeat,
  repeating-linear-gradient(0deg,#6f503307 0 1px,transparent 1px 4px),
  linear-gradient(105deg,#f1e3c5 0%,#fdf6e4 9%,#fffdf2 48%,#fdf4dd 94%,#f3e5c6 100%);
 box-shadow:1px 2px 4px #67451f25, 7px 16px 20px -13px #5d391d78, 13px 30px 40px -25px #53321a8c;
 border-radius:1px 3px 2px 2px;
}
@media(min-width:41rem){
 .receipt{rotate:1.65deg;transform-origin:50% 40%}
 .receipt:has(#lines > :nth-child(8)){rotate:.65deg}
}

/* The controls should look like parts you can actually press. */
.choice-switch{gap:.52rem;margin-bottom:.92rem}
.choice-switch button{
 padding:.67rem .76rem;min-height:3.25rem;
 border:1.5px solid #9b755a;background:#fffcf6;border-radius:.58rem;
 font-weight:800;box-shadow:0 2px 0 #9b755a45;
}
#cost-mode[aria-pressed=true]{background:#843c2a;color:#fffaf1;border-color:#843c2a;box-shadow:0 2px 0 #592c21}
#gain-mode[aria-pressed=true]{background:#345843;color:#f7fff8;border-color:#345843;box-shadow:0 2px 0 #213e2d}
.cards{gap:.62rem}
.topic{
 min-height:4.15rem;padding:.68rem .76rem;
 border:1.5px solid #b89c80;background:#fffdf7;
 border-radius:.6rem;font-weight:760;
 box-shadow:0 2px 0 #a3846555;
}
.topic span:last-child{min-width:0}
.mark{background:#f7e7d8;border:1px solid #ae775d;font-weight:800}
.gain-topic .mark{background:#ecf2e5;border-color:#6b8a72}
.cost-topic[aria-pressed=true]{background:#f5ddcf;border-color:#8f3925;box-shadow:inset 3px 0 #8f3925,0 2px 0 #8f392552;color:#602516}
.gain-topic[aria-pressed=true]{background:#e1eddf;border-color:#3c6549;box-shadow:inset 3px 0 #3c6549,0 2px 0 #3c654957;color:#23422e}
.cost-topic[aria-pressed=true] .mark{background:#843c2a;border-color:#843c2a;color:#fff}
.gain-topic[aria-pressed=true] .mark{background:#345843;border-color:#345843;color:#fff}
@media(max-width:40rem){
 .choice-switch{gap:.42rem;margin-bottom:.62rem}
 .choice-switch button{min-height:44px;padding:.5rem .42rem;font-size:.8rem}
 .cards{gap:.48rem}
 .topic{min-height:48px;padding:.45rem .39rem}
}
