:root {
  --moti: #EFEEEB;     /* background */
  --syahi: #1C1B1F;    /* text */
  --dhuan: #6B6A70;    /* secondary text, 4.6:1 on Moti */
  --genda: #F2A516;    /* the one accent: main button */
  --tulsi: #1F9D6B;    /* paid (icons and fills only, never text) */
  --glass: rgba(255, 255, 255, 0.6);
  --glass-edge: rgba(255, 255, 255, 0.75);
  --line: rgba(28, 27, 31, 0.08);
  --shadow: 0 1px 2px rgba(28, 27, 31, 0.04), 0 10px 30px rgba(28, 27, 31, 0.06);
  --sans: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --radius: 22px;
  --gap: clamp(10px, 1.8vh, 16px);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--moti);
  /* Pearl light so the glass has something to blur. The tints are capped
     (4% marigold, 2.5% tulsi) so Dhuan text stays >= 4.5:1 everywhere. */
  background-image:
    radial-gradient(60% 40% at 100% 0%, rgba(242, 165, 22, 0.04), transparent 70%),
    radial-gradient(55% 40% at 0% 100%, rgba(31, 157, 107, 0.025), transparent 70%),
    radial-gradient(70% 45% at 0% 15%, rgba(255, 255, 255, 0.95), transparent 70%),
    radial-gradient(60% 40% at 100% 70%, rgba(255, 255, 255, 0.7), transparent 70%);
  background-attachment: fixed;
  color: var(--syahi);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.page {
  max-width: 440px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 20px max(14px, env(safe-area-inset-bottom));
}

.view {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-height: calc(100vh - 30px);
  min-height: calc(100dvh - 30px);
}

p, h1, h2 { margin: 0; }

/* ---------- Type ---------- */

