:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --fill: rgb(120 120 128 / .12);
  --label: #1d1d1f;
  --label-2: rgb(60 60 67 / .72);
  --separator: rgb(60 60 67 / .16);
  --blue: #0071e3;
  --green: #248a3d;
  --red: #d70015;
  --on-accent: #ffffff;
  --material: rgb(255 255 255 / .72);
  --material-edge: rgb(255 255 255 / .5);
  --shadow-card: 0 1px 2px rgb(0 0 0 / .05), 0 18px 40px -18px rgb(0 0 0 / .28);
  --scrim: rgb(0 0 0 / .32);
  --radius: 22px;
  --gutter: 20px;
  --tabs-height: calc(58px + env(safe-area-inset-bottom));
  --body: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, 'Helvetica Neue', Arial, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #000000;
    --surface: #1c1c1e;
    --fill: rgb(120 120 128 / .24);
    --label: #f5f5f7;
    --label-2: rgb(235 235 245 / .68);
    --separator: rgb(84 84 88 / .6);
    --blue: #2997ff;
    --green: #30d158;
    --red: #ff453a;
    --on-accent: #000000;
    --material: rgb(30 30 32 / .72);
    --material-edge: rgb(255 255 255 / .08);
    --shadow-card: 0 18px 40px -18px rgb(0 0 0 / .9);
    --scrim: rgb(0 0 0 / .55);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #1c1c1e;
  --fill: rgb(120 120 128 / .24);
  --label: #f5f5f7;
  --label-2: rgb(235 235 245 / .68);
  --separator: rgb(84 84 88 / .6);
  --blue: #2997ff;
  --green: #30d158;
  --red: #ff453a;
  --on-accent: #000000;
  --material: rgb(30 30 32 / .72);
  --material-edge: rgb(255 255 255 / .08);
  --shadow-card: 0 18px 40px -18px rgb(0 0 0 / .9);
  --scrim: rgb(0 0 0 / .55);
}

:root[data-theme='light'] { color-scheme: light; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--label);
  background: var(--bg);
  font: 400 1.0625rem/1.47 var(--body);
  letter-spacing: -.012em;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
h1 { font: 700 2.125rem/1.1 var(--display); letter-spacing: -.024em; }
h2 { font: 700 1.5rem/1.15 var(--display); letter-spacing: -.02em; }
h3 { font: 600 1.0625rem/1.3 var(--body); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 6px; }

/* Bars */
.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: env(safe-area-inset-top) var(--gutter) 0;
  background: var(--material);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
}
.wordmark { color: var(--label); font: 600 1.0625rem var(--display); letter-spacing: -.02em; }
.wordmark:hover { text-decoration: none; }

.segmented { display: flex; padding: 2px; border-radius: 9px; background: var(--fill); }
.segmented button {
  min-width: 40px;
  min-height: 30px;
  border: 0;
  border-radius: 7px;
  color: var(--label);
  background: none;
  font: 500 .8125rem var(--body);
  cursor: pointer;
}
.segmented button[aria-pressed='true'] { background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .14); }

.test-note { padding: 6px var(--gutter) 0; color: var(--label-2); font-size: .8125rem; text-align: center; }

.tabs {
  position: fixed;
  inset: auto 0 0;
  z-index: 20;
  display: flex;
  justify-content: space-around;
  height: var(--tabs-height);
  padding: 6px 8px env(safe-area-inset-bottom);
  background: var(--material);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 -.5px 0 var(--separator);
}
.tabs a {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  max-width: 96px;
  color: var(--label-2);
  font: 500 .6875rem var(--body);
  letter-spacing: 0;
  white-space: nowrap;
  transition: transform 100ms ease-out;
}
.tabs a:hover { text-decoration: none; }
.tabs a:active { transform: scale(.94); }
.tabs a[aria-current='page'] { color: var(--blue); }
.tabs svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.page { max-width: 640px; margin: 0 auto; padding: 20px var(--gutter) calc(var(--tabs-height) + 32px); }
.page-wide { max-width: 1040px; }
.lede { margin-top: 8px; color: var(--label-2); }

/* Controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 12px 22px;
  border: 0;
  border-radius: 14px;
  font: 600 1.0625rem/1.2 var(--body);
  letter-spacing: -.012em;
  cursor: pointer;
  transition: transform 100ms ease-out, opacity 100ms ease-out;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); opacity: .85; }
.btn:disabled { opacity: .5; cursor: progress; }
.btn-ink { color: var(--on-accent); background: var(--blue); }
.btn-line { color: var(--blue); background: var(--fill); }
.btn-small { min-height: 44px; padding: 8px 14px; border-radius: 11px; font-size: .9375rem; }
.btn-plain { min-height: 44px; padding: 8px 4px; border: 0; color: var(--blue); background: none; font: 400 .9375rem var(--body); cursor: pointer; }
.btn-danger { color: var(--red); }

form { display: grid; gap: 18px; margin-top: 24px; }
.field { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; font-size: .9375rem; font-weight: 500; }
input[type='text'], input[type='email'], input[type='password'], input[type='number'], select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  color: var(--label);
  background: var(--surface);
  box-shadow: inset 0 0 0 .5px var(--separator);
  font: 400 1.0625rem var(--body);
}
input[type='file'] { font: 400 .9375rem var(--body); }
textarea { min-height: 104px; resize: vertical; }
input[type='checkbox'] { width: 22px; height: 22px; flex: none; accent-color: var(--blue); }
.consent { display: flex; align-items: flex-start; gap: 10px; font-size: .9375rem; line-height: 1.4; cursor: pointer; }
.hint { color: var(--label-2); font-size: .8125rem; font-weight: 400; }
.warn { color: var(--label-2); font-size: .9375rem; }
.form-error { color: var(--red); font-size: .9375rem; }
.form-error:empty { display: none; }
.preview { display: block; width: 100%; max-height: 360px; border-radius: 14px; object-fit: contain; background: var(--surface); }
.done { margin-top: 28px; padding: 28px 24px; border-radius: var(--radius); background: var(--surface); text-align: center; outline: 0; }
.done h3 { font: 700 1.375rem/1.2 var(--display); }
.done p { margin-top: 8px; color: var(--label-2); }
.switch { margin-top: 14px; text-align: center; }
.signin { max-width: 400px; margin: 7vh auto 0; }
.signin h1 { text-align: center; }
.signin .lede { text-align: center; }

/* Swipe stack */
body:has(.deck-page) { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.deck-page { display: flex; flex: 1; flex-direction: column; min-height: 0; padding: 0 var(--gutter) var(--tabs-height); }
.deck-toolbar { display: flex; justify-content: flex-end; width: 100%; max-width: 400px; margin: 8px auto 0; }
.stage { position: relative; flex: 1; width: 100%; max-width: 400px; min-height: 0; margin: 12px auto 0; }
.card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transform-origin: 50% 110%;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  cursor: grab;
  will-change: transform;
}
.card.dragging { cursor: grabbing; }
.card-under { transform: translateY(10px) scale(.94); pointer-events: none; }

.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card-alias { color: var(--label-2); font-size: .8125rem; }
.card-biller { margin-top: 2px; font: 700 1.375rem/1.15 var(--display); letter-spacing: -.02em; }
.card-photo { flex: 1 1 0; width: 100%; min-height: 120px; margin-top: 12px; border-radius: 12px; object-fit: contain; background: var(--fill); pointer-events: none; }
.card-story { display: -webkit-box; flex: none; margin-top: 12px; overflow: hidden; font-size: 1.0625rem; line-height: 1.3; letter-spacing: -.016em; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; }
.card-photoless .card-story { flex: 1 1 auto; align-content: center; font: 600 1.5rem/1.2 var(--display); letter-spacing: -.02em; -webkit-line-clamp: 6; line-clamp: 6; }
.lines { flex: none; margin: 12px 0 0; padding: 0; list-style: none; }
.line { display: flex; justify-content: space-between; gap: 16px; padding: 2px 0; color: var(--label-2); font-size: .875rem; font-variant-numeric: tabular-nums; }
.line span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-total { margin-top: 6px; padding-top: 8px; color: var(--label); box-shadow: inset 0 .5px 0 var(--separator); font: 700 1.25rem var(--display); letter-spacing: -.02em; }

