﻿:root {
  --ink: #1c2428;
  --ink-muted: #5c6770;
  --paper-0: #cfd5d8;
  --paper-1: #d9dee1;
  --surface: rgba(232, 236, 238, 0.72);
  --surface-strong: rgba(236, 239, 241, 0.88);
  --accent: #2f6f68;
  --accent-hover: #255952;
  --accent-soft: rgba(47, 111, 104, 0.16);
  --accent-glow: rgba(47, 111, 104, 0.28);
  --warn: #b7791f;
  --danger: #c45c4a;
  --danger-soft: rgba(196, 92, 74, 0.12);
  --line: rgba(28, 36, 40, 0.14);
  --focus: #2f6f68;
  --radius: 10px;
  /* Prefer installed CJK faces — avoid Google Fonts network on critical path */
  --font-display: "Noto Serif TC", "Source Han Serif TC", "Songti TC", "PMingLiU", serif;
  --font-body: "Noto Sans TC", "Source Han Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  background: var(--paper-0);
  -webkit-font-smoothing: antialiased;
}

.bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(980px 520px at 50% -8%, rgba(47, 111, 104, 0.11), transparent 52%),
    linear-gradient(168deg, #c5ccd1 0%, #d2d8dc 44%, #c9d0d4 100%);
  z-index: 0;
}
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.28;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cpath d='M0 40H80M40 0V80' stroke='%231c2428' stroke-opacity='0.045' stroke-width='1'/%3E%3C/svg%3E");
  pointer-events: none;
}

.shell {
  position: relative;
  z-index: 1;
  height: 100dvh;
  max-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding:
    calc(1.15rem + var(--safe-t))
    calc(1rem + var(--safe-r))
    calc(0.55rem + var(--safe-b))
    calc(1rem + var(--safe-l));
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
}
.shell.is-wide {
  max-width: min(88rem, 100%);
}
.shell.is-wide .stage {
  justify-content: flex-start;
  overflow: hidden;
}
.shell.is-wide .brand-caption {
  max-width: 32rem;
}

.top {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding-top: 0.55rem;
}
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  text-align: center;
}
.brand-logo {
  display: block;
  width: clamp(3.6rem, 14vw, 4.5rem);
  height: clamp(3.6rem, 14vw, 4.5rem);
  object-fit: cover;
  object-position: center;
  border: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
  border-radius: 22%;
  overflow: hidden;
  -webkit-clip-path: inset(0 round 22%);
  clip-path: inset(0 round 22%);
  content-visibility: auto;
}
.brand-caption {
  margin: 0;
  max-width: 18rem;
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 3.2vw, 1.05rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
  line-height: 1.35;
}

.stage {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
  padding: 0.35rem 0 0.5rem;
}

.screen {
  display: none;
  flex-direction: column;
  gap: 0.85rem;
  width: 100%;
  text-align: center;
  animation: fadeIn 0.28s ease both;
}
.screen.active { display: flex; }

.eyebrow {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
  text-align: center;
  text-wrap: pretty;
  line-height: 1.5;
  max-width: 28rem;
  margin-inline: auto;
  overflow-wrap: anywhere;
}
.lead {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 3.6vw, 1.45rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  text-align: center;
  text-wrap: balance;
  line-height: 1.35;
  max-width: 28rem;
  margin-inline: auto;
}

.label {
  display: block;
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  color: var(--ink-muted);
  text-align: left;
}
.field-block {
  text-align: left;
}
.hint-soft {
  margin: 0.15rem 0 0;
  color: var(--ink-muted);
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: center;
  text-wrap: pretty;
  max-width: 24rem;
  margin-inline: auto;
  overflow-wrap: anywhere;
}

