/* StashCash app. Phone first; on bigger screens it stays a phone-width column. */

:root {
  --lime: #C8F23A;
  --lime-dark: #B4DC26;
  --ink: #111111;
  --ink-2: #3A3A3A;
  --ink-3: #5C5C5C;
  --paper: #FAFAF7;
  --white: #FFFFFF;
  --gold: #F5C542;
  --line: #E7E7E1;
  --tint: #F2F2EC;
  --error: #B42318;

  --font-head: "Bricolage Grotesque", "Arial Black", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r-sm: 12px;
  --r: 16px;
  --r-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(17,17,17,.04), 0 2px 8px rgba(17,17,17,.04);
  --shadow: 0 2px 6px rgba(17,17,17,.04), 0 12px 32px rgba(17,17,17,.07);
  --gutter: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  height: calc(56px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) var(--gutter) 0;
  background: rgba(250,250,247,.92);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.logo {
  display: inline-flex; align-items: center;
  font-family: var(--font-head); font-weight: 800; font-size: 1.5rem;
  letter-spacing: -0.04em; line-height: 1; text-decoration: none;
}
.logo > span { display: inline-flex; align-items: center; }
.logo-c {
  display: inline-grid; place-items: center;
  font-size: .64em; width: 1.36em; height: 1.36em;
  margin: 0 .04em 0 .08em; border-radius: 50%;
  background: var(--ink); color: var(--lime);
}
.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; margin-right: -10px;
  border: 0; border-radius: 50%; background: none;
  font-size: 1.6rem; line-height: 1; cursor: pointer; text-decoration: none;
}
.icon-btn:active { background: var(--tint); }

.demo-banner {
  background: var(--gold); color: var(--ink);
  font-size: .875rem; font-weight: 600; text-align: center; padding: 6px var(--gutter);
}

/* ---------- Layout ---------- */
main { outline: none; }
.screen {
  max-width: 560px; margin: 0 auto;
  padding: 20px var(--gutter) calc(40px + var(--safe-b));
  display: flex; flex-direction: column; gap: 16px;
}
.boot { display: grid; place-items: center; min-height: 50vh; }

/* ---------- Type ---------- */
.h1 { font-family: var(--font-head); font-weight: 800; font-size: 2rem; line-height: 1.05; letter-spacing: -0.03em; }
.h2 { font-family: var(--font-head); font-weight: 800; font-size: 1.375rem; line-height: 1.15; letter-spacing: -0.02em; }
.h3 { font-size: 1rem; font-weight: 700; }
.lead { font-size: 1.0625rem; color: var(--ink-2); }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.fine { font-size: .8125rem; color: var(--ink-3); }
.center { text-align: center; }
.eyebrow { font-size: .8125rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.label { display: block; font-size: .875rem; font-weight: 600; color: var(--ink-2); }
.error { min-height: 1.2em; font-size: .875rem; color: var(--error); }
.error:empty { min-height: 0; }
.back { font-weight: 600; text-decoration: none; color: var(--ink-2); align-self: flex-start; padding: 6px 0; }
.section-title { margin-top: 8px; }

/* ---------- Cards ---------- */
.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 8px;
}
.card.notice { background: var(--tint); box-shadow: none; }
.card.tip { flex-direction: row; align-items: flex-start; gap: 4px; font-size: .9375rem; }
.card.tip .icon-btn { flex: none; margin: -10px -10px -10px 0; }

/* ---------- Buttons ---------- */
.btn {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 50px; padding: 12px 20px;
  border: 2px solid transparent; border-radius: 999px;
  font-weight: 700; font-size: 1rem; text-decoration: none; cursor: pointer;
  transition: transform .08s ease, background-color .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--lime); color: var(--ink); border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.btn-primary:active { box-shadow: 0 1px 0 var(--ink); transform: translateY(2px); }
.btn-secondary { background: var(--white); color: var(--ink); border-color: var(--ink); }
.btn-link { background: none; border: 0; min-height: 44px; padding: 8px; text-decoration: underline; font-weight: 600; color: var(--ink-2); }
.btn-link.danger { color: var(--error); align-self: center; margin-top: 8px; }
.btn-block { width: 100%; }
.btn-xl { min-height: 60px; font-size: 1.125rem; }
.btn-mini { min-height: 32px; padding: 4px 12px; font-size: .8125rem; background: var(--tint); border-color: var(--line); }
.btn.is-busy { color: transparent; position: relative; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 20px; height: 20px;
  border: 2.5px solid var(--ink); border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ---------- Forms ---------- */
.form { gap: 10px; padding: 20px; }
.input {
  width: 100%; min-height: 52px; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: var(--r-sm); background: var(--white);
  font: inherit; font-size: 1.0625rem; color: var(--ink);
}
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(200,242,58,.6); }
.input.code { font-size: 1.5rem; letter-spacing: .3em; text-align: center; font-weight: 700; }
.auth { padding-top: 32px; gap: 20px; }
.auth .h1 { font-size: 2.25rem; }

/* ---------- Home ---------- */
.stash-card {
  background: var(--ink); color: var(--white);
  border-radius: var(--r-lg); padding: 22px 20px 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.stash-card .eyebrow { color: var(--lime); }
.big-total {
  font-family: var(--font-head); font-weight: 800; font-size: 2.75rem;
  line-height: 1.05; letter-spacing: -0.03em; overflow-wrap: anywhere;
}
.stash-sub { color: rgba(255,255,255,.75); font-size: .9375rem; }
.gold-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); margin-right: 5px; vertical-align: 1px; }

