/* Referrals (REF-4F2K). The owner-reviewed mockups' layout and type; the
   floating glass tab bar and the sheets are Finance's. Colour comes only
   from the shell's theme (theme.js: getTheme, then __theme pushes), on the
   same CSS properties as Finance (apps/finance/styles.css). The two blocks
   below are Finance's own values, for a page opened outside the shell; no
   other rule names a colour (theme_test.js holds both). */
:root {
  color-scheme: light dark;
  --surface: #FFFBF8;
  --surface-low: #FFF3EC;
  --ink: #2A1710;
  --muted: #8A5A1E;
  --primary: #A8412A;
  --outline: #8C756B;
  --line: #E0CFC6;
  --danger: #8C3A26;
  --danger-container: #FBE0DA;
  --on-primary: #FFFBF8;
  --good: #23704F;
  --warn: #8F5A00;
  /* The shell's tokens carry no green or amber: the page follows the
     shell's brightness (data-brightness, set by theme.js) for these two,
     so a dark shell on a light system never gets the light greens. */
  --good-light: #23704F;
  --warn-light: #8F5A00;
  --good-dark: #4FB286;
  --warn-dark: #E0A63A;
  --surface-container-low: #FFF3EC;
  --primary-container: #F6DCCF;
  --secondary-container: #F2E3DA;
  --scrim: rgba(0, 0, 0, 0.62);
  --sheet-shadow: 0 -8px 40px -12px rgba(0, 0, 0, 0.35);
  --glow: 0 0 22px -4px color-mix(in srgb, var(--primary) 30%, transparent);
  /* The screens' names for the roles above. */
  --bg: var(--surface);
  --card: var(--surface-container-low);
  --hero: var(--primary-container);
  --neutral-pill: var(--secondary-container);
  --ink-2: color-mix(in srgb, var(--ink) 78%, var(--surface));
  --edge: var(--line);
  --accent: var(--primary);
  --accent-ink: var(--on-primary);
  --safe-top: var(--gisted-safe-top, env(safe-area-inset-top, 0px));
  --safe-bottom: var(--gisted-safe-bottom, env(safe-area-inset-bottom, 0px));
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

/* Outside the shell, a dark system: Finance's dark values. */
@media (prefers-color-scheme: dark) {
  :root {
    --surface: #17110F;
    --surface-low: #241B18;
    --ink: #F7EDE8;
    --muted: #F0C08A;
    --primary: #E8845F;
    --outline: #8E7F79;
    --line: #3A2E2A;
    --danger: #F3B5A2;
    --danger-container: #3A211C;
    --on-primary: #17110F;
    --good: #4FB286;
    --warn: #E0A63A;
    --surface-container-low: #241B18;
    --primary-container: #3A2620;
    --secondary-container: #2E2320;
    --glow: 0 0 26px -6px color-mix(in srgb, var(--primary) 38%, transparent);
  }
}

/* The shell's brightness wins over the system's for the two colours its
   tokens don't carry. */
:root[data-brightness="dark"] { --good: var(--good-dark); --warn: var(--warn-dark); }
:root[data-brightness="light"] { --good: var(--good-light); --warn: var(--warn-light); }

* { box-sizing: border-box; }
/* As Contacts: the hidden attribute wins over a display rule (.btn is
   inline-flex), so a hidden button never shows as an empty outline. */
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
button { font-family: inherit; }

.app {
  /* The capsule's reserve as the shell measured and injected it
     (--gisted-capsule-right); 5rem until it does. */
  padding: calc(var(--safe-top) + 60px) calc(20px + env(safe-area-inset-right, 0px)) calc(var(--safe-bottom) + 110px) calc(20px + env(safe-area-inset-left, 0px));
}
/* --view-gap: the page rhythm between blocks; reused wherever a card is
   followed by a button inside one block (.bank + .btn). */
.view { --view-gap: 20px; display: flex; flex-direction: column; gap: var(--view-gap); }
.view[hidden] { display: none; }
h1 { margin: 0; padding-right: calc(var(--gisted-capsule-right, 5rem)); font: 600 30px/1.2 var(--font); }
h2 { margin: 0; font: 600 22px/1.25 var(--font); }
.eyebrow { font: 600 11px/1.2 var(--font); letter-spacing: .8px; color: var(--muted); }
.intro, .note { margin: 0; font: 400 14px/1.45 var(--font); color: var(--muted); }
.big { font: 700 32px/1.1 var(--font); }
.title { font: 600 16px/1.3 var(--font); }
.sub { font: 400 14px/1.45 var(--font); color: var(--muted); }

.code-card { background: var(--hero); border-radius: 24px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.code { font: 700 32px/1.1 var(--font); letter-spacing: 3px; }
.link { font: 400 14px/1.45 var(--font); color: var(--ink-2); word-break: break-all; }
.pitch { margin: 0; font: 400 14px/1.45 var(--font); color: var(--ink-2); }
.pair { display: flex; gap: 10px; }

.btn { min-height: 44px; border-radius: 999px; font: 600 16px/1 var(--font); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 20px; text-decoration: none; cursor: pointer; }
.btn-primary { border: 0; background: var(--accent); color: var(--accent-ink); }
.btn-outline { border: 1px solid var(--outline); background: transparent; color: var(--ink); }
.btn-wide { min-height: 52px; width: 100%; }
.pair .btn { flex: 1; }
.btn[aria-busy="true"] { opacity: .6; }

.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--edge); }
.balance-head { display: flex; justify-content: space-between; align-items: flex-end; padding-bottom: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 4px; }
.see-all { font: 600 14px/44px var(--font); text-decoration: none; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }

