/* WaterSMS — shared design system
   Light-first, purple droplet on white. Dark theme is a full re-map of the
   same tokens, stamped on <html> by /js/theme.js before first paint.
   Change the default in theme.js (DEFAULT_THEME). */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@600;700;800&family=Source+Sans+3:ital,wght@0,400;0,600;1,400&display=swap');

/* ---------------------------------------------------------------- tokens */
:root,
:root[data-theme='light'] {
  --brand: #5949dd;
  --brand-deep: #4535c4;
  --brand-ink: #2b2188;
  --brand-soft: #efedff;
  --on-brand: #ffffff;

  --ink: #1c1850;          /* headings */
  --body: #4a4774;         /* body copy */
  --muted: #77749e;        /* secondary */
  --line: #e3e1f3;
  --pool: #f4f3ff;         /* tinted surface */
  --pool-2: #e9e7fe;
  --ring: #c9c4fb;
  --paper: #ffffff;        /* page + card background */
  --paper-2: #fbfaff;      /* inputs */

  --ok: #1e9e6a;
  --ok-soft: #e7f7f0;
  --warn: #b06d09;
  --warn-soft: #fdf3e3;
  --err: #cf2d38;
  --err-soft: #fdecee;

  --shadow-sm: 0 1px 2px rgba(28, 24, 80, .05);
  --shadow-md: 0 18px 40px -24px rgba(28, 24, 80, .28);
  --shadow-lg: 0 40px 70px -30px rgba(89, 73, 221, .45), 0 6px 20px -10px rgba(28, 24, 80, .15);

  --font-display: 'Montserrat', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'Source Sans 3', 'Segoe UI', ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --container: 1140px;
  --gutter: 24px;

  color-scheme: light;
}

:root[data-theme='dark'] {
  --brand: #8878ff;
  --brand-deep: #9c8fff;
  --brand-ink: #0d0b18;
  --brand-soft: #211d3d;
  --on-brand: #ffffff;

  --ink: #f1efff;
  --body: #bfbbdd;
  --muted: #8b87ad;
  --line: #2b2745;
  --pool: #191630;
  --pool-2: #221e3c;
  --ring: #3d3766;
  --paper: #100e1c;
  --paper-2: #17142a;

  --ok: #43cf92;
  --ok-soft: rgba(67, 207, 146, .12);
  --warn: #e8a951;
  --warn-soft: rgba(232, 169, 81, .12);
  --err: #ff7b84;
  --err-soft: rgba(255, 123, 132, .12);

  /* On a near-black page a big black shadow reads as a dark blob, so dark
     mode lifts surfaces with a soft brand glow instead. */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 18px 40px -26px rgba(136, 120, 255, .30);
  --shadow-lg: 0 30px 60px -32px rgba(136, 120, 255, .35), 0 4px 14px -8px rgba(0, 0, 0, .45);

  color-scheme: dark;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--body);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); color: var(--ink); margin: 0; letter-spacing: -.015em; }
h1 { font-weight: 800; font-size: clamp(2.5rem, 4.6vw, 3.5rem); line-height: 1.06; letter-spacing: -.025em; }
h2 { font-weight: 700; font-size: clamp(1.8rem, 3vw, 2.45rem); line-height: 1.15; }
h3 { font-weight: 700; font-size: 1.2rem; line-height: 1.3; }
h4 { font-weight: 700; font-size: 1rem; }
p { margin: 0; }
a { color: var(--brand); }
ul, ol { margin: 0; padding: 0; list-style: none; }
strong { font-weight: 600; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; border-radius: 4px; }

.container { width: min(var(--container), 100% - 2 * var(--gutter)); margin-inline: auto; }
.section { padding: 96px 0; }
.section--tint { background: var(--pool); }
.section-head { max-width: 42rem; margin-bottom: 48px; }
.section-head p { margin-top: 14px; font-size: 1.15rem; }

