/* Garlicoin Wallet (wallet.garlicoin.org). Light and dark follow the device. Strict CSP: no inline styles in HTML. */
@font-face { font-family: Nunito; src: url(/assets/fonts/nunito-latin.woff2) format("woff2"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: Fredoka; src: url(/assets/fonts/fredoka-600-latin.woff2) format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --bg: #fbf5e6; --card: #fffdf7; --ink: #2b2118; --muted: #7a6a58; --line: #ecdcc0;
  --gold: #f2b632; --gold-deep: #e09a12; --gold-soft: #fdf0cf; --on-gold: #2b1d05;
  --ok: #1f8a4c; --bad: #c0392b; --shadow: 0 10px 30px rgba(120, 80, 10, .12);
  --bulb: #fbf3df; --bulb-line: #d9b77a; --face: #4a3420; --cheek: #f6a6a0;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1b1510; --card: #261e17; --ink: #f6ead8; --muted: #b9a68e; --line: #3f3226;
    --gold-soft: #3a2c13; --ok: #5fd08f; --bad: #ff7a6b; --shadow: 0 10px 30px rgba(0, 0, 0, .35);
    --bulb: #f4e8cc; --bulb-line: #c9a865; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { min-height: 100vh; min-height: 100dvh; background: var(--bg); color: var(--ink); font: 17px/1.5 Nunito, system-ui, -apple-system, "Segoe UI", sans-serif;
  background-image: radial-gradient(circle at 20% -10%, var(--gold-soft) 0, transparent 45%), radial-gradient(circle at 110% 30%, var(--gold-soft) 0, transparent 35%); }
a { color: var(--gold-deep); font-weight: 700; }
h1, .h2 { font-family: Fredoka, Nunito, sans-serif; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; margin: 6px 0 8px; text-align: center; }
.h2 { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.15rem; margin: 26px 0 6px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; gap: 8px; max-width: 520px; margin: 0 auto; padding: 14px 16px 6px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 700; }
.brand b { color: var(--gold-deep); }
.beta { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; background: var(--gold-soft); color: var(--gold-deep); }
.top-actions { margin-left: auto; display: flex; gap: 6px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- screens ---------- */
main { max-width: 520px; margin: 0 auto; padding: 0 16px 40px; }
.screen { display: none; flex-direction: column; gap: 12px; padding: 18px; margin-top: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.screen.on { display: flex; animation: screen-in .35s ease-out; }
@keyframes screen-in { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
.lead { margin: 0; color: var(--muted); text-align: center; }
.step { margin: 0; text-align: center; font-size: .8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-deep); }
.note { margin: 4px 0 0; color: var(--muted); font-size: .88rem; text-align: center; }
.stack { display: grid; gap: 10px; margin-top: 6px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.lbl { font-weight: 800; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: -6px; }
.msg { margin: 0; min-height: 1.2em; font-size: .92rem; color: var(--muted); }
.msg.bad { color: var(--bad); } .msg.good { color: var(--ok); }
.warn { margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--gold-soft); font-size: .92rem; }
.empty { text-align: center; color: var(--muted); }

/* ---------- controls ---------- */
.btn { position: relative; overflow: hidden; display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 52px; padding: 12px 20px;
  border: 0; border-radius: 16px; background: var(--gold); color: var(--on-gold); font: inherit; font-weight: 800; font-size: 1.05rem; text-decoration: none; cursor: pointer;
  box-shadow: 0 4px 0 var(--gold-deep); transition: transform .08s, box-shadow .08s; -webkit-tap-highlight-color: transparent; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--gold-deep); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.ghost { background: var(--card); color: var(--ink); border: 2px solid var(--line); box-shadow: none; }
.btn.small { min-height: 40px; padding: 8px 14px; font-size: .92rem; border-radius: 12px; }
.link { background: none; border: 0; padding: 6px; color: var(--muted); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; align-self: center; }
.link.danger, .danger { color: var(--bad); }
.big-input { width: 100%; min-width: 0; padding: 14px 16px; border: 2px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--ink); font: inherit; font-size: 1.1rem; }
.big-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
textarea.big-input { resize: vertical; font-size: .95rem; }
.field-row { display: flex; gap: 8px; align-items: stretch; }
.unit-btn { flex: none; padding: 0 12px; border: 2px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); font: inherit; font-weight: 800; cursor: pointer; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; cursor: pointer; }
.check input { width: 22px; height: 22px; flex: none; accent-color: var(--gold-deep); margin-top: 1px; }
.meter { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: -4px; }
.meter span { display: block; height: 100%; width: 0; background: var(--bad); transition: width .3s, background .3s; }
.meter span.s2 { background: var(--gold-deep); } .meter span.s3 { background: var(--ok); }

/* ---------- key and QR ---------- */
.keybox { display: grid; justify-items: center; gap: 10px; padding: 14px; border: 2px dashed var(--gold); border-radius: 16px; background: var(--gold-soft); }
.keybox canvas, .qr-card canvas { width: 180px; height: 180px; border-radius: 12px; background: #fff; }
.key { display: block; max-width: 100%; font-size: .95rem; text-align: center; overflow-wrap: anywhere; user-select: all; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.qr-card { display: grid; place-items: center; padding: 16px; border-radius: 20px; background: #fff; align-self: center; }
.qr-card canvas { width: 220px; height: 220px; }
.addr { display: block; text-align: center; overflow-wrap: anywhere; font-size: .95rem; padding: 8px 10px; border-radius: 10px; background: var(--bg); }
.names { text-align: center; margin: 0; }
.more summary { cursor: pointer; font-weight: 700; color: var(--muted); text-align: center; }
.more .big-input { margin-top: 8px; }

/* ---------- home ---------- */
.hero { display: grid; justify-items: center; text-align: center; padding: 4px 0 6px; }
.bal-label { margin: 6px 0 0; font-size: .8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.bal { margin: 0; font-family: Fredoka, Nunito, sans-serif; font-size: clamp(2.2rem, 11vw, 3.2rem); line-height: 1.1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.bal .unit { font-size: .45em; color: var(--muted); }
.bal-fiat { margin: 2px 0 0; color: var(--muted); font-weight: 700; }
.pending { margin: 6px 0 0; padding: 4px 12px; border-radius: 999px; background: var(--gold-soft); font-size: .88rem; font-weight: 700; }
.actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.act { display: grid; justify-items: center; gap: 4px; padding: 12px 4px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); color: var(--ink); font: inherit; font-size: .85rem; font-weight: 800; cursor: pointer; transition: transform .1s; }
.act:active { transform: scale(.95); }
.act-i { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--gold); color: var(--on-gold); font-size: 1.2rem; font-weight: 900; }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.activity li:first-child { border-top: 0; }
.activity .ic { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--gold-soft); font-weight: 900; }
.activity .in .ic { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.activity .what { display: grid; min-width: 0; }
.activity .what span { color: var(--muted); font-size: .85rem; }
.activity .amt { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.activity .in .amt { color: var(--ok); }
.activity a { color: inherit; text-decoration: none; }

/* ---------- review / sent ---------- */
.review { text-align: center; padding: 14px; border-radius: 18px; background: var(--bg); }
.rv-amt { margin: 0; font-family: Fredoka, Nunito, sans-serif; font-size: 2.2rem; line-height: 1.1; overflow-wrap: anywhere; }
.rv-fiat { margin: 0; color: var(--muted); font-weight: 700; }
.rv-to { margin: 10px 0 0; font-size: 1.1rem; overflow-wrap: anywhere; }
.rv-addr { margin: 2px 0 0; font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; }
.rv-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 0; }
.rv-facts dt { font-size: .75rem; font-weight: 800; text-transform: uppercase; color: var(--muted); }
.rv-facts dd { margin: 0; font-weight: 800; overflow-wrap: anywhere; }
.hold .hold-fill { position: absolute; inset: 0; background: var(--gold-deep); transform: scaleX(0); transform-origin: left; }
.hold .hold-text { position: relative; }
.hold.holding .hold-text::after { content: "…"; }
.giftbox { padding: 14px; border-radius: 16px; border: 2px dashed var(--gold); background: var(--gold-soft); display: grid; gap: 8px; }
.giftbox p { margin: 0; }

/* ---------- settings ---------- */
.menu { list-style: none; margin: 0; padding: 0; }
.menu li { border-top: 1px solid var(--line); padding: 12px 2px; }
.menu li:first-child { border-top: 0; }
.menu button { display: grid; width: 100%; text-align: left; background: none; border: 0; padding: 0; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.menu button span { font-weight: 400; font-size: .85rem; color: var(--muted); }
.menu button.danger { color: var(--bad); }
.menu label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 700; }
.menu select { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); }
.menu .links { font-size: .9rem; color: var(--muted); }

/* ---------- Clove the mascot ---------- */
.mascot { width: 92px; height: 100px; margin: 0 auto; }
.mascot.big { width: 130px; height: 140px; }
.clove { width: 100%; height: 100%; overflow: visible; }
.clove-body { transform-origin: 60px 124px; animation: bob 3.2s ease-in-out infinite; }
.clove-bulb { fill: var(--bulb); stroke: var(--bulb-line); stroke-width: 3; }
.clove-line { fill: none; stroke: var(--bulb-line); stroke-width: 2; opacity: .7; }
.clove-sprout { fill: none; stroke: #7cb342; stroke-width: 4; stroke-linecap: round; }
.clove-roots { stroke: var(--bulb-line); stroke-width: 2.5; stroke-linecap: round; }
.clove-eye { fill: var(--face); transform-box: fill-box; transform-origin: center; animation: blink 4.5s infinite; }
.clove-cheek { fill: var(--cheek); opacity: .55; }
.clove-mouth { fill: none; stroke: var(--face); stroke-width: 3; stroke-linecap: round; transition: d .3s; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-1.5deg); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
.clove.happy .clove-body { animation: hop .5s ease-out 3; }
.clove.happy .clove-mouth { d: path("M46 92 Q 60 110 74 92"); }
@keyframes hop { 40% { transform: translateY(-18px) scale(1.04, .97); } 70% { transform: translateY(0) scale(.97, 1.04); } }
.clove.wow .clove-body { animation: wiggle .25s ease-in-out 6; }
.clove.wow .clove-eye { transform: scale(1.3); }
@keyframes wiggle { 50% { transform: rotate(6deg); } }
.clove.sleep .clove-eye { transform: scaleY(.15); animation: none; }
.clove.sleep .clove-body { animation-duration: 5s; }

/* ---------- toast, celebration, scanner, print ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; padding: 12px 18px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 700; box-shadow: var(--shadow); animation: toast-in .25s ease-out; max-width: calc(100vw - 32px); text-align: center; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }
.fx-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 30; }
.scanner { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; align-content: center; gap: 14px; background: rgba(0, 0, 0, .85); }
.scanner video { width: min(90vw, 420px); border-radius: 18px; }
.print-card { display: none; }
body.fewer-motion *, body.fewer-motion *::before { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
@media print {
  body { background: #fff; }
  body > *:not(.print-card) { display: none !important; }
  .print-card { display: block; max-width: 5.5in; margin: 0 auto; padding: 18px; border: 2px dashed #888; color: #000; font: 13px/1.5 sans-serif; }
  .print-card h2 { font-size: 16px; margin: 0 0 10px; }
  .print-card canvas { width: 2.2in; height: 2.2in; }
  .print-card .mono { font-family: monospace; overflow-wrap: anywhere; font-size: 14px; }
}
@media (max-width: 380px) { .actions { grid-template-columns: repeat(2, minmax(0, 1fr)); } .screen { padding: 14px; } }
.gift-list { list-style: none; margin: 6px 0 0; padding: 0; font-size: .9rem; }
.gift-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; color: var(--muted); }
.free { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 4px; font-size: .85rem; font-weight: 800; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-weight: 800; font-size: .88rem; text-decoration: none; cursor: pointer; font-family: inherit; }
.chip:hover { border-color: var(--gold); }
.paybox { margin: 0; padding: 10px 14px; border-radius: 14px; background: var(--gold-soft); border: 2px solid var(--gold); text-align: center; font-weight: 700; overflow-wrap: anywhere; }
.lbl-soft { text-transform: none; letter-spacing: 0; font-weight: 600; }
.recent { display: flex; flex-wrap: wrap; gap: 6px; }
.activity li { grid-template-columns: 36px minmax(0, 1fr) auto 28px; }
.note-text { font-style: normal; font-size: .85rem; color: var(--gold-deep); overflow-wrap: anywhere; }
.note-btn { width: 28px; height: 28px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; }
.note-btn:hover { background: var(--gold-soft); }
.nudge { display: grid; gap: 8px; }
.install { align-self: center; margin-top: 6px; }
.hat { transform-origin: 60px 22px; }
.clove.happy .hat { animation: hat-hop .5s ease-out 3; }
@keyframes hat-hop { 40% { transform: translateY(-6px) rotate(-8deg); } }
.muted-text { color: var(--muted); margin: 6px 0 0; }
.chip.ready { background: var(--gold); color: var(--on-gold); border-color: var(--gold-deep); animation: chip-pulse 2.4s ease-in-out infinite; }
@keyframes chip-pulse { 50% { box-shadow: 0 0 0 6px var(--gold-soft); } }

/* ---------- badges ---------- */
.center { text-align: center; }
.badges { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); gap: 10px; }
.badges li { display: grid; justify-items: center; gap: 2px; padding: 12px 8px; border-radius: 16px; border: 2px solid var(--gold); background: var(--gold-soft); text-align: center; }
.badges .b-icon { font-size: 2rem; line-height: 1.2; }
.badges strong { font-size: .95rem; }
.badges span:not(.b-icon) { font-size: .8rem; color: var(--muted); }
.badges li.locked { border: 2px dashed var(--line); background: var(--bg); }
.badges li.locked .b-icon { filter: grayscale(1); opacity: .35; }
.badges li.locked strong { color: var(--muted); }
.badge-pop { position: fixed; left: 50%; top: 18px; z-index: 35; display: flex; align-items: center; gap: 12px; padding: 10px 18px 10px 12px; border-radius: 18px; border: 2px solid var(--gold); background: var(--card); color: var(--ink); box-shadow: var(--shadow); transform: translateX(-50%); animation: pop-in .45s cubic-bezier(.2, 1.6, .4, 1); max-width: calc(100vw - 32px); }
.badge-pop .bp-icon { font-size: 2.2rem; animation: spin-in .7s ease-out; }
.badge-pop .bp-text { display: grid; }
.badge-pop small { font-weight: 800; color: var(--gold-deep); text-transform: uppercase; font-size: .72rem; letter-spacing: .04em; }
@keyframes pop-in { from { opacity: 0; transform: translate(-50%, -30px) scale(.6); } }
@keyframes spin-in { from { transform: rotate(-200deg) scale(.2); } }

/* ---------- watched savings ---------- */
.savings-line { margin: 8px auto 0; padding: 4px 12px; border-radius: 999px; border: 1px dashed var(--line); background: none; color: var(--muted); font: inherit; font-size: .88rem; font-weight: 700; cursor: pointer; }
.savings-line:hover { border-color: var(--gold); color: var(--ink); }
.savings { list-style: none; margin: 0; padding: 0; }
.savings li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 10px 2px; border-top: 1px solid var(--line); }
.savings li:first-child { border-top: 0; }
.savings .sv-name { font-weight: 800; }
.savings .sv-bal { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.savings a { grid-column: 1; font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.savings .link { grid-column: 2; padding: 0; font-size: .85rem; justify-self: end; }
.sv-total { margin: 0; text-align: center; font-weight: 800; }
.sv-add { display: grid; gap: 8px; }
