:root {
  --bg: #f5f3fa;
  --card: #ffffff;
  --card-2: #f9f8fd;
  --ink: #15121f;
  --muted: #67627a;
  --line: #e6e2f0;
  --brand: #6b4eff;
  --brand-hover: #5a3ef0;
  --brand-ink: #ffffff;
  --brand-strong: #5a3ef0;
  --brand-soft: #ece8ff;
  --dark: #1d1442;
  --dark-ink: #ffffff;
  --warn: #b42346;
  --warn-soft: #fde8ec;
  --danger: #b42318;
  --ok: #2f7a12;
  --shadow: 0 1px 2px rgba(29, 20, 66, 0.04), 0 8px 24px rgba(29, 20, 66, 0.06);
  --raised-shadow: 0 6px 20px rgba(29, 20, 66, 0.1), 0 1px 3px rgba(29, 20, 66, 0.08);
  --press: rgba(21, 18, 31, 0.06);
  --radius: 22px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
  /* SF Pro Rounded on Apple devices: friendlier titles and amounts */
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0c16;
    --card: #1a1726;
    --card-2: #221f30;
    --ink: #f2f0fa;
    --muted: #a6a0bd;
    --line: #2e2a40;
    --brand: #8b72ff;
    --brand-hover: #7a5ff5;
    --brand-strong: #a796ff;
    --brand-soft: #2a2450;
    --dark: #2a2160;
    --dark-ink: #ffffff;
    --warn: #ff9bb0;
    --warn-soft: #3d1a22;
    --danger: #ff8a7a;
    --ok: #7fd18a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --raised-shadow: 0 6px 20px rgba(0, 0, 0, 0.45), inset 0 0 0 0.5px rgba(255, 255, 255, 0.08);
    --press: rgba(255, 255, 255, 0.06);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button, label, a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
svg { width: 20px; height: 20px; flex: none; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; line-height: 1.15; }
h2 { font-size: 22px; font-weight: 800; }
h3 { font-size: 17px; font-weight: 700; }
p { margin: 0; }
small { font-size: 0.8em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* ---------- app layout: each screen fits the phone; only lists scroll ---------- */
.app { position: fixed; inset: 0; margin: 0 auto; max-width: 560px; display: flex; flex-direction: column; overflow: hidden; }
.content {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 14px;
  padding: 4px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  overflow-y: auto; overscroll-behavior: contain; /* only kicks in on phones too short for the screen */
}
.content > * { flex: none; }
.content.no-nav { padding-top: calc(env(safe-area-inset-top) + 18px); }
.content.no-dock { padding-bottom: calc(env(safe-area-inset-bottom) + 12px); }
/* the parts that can grow take the leftover space and scroll inside themselves */
.content > .scroll-area, .content > .fill { flex: 1 1 auto; min-height: 150px; }
.scroll-area { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 14px; border-radius: var(--radius); }
.scroll-area > * { flex: none; }
.fill { display: flex; flex-direction: column; }
.fill > .scroll-area { flex: 1 1 auto; min-height: 0; border-radius: 0; }

/* solid raised surfaces: menu bar, nav buttons, sheet */
.raised { position: relative; background: var(--card); box-shadow: var(--raised-shadow); border: 0; transition: transform 0.15s; }
.raised:active:not(:disabled) { transform: scale(0.96); }

/* navigation bar */
.nav {
  flex: none; display: grid; grid-template-columns: minmax(max-content, 1fr) minmax(0, auto) minmax(max-content, 1fr); align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) max(16px, env(safe-area-inset-right)) 6px max(16px, env(safe-area-inset-left));
}
.nav-side { display: flex; gap: 8px; min-width: 0; }
.nav-side.right { justify-content: flex-end; }
.nav-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; text-align: center; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  height: 44px; padding: 0 18px; border-radius: 999px; color: var(--ink); text-decoration: none; font-size: 17px; font-weight: 600;
}
.nav-btn.circle { width: 44px; padding: 0; }
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.is-on { background: var(--brand); color: var(--brand-ink); }

.page-title { padding: 0 4px; }
.page-title h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-title p { margin-top: 4px; color: var(--muted); font-size: 15px; }
.brand { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 10px; font-weight: 800; font-size: 20px; letter-spacing: -0.04em; }
.logo-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); font-size: 18px; }