.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font: 600 12px/1.3 var(--font); }
.chip-pending { background: var(--neutral-pill); color: var(--muted); }
.chip-available, .chip-earning, .chip-paid { background: color-mix(in srgb, var(--good) 16%, var(--surface)); color: var(--good); }
.chip-withdrawn, .chip-ended { background: color-mix(in srgb, var(--outline) 16%, var(--surface)); color: var(--ink-2); }
.chip-joined { background: var(--neutral-pill); color: var(--muted); }
.chip-review { background: color-mix(in srgb, var(--warn) 16%, var(--surface)); color: var(--warn); }
.chip-not_eligible, .chip-failed, .chip-returned { background: var(--danger-container); color: var(--danger); }

.segs { display: flex; gap: 6px; padding: 4px; border: 1px solid var(--edge); border-radius: 999px; background: var(--card); }
.seg { flex: 1; min-height: 44px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: 600 14px/1.2 var(--font); cursor: pointer; }
.seg[aria-pressed="true"] { background: var(--hero); color: var(--accent); }
.day { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 0; border: 0; border-top: 1px solid var(--edge); background: transparent;
  text-align: left; color: inherit; font: inherit; cursor: pointer; }
.day .grow { flex: 1; min-width: 0; }
.day .end { text-align: right; }
.day-lines { list-style: none; margin: 0 0 12px; padding: 10px 14px; border-radius: 16px; background: var(--card); display: flex; flex-direction: column; gap: 8px; }
.day-lines li { display: flex; justify-content: space-between; gap: 12px; font: 400 14px/1.45 var(--font); }
.day-lines .who { font-weight: 600; }
.day-lines .what { color: var(--muted); }
.day-lines .amt { font-weight: 600; }
.day-lines .amt.refund { color: var(--danger); }

.filters { display: flex; gap: 8px; overflow-x: auto; margin: 0 -20px; padding: 0 20px 2px; }
.filter { flex: none; min-height: 40px; padding: 0 14px; border: 1px solid var(--edge); border-radius: 999px; background: var(--card); color: var(--muted);
  font: 600 14px/1 var(--font); cursor: pointer; white-space: nowrap; }
.filter[aria-pressed="true"] { background: var(--hero); color: var(--accent); border-color: var(--hero); }
.person { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--edge); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--neutral-pill); display: flex; align-items: center; justify-content: center;
  font: 600 16px/1 var(--font); flex: none; }
.person .grow { flex: 1; min-width: 0; }
.empty { margin: 0; padding: 24px 0; text-align: center; font: 400 14px/1.45 var(--font); color: var(--muted); }

.payout-card { background: var(--card); border: 1px solid var(--edge); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.line { display: flex; justify-content: space-between; font: 400 14px/1.45 var(--font); color: var(--ink-2); }
.line.total { font-weight: 600; color: var(--ink); }
.meter { height: 8px; border-radius: 999px; background: var(--neutral-pill); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bank { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--edge); border-radius: 16px; }
.bank.none { border: 1px dashed var(--outline); padding: 14px; }
.bank .grow { flex: 1; }
.bank + .btn { margin-top: var(--view-gap); }
.bank-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--hero); color: var(--accent); display: flex;
  align-items: center; justify-content: center; flex: none; }
.link-btn { min-height: 44px; padding: 0 4px; border: 0; background: transparent; color: var(--accent); font: 600 14px/1 var(--font); cursor: pointer; }
.day .chev { width: 18px; height: 18px; flex: none; color: var(--muted); transition: transform 160ms ease; }
.day[aria-expanded="true"] .chev { transform: rotate(90deg); }
.status-msg { margin: 0; font: 400 14px/1.45 var(--font); color: var(--ink-2); }
.status-msg.error { color: var(--danger); }

