/* ============================================================ Contribly ===
   Dark, calm, a little luminous. One accent gradient does the heavy lifting.
   ========================================================================= */

:root {
  --ink-900: #070A0E;
  --ink-850: #0A0E14;
  --ink-800: #0E141C;
  --ink-700: #141C26;
  --line:    rgba(255, 255, 255, 0.09);
  --line-2:  rgba(255, 255, 255, 0.16);

  --text:    #E9EFF6;
  --muted:   #93A3B5;
  --faint:   #64748B;

  --mint:    #7CF5C4;
  --aqua:    #4ADEDE;
  --iris:    #8B8CFB;
  --amber:   #FFC46B;
  --rose:    #FF8FA3;

  --grad: linear-gradient(115deg, var(--mint), var(--aqua) 52%, var(--iris));

  --r-sm: 10px;
  --r:    16px;
  --r-lg: 22px;
  --r-xl: 28px;

  --shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.9);
  --pad: clamp(16px, 4vw, 28px);
  --maxw: 1080px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --display: 'Outfit', var(--font);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

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

body {
  background: var(--ink-900);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }

/* ------------------------------------------------------------- aurora --- */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora span {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.30;
  animation: drift 24s ease-in-out infinite alternate;
}
.aurora span:nth-child(1) { width: 46vmax; height: 46vmax; top: -18vmax; left: -12vmax; background: #127d68; }
.aurora span:nth-child(2) { width: 38vmax; height: 38vmax; top: 24vmax; right: -14vmax; background: #3b3f9e; animation-delay: -8s; }
.aurora span:nth-child(3) { width: 30vmax; height: 30vmax; bottom: -14vmax; left: 30vw; background: #0e6b8a; animation-delay: -15s; }
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(4vw, 5vh, 0) scale(1.14); }
}

/* ------------------------------------------------------------- topbar --- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px var(--pad);
  background: color-mix(in srgb, var(--ink-900) 78%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: -0.03em; }
.brand img { transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
.brand:hover img { transform: rotate(120deg); }

.app { flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: var(--pad) var(--pad) 72px; }

.footer { padding: 26px var(--pad) 34px; text-align: center; color: var(--faint); font-size: 13px; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------ buttons --- */
.btn {
  --bg: rgba(255,255,255,0.05);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--bg); font-weight: 600; font-size: 15px; cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.2s ease, background 0.2s ease, opacity 0.2s ease;
  white-space: nowrap; text-align: center;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); background: rgba(255,255,255,0.09); }
.btn:active:not(:disabled) { transform: translateY(0) scale(0.985); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--aqua); outline-offset: 2px; }
.btn-sm { padding: 9px 15px; font-size: 14px; }
.btn-lg { padding: 15px 26px; font-size: 16px; }
.btn-block { width: 100%; }

.btn-primary { background: var(--grad); color: #04140F; border-color: transparent; box-shadow: 0 10px 30px -12px rgba(74, 222, 222, 0.65); }
.btn-primary:hover:not(:disabled) { background: var(--grad); box-shadow: 0 16px 38px -12px rgba(74, 222, 222, 0.8); }
.btn-ghost { background: transparent; }
.btn-paid { border-color: rgba(124,245,196,0.35); background: rgba(124,245,196,0.10); color: var(--mint); }

/* -------------------------------------------------------------- cards --- */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.022));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

/* --------------------------------------------------------------- hero --- */
.hero { padding: clamp(18px, 5vw, 46px) 0 clamp(20px, 4vw, 34px); }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--mint); background: rgba(124,245,196,0.09);
  border: 1px solid rgba(124,245,196,0.20); padding: 6px 13px; border-radius: 999px;
}
.hero h1 { font-size: clamp(34px, 7.2vw, 62px); margin: 18px 0 14px; font-weight: 700; }
.hero h1 .grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); font-size: clamp(15px, 2.4vw, 18px); max-width: 54ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }

/* --------------------------------------------------------- pool cards --- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin: 34px 0 16px; flex-wrap: wrap; }
.section-head h2 { font-size: clamp(19px, 3vw, 23px); }
.section-head span { color: var(--faint); font-size: 13.5px; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(288px, 1fr)); }

.pool-card {
  position: relative; display: flex; flex-direction: column; gap: 14px;
  padding: 20px; border-radius: var(--r-lg); overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.pool-card::before {
  content: ''; position: absolute; inset: 0 0 auto; height: 2px; background: var(--grad); opacity: 0.75;
}
.pool-card:hover { transform: translateY(-3px); border-color: var(--line-2); }
.pool-card h3 { font-size: 18.5px; }
.pool-card .desc { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-clamp: 2; overflow: hidden; }
.pool-meta { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 4px; }
.per-head { font-family: var(--display); font-size: 26px; font-weight: 700; letter-spacing: -0.03em; }
.per-head small { display: block; font-family: var(--font); font-size: 11.5px; font-weight: 500; color: var(--faint); letter-spacing: 0.05em; text-transform: uppercase; }
.card-foot { display: flex; align-items: center; gap: 10px; font-size: 12.8px; color: var(--faint); flex-wrap: wrap; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------- pill --- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px; font-size: 12.4px; font-weight: 600;
  border: 1px solid var(--line-2); background: rgba(255,255,255,0.04); color: var(--muted);
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.open   { color: var(--mint);  background: rgba(124,245,196,0.10); border-color: rgba(124,245,196,0.26); }
.pill.open .dot { box-shadow: 0 0 0 0 rgba(124,245,196,0.6); animation: pulse 2.2s infinite; }
.pill.collect{ color: var(--amber); background: rgba(255,196,107,0.10); border-color: rgba(255,196,107,0.26); }
.pill.done   { color: var(--aqua);  background: rgba(74,222,222,0.10);  border-color: rgba(74,222,222,0.26); }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(124,245,196,0); } 100% { box-shadow: 0 0 0 0 rgba(124,245,196,0); } }

/* ------------------------------------------------------------- detail --- */
.detail { display: grid; gap: 18px; }
@media (min-width: 900px) { .detail { grid-template-columns: 1.15fr 0.85fr; align-items: start; } .detail .span-2 { grid-column: 1 / -1; } }

.back { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 14px; font-weight: 500; margin-bottom: 14px; }
.back:hover { color: var(--text); }

.pool-head { padding: clamp(20px, 4vw, 30px); border-radius: var(--r-xl); display: grid; gap: 16px; }
.pool-head h1 { font-size: clamp(26px, 5vw, 40px); font-weight: 700; }
.pool-head .desc { color: var(--muted); white-space: pre-wrap; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { padding: 14px; border-radius: var(--r); background: rgba(255,255,255,0.035); border: 1px solid var(--line); }
.stat .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--faint); font-weight: 600; }
.stat .value { font-family: var(--display); font-size: clamp(18px, 3.4vw, 24px); font-weight: 700; letter-spacing: -0.02em; margin-top: 3px; }
.stat.accent .value { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.progress { height: 8px; border-radius: 999px; background: rgba(255,255,255,0.07); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 999px; background: var(--grad); width: 0; transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1); }
.progress-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 8px; }