.badge {
  position: absolute;
  top: 18px;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--on-accent);
  font: 700 1.0625rem var(--body);
  opacity: 0;
  pointer-events: none;
}
.badge-pay { left: 18px; background: var(--green); }
.badge-skip { right: 18px; background: #8e8e93; color: #fff; }

.deck-actions { display: flex; justify-content: center; gap: 28px; padding: 16px 0 14px; }
.round {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 100ms ease-out;
}
.round:active { transform: scale(.92); }
.round svg { width: 28px; height: 28px; fill: none; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.round-skip svg { stroke: #8e8e93; }
.round-pay { background: var(--green); }
.round-pay svg { stroke: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .round-pay svg { stroke: #000; } }
:root[data-theme='dark'] .round-pay svg { stroke: #000; }

.deck-empty { position: absolute; inset: 0; display: grid; place-content: center; gap: 12px; padding: 24px; text-align: center; }
.deck-empty p { color: var(--label-2); }
.empty-actions { display: grid; gap: 8px; margin-top: 8px; }

.toast {
  position: fixed;
  left: 50%;
  top: calc(60px + env(safe-area-inset-top));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--material);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 8px 28px rgb(0 0 0 / .22);
  font-size: .9375rem;
  transform: translateX(-50%);
  animation: toast-in 240ms cubic-bezier(.16, 1, .3, 1) both;
}
.toast button { min-height: 32px; border: 0; color: var(--blue); background: none; font: 600 .9375rem var(--body); cursor: pointer; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -12px); } }

/* Sheets */
dialog.sheet-panel {
  position: fixed;
  inset: auto 0 0;
  width: min(100%, 480px);
  max-width: none;
  max-height: 92dvh;
  overflow-y: auto;
  margin: 0 auto;
  padding: 10px 24px calc(24px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 26px 26px 0 0;
  color: var(--label);
  background: var(--surface);
  box-shadow: 0 -12px 40px rgb(0 0 0 / .2);
  animation: sheet-in 320ms cubic-bezier(.16, 1, .3, 1) both;
}
dialog.sheet-panel::backdrop { background: var(--scrim); animation: fade-in 240ms ease-out both; }
.grabber { width: 36px; height: 5px; margin: 0 auto 16px; border-radius: 3px; background: var(--separator); }
.sheet-panel h2 { text-align: center; }
.sheet-amount { margin-top: 6px; font: 700 2.75rem/1.1 var(--display); letter-spacing: -.03em; text-align: center; font-variant-numeric: tabular-nums; }
.sheet-breakdown { margin-top: 6px; color: var(--label-2); font-size: .9375rem; text-align: center; font-variant-numeric: tabular-nums; }
.sheet-note { margin-top: 12px; color: var(--label-2); font-size: .8125rem; text-align: center; }
.sheet-actions { display: grid; gap: 8px; margin-top: 18px; }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }

/* Lists */
.empty { margin-top: 24px; padding: 40px 24px; border-radius: var(--radius); background: var(--surface); color: var(--label-2); text-align: center; }
.empty-action { display: grid; justify-items: center; gap: 14px; }
.activity-section { margin-top: 28px; }
.activity-section .profile-title { margin-top: 0; }
.compact-actions { margin-top: 8px; }
.settings-card { display: grid; gap: 4px; margin-top: 8px; padding: 12px 16px; border-radius: var(--radius); background: var(--surface); }
.setting-toggle { display: flex; align-items: center; gap: 12px; min-height: 48px; font-weight: 500; }
.settings-card .btn { justify-self: start; margin-top: 8px; }
.form-success { color: var(--green); font-size: .875rem; }
.filter-active { color: var(--blue); background: var(--fill); }
.sheet-detail-link { margin-top: 8px; text-align: center; }
.detail-card { display: grid; gap: 14px; margin-top: 18px; padding: 22px; border-radius: var(--radius); background: var(--surface); }
.detail-card h2 { font-size: 1.5rem; }
.detail-category { color: var(--label-2); font-size: .875rem; }
.detail-amount { font: 700 2.5rem/1 var(--display); font-variant-numeric: tabular-nums; }
.detail-story { font-size: 1.0625rem; line-height: 1.45; }
.detail-line { display: flex; justify-content: space-between; gap: 16px; padding-top: 10px; border-top: .5px solid var(--separator); color: var(--label-2); }
.detail-line strong { color: var(--label); text-align: right; }
.notice { margin-bottom: 14px; padding: 12px 14px; border-radius: 12px; color: var(--label-2); background: var(--fill); }
.group { margin-top: 20px; overflow: hidden; border-radius: 16px; background: var(--surface); }
.row { display: grid; gap: 3px; padding: 14px 16px; color: inherit; box-shadow: inset 0 -.5px 0 var(--separator); }
.row:last-child { box-shadow: none; }
a.row:hover { text-decoration: none; background: var(--fill); }
.row-top { display: flex; justify-content: space-between; gap: 12px; }
.row-sub { overflow: hidden; color: var(--label-2); font-size: .9375rem; text-overflow: ellipsis; white-space: nowrap; }
.status { font-size: .8125rem; font-weight: 500; color: var(--label-2); white-space: nowrap; }
.status-good { color: var(--green); }
.status-bad { color: var(--red); }

/* Receipt Chat */
.receipt {
  --tooth: 10px;
  margin-top: 16px;
  padding: 24px 22px 34px;
  background: var(--surface);
  font: 400 .9375rem/1.45 var(--mono);
  letter-spacing: 0;
  -webkit-mask: radial-gradient(circle at 50% 100%, transparent 6px, #000 6.5px) bottom / 20px 100% repeat-x;
  mask: radial-gradient(circle at 50% 100%, transparent 6px, #000 6.5px) bottom / 20px 100% repeat-x;
  border-radius: 16px 16px 0 0;
}
.receipt-head { padding-bottom: 12px; border-bottom: 1px dashed var(--separator); text-align: center; }
.receipt-head b { display: block; font-size: 1.0625rem; letter-spacing: .04em; text-transform: uppercase; }
.receipt-line { display: flex; justify-content: space-between; gap: 12px; margin-top: 4px; color: var(--label-2); font-size: .8125rem; }
.printed { margin-top: 16px; animation: fade-in 200ms ease-out both; }
.printed-name { color: var(--label-2); font-size: .75rem; letter-spacing: .03em; text-transform: uppercase; }
.printed-mine .printed-name { color: var(--blue); }
.printed p { overflow-wrap: anywhere; white-space: pre-wrap; }
.receipt-end { margin-top: 20px; padding-top: 12px; border-top: 1px dashed var(--separator); color: var(--label-2); font-size: .8125rem; text-align: center; }
.composer {
  position: sticky;
  bottom: calc(var(--tabs-height) + 10px);
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding: 6px;
  border-radius: 26px;
  background: var(--material);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 6px 22px rgb(0 0 0 / .14);
}
.composer input { flex: 1; min-width: 0; border-radius: 20px; background: transparent; box-shadow: none; }
.composer .btn { min-height: 44px; padding: 8px 18px; border-radius: 20px; font-size: .9375rem; }
.chat-tools { display: flex; justify-content: center; gap: 20px; margin-top: 10px; }

/* Review */
.review { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 28px; margin-top: 20px; align-items: start; }
.review form { margin-top: 0; }
.canvas-wrap { line-height: 0; }
.canvas-wrap canvas { width: 100%; height: auto; border-radius: 12px; cursor: crosshair; touch-action: none; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.item-row { display: grid; grid-template-columns: minmax(0, 1fr) 96px 44px; gap: 6px; }
.items { display: grid; gap: 6px; }
.report { margin-top: 12px; padding: 16px; border-radius: 16px; background: var(--surface); }
.report p + p { margin-top: 6px; }

.legal { max-width: 640px; margin: 0 auto; padding: 40px var(--gutter); }
.legal h1 { margin-top: 28px; }
.legal h2 { margin-top: 28px; font-size: 1.25rem; }
.legal p, .legal ul { margin-top: 10px; }

@media (min-width: 860px) {
  :root { --tabs-height: 0px; }
  .tabs {
    position: sticky;
    top: 52px;
    inset: auto;
    z-index: 19;
    height: auto;
    justify-content: center;
    gap: 6px;
    padding: 0 0 10px;
    box-shadow: none;
  }
  .tabs a { flex: 0 auto; flex-direction: row; gap: 6px; max-width: none; padding: 6px 12px; border-radius: 10px; font-size: .875rem; }
  .tabs a[aria-current='page'] { background: var(--fill); }
  .tabs svg { width: 18px; height: 18px; }
  .deck-page { padding-bottom: 8px; }
  .toast { top: 112px; }
  .composer { bottom: 16px; }
  dialog.sheet-panel { inset: 0; margin: auto; height: fit-content; border-radius: 26px; padding-bottom: 24px; }
  .grabber { display: none; }
}

@media (max-width: 760px) {
  .review { grid-template-columns: minmax(0, 1fr); }
}

@media (max-height: 820px) {
  .card { padding: 16px; }
  .card-biller { font-size: 1.1875rem; }
  .card-story { -webkit-line-clamp: 2; line-clamp: 2; font-size: 1rem; }
  .lines .line:not(.line-total):not(.line-bill):not(:nth-last-child(2)) { display: none; }
  .deck-actions { padding: 10px 0 8px; }
  .round { width: 54px; height: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  .toast, dialog.sheet-panel, dialog.sheet-panel::backdrop, .printed { animation: fade-in 150ms ease both; }
  .btn, .round, .tabs a { transition: none; }
}

@media (prefers-reduced-transparency: reduce) {
  .bar, .tabs, .toast, .composer { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

@media (prefers-contrast: more) {
  :root { --separator: var(--label); --label-2: var(--label); }
  .card, .group, .sheet-panel { outline: 1px solid var(--label); }
}

/* Welcome */
.welcome { max-width: 440px; margin: 8vh auto 0; }
.welcome h1 { text-align: center; }
.choices { display: grid; gap: 12px; margin-top: 28px; }
.choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-height: 104px;
  padding: 20px;
  border: 0;
  border-radius: var(--radius);
  color: var(--label);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  text-align: left;
  cursor: pointer;
  transition: transform 100ms ease-out;
}
.choice:active { transform: scale(.97); }
.choice-text { display: grid; gap: 4px; font: 400 .9375rem/1.35 var(--body); color: var(--label-2); letter-spacing: -.008em; }
.choice-text strong { color: var(--label); font: 700 1.375rem/1.15 var(--display); letter-spacing: -.02em; }
.choice svg { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--label-2); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

@media (prefers-reduced-motion: reduce) {
  .choice { transition: none; }
}

/* Sign-in */
.social { display: grid; gap: 10px; }
.btn-social { gap: 8px; width: 100%; }
.btn-social svg { width: 20px; height: 20px; flex: none; }
.btn-apple { color: #fff; background: #000; }
.btn-google { color: #1f1f1f; background: #fff; box-shadow: inset 0 0 0 1px #dadce0; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--label-2); font-size: .8125rem; }
.divider::before, .divider::after { flex: 1; height: .5px; background: var(--separator); content: ''; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .btn-apple { color: #000; background: #fff; }
}
:root[data-theme='dark'] .btn-apple { color: #000; background: #fff; }

/* Bill photo */
.sheet-photo { display: block; width: 100%; margin-top: 12px; padding: 0; overflow: hidden; border: 0; border-radius: 14px; background: var(--fill); cursor: zoom-in; }
.sheet-photo img { display: block; width: 100%; height: 34dvh; object-fit: contain; }
dialog.viewer { position: fixed; inset: 0; width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; background: #000; }
dialog.viewer::backdrop { background: #000; }
.viewer img { display: block; width: 100%; height: 100%; object-fit: contain; touch-action: pinch-zoom; }
.viewer-close {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgb(120 120 128 / .5);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  font-size: 1.5rem;
  cursor: pointer;
}

/* Browse bill */
.card-invoice {
  color: var(--label);
  background: var(--surface);
  border: 1px solid var(--separator);
  box-shadow: var(--shadow-card);
}

.invoice-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 0.5px solid var(--separator);
}

.invoice-title {
  font: 700 1.375rem/1.2 var(--display);
  letter-spacing: -.022em;
  color: var(--label);
}

.invoice-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--label-2);
  font: 600 .75rem/1 var(--body);
  letter-spacing: -.01em;
}

.invoice-party {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.invoice-party-text {
  flex: 1;
  min-width: 0;
}

.invoice-small {
  color: var(--label-2);
  font: 600 .6875rem/1.2 var(--body);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.invoice-name {
  margin: 2px 0 0;
  font: 600 1.0625rem/1.3 var(--body);
  letter-spacing: -.015em;
  color: var(--label);
}

.invoice-amount-box {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--fill);
}

.invoice-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font: 400 .9375rem/1.3 var(--body);
  letter-spacing: -.01em;
  color: var(--label-2);
}

.invoice-row-value {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--label);
}

.invoice-amount-box .invoice-row:not(.invoice-due) {
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 0.5px solid var(--separator);
}

.invoice-due {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-top: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.invoice-due-label {
  font: 600 .9375rem var(--body);
  color: var(--label);
  letter-spacing: -.015em;
}

.invoice-due-value {
  font: 700 1.5rem/1 var(--display);
  letter-spacing: -.025em;
  color: var(--label);
  font-variant-numeric: tabular-nums;
}

.invoice-story {
  flex: 1;
  min-height: 0;
  margin-top: 14px;
  padding-top: 14px;
  overflow: hidden;
  border-top: 0.5px solid var(--separator);
  display: flex;
  flex-direction: column;
}

.invoice-story .card-story {
  margin-top: 6px;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  font: 400 1rem/1.4 var(--body);
  letter-spacing: -.012em;
  color: var(--label);
}


/* Owner and profile */
.card-owner { font: 600 1rem/1.3 var(--body); }
.sheet-owner { margin-top: 10px; color: var(--label-2); font-size: .9375rem; text-align: center; }
.profile-title { margin-top: 20px; font-size: 1.125rem; }
.profile-title + .group { margin-top: 8px; }

/* Avatars and profile */
.avatar { display: inline-grid; flex: none; place-items: center; width: 40px; height: 40px; overflow: hidden; border-radius: 50%; color: var(--label-2); background: var(--fill); font: 600 1rem var(--body); user-select: none; -webkit-user-select: none; }
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.avatar-photo { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--blue); }
.avatar-small { width: 26px; height: 26px; font-size: .75rem; }
.avatar-small.avatar-photo { box-shadow: none; }
.avatar-large { width: 92px; height: 92px; font-size: 2rem; }
.owner { display: flex; align-items: center; gap: 12px; }
.owner-text { flex: 1; min-width: 0; }
.sheet-owner { display: flex; align-items: center; justify-content: center; gap: 8px; }
.printed-who { display: flex; align-items: center; gap: 8px; }
.printed-who + p { margin-top: 4px; }
.profile { display: grid; justify-items: center; gap: 8px; margin-top: 8px; padding: 20px; border-radius: var(--radius); background: var(--surface); text-align: center; }
.profile-actions { display: flex; gap: 18px; }
.profile-name { display: flex; width: 100%; gap: 8px; margin-top: 6px; }
.profile-name input { flex: 1; min-width: 0; background: var(--bg); }
.report.owner { align-items: flex-start; }

/* Theme switch */
.bar-tools { display: flex; align-items: center; gap: 6px; }
.theme-toggle { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; color: var(--label); background: none; cursor: pointer; transition: transform 100ms ease-out; }
.theme-toggle:active { transform: scale(.9); }
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

@media (prefers-reduced-motion: reduce) {
  .theme-toggle { transition: none; }
}

.btn-destructive { color: #fff; background: var(--red); }

/* Admin tools */
.admin-section { margin-top: 36px; }
.admin-search { display: flex; gap: 8px; margin-top: 12px; }
.admin-search input { flex: 1; min-width: 0; }
.report textarea, .report input { margin-top: 8px; }
.report .row-actions { margin-top: 10px; }

.duplicate-warning { display: grid; gap: 6px; padding: 14px; border-radius: 14px; background: var(--fill); justify-items: start; }

.bill-remove { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.legal-links { margin-top: 18px; color: var(--label-2); font-size: .8125rem; text-align: center; }

/* Unread dots, bill photo and report link */
.tabs a { position: relative; }
.tab-dot { position: absolute; top: 2px; left: calc(50% + 6px); width: 9px; height: 9px; border-radius: 50%; background: var(--red); }
.row-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--blue); vertical-align: middle; }
.detail-photo { width: 100%; max-height: 420px; border-radius: 12px; object-fit: contain; background: var(--fill); }
.card-report { display: block; margin-top: 12px; color: var(--label-2); font-size: .8125rem; text-align: center; }
@media (min-width: 768px) { .tab-dot { top: 4px; left: auto; right: 4px; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Shared structure */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.segmented-wide { margin-top: 18px; }
.segmented-wide button { flex: 1 1 0; min-width: 0; min-height: 36px; padding: 0 6px; }

/* Shown until a page's content arrives. */
#activity:empty::before, #my-bills:empty::before, #chats:empty::before, #bill-detail:empty::before, .stage:empty::before {
  content: '';
  display: block;
  height: 220px;
  margin-top: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  animation: loading-pulse 1.4s ease-in-out infinite;
}
.stage:empty::before { position: absolute; inset: 0; height: auto; margin: 0; }
@keyframes loading-pulse { 50% { opacity: .55; } }

/* List rows */
.row-item { display: block; padding: 0; }
.row-link { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 12px 30px 12px 16px; position: relative; color: inherit; }
.row-link:hover { text-decoration: none; background: var(--fill); }
.row-link:active { background: var(--fill); }
.row-link::after, .setting-row::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 16px;
  width: 8px;
  height: 8px;
  border-top: 2px solid var(--separator);
  border-right: 2px solid var(--separator);
  transform: translateY(-50%) rotate(45deg);
}
.row-text { flex: 1; min-width: 0; }
.row-text h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { display: grid; flex: none; justify-items: end; gap: 2px; max-width: 62%; }
.row-side .status { overflow: hidden; max-width: 100%; text-overflow: ellipsis; }
.row-amount { font-size: .9375rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.row-extras { display: grid; justify-items: start; gap: 6px; padding: 0 16px 12px; }
.row-fee { display: grid; gap: 6px; width: 100%; }
.row-fee .btn { width: 100%; }

/* Settings rows */
.setting-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  padding: 10px 34px 10px 16px;
  border: 0;
  color: var(--label);
  background: none;
  box-shadow: inset 0 -.5px 0 var(--separator);
  font: 400 1.0625rem/1.3 var(--body);
  letter-spacing: inherit;
  text-align: left;
  cursor: pointer;
}
.setting-row:last-child { box-shadow: none; }
.setting-row:hover { text-decoration: none; background: var(--fill); }
.setting-row:active { background: var(--fill); }
.setting-value { overflow: hidden; min-width: 0; color: var(--label-2); font-size: .9375rem; text-overflow: ellipsis; white-space: nowrap; }
.setting-action { justify-content: center; padding-right: 16px; color: var(--blue); }
.setting-action::after { content: none; }
.setting-danger { color: var(--red); }

/* Forms inside sheets */
.sheet-panel .settings-card { gap: 12px; margin-top: 14px; padding: 0; border-radius: 0; background: none; }
.sheet-panel .settings-card .btn { justify-self: stretch; margin-top: 4px; }
.sheet-input { width: 100%; min-height: 96px; margin-top: 14px; }

/* Photo picker */
.photo-tile {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface);
  cursor: pointer;
}
.photo-tile:focus-within { outline: 3px solid var(--blue); outline-offset: 2px; }
.photo-tile:active { opacity: .85; }
.photo-empty { display: grid; justify-items: center; gap: 8px; padding: 36px 16px; color: var(--blue); }
.photo-empty svg { width: 36px; height: 36px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.photo-empty strong { font-weight: 600; }
.photo-tile .preview { border-radius: 0; }
.photo-change {
  position: absolute;
  bottom: 10px;
  left: 50%;
  padding: 5px 12px;
  border-radius: 999px;
  color: #fff;
  background: rgb(0 0 0 / .6);
  font-size: .8125rem;
  white-space: nowrap;
  transform: translateX(-50%);
}

/* Finished states */
.done { display: grid; justify-items: center; gap: 4px; }
.done::before {
  content: '✓';
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 10px;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  font-size: 1.75rem;
  font-weight: 700;
}
.done .btn { justify-self: stretch; margin-top: 14px; }
.signin .form-error { margin-top: 10px; text-align: center; }

/* Legal pages share the app's bar now. */
.legal { padding-top: 16px; padding-bottom: 48px; }
.legal section:first-of-type h1, .legal section h1 { margin-top: 10px; }

/* Admin sections */
.admin-tabs { position: sticky; top: 60px; z-index: 10; }
.admin-list:empty::after { content: attr(data-empty); display: block; margin-top: 12px; padding: 32px 20px; border-radius: 16px; color: var(--label-2); background: var(--surface); text-align: center; }

@media (prefers-reduced-motion: reduce) {
  #activity:empty::before, #chats:empty::before, #bill-detail:empty::before, .stage:empty::before { animation: none; }
}

.admin-tabs button { padding: 0 2px; font-size: .75rem; white-space: nowrap; }

/* Short screens, which include most phones once Safari's bars are showing.
   The amount to pay must always stay on the card, so everything else gives way first. */
@media (max-height: 820px) {
  body:has(.deck-page) .test-note { display: none; }
  .deck-toolbar { margin-top: 4px; }
  .deck-toolbar .btn { min-height: 36px; padding: 4px 12px; }
  .stage { margin-top: 6px; }
  .card { padding: 14px; }
  .card .owner .card-alias { display: none; }
  .card-photo { min-height: 64px; margin-top: 8px; }
  .card-story { margin-top: 8px; -webkit-line-clamp: 1; line-clamp: 1; font-size: .9375rem; }
  .lines { margin-top: 8px; }
  .deck-actions { padding: 8px 0 6px; }
}
@media (max-height: 600px) {
  .lines .line:not(.line-total) { display: none; }
  .line-total { margin-top: 0; padding-top: 6px; font-size: 1.125rem; }
  .card-biller { font-size: 1.0625rem; }
}

/* Long bills: the photo and name give way, so the total is never pushed off the card. */
.card-photo { min-height: 64px; }
.card-biller { flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag-ai { justify-self: start; width: fit-content; margin-top: 6px; padding: 2px 8px; border-radius: 999px; color: var(--blue); background: var(--fill); font-size: .75rem; font-weight: 600; }
.live-photo { display: block; width: 100%; max-height: 260px; margin-top: 8px; border-radius: 10px; object-fit: contain; background: var(--fill); }

/* Covering private details when posting */
.cover-area { display: grid; gap: 8px; }
.cover-title { font: 600 1.0625rem/1.3 var(--body); letter-spacing: inherit; }
/* Sized by width, so the drawing stays lined up with the photo and a tall bill still fits the screen. */
.cover-area .canvas-wrap { width: min(100%, 55vh); margin: 0 auto; }

/* The basics on the card. The type gives way first, then the posted date, so the due date always shows. */
.card-facts { display: flex; flex: none; gap: 6px; margin-top: 3px; overflow: hidden; color: var(--label-2); font-size: .8125rem; white-space: nowrap; }
.card-facts span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.card-facts span + span::before { content: '· '; color: var(--label-2); }
.fact-type { flex: 0 2 auto; }
.fact-due { flex: none; }
.fact-posted { flex: 0 100 auto; }
.fact-overdue { color: var(--red); font-weight: 500; }
/* With a due date, narrow phones drop the posted date, which stays on the bill's details. */
@media (max-width: 399px) { .fact-due + .fact-posted { display: none; } }

.quick-thanks { width: 100%; margin-top: 10px; }

/* First-run steps */
.intro-steps { display: grid; gap: 12px; margin: 14px 0 0; padding-left: 22px; }

/* Two-step login */
.qr { justify-self: center; width: 200px; height: 200px; border-radius: 12px; }
.totp-key { overflow-wrap: anywhere; font: 500 .875rem/1.4 var(--mono); user-select: all; }
.recovery-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 8px 0 0; padding: 0; font: 500 .9375rem var(--mono); list-style: none; user-select: all; }