/* bottom: "your share", menu bar, editor panel */
.dock {
  flex: none; display: flex; flex-direction: column; gap: 10px;
  padding: 4px max(16px, env(safe-area-inset-right)) max(12px, calc(env(safe-area-inset-bottom) - 8px)) max(16px, env(safe-area-inset-left));
}
.tabbar-row { display: flex; gap: 10px; align-items: center; }
.tabbar { flex: 1; display: grid; grid-template-columns: repeat(var(--n), 1fr); padding: 4px; border-radius: 999px; height: 64px; }
.tabbar.raised:active { transform: none; }
.tabbar button {
  position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 600; border-radius: 999px;
}
.tabbar button svg { width: 25px; height: 25px; }
.tabbar button[aria-selected="true"] { color: var(--brand-strong); }
.tab-lens {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / var(--n));
  border-radius: 999px; background: var(--brand-soft);
  transform: translateX(calc(var(--i) * 100%));
}
.tab-lens.moving { animation: lens-slide 0.4s cubic-bezier(0.3, 1.25, 0.5, 1); }
@keyframes lens-slide {
  from { transform: translateX(calc(var(--from) * 100%)); }
  to { transform: translateX(calc(var(--i) * 100%)); }
}
.dock-circle { flex: none; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 999px; color: var(--brand-strong); }
.dock-circle svg { width: 26px; height: 26px; }
.accessory {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 54px; padding: 0 16px 0 22px;
  border-radius: 999px; color: var(--ink); text-align: left;
}
.accessory span { flex: 1; font-size: 15px; font-weight: 600; color: var(--muted); }
.accessory strong { font-family: var(--font-rounded); font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.accessory svg { color: var(--muted); }
.dock-panel { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 30px; }
.dock-panel.raised:active { transform: none; }
.dock-panel .draft-summary { padding: 0 6px; }

/* home: compact "how it works" */
.steps-row { list-style: none; margin: 0; padding: 0 4px; display: flex; justify-content: space-between; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.steps-row li { display: flex; align-items: center; gap: 6px; }
.steps-row span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-strong); font-size: 12px; font-weight: 800; }

/* ---------- buttons ---------- *//* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 24px; border: 0; border-radius: 999px;
  font-weight: 700; font-size: 16px; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-dark { background: var(--dark); color: var(--dark-ink); }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--card-2); }
.btn-small { min-height: 40px; padding: 0 16px; font-size: 14px; }
.btn-small svg { width: 18px; height: 18px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 8px 0; color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-align: left; }
.btn-link.danger { color: var(--danger); }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--card-2); color: var(--ink); }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------- cards & fields ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.card.center { align-items: center; text-align: center; padding: 36px 22px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 14px; font-weight: 600; color: var(--muted); }
input[type="text"], input[type="number"] {
  width: 100%; min-height: 52px; padding: 0 16px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--card); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px var(--brand-soft); }
input::placeholder { color: var(--muted); opacity: 0.7; }
.error { color: var(--danger); font-weight: 600; font-size: 15px; }

/* ---------- home ---------- */
.upload {
  display: flex; align-items: center; gap: 16px; padding: 20px;
  border: 2px dashed var(--line); border-radius: 18px; background: var(--card-2);
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.upload:hover { border-color: var(--brand); background: var(--brand-soft); }
.upload-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--brand); color: var(--brand-ink); flex: none; }
.upload-icon svg { width: 28px; height: 28px; }
.upload-text { display: flex; flex-direction: column; }
.upload-text strong { font-size: 17px; }
.upload-text span { color: var(--muted); font-size: 14px; }

.join-code { display: flex; gap: 10px; }
.code-input { text-transform: uppercase; letter-spacing: 0.25em; font-weight: 700; font-size: 20px; text-align: center; }
.join-code .btn { flex: none; }

.steps { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.steps li { display: flex; gap: 12px; padding: 16px; border-radius: 18px; background: var(--card); font-size: 14px; color: var(--muted); }
.steps li span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 999px; background: var(--brand-soft); color: var(--ink); font-weight: 800; font-size: 14px; flex: none; }
.steps strong { display: block; color: var(--ink); font-size: 15px; }