/* kit.js list skeletons (the loading rule: a list empty while it loads
   shows skeleton rows, never "Loading…"). */
.skeleton-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--edge); }
.skeleton-disc { width: 40px; height: 40px; border-radius: 50%; background: var(--neutral-pill); flex: none; }
.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.skeleton-line { height: 12px; border-radius: 6px; background: var(--neutral-pill); }
.skeleton-line.is-short { width: 55%; }
.skeleton-block { height: 180px; border-radius: 24px; background: var(--hero); }
@media (prefers-reduced-motion: no-preference) {
  .skeleton-disc, .skeleton-line, .skeleton-block { animation: pulse 1.4s ease-in-out infinite; }
}
@keyframes pulse { 50% { opacity: .55; } }

/* The floating glass tab bar (Finance's), four tabs. */
.tabbar {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--safe-bottom) + 0.7rem); z-index: 40;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 6px; border-radius: 28px;
  border: 1px solid var(--edge); background: color-mix(in srgb, var(--surface) 62%, transparent);
  backdrop-filter: saturate(1.7) blur(26px); -webkit-backdrop-filter: saturate(1.7) blur(26px);
  box-shadow: var(--glow), inset 0 1px 0 color-mix(in srgb, var(--surface) 70%, transparent);
}
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .tabbar { background: color-mix(in srgb, var(--surface) 93%, transparent); }
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 44px; padding: 6px 3px 5px;
  border-radius: 22px; font: 600 11px/1.2 var(--font); color: var(--muted); text-decoration: none; }
.tabbar a[aria-current="page"] { background: var(--hero); color: var(--accent); }

/* Bottom sheets (Finance's .sheet, apps/finance/styles.css): the withdraw
   confirm sheet. Up from the bottom with a scrim; kit.js closeSheet slides
   it away. */
.sheet {
  width: 100%; max-width: 100%; max-height: 88dvh; margin: auto 0 0; padding: 0; border: 0;
  border-top: 1px solid var(--edge); border-radius: 20px 20px 0 0; background: var(--card); color: var(--ink);
  box-shadow: var(--sheet-shadow);
}
.sheet::backdrop { background: var(--scrim); }
.sheet[open] { animation: sheet-in 320ms cubic-bezier(.2, .9, .25, 1) both; }
.sheet[open]::backdrop { animation: scrim-in 320ms ease-out both; }
.sheet.is-closing { animation: sheet-out 220ms ease-in both; pointer-events: none; }
.sheet.is-closing::backdrop { animation: scrim-out 220ms ease-in both; }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes scrim-in { from { opacity: 0; } }
@keyframes scrim-out { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .sheet[open], .sheet[open]::backdrop { animation: scrim-in 150ms ease-out both; }
}
.sheet.is-closing.is-fade, .sheet.is-closing.is-fade::backdrop { animation: scrim-out 120ms ease-out both; }
.sheet.is-closing:not(:modal) { position: fixed; left: 0; right: 0; top: auto; bottom: 0; margin: 0; z-index: 1001; pointer-events: none; }
.sheet-scrim-out { position: fixed; inset: 0; z-index: 1000; background: var(--scrim); pointer-events: none; animation: scrim-out 220ms ease-in both; }
.sheet-scrim-out.is-fade { animation-duration: 120ms; }
.sheet-form { overscroll-behavior: contain; padding: 24px 1rem 16px; overflow-x: hidden; overflow-y: auto; max-height: 88dvh; }
.sheet-form h2 { margin: 0 0 0.75rem; padding-right: 44px; font: 600 20px/1.3 var(--font); }
.sheet-handle, .sheet-form > h2 { touch-action: none; }
.sheet-handle { position: absolute; top: 8px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px;
  background: color-mix(in srgb, var(--ink) 35%, transparent); }
.sheet-handle::after { content: ''; position: absolute; inset: -16px -48px; }
.sheet-x { -webkit-tap-highlight-color: transparent; position: absolute; top: 12px; right: 8px; z-index: 3; display: inline-flex;
  align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--ink); }
.sheet-lines { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 8px; }
.sheet-actions { position: sticky; bottom: 0; z-index: 3; display: grid; gap: 0.5rem; margin-top: 0.25rem;
  padding: 12px 0 calc(8px + var(--safe-bottom)); background: linear-gradient(to bottom, transparent, var(--card) 30%); }