.field {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.amount-wrap {
  text-align: center;
  padding: 0.25rem 0 0.1rem;
}
.amount-prefix {
  display: block;
  color: var(--ink-muted);
  font-size: 0.85rem;
  margin-bottom: 0.2rem;
}
.amount-input {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 10vw, 3.4rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--ink);
  outline: none;
  cursor: pointer;
  border-radius: 8px;
  padding: 0.15rem 0.35rem 0.35rem;
  box-shadow: inset 0 -2px 0 var(--accent-glow);
  transform-origin: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.amount-input:hover {
  background: var(--accent-soft);
  box-shadow:
    inset 0 -2px 0 var(--accent),
    0 0 0 3px var(--accent-soft);
}
.amount-input:focus {
  cursor: text;
  transform: scale(1.03);
  background: var(--accent-soft);
  box-shadow:
    inset 0 -3px 0 var(--accent),
    0 0 0 3px var(--accent-glow);
  animation: none;
}
.amount-hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
}
.amount-hint.edit-tip {
  color: var(--accent);
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
}
.segmented button {
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.segmented button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.segmented button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn {
  min-height: 2.85rem;
  padding: 0.7rem 1rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease, opacity 0.15s ease;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.ghost:hover { background: var(--surface); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { filter: brightness(0.95); }
.btn.block { width: 100%; }
.btn.is-loading {
  position: relative;
  opacity: 0.92;
  pointer-events: none;
}
.btn.is-loading::after {
  content: "";
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  margin-left: 0.45rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -0.1rem;
  animation: spin 0.7s linear infinite;
}

.trust {
  margin: 0 auto;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.78rem;
  line-height: 1.5;
  text-wrap: pretty;
  max-width: 28rem;
  overflow-wrap: anywhere;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.choice-grid .btn {
  min-height: 4.5rem;
  font-size: 1rem;
}

.stack { display: flex; flex-direction: column; gap: 0.65rem; }
.row { display: flex; gap: 0.55rem; align-items: center; }
.row .btn { flex: 1; }

.turnstile-slot {
  min-height: 65px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Progressive loading: skeleton / shimmer (respects reduced-motion below) */
.skel {
  display: block;
  border-radius: 8px;
  background: rgba(28, 36, 40, 0.08);
  position: relative;
  overflow: hidden;
}
.skel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(255, 255, 255, 0.38) 42%,
    transparent 78%
  );
  transform: translateX(-120%);
  animation: shimmer 1.15s ease-in-out infinite;
}
.skel-line {
  height: 0.72rem;
  margin: 0.2rem 0;
}
.skel-w-30 { width: 30%; }
.skel-w-50 { width: 50%; }
.skel-w-60 { width: 60%; }
.skel-w-80 { width: 80%; }
.skel-field {
  height: 2.75rem;
  width: 100%;
  border-radius: var(--radius);
}
.skel-btn {
  height: 2.45rem;
  flex: 1;
  min-width: 5rem;
  border-radius: var(--radius);
}
.skel-btn-block {
  height: 2.85rem;
  width: 100%;
  border-radius: var(--radius);
}
.skel-turnstile {
  width: min(100%, 18.75rem);
  height: 4.05rem;
  border-radius: 8px;
}
.skel-card {
  pointer-events: none;
  animation: none;
}
.skel-card .skel-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: auto;
  padding-top: 0.35rem;
}
.library.is-loading {
  opacity: 1;
}
.library.is-ready > .pay-card:not(.skel-card) {
  animation: fadeIn 0.22s ease both;
}
.sync-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 0 auto;
  padding: 0.28rem 0.7rem;
  width: fit-content;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.sync-pill::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border: 2px solid rgba(47, 111, 104, 0.35);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.manage-sync {
  text-align: center;
  min-height: 1.4rem;
}
.confirming-screen {
  text-align: center;
  gap: 0.85rem;
}

.manage-screen {
  text-align: left;
  min-height: 0;
  flex: 1;
  gap: 0.75rem;
}
.manage-screen > .lead,
.manage-screen > .eyebrow {
  text-align: center;
}
.manage-hint {
  margin: 0 auto;
  color: var(--ink-muted);
  font-size: 0.82rem;
  text-align: center;
  line-height: 1.55;
  text-wrap: pretty;
  max-width: 32rem;
  overflow-wrap: anywhere;
}

.manage-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  max-width: 28rem;
  margin: 0 auto;
  width: 100%;
}
.manage-tab {
  min-height: 2.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.manage-tab[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.manage-tab:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.library {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  max-height: min(58dvh, 34rem);
  overflow: auto;
  padding: 0.1rem 0.2rem 0.35rem;
  text-align: left;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}
.library-empty {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 8.5rem;
  padding: 1.25rem 1rem;
  text-align: center;
}
.library-empty-text {
  margin: 0;
  max-width: 22rem;
  color: var(--ink-muted);
  font-size: 0.92rem;
  line-height: 1.65;
  text-align: center;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}
.pay-card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 11.5rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(165deg, rgba(236, 239, 241, 0.95), rgba(226, 232, 234, 0.88));
  text-align: left;
  animation: fadeIn 0.28s ease both;
}
.pay-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
}
.pay-card-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.3;
  letter-spacing: 0.01em;
}
.pay-card-amount {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
}
.pay-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin: 0;
  padding: 0.18rem 0.5rem;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.pay-badge.is-warn {
  background: rgba(183, 121, 31, 0.14);
  color: #8a5a12;
}
.pay-badge.is-muted {
  background: rgba(28, 36, 40, 0.08);
  color: var(--ink-muted);
}
.pay-card-meta {
  display: grid;
  gap: 0.28rem;
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}
.pay-card-meta dt {
  display: none;
}
.pay-card-meta dd {
  margin: 0;
}
.pay-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: auto;
  padding-top: 0.25rem;
}
.pay-card-actions .btn {
  flex: 1 1 auto;
  min-height: 2.45rem;
  font-size: 0.88rem;
  padding: 0.45rem 0.7rem;
}
.pay-card-note {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.75rem;
  line-height: 1.5;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: min(42dvh, 18rem);
  overflow: auto;
  padding-right: 0.15rem;
  text-align: left;
}
.item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.75rem;
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  text-align: left;
}
.item-title {
  margin: 0;
  font-weight: 700;
  font-size: 0.95rem;
}
.item-meta {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.78rem;
}
.item-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  align-self: center;
}
.item-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--ink-muted);
}
.pager button {
  min-height: 2.4rem;
  min-width: 2.4rem;
}