.text-link { font-weight: 600; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1.5px; }
.text-link:hover { color: var(--brand-deep); }

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.dim { color: var(--muted); }
.small { font-size: .92rem; }
.center { text-align: center; }
.strong-ink { color: var(--ink); }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap-row { flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.grow { flex: 1; }
.hide { display: none !important; }
.stack > * + * { margin-top: 12px; }
.sep { height: 1px; background: var(--line); margin: 20px 0; }

/* ---------------------------------------------------------------- buttons */
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 22px; border-radius: var(--r-sm);
  font: 600 1.05rem/1 var(--font-body); text-decoration: none;
  border: 1.5px solid transparent; cursor: pointer; white-space: nowrap;
  background: var(--brand); color: var(--on-brand);
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, opacity .15s ease;
}
.btn:hover, button:hover { background: var(--brand-deep); text-decoration: none; }
button:disabled, .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-deep); }
.btn-outline, button.ghost, .btn.ghost {
  border-color: var(--ring); color: var(--brand); background: transparent;
}
.btn-outline:hover, button.ghost:hover, .btn.ghost:hover { background: var(--pool); }
.btn-ghost { color: var(--ink); background: transparent; padding-inline: 14px; border-color: transparent; }
.btn-ghost:hover { background: var(--pool); color: var(--ink); }
.btn-light { background: var(--paper); color: var(--brand); }
.btn-light:hover { background: var(--pool-2); }
.btn-ghost-light { color: #fff; border-color: rgba(255,255,255,.45); background: transparent; }
.btn-ghost-light:hover { border-color: #fff; background: rgba(255,255,255,.08); }
.btn-lg { padding: 16px 28px; font-size: 1.1rem; }
.btn.sm, button.sm { padding: 8px 14px; font-size: .95rem; border-radius: 8px; }
button.danger { background: transparent; border-color: var(--err); color: var(--err); }
button.danger:hover { background: var(--err-soft); }
button.full, .btn.full { width: 100%; }

/* ---------------------------------------------------------------- header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; gap: 32px; height: 72px; }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--brand); }
.brand svg { width: 40px; height: 32px; }
.brand:hover { text-decoration: none; }
.wordmark { font: 800 1.45rem/1 var(--font-display); letter-spacing: -.03em; color: var(--brand); }
.nav-menu { display: flex; align-items: center; flex: 1; gap: 32px; }
.nav-links { display: flex; gap: 26px; }
.nav-links a { color: var(--body); text-decoration: none; font-weight: 600; font-size: 1rem; white-space: nowrap; }
.nav-links a:hover { color: var(--brand); }
.nav-links a.active { color: var(--brand); }
.nav-actions { display: flex; gap: 10px; margin-left: auto; align-items: center; }
.nav-toggle {
  display: none; margin-left: auto; background: none; border: 1.5px solid var(--line);
  border-radius: var(--r-sm); width: 44px; height: 44px; cursor: pointer; color: var(--ink); padding: 0;
}
.nav-toggle:hover { background: var(--pool); }

.balance-pill {
  font-family: var(--font-mono); background: var(--pool); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 999px; font-size: .95rem; color: var(--ink); white-space: nowrap;
}
.balance-pill b { color: var(--ok); font-weight: 600; }

/* theme toggle */
.theme-toggle { padding: 10px; line-height: 0; border-color: var(--line); color: var(--ink); background: transparent; }
.theme-toggle:hover { background: var(--pool); }
.theme-toggle svg { display: block; }
:root[data-theme='dark'] .theme-toggle .ico-moon,
:root:not([data-theme='dark']) .theme-toggle .ico-sun { display: none; }
.theme-toggle.floating {
  position: fixed; right: 18px; bottom: 18px; z-index: 60;
  background: var(--paper); border: 1.5px solid var(--line); box-shadow: var(--shadow-md);
}

/* ---------------------------------------------------------------- surfaces */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 26px; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 18px; }
.card h2, .card h3 { margin-bottom: 8px; }
.card--tint { background: var(--pool); }

.grid { display: grid; gap: 20px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat { background: var(--pool); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px 20px; }
.stat .k { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.stat .v { font-family: var(--font-display); font-size: 1.75rem; font-weight: 700; color: var(--ink); margin-top: 4px; letter-spacing: -.02em; }

/* ---------------------------------------------------------------- forms */
label { display: block; font-size: .95rem; font-weight: 600; color: var(--ink); margin-bottom: 7px; }
input, select, textarea {
  width: 100%; background: var(--paper-2); border: 1.5px solid var(--line);
  color: var(--body); border-radius: var(--r-sm); padding: 12px 14px;
  font-size: 1.02rem; font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input::placeholder { color: var(--muted); opacity: .8; }
input[type='checkbox'] { width: auto; accent-color: var(--brand); }
.field + .field { margin-top: 16px; }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .82rem; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: var(--pool); white-space: nowrap;
}
.badge.ok { color: var(--ok); border-color: transparent; background: var(--ok-soft); }
.badge.warn { color: var(--warn); border-color: transparent; background: var(--warn-soft); }
.badge.err { color: var(--err); border-color: transparent; background: var(--err-soft); }
.badge.brand { color: var(--brand); border-color: transparent; background: var(--brand-soft); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--err); }

/* ---------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; font-size: 1rem; }
th, td { text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font: 700 .85rem/1.3 var(--font-display); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
td { color: var(--body); }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tbody tr:hover { background: var(--pool); }
.table-scroll { overflow-x: auto; margin: 0 -26px; padding: 0 26px; }
td.num, .num-cell { font-family: var(--font-mono); color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- alerts */
.alert { border-radius: var(--r-sm); padding: 13px 16px; font-size: 1rem; border: 1px solid var(--line); background: var(--pool); margin-bottom: 16px; }
.alert.err { border-color: transparent; background: var(--err-soft); color: var(--err); }
.alert.ok { border-color: transparent; background: var(--ok-soft); color: var(--ok); }
.alert.warn { border-color: transparent; background: var(--warn-soft); color: var(--warn); }

/* ---------------------------------------------------------------- bits */
.code-big {
  font: 700 2.2rem/1 var(--font-display); letter-spacing: .12em;
  color: var(--ink); background: var(--pool); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 20px 18px; text-align: center;
  user-select: all; font-variant-numeric: tabular-nums;
}
.copy { cursor: pointer; }

.pill-tabs { display: inline-flex; background: var(--pool); border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 4px; }
.pill-tabs button { background: transparent; color: var(--muted); border-radius: 999px; padding: 8px 18px; font-size: .98rem; border-color: transparent; }
.pill-tabs button:hover { background: transparent; color: var(--ink); }
.pill-tabs button.active { background: var(--brand); color: var(--on-brand); }

.toast-host { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--brand);
  border-radius: var(--r-sm); padding: 13px 17px; box-shadow: var(--shadow-md);
  font-size: 1rem; color: var(--ink); max-width: 350px; animation: slidein .18s ease;
}
.toast.err { border-left-color: var(--err); }
.toast.ok { border-left-color: var(--ok); }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--ring); border-top-color: var(--brand);
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* auth pages */
.auth-wrap { max-width: 440px; margin: 72px auto; padding: 0 var(--gutter); }
.auth-wrap .brand { justify-content: center; display: flex; margin-bottom: 30px; }
.auth-foot { text-align: center; margin-top: 20px; font-size: 1rem; color: var(--muted); }
.code-input { font-family: var(--font-mono); font-size: 1.6rem; letter-spacing: .5em; text-align: center; text-indent: .5em; }

