/* Fonts are vendored in /fonts/ (SIL OFL 1.1); nothing loads from a third party. */
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("/fonts/space-grotesk-latin-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("/fonts/space-grotesk-latin-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-latin-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */

:root,
:root[data-theme="light"] {
  --paper: #f3efe6;
  --card: #fffdf8;
  --field: #ffffff;
  --field-soft: #f8f5ee;
  --ink: #1a1814;
  --on-ink: #f3efe6;
  --ink-2: #5e584d;
  --muted: #6b655a;
  --line: #e2dccf; /* decorative card outlines only */
  --line-2: #ece6da; /* decorative row dividers */
  --control: #8c8475; /* every border that marks a control */
  --accent: #ffc23d;
  --ok-bg: #e1f1e6;
  --ok-fg: #165a37;
  --wait-bg: #fff0c7;
  --wait-fg: #74510a;
  --neutral-bg: #eee9df;
  --neutral-fg: #5e584d;
  --track: #e6dfd1; /* progress bar track, decorative */
  --error-bg: #fbe4df;
  --error-fg: #8a2414;

  --radius-card: 16px;
  --radius-row: 14px;
  --radius-control: 10px;
  --radius-btn: 12px;

  /* Fixed dark surfaces, the same in both themes. */
  --stage: #1a1814;
  --stage-2: #2a2620;
  --stage-text: #f3efe6;
  --stage-text-2: #cfc7b6;
  --stage-line: #7a7264;
  --stage-rule: #4a443a;
  --accent-ink: #1a1814;

  --font-ui: "Inter", system-ui, sans-serif;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #12110e;
  --card: #1c1a16;
  --field: #24211c;
  --field-soft: #24211c;
  --ink: #f3efe6;
  --on-ink: #1a1814;
  --ink-2: #cfc7b6;
  --muted: #a39b8b;
  --line: #2f2b24;
  --line-2: #2a2620;
  --control: #7a7264;
  --ok-bg: #173a27;
  --ok-fg: #9ee2b9;
  --wait-bg: #3a2e10;
  --wait-fg: #ffd98a;
  --neutral-bg: #24211c;
  --neutral-fg: #cfc7b6;
  --track: #3a352d;
  --error-bg: #3d1a14;
  --error-fg: #ffb4a6;
  color-scheme: dark;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body[data-view="crop"] {
  background: var(--stage);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
}

h1 {
  font-size: 32px;
  line-height: 1.08;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
}

img {
  max-width: 100%;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.view-stage :focus-visible,
.stage-card :focus-visible {
  outline-color: var(--stage-text);
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-lg {
  width: 26px;
  height: 26px;
}

/* ---------- Layout ---------- */

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page {
  flex: 1;
  padding: 0 16px 32px;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 8px;
}

body[data-view="crop"] .app-header,
body[data-view="review"] .app-header,
body[data-view="pay"] .app-header {
  display: none;
}

.app-header-end {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.logo-mark .icon {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.logo-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.theme-toggle .icon-sun,
:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 13px;
  font-weight: 600;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1f8a4c;
}

.screen-header {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 60px;
  margin: 0 -8px;
  padding-top: 8px;
}

.screen-title {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  text-align: center;
}

.step-count {
  font-size: 13px;
  color: var(--muted);
  text-align: right;
  padding-right: 8px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-btn);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button .icon {
  width: 22px;
  height: 22px;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 4px 4px;
}

.hero-tight {
  gap: 6px;
}

.lede {
  font-size: 16px;
  color: var(--ink-2);
}

.eyebrow {
  font-size: 13px;
  color: var(--ink-2);
}

.eyebrow:empty {
  display: none;
}

#edit-items {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 4px 0;
}

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 20px;
}

.stage-card {
  background: var(--stage);
  color: var(--stage-text);
  border-radius: var(--radius-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

:root[data-theme="dark"] .stage-card {
  background: var(--card);
  border: 1px solid var(--line);
}

.list-card {
  padding: 0;
  overflow: hidden;
}

/* ---------- Forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.field > label,
.field-label,
.tip-other label {
  font-size: 13px;
  font-weight: 600;
  padding: 0;
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--field);
  font-size: 15px;
}

input[readonly] {
  background: var(--field-soft);
}

select {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238c8475' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.dropzones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dropzone {
  min-height: 96px;
  border: 1.5px dashed var(--control);
  border-radius: var(--radius-btn);
  background: var(--field-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.dropzone:focus-within {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.receipt-chosen {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.receipt-chosen.chosen {
  color: var(--ok-fg);
}

/* ---------- Buttons ---------- */

.btn {
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  font-size: 16px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.55;
}

.btn-primary {
  background: var(--ink);
  color: var(--on-ink);
}

.btn-accent {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-accent .icon {
  stroke-width: 2.2;
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--control);
}

.btn-stage {
  background: transparent;
  color: var(--stage-text);
  border-color: var(--stage-line);
}

.btn-small {
  width: auto;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  border: 1px solid var(--control);
  color: var(--ink);
}

.btn-copy {
  width: auto;
  min-height: 48px;
  padding: 0 18px;
}

.link-button {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.inline-link {
  display: inline;
  min-height: 0;
  padding: 0;
}

.row-button {
  width: 100%;
  min-height: 52px;
  border: 0;
  background: transparent;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.button-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.copy-row {
  display: flex;
  gap: 8px;
}

.copy-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 14px;
  text-overflow: ellipsis;
}

/* ---------- Stepper, chips, pills ---------- */

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--field);
  overflow: hidden;
  flex-shrink: 0;
}

.stepper button {
  width: 40px;
  height: 36px;
  border: 0;
  background: var(--field-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.stepper button .icon {
  width: 16px;
  height: 16px;
}

.stepper button:disabled {
  color: var(--muted);
  opacity: 0.6;
}

.stepper-value {
  min-width: 40px;
  padding: 0 6px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
}

.stepper-wide button {
  width: 44px;
  background: transparent;
}

.chips {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.chip {
  min-height: 44px;
  padding: 0 4px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--field);
  font-size: 14px;
}

.chip[aria-checked="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}

.tip-other {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.pill {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--control);
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.pill[aria-pressed="true"],
.pill.filled {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--neutral-bg);
  color: var(--neutral-fg);
}

.badge .icon {
  width: 12px;
  height: 12px;
  stroke-width: 3;
}

.badge-ok {
  background: var(--ok-bg);
  color: var(--ok-fg);
}

.badge-wait {
  background: var(--wait-bg);
  color: var(--wait-fg);
}

/* ---------- Banners and results ---------- */

.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-btn);
  font-size: 14px;
  background: var(--neutral-bg);
  color: var(--neutral-fg);
}

.banner .icon {
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.banner-ok {
  background: var(--ok-bg);
  color: var(--ok-fg);
}

.banner-wait {
  background: var(--wait-bg);
  color: var(--wait-fg);
}

.pulse-dot {
  width: 12px;
  height: 12px;
  margin-top: 4px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #d39400;
  box-shadow: 0 0 0 4px rgba(255, 194, 61, 0.35);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 7px rgba(255, 194, 61, 0.1);
  }
}

.result {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-control);
  font-size: 14px;
  background: var(--ok-bg);
  color: var(--ok-fg);
}

.result.error {
  background: var(--error-bg);
  color: var(--error-fg);
}

.stage-card .result {
  margin-top: 0;
}

/* ---------- Breakdown ---------- */

.breakdown {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.breakdown > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.breakdown dt {
  font-size: 14px;
  color: var(--ink-2);
}

.breakdown dd {
  margin: 0;
  font-size: 14px;
  white-space: nowrap;
}

.card .breakdown {
  border-top: 1px dashed var(--control);
  padding-top: 14px;
}

.card .breakdown.breakdown-plain {
  border-top: 0;
  padding-top: 0;
}

.breakdown-total dt,
.breakdown-total dd {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.stage-card .breakdown dt,
.stage-card .breakdown dd {
  color: var(--stage-text-2);
}

:root[data-theme="dark"] .stage-card .breakdown dt,
:root[data-theme="dark"] .stage-card .breakdown dd {
  color: var(--ink-2);
}

.breakdown-hero {
  border-top: 1px dashed var(--stage-rule);
  padding-top: 12px;
  margin-top: 4px;
}

.stage-card .breakdown-hero dt {
  font-size: 15px;
  font-weight: 600;
  color: var(--stage-text);
}

.stage-card .breakdown-hero dd {
  font-size: 26px;
  font-weight: 500;
  color: var(--stage-text);
}

:root[data-theme="dark"] .stage-card .breakdown-hero dt,
:root[data-theme="dark"] .stage-card .breakdown-hero dd {
  color: var(--ink);
}

/* ---------- Start ---------- */

.steps-strip {
  list-style: none;
  margin: 8px 0 0;
  padding: 0 4px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.steps-strip li {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.steps-strip .mono {
  color: var(--ink);
}

/* ---------- Crop ---------- */

.view-stage {
  margin: 0 -16px -32px;
  min-height: 100vh;
  background: var(--stage);
  color: var(--stage-text);
  gap: 0;
}

.view-stage .screen-header {
  margin: 0;
  padding: 8px 8px 8px;
}

.view-stage .step-count {
  color: var(--stage-text-2);
}

.view-stage .icon-button {
  color: var(--stage-text);
}

.crop-stage {
  background: var(--stage-2);
  overflow: hidden;
  padding: 24px 16px;
  display: flex;
  justify-content: center;
}

.cropper {
  position: relative;
  display: inline-block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  max-width: 100%;
}

.cropper img {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  -webkit-user-drag: none;
}

.crop-overlay {
  position: absolute;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 999px rgba(26, 24, 20, 0.55);
  pointer-events: none;
}

.crop-handle {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--accent);
}

/* The visible handle is 14 px; the touch area around it is 44 px. */
.crop-handle::after {
  content: "";
  position: absolute;
  inset: -15px;
}

.crop-handle[data-corner="nw"] {
  top: -8px;
  left: -8px;
}
.crop-handle[data-corner="ne"] {
  top: -8px;
  right: -8px;
}
.crop-handle[data-corner="sw"] {
  bottom: -8px;
  left: -8px;
}
.crop-handle[data-corner="se"] {
  bottom: -8px;
  right: -8px;
}

.crop-footer {
  padding: 20px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.crop-hint {
  text-align: center;
  color: var(--stage-text-2);
  font-size: 15px;
}

.crop-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--stage-text-2);
  font-size: 14px;
}

.spinner {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2.5px solid var(--stage-rule);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Review ---------- */

.summary-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}

.review-thumb {
  width: 44px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--field-soft);
  flex-shrink: 0;
}

.review-thumb:not([src]) {
  visibility: hidden;
}

.summary-card-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  font-size: 14px;
}

.summary-card-text strong {
  font-size: 16px;
  font-weight: 600;
}

.review-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
}

.review-panel img {
  display: block;
  width: 100%;
  border-radius: 8px;
}

.label-heading {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  margin-bottom: 6px;
}

.review-panel pre {
  margin: 0;
  max-height: 280px;
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: var(--field-soft);
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
}

.rows > * + * {
  border-top: 1px solid var(--line-2);
}

.list-card .row-button {
  border-top: 1px solid var(--line-2);
}

.edit-row {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.edit-row-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.edit-name-button {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  margin: -6px 0 -6px -6px;
  padding: 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item-name {
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.item-name .icon {
  width: 14px;
  height: 14px;
  margin-left: 6px;
  vertical-align: -1px;
  color: var(--muted);
}

.item-original {
  font-size: 12px;
  font-style: italic;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.item-amount {
  font-family: var(--font-mono);
  font-size: 14px;
  white-space: nowrap;
  padding-top: 1px;
}

.edit-row-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.item-each {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.spacer {
  flex: 1;
}

.split-stepper .stepper-value {
  min-width: 64px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
}

.edit-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.edit-fields-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
}

.edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.edit-actions .btn {
  width: auto;
  min-height: 44px;
  font-size: 14px;
}

.edit-row .edit-fields,
.edit-row.editing .edit-name-button,
.edit-row.editing .item-amount,
.edit-row.editing .edit-row-controls {
  display: none;
}

.edit-row.editing .edit-fields {
  display: flex;
}

.edit-row.editing .edit-row-head {
  display: none;
}

/* ---------- Share ---------- */

.share-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.qr-frame {
  align-self: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: #ffffff;
  line-height: 0;
  position: relative;
}

.qr-frame img {
  width: 200px;
  height: 200px;
  image-rendering: pixelated;
}

.qr-frame-lg img {
  width: 236px;
  height: 236px;
}

.qr-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 10px;
  border: 3px solid #ffffff;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-badge .icon {
  width: 20px;
  height: 20px;
  stroke-width: 2.2;
}

.center-note {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.claimed-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 14px;
  color: var(--stage-text-2);
}

.claimed-amount {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 500;
  line-height: 1.1;
  color: var(--stage-text);
  overflow-wrap: anywhere;
}

.claimed-rest {
  font-size: 14px;
  color: var(--stage-text-2);
}

:root[data-theme="dark"] .claimed-top,
:root[data-theme="dark"] .claimed-rest {
  color: var(--ink-2);
}

:root[data-theme="dark"] .claimed-amount {
  color: var(--ink);
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--stage-2);
  overflow: hidden;
}

:root[data-theme="dark"] .progress {
  background: var(--track);
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.3s ease;
}

.progress-thin {
  height: 4px;
  background: var(--track);
}

.progress-thin span {
  background: var(--ink);
}

.who-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.who-empty {
  color: var(--muted);
  font-size: 14px;
}

.who-card {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.who-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--neutral-bg);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}

.who-name {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.who-name strong {
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.who-sats {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.who-end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.who-amount {
  font-family: var(--font-mono);
  font-size: 14px;
}

.who-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-left: 48px;
}

.who-actions .btn-small.mono {
  font-weight: 500;
}

.share-items .share-item-row {
  padding: 12px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 16px;
  align-items: center;
}

.share-item-foot {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
}

.share-item-foot .progress {
  flex: 1 1 96px;
}

.share-item-foot .share-item-names:empty {
  display: none;
}

.share-item-label {
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.share-item-label .item-original {
  display: block;
  font-weight: 400;
}

.share-item-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

.share-item-names {
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  overflow-wrap: anywhere;
}

/* ---------- Host history ---------- */

.header-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.history-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.history-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.history-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.history-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.history-meta {
  font-size: 13px;
  color: var(--muted);
}

.history-total {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
}

.history-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.history-details summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

/* The invoices sit inside the receipt's card, so they are rows, not cards. */
.history-who {
  gap: 0;
}

.history-who .who-card {
  padding: 12px 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: none;
}

.history-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-remove {
  font-size: 14px;
  color: var(--ink-2);
}

.history-note {
  font-size: 14px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* ---------- Guest ---------- */

.claim-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.claim-card {
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-row);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.claim-card.selected {
  border: 2px solid var(--ink);
  padding: 13px;
}

.claim-card.claimed-out {
  background: var(--neutral-bg);
  opacity: 0.6;
}

.claim-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

.claim-card.claimed-out .claim-main {
  cursor: default;
}

.checkmark {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  margin-top: 1px;
  border-radius: 6px;
  border: 1.5px solid var(--control);
  background: var(--field);
  color: var(--on-ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

.checkmark .icon {
  width: 14px;
  height: 14px;
  stroke-width: 3;
  visibility: hidden;
}

.claim-main input:checked + .checkmark {
  background: var(--ink);
  border-color: var(--ink);
}

.claim-main input:checked + .checkmark .icon {
  visibility: visible;
}

.claim-main input:focus-visible + .checkmark {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.claim-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.claim-note {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.claim-status.has-sep::before {
  content: " \00b7  ";
}

.claim-price {
  font-family: var(--font-mono);
  font-size: 14px;
  white-space: nowrap;
}

.claim-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-left: 34px;
  font-size: 13px;
  color: var(--ink-2);
}

.claim-controls:empty {
  display: none;
}

.claim-qty {
  display: flex;
  align-items: center;
  gap: 10px;
}

.claim-qty .stepper {
  background: var(--field);
}

.claim-left {
  font-size: 12px;
  color: var(--muted);
}

.claim-split {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.owe-card {
  margin-top: 4px;
}

/* ---------- Pay ---------- */

.pay-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0 4px;
}

.pay-sats {
  font-family: var(--font-mono);
  font-size: 40px;
  font-weight: 500;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.pay-sats small {
  font-size: 20px;
  font-weight: 400;
  color: var(--ink-2);
  margin-left: 6px;
}

.pay-fiat {
  font-size: 15px;
  color: var(--ink-2);
}

.pay-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pay-footer {
  text-align: center;
  font-size: 14px;
  color: var(--ink-2);
}

.pay-footer .link-button {
  font-size: inherit;
  color: var(--ink);
}

@media (max-width: 360px) {
  .page {
    padding: 0 12px 28px;
  }
  .card {
    padding: 16px;
  }
  .view-stage {
    margin: 0 -12px -28px;
  }
  h1 {
    font-size: 28px;
  }
  .chip {
    font-size: 13px;
  }
  .who-actions {
    padding-left: 0;
  }
  .claim-controls {
    padding-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pulse-dot,
  .spinner {
    animation: none;
  }
  .progress span {
    transition: none;
  }
}
