/* WaterSMS — shared theme
   Brand carried over from WaterProxy / WaterVPN: purple droplet.

   Two themes, one set of tokens. `data-theme` is stamped on <html> by
   /js/theme.js before first paint, so there is never a flash of the wrong one.
   To change the default, edit DEFAULT_THEME in /js/theme.js. */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@500;600;700;800&family=Inter:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root,
:root[data-theme='dark'] {
  --brand: #6337ea;
  --brand-2: #7c5cff;
  --brand-fg: #cfc4ff;
  --brand-soft: rgba(124, 92, 255, 0.12);
  --brand-line: rgba(124, 92, 255, 0.45);
  --brand-dim: rgba(99, 55, 234, 0.16);
  --grad-a: #7c5cff;
  --grad-b: #b9a4ff;

  --bg: #0a0c12;
  --bg-2: #0e1118;
  --surface: #141824;
  --surface-2: #1a1f2e;
  --card-bg: linear-gradient(180deg, #141824 0%, #0e1118 140%);
  --line: #242a3a;
  --line-2: #2f3648;
  --hover: rgba(255, 255, 255, 0.02);

  --strong: #ffffff;
  --text: #e9ebf2;
  --muted: #8b93a8;
  --dim: #666e83;
  --placeholder: #565d70;

  --ok: #2fbf71;
  --ok-fg: #7ce0aa;
  --ok-soft: rgba(47, 191, 113, 0.10);
  --ok-line: rgba(47, 191, 113, 0.40);
  --warn: #f0a63a;
  --warn-fg: #ffcb7d;
  --warn-soft: rgba(240, 166, 58, 0.10);
  --warn-line: rgba(240, 166, 58, 0.40);
  --err: #f2545b;
  --err-fg: #ff9a9e;
  --err-soft: rgba(242, 84, 91, 0.10);
  --err-line: rgba(242, 84, 91, 0.40);

  --glow-1: rgba(99, 55, 234, 0.18);
  --glow-2: rgba(124, 92, 255, 0.10);
  --topbar: rgba(10, 12, 18, 0.82);
  --backdrop: rgba(0, 0, 0, 0.6);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);

  --radius: 14px;
  --radius-sm: 10px;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --display: 'Outfit', var(--sans);
  --mono: 'DM Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

:root[data-theme='light'] {
  --brand: #6337ea;
  --brand-2: #5729d1;
  --brand-fg: #4a21b8;
  --brand-soft: rgba(99, 55, 234, 0.08);
  --brand-line: rgba(99, 55, 234, 0.28);
  --brand-dim: rgba(99, 55, 234, 0.09);
  --grad-a: #6337ea;
  --grad-b: #9560f0;

  --bg: #ffffff;
  --bg-2: #f7f8fc;
  --surface: #ffffff;
  --surface-2: #f3f4fa;
  --card-bg: #ffffff;
  --line: #e7e9f2;
  --line-2: #d9dce9;
  --hover: rgba(99, 55, 234, 0.035);

  --strong: #12141f;
  --text: #2c3141;
  --muted: #5d6478;
  --dim: #878ea3;
  --placeholder: #a3a9bb;

  --ok: #12894f;
  --ok-fg: #0f7043;
  --ok-soft: rgba(18, 137, 79, 0.09);
  --ok-line: rgba(18, 137, 79, 0.28);
  --warn: #b06d09;
  --warn-fg: #8f5806;
  --warn-soft: rgba(176, 109, 9, 0.09);
  --warn-line: rgba(176, 109, 9, 0.28);
  --err: #cf2d38;
  --err-fg: #b0202b;
  --err-soft: rgba(207, 45, 56, 0.08);
  --err-line: rgba(207, 45, 56, 0.26);

  --glow-1: rgba(99, 55, 234, 0.10);
  --glow-2: rgba(124, 92, 255, 0.07);
  --topbar: rgba(255, 255, 255, 0.86);
  --backdrop: rgba(18, 20, 31, 0.35);
  --shadow: 0 16px 40px rgba(20, 24, 48, 0.10);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 12% -10%, var(--glow-1), transparent 60%),
    radial-gradient(700px 420px at 92% 4%, var(--glow-2), transparent 60%);
  z-index: 0;
}

a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-family: var(--display); letter-spacing: -0.02em; margin: 0 0 12px; color: var(--strong); }
h1 { font-size: 32px; font-weight: 800; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 600; }
p { margin: 0 0 14px; color: var(--muted); }

.wrap { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 460px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.strong { color: var(--strong); }
.small { font-size: 13px; }
.center { text-align: center; }
.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; }