/* footer */
.footer { padding: 64px 0 36px; border-top: 1px solid var(--line); }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 40px; }
.footer-about p { margin-top: 16px; max-width: 22rem; font-size: 1rem; }
.footer h3 { font-size: .98rem; margin-bottom: 14px; }
.footer-links { display: flex; flex-direction: column; gap: 9px; }
.footer-links a { color: var(--body); text-decoration: none; font-size: 1rem; }
.footer-links a:hover { color: var(--brand); }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px; margin-top: 52px; padding-top: 24px; border-top: 1px solid var(--line); font-size: .95rem; color: var(--muted); }
.footer-bottom ul { display: flex; gap: 22px; }
.footer-bottom a { color: var(--muted); text-decoration: none; }
.footer-bottom a:hover { color: var(--brand); }

/* app page shell */
.page { padding: 40px 0 80px; }
.page-head { margin-bottom: 28px; }
.page-head h1 { font-size: clamp(1.9rem, 3.2vw, 2.4rem); }
.page-head p { margin-top: 8px; }

@media (max-width: 980px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 880px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .nav-menu {
    display: none; position: absolute; left: 0; right: 0; top: 72px; flex-direction: column;
    align-items: stretch; gap: 0; background: var(--paper); border-bottom: 1px solid var(--line);
    padding: 12px var(--gutter) 20px;
  }
  .site-header.is-open .nav-menu { display: flex; }
  .nav-links { flex-direction: column; gap: 0; }
  .nav-links a { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .nav-actions { margin: 16px 0 0; flex-wrap: wrap; }
}
@media (max-width: 700px) {
  .section { padding: 64px 0; }
  .card { padding: 20px; }
  .table-scroll { margin: 0 -20px; padding: 0 20px; }
  .footer-grid { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; }
  .code-big { font-size: 1.7rem; letter-spacing: .08em; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .toast, .msg.is-new { animation: none; }
  .btn, button { transition: none; }
}