/* ---------- scanning ---------- */
.scan-card { align-items: center; text-align: center; }
.scan-card .stack { width: 100%; }
.scan-preview { position: relative; width: 100%; max-height: 340px; border-radius: 16px; overflow: hidden; background: var(--card-2); min-height: 160px; }
.scan-preview img { display: block; width: 100%; max-height: 340px; object-fit: cover; object-position: top; }
.scan-preview.is-scanning img { filter: saturate(0.6) brightness(0.95); }
.scan-line { position: absolute; left: 0; right: 0; height: 80px; top: -80px; background: linear-gradient(transparent, rgba(107, 78, 255, 0.45), transparent); animation: scan 1.8s ease-in-out infinite; }
@keyframes scan { to { top: 100%; } }

.spinner { width: 36px; height: 36px; border-radius: 999px; border: 4px solid var(--line); border-top-color: var(--brand); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- bill summary ---------- */
.bill-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 12px 12px 18px; border-radius: var(--radius); background: var(--dark); color: var(--dark-ink); }
.bill-summary div { display: flex; flex-direction: column; }
.bill-summary span { font-size: 13px; font-weight: 600; opacity: 0.75; }
.bill-summary strong { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.code-chip { display: flex; flex-direction: column; align-items: center; padding: 8px 14px; border: 0; border-radius: 16px; background: var(--brand); color: var(--brand-ink); flex: none; }
.code-chip span { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.75; }
.code-chip strong { font-size: 18px; letter-spacing: 0.1em; }
.intro { color: var(--muted); padding: 0 4px; }
.section-label { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 4px 4px 0; margin-bottom: -8px; }

/* ---------- banners & tags ---------- */
.banner { display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-radius: 16px; font-size: 15px; }
.banner-info { background: var(--brand-soft); justify-content: space-between; }
.banner-info .btn { flex: none; }
.banner-lock { background: var(--card); box-shadow: inset 0 0 0 1.5px var(--line); padding: 12px 14px; font-weight: 600; }
.banner-ok { background: var(--brand-soft); font-weight: 600; }
.banner-ok svg { color: var(--ok); }
.banner-warn { background: var(--warn-soft); color: var(--ink); flex-direction: column; align-items: stretch; gap: 6px; }
.banner-warn strong { color: var(--warn); }
.banner-warn ul { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.banner-warn li { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--card-2); color: var(--muted); font-size: 12px; font-weight: 700; vertical-align: middle; box-shadow: inset 0 0 0 1px var(--line); }
.tag-warn { background: var(--warn-soft); color: var(--warn); box-shadow: none; }
.tag-accent { background: var(--brand); color: var(--brand-ink); box-shadow: none; }

/* ---------- segmented ---------- */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 4px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); }
.segmented { background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line); }
.segmented button { min-height: 44px; border: 0; border-radius: 999px; background: transparent; font-weight: 700; color: var(--muted); }
.segmented button[aria-checked="true"] { background: var(--dark); color: var(--dark-ink); }