/* ---------------------------------------------------------------- topbar */
header.top {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--line);
  background: var(--topbar);
  backdrop-filter: blur(14px);
}
header.top .inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 22px;
}
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--display); font-weight: 800; font-size: 19px; color: var(--strong); letter-spacing: -0.03em; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; }
nav.main { display: flex; gap: 4px; margin-left: 8px; flex-wrap: wrap; }
nav.main a {
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
}
nav.main a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
nav.main a.active { background: var(--brand-dim); color: var(--brand-fg); }
.top .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.balance-pill {
  font-family: var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--strong);
}
.balance-pill b { color: var(--ok); font-weight: 500; }

/* ------------------------------------------------------------ theme toggle */
.theme-toggle { padding: 7px 9px; line-height: 0; }
.theme-toggle svg { display: block; }
:root[data-theme='dark'] .theme-toggle .ico-moon,
:root[data-theme='light'] .theme-toggle .ico-sun { display: none; }
.theme-toggle.floating {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
:root[data-theme='light'] .card { box-shadow: 0 1px 2px rgba(20, 24, 48, 0.04); }
.card + .card { margin-top: 16px; }
.card h2, .card h3 { margin-bottom: 6px; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; }
:root[data-theme='light'] .stat { background: var(--surface-2); }
.stat .k { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); }
.stat .v { font-family: var(--display); font-size: 26px; font-weight: 700; color: var(--strong); margin-top: 2px; }

/* ---------------------------------------------------------------- forms */
label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-dim); }
input::placeholder { color: var(--placeholder); }
input[type='checkbox'] { width: auto; accent-color: var(--brand); }
.field + .field { margin-top: 14px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--brand);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-size: 14.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s, opacity 0.15s;
}
button:hover, .btn:hover { filter: brightness(1.12); text-decoration: none; }
button:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }
button.ghost, .btn.ghost { background: transparent; border-color: var(--line-2); color: var(--text); }
button.ghost:hover, .btn.ghost:hover { background: var(--surface-2); }
button.danger { background: transparent; border-color: var(--err-line); color: var(--err-fg); }
button.danger:hover { background: var(--err-soft); }
button.sm, .btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
button.full { width: 100%; }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}
.badge.ok { color: var(--ok-fg); border-color: var(--ok-line); background: var(--ok-soft); }
.badge.warn { color: var(--warn-fg); border-color: var(--warn-line); background: var(--warn-soft); }
.badge.err { color: var(--err-fg); border-color: var(--err-line); background: var(--err-soft); }
.badge.brand { color: var(--brand-fg); border-color: var(--brand-line); background: var(--brand-soft); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); display: inline-block; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok-line); }
.dot.off { background: var(--err); }

/* ---------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--dim); font-weight: 600; }
tbody tr:hover { background: var(--hover); }
.table-scroll { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }

/* ---------------------------------------------------------------- alerts */
.alert { border-radius: var(--radius-sm); padding: 11px 14px; font-size: 14px; border: 1px solid var(--line-2); background: var(--surface-2); margin-bottom: 14px; }
.alert.err { border-color: var(--err-line); background: var(--err-soft); color: var(--err-fg); }
.alert.ok { border-color: var(--ok-line); background: var(--ok-soft); color: var(--ok-fg); }
.alert.warn { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn-fg); }

/* ---------------------------------------------------------------- misc */
.code-big {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 500;
  letter-spacing: 6px;
  color: var(--strong);
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  text-align: center;
  user-select: all;
}
.copy { cursor: pointer; }
.sep { height: 1px; background: var(--line); margin: 18px 0; }
.pill-tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 3px; }
.pill-tabs button { background: transparent; color: var(--muted); border-radius: 999px; padding: 7px 16px; font-size: 14px; }
.pill-tabs button.active { background: var(--brand); color: #fff; }

.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  box-shadow: var(--shadow);
  font-size: 14px;
  max-width: 340px;
  animation: slidein 0.18s ease;
}
.toast.err { border-left-color: var(--err); }
.toast.ok { border-left-color: var(--ok); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--line-2); border-top-color: var(--brand);
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

footer.site { border-top: 1px solid var(--line); margin-top: 60px; padding: 26px 0; color: var(--dim); font-size: 13px; }

@media (max-width: 640px) {
  h1 { font-size: 26px; }
  header.top .inner { gap: 12px; }
  nav.main { order: 3; width: 100%; margin-left: 0; }
  .card { padding: 16px; }
  .code-big { font-size: 26px; letter-spacing: 4px; }
}