.footer-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding-top: 0.15rem;
}
.help-link {
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  font-size: 0.8rem;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}
.help-link:hover { color: var(--ink); }
.help-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.status {
  min-height: 1.4rem;
  font-size: 0.82rem;
  color: var(--ink-muted);
  text-align: center;
  text-wrap: pretty;
  overflow-wrap: anywhere;
  line-height: 1.5;
  max-width: 34rem;
  margin-inline: auto;
}
.status.is-error { color: var(--danger); }
.status.is-ok { color: var(--accent); }

.success-mark {
  width: 3rem;
  height: 3rem;
  margin: 0 auto;
  border-radius: 50%;
  border: 2px solid var(--accent);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 1.4rem;
  animation: popIn 0.32s ease both;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(28, 36, 40, 0.38);
  padding: 1rem;
}
.modal[hidden] { display: none !important; }
.modal-card {
  width: min(100%, 22rem);
  padding: 1.15rem 1.1rem 1rem;
  border-radius: 12px;
  background: #e8ecee;
  border: 1px solid var(--line);
  text-align: left;
}
.detail-sheet {
  width: min(100%, 44rem);
  max-height: min(90dvh, 48rem);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  background: #f7f6f3;
  border: 1px solid rgba(28, 36, 40, 0.12);
  box-shadow: 0 18px 48px rgba(28, 36, 40, 0.16);
}
.detail-sheet .help-body {
  flex: 1;
  min-height: 0;
}
.detail-grid {
  display: grid;
  gap: 0.55rem 1rem;
  margin: 0;
}
.detail-grid > div {
  display: grid;
  gap: 0.15rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(28, 36, 40, 0.08);
}
.detail-grid dt {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.78rem;
}
.detail-grid dd {
  margin: 0;
  color: var(--ink);
  font-size: 0.92rem;
  word-break: break-all;
  font-variant-numeric: tabular-nums;
}
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1.05rem 1rem;
  border-top: 1px solid rgba(28, 36, 40, 0.1);
}
.detail-actions .btn {
  flex: 1 1 auto;
  min-height: 2.55rem;
}
.modal-card h2 {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  text-wrap: balance;
  text-align: center;
  line-height: 1.35;
}
.modal-card p {
  margin: 0 auto 1rem;
  color: var(--ink-muted);
  font-size: 0.92rem;
  text-align: center;
  text-wrap: pretty;
  line-height: 1.55;
  max-width: 28rem;
  overflow-wrap: anywhere;
}
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.help-sheet {
  width: min(100%, 48rem);
  max-height: min(90dvh, 48rem);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  background: #f7f6f3;
  border: 1px solid rgba(28, 36, 40, 0.12);
  box-shadow: 0 18px 48px rgba(28, 36, 40, 0.16);
}
.help-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 1rem 0.75rem;
  border-bottom: 1px solid rgba(28, 36, 40, 0.1);
}
.help-sheet-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.12rem;
  letter-spacing: 0.01em;
}
.help-close {
  min-width: 2.4rem;
  min-height: 2.4rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.help-close:hover { background: rgba(28, 36, 40, 0.06); color: var(--ink); }
.help-body {
  overflow: auto;
  padding: 0.85rem 1.05rem 1.2rem;
  text-align: left;
  -webkit-overflow-scrolling: touch;
}
.help-section {
  padding: 0.75rem 0;
}
.help-section + .help-section {
  border-top: 1px solid rgba(28, 36, 40, 0.1);
}
.help-section h3 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--ink);
}
.help-section p,
.help-section li {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.88rem;
  line-height: 1.6;
  text-wrap: pretty;
  overflow-wrap: anywhere;
  max-width: 40rem;
}
.help-section p + p { margin-top: 0.45rem; }
.help-section ol,
.help-section ul {
  margin: 0.35rem 0 0;
  padding-left: 1.15rem;
}
.help-section li + li { margin-top: 0.3rem; }
.help-callout {
  margin-top: 0.55rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  background: rgba(47, 111, 104, 0.1);
  border-left: 3px solid var(--accent);
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.55;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}
.help-callout.warn {
  background: rgba(183, 121, 31, 0.12);
  border-left-color: var(--warn);
}
.help-meta {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px dashed rgba(28, 36, 40, 0.14);
  color: var(--ink-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.82); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes shimmer {
  to { transform: translateX(120%); }
}

@media (min-width: 640px) {
  .library {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: min(62dvh, 38rem);
  }
  .detail-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 960px) {
  .library {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.85rem;
  }
}

@media (max-width: 400px) {
  .choice-grid { grid-template-columns: 1fr; }
  .segmented {
    grid-template-columns: repeat(3, 1fr);
  }
  .segmented button {
    font-size: 0.72rem;
    min-height: 2.55rem;
    padding: 0.35rem 0.2rem;
  }
  .amount-input { font-size: 2.2rem; }
  .pay-card-actions { flex-direction: column; }
}

@media (max-height: 560px) {
  .shell { padding-top: calc(0.65rem + var(--safe-t)); }
  .top { padding-top: 0.28rem; }
  .brand-logo {
    width: clamp(3.2rem, 12vw, 4rem);
    height: clamp(3.2rem, 12vw, 4rem);
  }
  .brand-caption { font-size: 0.9rem; }
  .brand { gap: 0.28rem; }
  .stage { justify-content: flex-start; padding-top: 0.15rem; }
  .lead { font-size: 1.15rem; }
  .amount-input { font-size: 2.1rem; }
  .choice-grid .btn { min-height: 3.4rem; }
  .list { max-height: 28dvh; }
  .library { max-height: 42dvh; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .amount-input:focus { transform: none; }
  .btn.is-loading::after { display: none; }
  .skel::after { display: none; }
  .sync-pill::before { display: none; }
  .library.is-ready > .pay-card:not(.skel-card) { animation: none; }
}

/* Compact chrome when embedded in partner iframe (?embed=1 or framed) */
html.is-embed .bg {
  opacity: 0.35;
}
html.is-embed .shell {
  padding: 0.5rem 0.75rem calc(0.5rem + var(--safe-b));
  max-width: 100%;
}
html.is-embed .top {
  padding-top: 0.15rem;
  margin-bottom: 0.25rem;
}
html.is-embed .brand-logo,
html.is-embed .brand-logo.is-embed-icon {
  width: 3.25rem;
  height: 3.25rem;
  display: block;
  flex-shrink: 0;
}
html.is-embed .brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}
html.is-embed .brand-caption {
  display: none !important;
}
html.is-embed .embed-zeitfrei {
  display: block;
  margin: 0;
  max-width: 18rem;
  font-size: 0.85rem;
  line-height: 1.35;
  text-align: center;
  color: var(--ink-muted, #5a706c);
}
.embed-zeitfrei[hidden] {
  display: none !important;
}
html.is-embed .footer-bar .help-link {
  display: none;
}
html.is-embed .stage {
  justify-content: flex-start;
  padding-top: 0;
}
html.is-embed .lead {
  font-size: 1.1rem;
}
html.is-embed .embed-login-hint {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid color-mix(in srgb, var(--ink, #1a1f24) 12%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, #fff 70%, transparent);
}
html.is-embed .embed-login-hint a {
  color: var(--accent, #2f6f68);
}
