:root {
  --paper: #f1e6cf; --paper-2: #e6d7b9; --paper-3: #d6c4a0;
  --ink: #2a2118; --ink-2: #6b5a44; --ink-3: #9a8768;
  --ochre: #c8742e; --ochre-2: #e39a4c; --teal: #2f6a66; --red: #a3302a; --green: #4f7a3e;
  --night: #1c140c;
  --serif: "Libre Baskerville", Georgia, serif; --sans: "Libre Franklin", system-ui, sans-serif;
  --paper-tex: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='3'/><feColorMatrix values='0 0 0 0 .4  0 0 0 0 .3  0 0 0 0 .15  0 0 0 .1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--ink); font-family: var(--sans); overscroll-behavior: none; }
body { position: fixed; inset: 0; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
#stage, #stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#grain { position: absolute; inset: 0; pointer-events: none; opacity: .12; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }

/* ---------- every panel floats in 3D ---------- */
#ui3d { z-index: 5; }
.p3d { pointer-events: auto; will-change: transform, opacity; }
.p3d > * { filter: drop-shadow(0 14px 22px rgba(10, 5, 0, .45)); }
.plaque { width: 350px; padding: 16px 18px; border-radius: 18px; color: var(--ink); background: var(--paper) var(--paper-tex);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5), inset 0 -3px 0 rgba(120,90,50,.18); -webkit-user-select: text; user-select: text; }
.plaque h2 { margin: 0; font: 700 19px/1.25 var(--serif); }
.plaque h3 { margin: 18px 0 8px; font: italic 400 15px var(--serif); color: var(--ink-2); }
.plaque.mini { width: 112px; padding: 6px 8px 7px; border-radius: 10px; display: grid; gap: 3px; }
.plaque.mini b { font: 700 10.5px var(--sans); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plaque.info { display: grid; gap: 5px; padding: 13px 16px; }
.plaque.info h2 { font-size: 17px; }
.plaque.form { max-height: 640px; overflow-y: auto; overscroll-behavior: contain; }
.plaque.ledger { width: 360px; max-height: 690px; display: flex; flex-direction: column; padding-bottom: 12px; }
.ledger .tabBody { overflow-y: auto; overscroll-behavior: contain; margin: 0 -18px; padding: 0 18px; flex: 1; min-height: 0; }

.title3d { width: 330px; text-align: center; color: #fbf1da; text-shadow: 0 2px 12px rgba(0,0,0,.7); }
.title3d h2 { margin: 0; font: italic 700 24px var(--serif); }
.title3d p { margin: 4px 0 0; font: 500 12px var(--sans); letter-spacing: .05em; opacity: .85; }
.note3d { padding: 9px 16px; border-radius: 14px; background: rgba(30,20,12,.72); color: #f6ead0; font-size: 13px; white-space: nowrap; }
.note3d em { color: rgba(246,234,208,.7); font-family: var(--serif); }
.toast3d { padding: 12px 18px; border-radius: 16px; background: var(--paper) var(--paper-tex); font-size: 14px; white-space: nowrap; }

.b3d { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 46px; padding: 0 22px; border-radius: 23px; font: 600 14.5px var(--sans);
  background: var(--paper) var(--paper-tex); color: var(--ink); box-shadow: inset 0 -3px 0 rgba(120,90,50,.2); white-space: nowrap; transition: transform .15s; }
.b3d:active { transform: scale(.95); }
.b3d.ghost { background: rgba(30,20,12,.7); color: #f6ead0; box-shadow: inset 0 0 0 1px rgba(246,234,208,.25); }
.choice { white-space: normal; width: 170px; height: 96px; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 2px; text-align: left; padding: 14px; border-radius: 18px;
  background: var(--paper) var(--paper-tex); font: 700 15px var(--sans); box-shadow: inset 0 -4px 0 rgba(120,90,50,.2); transition: transform .15s; }
.choice span { font-size: 19px; margin-bottom: auto; }
.choice small { font: 400 12px/1.3 var(--sans); color: var(--ink-2); }
.choice.primary { background: #2f241a; color: var(--paper); box-shadow: inset 0 -4px 0 rgba(0,0,0,.35); }
.choice.primary small { color: rgba(241,230,207,.7); }
.choice.small { width: 190px; height: 50px; flex-direction: row; align-items: center; justify-content: center; border-radius: 25px; padding: 0 16px; }
.choice:active { transform: scale(.96); }

/* ---------- HUD ---------- */
.hud.title { width: 230px; color: #fbf1da; text-shadow: 0 2px 10px rgba(0,0,0,.65); }
.hud.title h1 { margin: 0; font: italic 700 19px/1.1 var(--serif); }
.hud.title p { margin: 3px 0 0; font: 500 10.5px var(--sans); letter-spacing: .06em; text-transform: uppercase; opacity: .8; }
.hud.menuBtn { width: 46px; height: 46px; border-radius: 14px; color: #fbf1da; background: rgba(30,20,12,.6); box-shadow: inset 0 0 0 1px rgba(246,234,208,.2); display: grid; place-items: center; }
.hud.modeSwitch { position: relative; display: grid; grid-template-columns: 1fr 1fr; width: 230px; height: 50px; padding: 4px; border-radius: 25px; background: rgba(30,20,12,.7); box-shadow: inset 0 0 0 1px rgba(246,234,208,.2); }
.modeSwitch button { position: relative; z-index: 1; font: 700 14px var(--sans); color: rgba(246,234,208,.7); border-radius: 21px; transition: color .3s; }
.modeSwitch button.on { color: var(--ink); }
.modeSwitch .thumbPill { position: absolute; top: 4px; left: 4px; width: calc(50% - 4px); height: 42px; border-radius: 21px; background: var(--paper); transition: transform .45s cubic-bezier(.3,1.4,.5,1); }
.modeSwitch[data-mode=out] .thumbPill { transform: translateX(100%); }
.hint3d { width: 320px; text-align: center; font: italic 400 13px var(--serif); color: #fbf1da; text-shadow: 0 1px 6px rgba(0,0,0,.85); opacity: 0; pointer-events: none; }
.hint3d.fade { animation: hint 4.5s ease forwards; }
.hint3d.idle { opacity: .85; animation: breathe 3s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .4; } }
@keyframes hint { 0% { opacity: 0; } 12%, 70% { opacity: .95; } 100% { opacity: 0; } }

/* ---------- meters ---------- */
.meter { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.meter b { flex: none; width: 40px; font: 800 9px var(--sans); text-transform: uppercase; letter-spacing: .03em; color: var(--ink-2); }
.mini .meter b { width: 28px; font-size: 7.5px; }
.meter .track { position: relative; flex: 1; height: 18px; border-radius: 9px; background: #4e4234; overflow: hidden; }
.mini .meter .track { height: 13px; }
.meter .fill { position: absolute; inset: 0 auto 0 0; border-radius: 9px; background: linear-gradient(90deg, var(--ochre), var(--ochre-2)); transition: width .8s cubic-bezier(.3,1.2,.5,1); }
.meter .track span { position: absolute; inset: 0; display: grid; place-items: center; font: 700 10.5px var(--sans); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.8); }
.mini .meter .track span { font-size: 8.5px; }
.meter .min { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; }
.meter .min.met { background: #b8e08a; }
.meter.locked .fill { background: repeating-linear-gradient(135deg, #8a7a62 0 4px, #6e604c 4px 8px); }
.meter.maxed .fill { background: linear-gradient(90deg, #4f7a3e, #79a85a); }
.meter.uncapped { justify-content: center; gap: 5px; height: 18px; border-radius: 9px; background: #4e4234; padding: 0 6px; }
.mini .meter.uncapped { height: 13px; }
.meter.uncapped span { font: 700 10.5px var(--sans); color: #fff; } .meter.uncapped em { font: italic 10px var(--serif); color: rgba(255,240,210,.75); }
.mini .meter.uncapped span, .mini .meter.uncapped em { font-size: 8.5px; }

.chip { display: inline-block; padding: 3px 8px; border-radius: 10px; background: var(--paper-2); font: 600 11px var(--sans); color: var(--ink-2); margin: 2px 4px 0 0; }
.chip.warn { background: #f0cdb8; color: var(--red); }
.detail { margin: 0 0 4px; font-size: 12px; color: var(--ink-2); line-height: 1.4; }
.detail strong { color: var(--red); font-weight: 600; }
.thumb { width: 92px; aspect-ratio: 1.586; border-radius: 6px; box-shadow: 0 4px 12px rgba(40,25,10,.35); object-fit: cover; flex: none; }

/* ---------- log form ---------- */
.log { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.log > * { min-width: 0; }
.amount { display: flex; align-items: baseline; gap: 6px; padding: 2px 4px 8px; border-bottom: 2px solid var(--ink); }
.amount span { font: 700 22px var(--serif); color: var(--ink-2); }
.amount input { flex: 1; width: 100%; min-width: 0; border: 0; background: none; font: 700 38px var(--serif); color: var(--ink); outline: none; padding: 0; }
.amount.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.noteIn, .log select, .log input[type=date] { width: 100%; border: 0; border-radius: 12px; background: var(--paper-2); padding: 11px 12px; font: 400 16px var(--sans); color: var(--ink); outline: none; -webkit-appearance: none; appearance: none; }
.lbl { margin: 8px 0 2px; font: 700 10.5px var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.cats, .seg { display: flex; flex-wrap: wrap; gap: 5px; }
.cats button, .seg button { padding: 8px 11px; border-radius: 16px; background: var(--paper-2); font: 500 13px var(--sans); color: var(--ink-2); transition: background .2s, color .2s; }
.cats button.on, .seg button.on { background: var(--ink); color: var(--paper); }
.toggles { display: grid; gap: 2px; margin-top: 4px; }
.toggles [hidden] { display: none; }
.toggle { display: flex; align-items: center; gap: 12px; padding: 6px 0; font: 500 14px var(--sans); }
.toggle small { display: block; font-size: 11.5px; color: var(--ink-3); font-weight: 400; }
.toggle input { display: none; }
.toggle span { flex: none; width: 44px; height: 26px; border-radius: 13px; background: var(--paper-3); position: relative; transition: background .2s; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 10px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .25s cubic-bezier(.3,1.4,.5,1); }
.toggle input:checked + span { background: var(--teal); }
.toggle input:checked + span::after { transform: translateX(18px); }
.verdict { margin-top: 10px; padding: 12px 14px; border-radius: 14px; background: var(--paper-2); font-size: 13px; line-height: 1.45; }
.verdict .big { font: 700 21px var(--serif); margin-bottom: 2px; }
.verdict .big em { display: block; font: italic 12px var(--serif); color: var(--ink-2); }
.verdict p { margin: 4px 0 0; color: var(--ink-2); }
.verdict .warn { color: var(--red); font-weight: 600; }
.verdict .after { color: var(--ink); font-weight: 600; }
.verdict.good { background: #d8e2c2; } .verdict.good .big { color: var(--green); }
.verdict.meh .big { color: var(--ochre); }
.row2 { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin-top: 10px; }
.save { height: 50px; border-radius: 16px; background: var(--ochre); color: #fff; font: 700 16px var(--sans); box-shadow: 0 4px 0 #8f4f1c; }
.save:active { transform: translateY(3px); box-shadow: 0 1px 0 #8f4f1c; }

/* ---------- card chat ---------- */
.chat3d { width: 350px; height: 480px; display: flex; flex-direction: column; border-radius: 20px; background: rgba(241,230,207,.92) var(--paper-tex); padding: 12px 14px 0; }
.chat3d header { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--paper-3); }
.chat3d header img { width: 40px; height: 40px; border-radius: 20px; object-fit: cover; object-position: 12% 50%; }
.chat3d header b { display: block; font: 700 15px var(--serif); } .chat3d header small { color: var(--ink-3); font-size: 11.5px; }
.chat { flex: 1; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 6px; padding: 12px 0; }
.chat.static { overflow: visible; padding: 8px 0; }
.bubble { align-self: flex-start; max-width: 86%; padding: 9px 13px; border-radius: 18px 18px 18px 6px; background: #fffaf0; box-shadow: 0 1px 2px rgba(60,40,20,.15); font-size: 14px; line-height: 1.4; animation: pop .3s cubic-bezier(.3,1.5,.5,1); }
.bubble.typing { display: flex; gap: 4px; padding: 13px; }
.bubble.typing i { width: 7px; height: 7px; border-radius: 4px; background: var(--ink-3); animation: dot 1s infinite; }
.bubble.typing i:nth-child(2) { animation-delay: .15s; } .bubble.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes pop { from { transform: scale(.85) translateY(6px); opacity: 0; } }
@keyframes dot { 50% { transform: translateY(-3px); opacity: .4; } }

/* ---------- ledger (menu) ---------- */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 12px; border-radius: 14px; background: var(--paper-2); }
.tabs button { padding: 9px; border-radius: 10px; font: 600 13.5px var(--sans); color: var(--ink-2); }
.tabs button.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.monthTitle { font-style: italic; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.tiles div { padding: 11px; border-radius: 14px; background: var(--paper-2); }
.tiles small { display: block; font: 600 10px var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.tiles b { font: 700 21px var(--serif); }
.moves { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.moves li { padding: 9px 12px; border-radius: 12px; background: #fffaf0; font-size: 13px; line-height: 1.4; border-left: 3px solid var(--ochre); }
.caps { display: grid; gap: 9px; }
.capRow { display: grid; gap: 4px; }
.capName { display: flex; justify-content: space-between; font: 600 12.5px var(--sans); }
.capName small { color: var(--teal); font-weight: 700; } .capName small em { color: var(--ink-3); font: italic 400 11px var(--serif); }
.cats-chart { display: grid; gap: 6px; }
.catRow { display: grid; grid-template-columns: 96px 1fr 60px; align-items: center; gap: 8px; font-size: 12.5px; }
.catRow div { height: 12px; border-radius: 6px; background: var(--paper-2); overflow: hidden; }
.catRow i { display: block; height: 100%; border-radius: 6px; background: var(--teal); }
.catRow b { text-align: right; }
.txns { list-style: none; margin: 0; padding: 0; }
.txns li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--paper-3); font-size: 13.5px; }
.txns li > div { flex: 1; min-width: 0; }
.txns small { display: block; color: var(--ink-3); font-size: 11px; margin-top: 2px; }
.txns .mi { font: 700 13.5px var(--sans); color: var(--teal); text-align: right; }
.txns .mi em { display: block; font: italic 10px var(--serif); color: var(--ink-3); }
.txns button { width: 30px; height: 30px; border-radius: 15px; color: var(--ink-3); font-size: 18px; }
.empty, .fine, .intro { color: var(--ink-3); font-size: 12.5px; font-style: italic; font-family: var(--serif); }
.wish { margin: 12px 0 20px; }
.wish header { display: flex; align-items: center; gap: 12px; }
.wish h2 { font-size: 16px; }
.menuFoot { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.menuFoot button, .menuFoot .btn { display: grid; place-items: center; height: 42px; border-radius: 13px; background: var(--paper-2); font: 600 13.5px var(--sans); cursor: pointer; }

/* ---------- loading ---------- */
#loading { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; background: var(--night); color: #f6ead0; font: italic 15px var(--serif); transition: opacity .8s; }
#loading.done { opacity: 0; pointer-events: none; }
#loading .brush { width: 64px; height: 10px; margin: 0 auto 14px; border-radius: 5px; background: linear-gradient(90deg, var(--ochre), var(--teal)); animation: brush 1.2s ease-in-out infinite alternate; }
@keyframes brush { from { transform: scaleX(.3); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01s !important; transition-duration: .01s !important; } }

/* ---------- fridge ---------- */
.choice.wide { width: 300px; height: 74px; flex-direction: row; align-items: center; justify-content: flex-start; gap: 12px; }
.choice.wide span { margin: 0; font-size: 26px; }
.choice.wide small { display: block; }
.fld { display: grid; gap: 3px; min-width: 0; }
.fld span { font: 700 10px var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.fld input, .fld select { width: 100%; min-width: 0; border: 0; border-radius: 10px; background: var(--paper-2); padding: 10px; font: 500 16px var(--sans); color: var(--ink); outline: none; -webkit-appearance: none; appearance: none; }
.fld input[type=file] { padding: 8px; font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }
.fridgeForm { gap: 8px; }
.pickBig { display: block; cursor: pointer; }
.pickBig .preview { display: grid; place-items: center; gap: 4px; min-height: 150px; padding: 14px; border-radius: 14px; border: 2px dashed var(--paper-3); text-align: center; font: 600 14px var(--sans); color: var(--ink-2); }
.pickBig .preview span { font-size: 30px; }
.pickBig .preview small { font: 400 12px var(--sans); color: var(--ink-3); }
.pickBig .preview img { max-width: 170px; max-height: 170px; filter: drop-shadow(0 6px 10px rgba(40,25,10,.35)); }
.noteText { width: 100%; border: 0; border-radius: 6px; padding: 14px; font: 600 26px/1.1 "Caveat", cursive; color: #2a2a3a; resize: none; outline: none; box-shadow: 0 3px 8px rgba(0,0,0,.15); }
.swatches { display: flex; gap: 10px; }
.swatches button { width: 38px; height: 38px; border-radius: 8px; box-shadow: inset 0 0 0 2px rgba(0,0,0,.1); }
.swatches button.on { box-shadow: 0 0 0 3px var(--ink); }
.plaque.center { text-align: center; width: 300px; }
.magnetBig { max-width: 200px; max-height: 200px; filter: drop-shadow(0 8px 12px rgba(40,25,10,.4)); }
.detail.center { text-align: center; margin-top: 10px; }
.countdown { margin: 2px 0 6px; font: italic 700 16px var(--serif); color: var(--ochre); }
.kv { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px 10px; }
.kv small { display: block; font: 700 9.5px var(--sans); text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); }
.kv b { font: 700 14px var(--sans); word-break: break-word; }
.ticketNote { margin: 0; }

/* ---------- nav: table · fridge · kitchen ---------- */
.hud.nav3d { position: relative; display: grid; grid-template-columns: repeat(3, 40px); gap: 2px; padding: 3px; height: 46px; border-radius: 15px;
  background: rgba(30,20,12,.6); box-shadow: inset 0 0 0 1px rgba(246,234,208,.2); }
.nav3d button { position: relative; z-index: 1; display: grid; place-items: center; border-radius: 12px; color: rgba(251,241,218,.72); transition: color .3s; }
.nav3d button.on { color: var(--ink); }
.nav3d .navPill { position: absolute; top: 3px; left: 3px; width: 40px; height: 40px; border-radius: 12px; background: var(--paper); transition: transform .45s cubic-bezier(.3,1.4,.5,1); }
.nav3d[data-at=fridge] .navPill { transform: translateX(42px); }
.nav3d[data-at=kitchen] .navPill { transform: translateX(84px); }

/* ---------- points ---------- */
.verdict .big .worth { display: block; font: 600 14px var(--sans); color: var(--ink-2); margin-top: 2px; }
.verdict .rate { font-size: 11.5px; color: var(--ink-3); }
.txns .mi small { display: block; font: 500 11px var(--sans); color: var(--ink-3); }
.ptsRows { display: grid; gap: 6px; }
.ptsRows div { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 0 10px; padding: 10px 12px; border-radius: 12px; background: var(--paper-2); }
.ptsRows span { font: 600 13px var(--sans); }
.ptsRows b { font: 700 17px var(--serif); text-align: right; }
.ptsRows small { grid-column: 1 / -1; font-size: 11.5px; color: var(--teal); font-weight: 700; }