.panel { padding: clamp(18px, 3.6vw, 24px); border-radius: var(--r-xl); display: grid; gap: 16px; }
.panel h2 { font-size: 17px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel h2 .count { font-family: var(--font); font-size: 12.5px; font-weight: 600; color: var(--faint); }

.notes { font-size: 14.4px; color: var(--muted); white-space: pre-wrap; padding: 14px 16px; border-radius: var(--r); background: rgba(255,196,107,0.06); border: 1px solid rgba(255,196,107,0.18); }
.notes b { color: var(--amber); display: block; font-size: 12px; letter-spacing: 0.07em; text-transform: uppercase; margin-bottom: 5px; }

.window-note { display: flex; gap: 10px; align-items: flex-start; font-size: 13.6px; color: var(--muted); padding: 12px 14px; border-radius: var(--r); background: rgba(255,255,255,0.035); border: 1px solid var(--line); }
.window-note svg { flex: none; margin-top: 2px; color: var(--aqua); }

/* ------------------------------------------------------------ members --- */
.members { display: grid; gap: 8px; }
.member {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  border-radius: var(--r); border: 1px solid var(--line); background: rgba(255,255,255,0.028);
  animation: rise 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.member.is-paid { border-color: rgba(124,245,196,0.24); background: rgba(124,245,196,0.055); }
.avatar {
  width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; font-size: 15px; color: #04140F; background: var(--grad);
}
.member .who { min-width: 0; flex: 1; }
.member .who .name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .who .sub { font-size: 12.4px; color: var(--faint); }
.member .amt { font-family: var(--display); font-weight: 700; font-size: 16px; }
.tag-you { font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--iris); background: rgba(139,140,251,0.14); border-radius: 5px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px; }

.empty { text-align: center; padding: 34px 18px; color: var(--faint); border: 1px dashed var(--line-2); border-radius: var(--r-lg); }
.empty strong { display: block; color: var(--text); font-family: var(--display); font-size: 17px; margin-bottom: 5px; }

/* --------------------------------------------------------------- form --- */
.form { display: grid; gap: 18px; padding: clamp(20px, 4vw, 32px); border-radius: var(--r-xl); }
.field { display: grid; gap: 7px; }
.field > label { font-size: 13.4px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 12.4px; color: var(--faint); }
.field input[type="text"], .field input[type="number"], .field input[type="datetime-local"], .field textarea {
  width: 100%; padding: 13px 15px; border-radius: var(--r-sm);
  background: rgba(255,255,255,0.045); border: 1px solid var(--line-2); color: var(--text);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.field input::placeholder, .field textarea::placeholder { color: #556270; }
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--aqua); background: rgba(255,255,255,0.07);
  box-shadow: 0 0 0 3px rgba(74,222,222,0.14);
}
.field textarea { resize: vertical; min-height: 92px; line-height: 1.5; }
.field input[type="datetime-local"] { color-scheme: dark; }
.row-2 { display: grid; gap: 18px; }
@media (min-width: 640px) { .row-2 { grid-template-columns: 1fr 1fr; } }

.money { position: relative; }
.money span { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; pointer-events: none; }
.money input { padding-left: 32px !important; }

.switch { display: flex; align-items: flex-start; gap: 13px; padding: 14px 15px; border-radius: var(--r); border: 1px solid var(--line); background: rgba(255,255,255,0.028); cursor: pointer; transition: border-color 0.2s ease, background 0.2s ease; }
.switch:hover { border-color: var(--line-2); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .box { width: 22px; height: 22px; flex: none; border-radius: 7px; border: 1.6px solid var(--line-2); display: grid; place-items: center; margin-top: 1px; transition: all 0.2s ease; }
.switch .box svg { opacity: 0; transform: scale(0.5); transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1); color: #04140F; }
.switch input:checked ~ .box { background: var(--grad); border-color: transparent; }
.switch input:checked ~ .box svg { opacity: 1; transform: scale(1); }
.switch input:focus-visible ~ .box { outline: 2px solid var(--aqua); outline-offset: 2px; }
.switch .txt strong { display: block; font-size: 14.4px; font-weight: 600; }
.switch .txt small { color: var(--faint); font-size: 12.6px; line-height: 1.45; display: block; }

.form-error { padding: 12px 15px; border-radius: var(--r-sm); background: rgba(255,143,163,0.10); border: 1px solid rgba(255,143,163,0.3); color: var(--rose); font-size: 13.8px; }
.divider { height: 1px; background: var(--line); }
.form-legend { font-family: var(--display); font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }

/* ---------------------------------------------------- share / copy row --- */
.copy-row { display: flex; align-items: center; gap: 8px; padding: 11px 12px; border-radius: var(--r); background: rgba(255,255,255,0.045); border: 1px solid var(--line); }
.copy-row code { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.icon-btn { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line-2); background: rgba(255,255,255,0.05); cursor: pointer; transition: all 0.18s ease; }
.icon-btn:hover { background: rgba(255,255,255,0.12); }

/* -------------------------------------------------------------- modal --- */
.overlay {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px;
  background: rgba(4, 7, 11, 0.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fade 0.22s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(420px, 100%); max-height: 90dvh; overflow-y: auto; padding: 24px; border-radius: var(--r-xl);
  background: var(--ink-800); border: 1px solid var(--line-2); box-shadow: 0 40px 90px -30px #000;
  animation: pop 0.34s cubic-bezier(0.22, 1, 0.36, 1) both; display: grid; gap: 16px;
}
@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(0.96); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-head h3 { font-size: 19px; }
.modal-head p { color: var(--faint); font-size: 13.4px; margin-top: 3px; }
.qr-frame { background: #fff; padding: 12px; border-radius: var(--r); width: min(232px, 62vw); margin: 0 auto; }
.qr-frame svg { width: 100%; height: auto; }
.qr-amt { text-align: center; }
.qr-amt .big { font-family: var(--display); font-size: 34px; font-weight: 700; letter-spacing: -0.03em; }
.qr-amt .lbl { font-size: 12.6px; color: var(--faint); }

/* ------------------------------------------------------------ success --- */
.success-overlay {
  position: fixed; inset: 0; z-index: 120; display: grid; place-items: center;
  background: radial-gradient(120% 100% at 50% 40%, #0d2a26, var(--ink-900) 70%);
  animation: fade 0.25s ease both; text-align: center; padding: 24px;
}
.success-overlay .ring { width: 108px; height: 108px; margin: 0 auto 22px; }
.success-overlay circle.track { fill: none; stroke: rgba(124,245,196,0.18); stroke-width: 5; }
.success-overlay circle.arc { fill: none; stroke: var(--mint); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 302; stroke-dashoffset: 302; animation: draw 0.7s cubic-bezier(0.65,0,0.35,1) 0.05s forwards; }
.success-overlay path.tick { fill: none; stroke: var(--mint); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 48; stroke-dashoffset: 48; animation: draw2 0.4s cubic-bezier(0.65,0,0.35,1) 0.6s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes draw2 { to { stroke-dashoffset: 0; } }
.success-overlay h2 { font-size: clamp(24px, 5vw, 32px); animation: rise 0.5s 0.7s both; }
.success-overlay p { color: var(--muted); margin-top: 8px; animation: rise 0.5s 0.82s both; }
.spark { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--mint); opacity: 0; }

/* ------------------------------------------------------------- toasts --- */
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; width: min(400px, calc(100vw - 32px)); }
.toast {
  padding: 12px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; text-align: center;
  background: var(--ink-700); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  animation: toastIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.toast.err { border-color: rgba(255,143,163,0.4); color: var(--rose); }
.toast.out { animation: toastOut 0.25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(0.96); } }

/* ---------------------------------------------------------- skeletons --- */
.skel { border-radius: var(--r-lg); height: 172px; background: linear-gradient(100deg, rgba(255,255,255,0.04) 30%, rgba(255,255,255,0.09) 50%, rgba(255,255,255,0.04) 70%); background-size: 220% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -120% 0; } }

.spinner { width: 17px; height: 17px; border-radius: 50%; border: 2px solid rgba(0,0,0,0.25); border-top-color: currentColor; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.only-xs { display: none; }
@media (max-width: 420px) {
  .hide-xs { display: none; }
  .only-xs { display: inline; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:first-child { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* -------------------------------------------- detail column ordering --- */
.detail .span-2 { order: 1; }
.detail .side { order: 2; }
.detail .members-panel { order: 3; }
@media (min-width: 900px) {
  .detail .side { order: 3; }
  .detail .members-panel { order: 2; }
}
.member .who .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-head { justify-content: flex-start; }