.head { padding: 2px 4px 0; }
.eyebrow { color: var(--dhuan); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#pay-organizer { display: inline-block; max-width: calc(100% - 8.6em); overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.headline {
  font-weight: 650;
  font-size: clamp(25px, 6.6vw, 30px);
  line-height: 1.12;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.note {
  color: var(--dhuan); font-size: 14px; margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.muted { color: var(--dhuan); }
.small { font-size: 14px; }
.label { color: var(--dhuan); font-size: 14px; }
.card-title { font-size: 22px; font-weight: 650; line-height: 1.15; letter-spacing: -0.015em; }

.amount {
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  font-size: clamp(46px, 12.5vw, 56px);
  line-height: 1;
  letter-spacing: -0.03em;
  margin-top: 2px;
}
.rs {
  font-weight: 300;
  font-size: 0.7em;
  margin-right: 0.06em;
  vertical-align: 0.14em;
}
.paise { font-size: 0.55em; }
.breakdown { color: var(--dhuan); font-size: 14px; margin-top: 4px; }
.breakdown .rs { font-size: 1em; font-weight: 400; vertical-align: 0; margin: 0; }

/* ---------- Glass ---------- */

.card {
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(14px, 2.2vh, 20px) 18px;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card { background: rgba(255, 255, 255, 0.86); }
}

.share-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }

/* ---------- QR ---------- */

.pay-block { margin-top: var(--gap); }
.qr-tile {
  background: #fff;
  border-radius: 18px;
  border: 1px solid var(--line);
  display: flex;
  justify-content: center;
  padding: 4px;
}
.qr {
  display: block;
  /* shrink on short screens so everything fits without scrolling */
  width: clamp(140px, calc(100vh - 486px), 236px);
  width: clamp(140px, calc(100dvh - 486px), 236px);
  height: auto;
  aspect-ratio: 1;
  image-rendering: auto;
  -webkit-touch-callout: default;
}
/* QR shares the card with a status message: keep it all on one screen */
.pay-card.both .qr {
  width: clamp(130px, calc(100vh - 560px), 200px);
  width: clamp(130px, calc(100dvh - 560px), 200px);
}
.pay-card.both .status-block + .pay-block { margin-top: 12px; }
.sheet-panel:focus { outline: none; }

.hint { color: var(--dhuan); font-size: 13px; text-align: center; margin-top: 8px; }

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

.btn {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  font: inherit;
  font-weight: 600;
  color: var(--syahi);
  min-height: 48px;
  padding: 0 16px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, background-color 0.15s ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible, .link-btn:focus-visible, .picker button:focus-visible {
  outline: 3px solid var(--syahi); outline-offset: 2px;
}
.btn[disabled] { opacity: 0.6; cursor: default; transform: none; }

.btn-primary {
  background: var(--genda);
  min-height: 56px;
  font-size: 17px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 6px 18px rgba(242, 165, 22, 0.28);
}
.btn-quiet {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  font-size: 15px;
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
}
.actions { display: flex; gap: 10px; margin-top: 10px; }
.actions .btn { padding: 0 12px; }
.btn-stack { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; min-width: 0; }
.btn-stack > * { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.btn-stack small { font-size: 12px; font-weight: 500; color: var(--dhuan); }
@media (max-width: 380px) {
  .actions .btn .ico { display: none; }
  .btn-quiet { font-size: 14px; }
}
.ico {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

.link-btn {
  appearance: none; background: none; border: 0; padding: 4px 0;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--syahi);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}

/* ---------- Status ---------- */

.status-block {
  display: flex; gap: 12px; align-items: flex-start;
  margin-top: var(--gap);
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
}
.status-title { font-weight: 600; }
.status-body { color: var(--dhuan); font-size: 14px; margin-top: 2px; }
.status-ico {
  width: 36px; height: 36px; flex: none; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--syahi);
}
.status-ico svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.status-ico.ok { background: var(--tulsi); }
.status-ico.wait { background: var(--genda); }
.status-ico.wait svg { stroke: var(--syahi); }
.status-ico.off { background: var(--dhuan); }

.paid-note { text-align: center; }

/* Pay (opens the app) and I've paid, stacked full width. Whichever is the
   next step is .btn-primary; the other is quiet. */
.pay-actions { display: flex; flex-direction: column; gap: 10px; }
.pay-actions .btn { flex: none; width: 100%; }
.pay-prompt { color: var(--dhuan); font-size: 14px; text-align: center; padding: 0 4px; }
.pay-prompt.ask { color: var(--syahi); font-weight: 600; font-size: 15px; }

/* ---------- Person (/u) ---------- */

.groups { display: flex; flex-direction: column; gap: var(--gap); }
.group-card .pay-actions { margin-top: 14px; }
.items { list-style: none; margin: 10px 0 0; padding: 0; }
.items li {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 0; font-size: 15px;
  border-top: 1px solid var(--line);
}
.it-title { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.it-amt { flex: none; font-variant-numeric: tabular-nums; }
.items .chip { font-size: 12px; color: var(--dhuan); }
.recent-label { margin-top: var(--gap); }
.card > .status-block:first-child { margin-top: 0; }

/* ---------- Trust ---------- */

.trust {
  margin-top: auto;
  display: flex; gap: 10px; align-items: flex-start;
  color: var(--dhuan); font-size: 13px; line-height: 1.35;
  padding: 0 4px;
}
.trust .ico { margin-top: 1px; color: var(--tulsi); }

/* ---------- Picker ---------- */

.picker { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.picker button {
  width: 100%; min-height: 52px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 16px;
  font: inherit; font-size: 17px; color: var(--syahi); text-align: left;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line); border-radius: 14px; cursor: pointer;
  touch-action: manipulation;
}
.picker button:active { transform: scale(0.99); }
.chip {
  font-size: 13px; color: var(--syahi); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: rgba(28, 27, 31, 0.18); }
.chip.ok::before { background: var(--tulsi); }
.chip.wait::before { background: var(--genda); }

/* ---------- Message, loading, sheet, toast ---------- */

.view-message { justify-content: center; }
.message-card { display: grid; gap: 10px; justify-items: start; padding: 24px 20px; }
.message-card .btn { width: 100%; margin-top: 8px; }
.brand { text-align: center; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; color: var(--dhuan); }

.skel { background: rgba(28, 27, 31, 0.06); border-radius: 10px; }
.skel-title { height: 30px; width: 80%; }
.skel-title.short { width: 50%; }
.skel-line { height: 14px; width: 30%; }
.skel-amount { height: 52px; width: 45%; margin: 10px 0 18px; }
.skel-qr { height: 220px; border-radius: 18px; }

.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 10;
  background: rgba(28, 27, 31, 0.35);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px;
}
.sheet-panel {
  width: 100%; max-width: 420px;
  background: #fff; border-radius: 24px; padding: 18px;
  display: grid; gap: 10px;
  max-height: calc(100dvh - 32px); overflow: auto;
}
.sheet-img { width: 100%; max-width: 300px; height: auto; justify-self: center; border-radius: 12px; border: 1px solid var(--line); }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 40px);
  background: var(--syahi); color: #fff;
  padding: 12px 16px; border-radius: 14px; font-size: 14px;
  box-shadow: 0 10px 30px rgba(28, 27, 31, 0.25);
  z-index: 20;
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 24px; text-align: center; }

/* short screens (small phones, in-app browser chrome) */
@media (max-height: 680px) {
  .headline { font-size: 24px; }
  .amount { font-size: 44px; }
  .eyebrow { font-size: 14px; }
  .note { display: none; }
  .btn-primary { min-height: 52px; }
  .items li { padding: 4px 0; font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .picker button { transition: none; }
  .btn:active, .picker button:active { transform: none; }
}
