:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --ink: #1d1b26;
  --muted: #6b6878;
  --line: #e7e2da;
  --soft: #f1ede6;
  --accent: #6d4aff;
  --accent-ink: #ffffff;
  --accent-soft: #eee9ff;
  --pink: #ec4899;
  --green: #16a34a;
  --danger: #dc2626;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(29, 27, 38, .06), 0 8px 24px rgba(29, 27, 38, .06);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14131a;
    --card: #1d1c25;
    --ink: #f1eff7;
    --muted: #a19eb0;
    --line: #2e2c3a;
    --soft: #25232f;
    --accent: #8b70ff;
    --accent-soft: #2a2442;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
p { margin: 0 0 1rem; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* header / footer */
.site-header { padding: 14px 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 1.5rem; letter-spacing: -.02em; }
.brand img { height: 36px; width: 36px; border-radius: 10px; }
.grad { background: linear-gradient(90deg, #34d399, var(--pink), #8b5cf6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.site-footer { padding: 48px 0 32px; text-align: center; color: var(--muted); font-size: .875rem; }
.site-footer a { color: var(--muted); }
.site-footer .play { display: inline-block; margin-top: 12px; }
.site-footer .play img { height: 56px; }

/* building blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 12px; padding: 10px 16px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-ink); transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.secondary { background: var(--soft); color: var(--ink); border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--muted); padding: 6px 10px; }
.btn.block { width: 100%; }
.btn svg { width: 20px; height: 20px; }

input[type=text], input[type=number], select {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-width: 0;
}
input[type=text]:focus, input[type=number]:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* home */
.hero { display: grid; gap: 24px; padding: 24px 0 8px; align-items: start; }
@media (min-width: 860px) { .hero { grid-template-columns: 1.05fr 1fr; padding-top: 48px; } }
.hero h1 { font-size: clamp(2rem, 6vw, 3.25rem); font-weight: 800; letter-spacing: -.03em; }
.hero .lead { font-size: 1.125rem; color: var(--muted); max-width: 34ch; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 24px; }
.badge { font-size: .8125rem; padding: 4px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--muted); }

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: 8px; padding: 32px 16px; border: 2px dashed var(--line); border-radius: var(--radius);
  background: var(--soft); cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop svg { width: 40px; height: 40px; color: var(--accent); }
.drop strong { font-size: 1.0625rem; }
.upload-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.steps li { display: flex; gap: 12px; }
.steps .n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; font-size: .875rem; }

.recent a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.recent a:first-child { border-top: 0; }
.recent a:hover .name { color: var(--accent); }
.recent .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* analyzing / error */
.center-card { max-width: 460px; margin: 48px auto; text-align: center; }
.spinner { width: 56px; height: 56px; margin: 8px auto 20px; border-radius: 50%; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-bad { width: 56px; height: 56px; color: var(--danger); margin: 0 auto 12px; }

/* results */
.results { display: grid; gap: 16px; padding-top: 8px; }
@media (min-width: 900px) { .results { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; } .receipt-col { position: sticky; top: 16px; } }
.title-block h1 { font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 800; letter-spacing: -.02em; }

.people { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 999px; font-weight: 600; font-size: .9375rem; color: #fff; }
.chip button { border: 0; background: rgba(255, 255, 255, .25); color: #fff; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-size: 14px; line-height: 1; }

.totals { display: grid; gap: 6px; }
.total-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.total-row .who { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.total-row .amt { font-family: var(--mono); font-weight: 700; font-size: 1.125rem; }
.total-row.minor { color: var(--muted); font-size: .9375rem; }
.total-row.minor .amt { font-size: .9375rem; font-weight: 500; }
.total-row.grand { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
.total-row.warn { color: #b45309; }
.check { display: flex; gap: 8px; align-items: center; font-size: .9375rem; color: var(--muted); margin-top: 8px; cursor: pointer; }

.items { width: 100%; border-collapse: collapse; }
.items td { padding: 10px 4px; border-top: 1px solid var(--line); vertical-align: middle; }
.items tr:first-child td { border-top: 0; }
.items .name { font-weight: 500; overflow-wrap: anywhere; }
.items .qty { color: var(--muted); font-size: .8125rem; }
.items .price { font-family: var(--mono); text-align: right; white-space: nowrap; padding-right: 10px; }
.items tr.sub td { background: var(--soft); }
.items tr.sub .name { padding-left: 20px; font-weight: 400; }
.items tr.parent .price { color: var(--muted); }

.receipt-img { border-radius: 12px; border: 1px solid var(--line); width: 100%; }
.saved { font-size: .8125rem; color: var(--muted); min-height: 1.2em; }

.prose h2 { font-size: 1.125rem; margin-top: 1.5rem; }
.prose p, .prose li { color: var(--muted); }

/* item rows: assignee pill + drawer */
.btn.small { padding: 6px 12px; font-size: .875rem; border-radius: 10px; }
.btn.danger { color: var(--danger); }
.row.wrap { flex-wrap: wrap; }
.stack-sm > * + * { margin-top: 12px; }
.items .assign { text-align: right; width: 1%; white-space: nowrap; }
.items tr.open td { background: var(--accent-soft); }
.items tr.drawer td { background: var(--accent-soft); border-top: 0; padding: 4px 8px 14px; }
.pill {
  font: inherit; font-size: .875rem; font-weight: 600; cursor: pointer; max-width: 9.5rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--soft); color: var(--ink);
}
.pill.empty { border: 1px dashed #f59e0b; color: #b45309; background: transparent; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.opt { font: inherit; font-size: .875rem; font-weight: 600; cursor: pointer; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.opt.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.edit { display: grid; gap: 10px; }
.field { display: grid; gap: 4px; font-size: .8125rem; color: var(--muted); }
.field input { width: 100%; }
.edit-nums { display: grid; grid-template-columns: 1fr 1.3fr 1.3fr; gap: 8px; }
.notice { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: #fef3c7; color: #92400e; font-size: .875rem; }
@media (prefers-color-scheme: dark) { .notice { background: #422006; color: #fcd34d; } }
.price-inline { display: none; }
@media (max-width: 560px) {
  .items td.price { display: none; }
  .items .price-inline { display: block; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .9375rem; margin-top: 2px; }
  .items .qty + .price-inline, .items .name + .price-inline { color: var(--ink); }
}