/* ---------- items ---------- */
.hint { color: var(--muted); font-size: 14px; padding: 0 4px; }
.items, .people { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item, .person { position: relative; transition: background 0.15s; }
.item + .item::before, .person + .person::before { content: ""; position: absolute; top: 0; left: 58px; right: 0; border-top: 0.5px solid var(--line); }
.item.is-mine { background: color-mix(in srgb, var(--brand-soft) 60%, transparent); }
.item-main { display: flex; align-items: flex-start; gap: 14px; width: 100%; padding: 14px 16px; border: 0; background: transparent; text-align: left; }
.item-main:active:not(:disabled), .person-main:active { background: var(--press); }
.item-main:disabled { opacity: 1; }
.check { display: grid; place-items: center; width: 28px; height: 28px; margin-top: 1px; border-radius: 999px; box-shadow: inset 0 0 0 2px var(--line); color: transparent; flex: none; transition: background 0.15s; }
.check svg { width: 16px; height: 16px; }
.is-mine .check { background: var(--brand); color: var(--brand-ink); box-shadow: none; }
.item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.item-name { font-weight: 700; font-size: 16px; word-break: break-word; }
.item-meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.item-meta:empty { display: none; }
.item-price { font-weight: 800; font-size: 16px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.claimers { display: flex; flex-wrap: wrap; gap: 6px; }
.claimer { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 2px; border-radius: 999px; background: var(--card-2); font-size: 13px; font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.stepper-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px 14px 58px; font-size: 14px; color: var(--muted); font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 4px; background: var(--card-2); border-radius: 999px; padding: 4px; box-shadow: inset 0 0 0 1px var(--line); }
.stepper button { width: 36px; height: 36px; border: 0; border-radius: 999px; background: var(--card); font-size: 20px; font-weight: 700; box-shadow: var(--shadow); }
.stepper button:disabled { opacity: 0.35; }
.stepper output { min-width: 56px; text-align: center; font-weight: 800; color: var(--ink); }
.stepper output small { color: var(--muted); font-weight: 600; }

.avatar { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; font-weight: 800; font-size: 15px; flex: none; color: #1d1442; }
.avatar.xs { width: 22px; height: 22px; font-size: 10px; }
.hue-0 { background: #b9a8ff; } .hue-1 { background: #ffc091; } .hue-2 { background: #9fe0d6; } .hue-3 { background: #ffd56b; }
.hue-4 { background: #ffb3c7; } .hue-5 { background: #a8d1ff; } .hue-6 { background: #c7e59a; } .hue-7 { background: #e5b8f2; }

.mini-items { list-style: none; margin: 0; padding: 0; }
.mini-items li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.mini-items li:last-child { border-bottom: 0; }

/* ---------- join ---------- */
.rejoin { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; border-top: 1px solid var(--line); }
.rejoin p { padding-top: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 12px 4px 6px; border: 0; border-radius: 999px; background: var(--card-2); font-weight: 600; font-size: 14px; box-shadow: inset 0 0 0 1px var(--line); }
.chip:hover { background: var(--brand-soft); }
.tip-chips .chip { padding: 4px 14px; }

/* ---------- totals ---------- */
.progress-label { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; color: var(--muted); gap: 12px; }
.progress { height: 10px; border-radius: 999px; background: var(--card-2); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.progress span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width 0.3s; }
.person.is-me { background: color-mix(in srgb, var(--brand-soft) 60%, transparent); }
.person-main { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border: 0; background: transparent; text-align: left; }
.person-name { flex: 1; min-width: 0; font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.person-name small { width: 100%; color: var(--muted); font-weight: 500; font-size: 13px; }
.person-total { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.chev { color: var(--muted); transition: transform 0.2s; display: grid; }
.is-open .chev { transform: rotate(90deg); }
.breakdown { padding: 0 16px 14px 68px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.breakdown > div { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.breakdown small { color: var(--muted); }
.breakdown .sub { color: var(--muted); }

/* ---------- editor ---------- */
.editor h3 { margin-top: 8px; }
.editor-head { display: flex; flex-direction: column; gap: 6px; }
.edit-head, .edit-row { display: grid; grid-template-columns: 1fr 64px 112px 36px; gap: 6px; align-items: center; }
.qty-input span { display: none; }
.edit-head { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 0 4px; margin-bottom: -6px; }
.edit-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.edit-items .empty { padding: 12px 4px; }
.edit-row input { min-height: 46px; padding: 0 10px; border-radius: 12px; }
.edit-row .e-qty { text-align: center; padding: 0 4px; }
.edit-row .icon-btn { width: 36px; height: 36px; }
/* phones: item name on its own line, quantity and price underneath */
@media (max-width: 520px) {
  .edit-head { display: none; }
  .edit-items { gap: 0; }
  .edit-row { grid-template-columns: 1fr 1fr 36px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .edit-row .e-name { grid-column: 1 / -1; }
  .qty-input { position: relative; }
  .qty-input span { display: block; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; font-size: 14px; pointer-events: none; }
  .edit-row .e-qty { text-align: right; padding: 0 10px 0 40px; }
}
.money-input { position: relative; }
.money-input span { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; pointer-events: none; }
.money-input input { padding-left: 24px; text-align: right; font-variant-numeric: tabular-nums; }
.field-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.field-row .money-input { width: 140px; flex: none; }
.field-row .label small { font-weight: 500; }
.tip-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.draft-summary { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.draft-summary strong { color: var(--ink); }
.draft-summary .ok { color: var(--ok); font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
.draft-summary .ok svg { width: 16px; height: 16px; }
.draft-summary .warn { color: var(--warn); font-weight: 600; }
.editor-actions { display: flex; gap: 10px; justify-content: flex-end; }
.editor-actions .btn { flex: 1; }

.footnote { text-align: center; color: var(--muted); font-size: 13px; padding-top: 8px; }

/* ---------- share sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 6, 2, 0.35); animation: fade 0.2s; z-index: 20; }
.sheet {
  position: fixed; z-index: 21; left: 50%; bottom: max(8px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(520px, calc(100% - 16px)); max-height: calc(100% - env(safe-area-inset-top) - 24px); overflow: auto;
  background: var(--card); box-shadow: var(--raised-shadow); border-radius: 32px; padding: 30px 20px 22px;
  display: flex; flex-direction: column; gap: 14px; animation: rise 0.35s cubic-bezier(0.2, 1.1, 0.4, 1);
}
.sheet.raised:active { transform: translateX(-50%); }
.grabber { position: absolute; top: 8px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 99px; background: var(--line); }
.sheet-close { position: absolute; top: 14px; right: 14px; }
.sheet h2 { padding-right: 48px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translate(-50%, 60px); opacity: 0; } }
.big-code { display: flex; justify-content: center; gap: 6px; }
.big-code span { display: grid; place-items: center; width: 46px; height: 58px; border-radius: 12px; background: var(--brand-soft); font-size: 28px; font-weight: 800; }
.qr { width: 180px; margin: 0 auto; padding: 10px; background: #fff; border-radius: 16px; }
.qr svg { width: 100%; height: auto; display: block; }
.link-box { padding: 14px 16px; border-radius: 14px; background: var(--card-2); font-size: 14px; font-weight: 600; word-break: break-all; text-align: center; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 30;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-weight: 600; font-size: 15px; border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  animation: fade 0.2s;
}
.toast.good { background: var(--dark); color: var(--dark-ink); }
.toast.bad { background: var(--danger); color: #fff; }

@media (max-width: 380px) {
  .steps { grid-template-columns: 1fr; }
  .big-code span { width: 40px; height: 52px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- "add to home screen" tip ---------- */
.install-tip { display: flex; align-items: center; gap: 12px; padding: 12px 8px 12px 12px; border-radius: 18px; background: var(--brand-soft); }
.install-tip img { border-radius: 11px; flex: none; }
.install-tip p { flex: 1; font-size: 14px; line-height: 1.4; }
.install-tip p > strong:first-child { display: block; font-size: 15px; }
.inline-icon svg { width: 16px; height: 16px; vertical-align: -3px; }
.nowrap { white-space: nowrap; }

/* short phones: tighten everything so screens still fit */
@media (max-height: 740px) {
  .content { gap: 10px; }
  .page-title h1 { font-size: 26px; }
  .page-title p { font-size: 14px; }
  .brand { margin-bottom: 4px; }
  .card { padding: 16px; gap: 12px; }
  .upload { padding: 14px; }
  .upload-icon { width: 46px; height: 46px; }
  .tabbar { height: 58px; }
  .dock-circle { width: 58px; height: 58px; }
  .accessory { height: 48px; }
  .banner { padding: 10px 14px; }
  .hint { display: none; }
  .join-card > p.muted { display: none; }
  .content > .fill { min-height: 110px; }
  .rejoin p { padding-top: 8px; }
}
@media (max-height: 620px) {
  .steps-row, .page-title p { display: none; }
}


/* ---------- iOS polish ---------- */
.page-title h1, .bill-summary strong, .item-price, .person-total, .big-code span, .brand, h2 { font-family: var(--font-rounded); }
button, .nav, .dock, .tabbar, .brand, .code-chip, .chip { -webkit-user-select: none; user-select: none; }
img { -webkit-touch-callout: none; }

/* bill page: the whole page scrolls; the big title tucks into the top bar */
.content.scrolls { padding-bottom: 18px; }
.nav { transition: box-shadow 0.2s; position: relative; z-index: 5; }
.nav.scrolled { box-shadow: 0 0.5px 0 var(--line); }
.nav.collapsing .nav-title { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }
.nav.collapsing.show-title .nav-title { opacity: 1; transform: none; }

/* screen changes slide like iOS navigation */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.38s; animation-timing-function: cubic-bezier(0.2, 0.9, 0.25, 1); }
html[data-nav="forward"]::view-transition-new(root) { animation-name: vt-in-from-right; }
html[data-nav="forward"]::view-transition-old(root) { animation-name: vt-out-to-left; }
html[data-nav="back"]::view-transition-old(root) { animation-name: vt-out-to-right; z-index: 2; }
html[data-nav="back"]::view-transition-new(root) { animation-name: vt-in-from-left; }
@keyframes vt-in-from-right { from { transform: translateX(100%); } }
@keyframes vt-out-to-left { to { transform: translateX(-28%); opacity: 0.7; } }
@keyframes vt-out-to-right { to { transform: translateX(100%); } }
@keyframes vt-in-from-left { from { transform: translateX(-28%); opacity: 0.7; } }

/* ticking an item: the check pops */
.item.pop .check { animation: check-pop 0.42s cubic-bezier(0.3, 1.6, 0.5, 1); }
.item.pop .check svg path { stroke-dasharray: 24; animation: check-draw 0.3s 0.05s ease-out both; }
@keyframes check-pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes check-draw { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } }
.item-main:active:not(:disabled) .check { transform: scale(0.9); }

/* who's paying what */
.split-bar { display: flex; gap: 3px; height: 14px; border-radius: 999px; overflow: hidden; background: var(--card-2); }
.split-bar span { min-width: 6px; flex-basis: 0; transition: flex-grow 0.5s cubic-bezier(0.2, 0.9, 0.25, 1); }
.split-bar .rest { background: repeating-linear-gradient(-45deg, var(--line) 0 6px, transparent 6px 12px); }

/* loading placeholders */
.skeleton { border-radius: 16px; background: linear-gradient(90deg, var(--card) 0%, var(--card-2) 40%, var(--card) 80%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.sk-title { height: 34px; width: 60%; border-radius: 10px; }
.sk-summary { height: 74px; border-radius: var(--radius); }
.skeleton-list { display: flex; flex-direction: column; gap: 2px; border-radius: var(--radius); overflow: hidden; }
.sk-row { height: 64px; border-radius: 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* scanning: the photo, and the receipt filling in live */
.scan-photo { position: relative; flex: none; height: 30vh; min-height: 140px; border-radius: var(--radius); overflow: hidden; background: var(--card); box-shadow: var(--shadow); }
.scan-photo img { width: 100%; height: 100%; object-fit: cover; object-position: top; filter: saturate(0.5); }
.scan-skeleton { height: 100%; border-radius: 0; }
.scan-status { display: flex; align-items: center; justify-content: center; gap: 10px; font-family: var(--font-rounded); font-size: 18px; font-weight: 700; }
.spinner.small { width: 18px; height: 18px; border-width: 2.5px; flex: none; }
.receipt { background: var(--card); border-radius: 18px 18px 0 0; box-shadow: var(--shadow); position: relative; margin-bottom: 10px; }
.receipt::after { /* torn paper edge */
  content: ""; position: absolute; left: 0; right: 0; bottom: -10px; height: 10px;
  background: linear-gradient(-45deg, transparent 7px, var(--card) 0) 0 0 / 14px 10px repeat-x, linear-gradient(45deg, transparent 7px, var(--card) 0) 0 0 / 14px 10px repeat-x;
}
.receipt-items { list-style: none; margin: 0; padding: 10px 18px; gap: 0; border-radius: 18px 18px 0 0; font-variant-numeric: tabular-nums; }
.receipt-items li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.receipt-items li:last-child { border-bottom: 0; }
.receipt-items li.fresh { animation: print-in 0.35s cubic-bezier(0.2, 0.9, 0.25, 1); }
.receipt-items .receipt-wait { justify-content: center; color: var(--muted); border: 0; padding: 18px 0; }
@keyframes print-in { from { opacity: 0; transform: translateY(-8px); } }