.scan-list { display: flex; flex-direction: column; gap: 10px; }
.scan-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px; text-decoration: none; box-shadow: var(--shadow-sm);
}
.scan-row:active { background: var(--tint); }
.thumb {
  flex: none; width: 56px; height: 56px; border-radius: var(--r-sm);
  background: var(--tint) center / cover no-repeat;
}
.scan-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.scan-row-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scan-row-total { flex: none; font-weight: 800; font-family: var(--font-head); font-size: 1.0625rem; }

.how { gap: 14px; }
.how li { display: flex; gap: 12px; align-items: flex-start; }
.how span {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--lime); border: 1.5px solid var(--ink); font-weight: 800; font-size: .875rem;
}

/* ---------- Scan ---------- */
.pick { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.tips { display: flex; flex-direction: column; gap: 6px; font-size: .9375rem; color: var(--ink-2); }
.tips li { padding-left: 22px; position: relative; }
.tips li::before { content: ""; position: absolute; left: 4px; top: .55em; width: 8px; height: 8px; border-radius: 50%; background: var(--lime); border: 1.5px solid var(--ink); }
.preview { border-radius: var(--r); overflow: hidden; background: var(--tint); border: 1px solid var(--line); }
.preview img { width: 100%; max-height: 52vh; object-fit: cover; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px; padding: 8px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--white);
  font-weight: 600; font-size: .9375rem; cursor: pointer;
}
.auth-tabs { margin: 4px 0 16px; }
.auth-tabs .chip { text-decoration: none; display: inline-flex; align-items: center; color: var(--ink); }
.chip.is-on { background: var(--ink); color: var(--white); border-color: var(--ink); }

.scanning { padding-top: 32px; align-items: stretch; }
.scanning-photo { position: relative; }
.scanning-photo img { filter: saturate(.85); }
.scanline {
  position: absolute; left: 0; right: 0; top: 0; height: 30%;
  background: linear-gradient(to bottom, rgba(200,242,58,0), rgba(200,242,58,.55));
  border-bottom: 3px solid var(--lime);
  animation: scan 2.2s ease-in-out infinite alternate;
}
@keyframes scan { from { transform: translateY(-100%); } to { transform: translateY(240%); } }

/* ---------- Results ---------- */
.result-hero {
  position: relative; border-radius: var(--r-lg); overflow: hidden;
  background: var(--ink); color: var(--white); min-height: 200px;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.hero-photo { position: absolute; inset: 0; background: center / cover no-repeat; opacity: .55; }
.result-total {
  position: relative; padding: 20px;
  background: linear-gradient(to top, rgba(17,17,17,.92) 30%, rgba(17,17,17,0));
  display: flex; flex-direction: column; gap: 2px;
}
.result-total .eyebrow { color: var(--lime); }
.summary { color: var(--ink-2); }

.item-list { display: flex; flex-direction: column; background: var(--white); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.item { display: flex; align-items: center; gap: 10px; padding-right: 14px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 14px 0 14px 14px; background: none; border: 0; text-align: left; cursor: pointer;
}
.item-name { font-weight: 700; line-height: 1.3; }
.item-meta { font-size: .8125rem; color: var(--ink-3); }
.item-price { flex: none; font-family: var(--font-head); font-weight: 800; font-size: 1.0625rem; white-space: nowrap; }
.item.is-keeping .item-name, .item.is-keeping .item-price { color: var(--ink-3); text-decoration: line-through; }
.item.is-sold .item-price { color: #7A5B00; }
.warn { color: #8A5A00; font-weight: 600; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-weight: 700; font-size: .75rem; background: var(--tint); color: var(--ink); }
.pill-listed { background: var(--lime); }
.pill-sold { background: var(--gold); }

/* ---------- Item sheet ---------- */
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh;
  margin: auto auto 0; padding: 0;
  border: 0; border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 -10px 40px rgba(0,0,0,.2);
}
.sheet::backdrop { background: rgba(17,17,17,.45); }
.sheet[open] { animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-inner { padding: 18px var(--gutter) calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.sheet-head .icon-btn { margin-top: -8px; flex: none; }
.sheet-price { font-family: var(--font-head); font-weight: 800; font-size: 1.75rem; line-height: 1.1; }
.reason { font-size: .9375rem; color: var(--ink-2); }
.sell-tip { font-size: .9375rem; background: rgba(200,242,58,.35); border-radius: var(--r-sm); padding: 10px 12px; }
.listing { gap: 6px; }
.listing-row { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.listing-title { font-weight: 700; }
.listing-price { font-weight: 700; }
.listing-desc { font-size: .9375rem; white-space: pre-wrap; }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; }
.sold-box { display: flex; flex-direction: column; gap: 8px; }
.money { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.25rem; }

/* ---------- Account ---------- */
.account .card p + .label { margin-top: 6px; }
.links { text-align: center; font-size: .9375rem; }

/* ---------- Toast, spinner ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--white); font-weight: 600; font-size: .9375rem;
  padding: 12px 18px; border-radius: 999px; max-width: calc(100% - 32px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.spinner {
  display: inline-block; width: 32px; height: 32px;
  border: 3px solid var(--line); border-top-color: var(--ink); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .scanline, .sheet[open] { animation: none; }
  .btn { transition: none; }
}

@media (min-width: 600px) {
  .sheet { margin: auto; border-radius: var(--r-lg); }
}
