/* Backend-rendered pages: consolidated stylesheet served at /backend.css.
   Dark-only Apple-style aesthetic, matching the marketing site at /style.css.
   Class names preserved so the FastAPI _page() helper and route templates
   render unchanged. */

/* ---------- Foundation: theme variables, reset, layout, forms, buttons */
:root {
  --bg: #000; --fg: #f5f5f7; --muted: #86868b;
  --line: rgba(255,255,255,0.10);
  --hair: rgba(255,255,255,0.10);
  --card: #1d1d1f; --card-2: #16161a;
  --feature: #131318;
  --blue: #2997ff; --blue-hi: #147ce5;
  --indigo: #7d6cff; --rose: #ff5e57; --teal: #39c5cf;
  --error: #ff6679;
  --hover-line: rgba(255,255,255,0.20);
  --pad: max(20px, env(safe-area-inset-left));
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: #000; color-scheme: dark; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background:
    radial-gradient(60% 50% at 50% 12%, rgba(125,108,255,0.16), transparent 60%),
    radial-gradient(70% 50% at 50% 60%, rgba(41,151,255,0.08), transparent 60%),
    #000;
  color: var(--fg);
  font-size: 16px; line-height: 1.55; letter-spacing: -0.011em;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  display: flex; flex-direction: column; min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }

.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(0,0,0,0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hair);
  height: 48px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--pad); font-size: 13px; letter-spacing: -0.01em;
  width: 100%;
}
.brand { font-weight: 600; letter-spacing: 0.04em; font-size: 13px; color: var(--fg); }
.brand-beta {
  display: inline-block; margin-left: 8px;
  padding: 1px 6px; font-size: 9px; font-weight: 600;
  letter-spacing: 0.18em; border: 1px solid currentColor;
  vertical-align: 2px; color: var(--muted);
}
.nav-right { font-size: 13px; color: var(--fg); display: flex; gap: 18px; align-items: center; }
.nav-right a { color: var(--fg); opacity: 0.84; transition: opacity 0.2s ease; }
.nav-right a:hover { opacity: 1; }

main {
  flex: 1; max-width: 1100px; width: 100%; margin: 0 auto;
  padding: 56px var(--pad);
  display: flex; flex-direction: column; align-items: center;
}
/* narrow auth pages (sign in / sign up / approve / forgot pw) center vertically */
main.auth-narrow { justify-content: center; padding-top: 40px; padding-bottom: 80px; }

.card {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: 22px;
  padding: 40px 32px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.45);
}
.auth-narrow .card { max-width: 440px; }
.auth-wide .card { max-width: 720px; }

.eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 0.18em;
  color: var(--muted); margin: 0 0 12px; text-transform: uppercase;
}
h1 {
  font-size: clamp(30px, 3.8vw, 38px);
  line-height: 1.05; letter-spacing: -0.030em;
  font-weight: 600; margin: 0 0 12px;
  /* background-clip:text paints only inside the padding box; with a tight
     line-height descenders (g, y, p) fall below it and get clipped. The
     padding-bottom extends the paint box past the descenders; margin is
     trimmed to keep the original spacing. */
  padding-bottom: 0.2em;
  background: linear-gradient(180deg, #fff 0%, #a5a5ad 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
p { margin: 0 0 14px; color: var(--muted); }
p.muted { color: var(--muted); font-size: 13px; }
strong { color: var(--fg); font-weight: 600; }

.error {
  background: rgba(255,102,121,0.08);
  border-left: 3px solid var(--error);
  border-radius: 8px;
  padding: 12px 14px; color: var(--fg); font-size: 14px; margin: 0 0 16px;
}

form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
input[type=text], input[type=email], input[type=password] {
  width: 100%; background: rgba(255,255,255,0.04);
  border: 1px solid var(--hair);
  color: var(--fg); padding: 12px 14px; font-size: 15px; outline: none;
  font-family: inherit; border-radius: 10px;
  transition: border-color 0.2s ease, background 0.2s ease;
}
input:focus { border-color: var(--blue); background: rgba(255,255,255,0.06); }

.pw-wrap { position: relative; }
.pw-wrap > input { padding-right: 84px; }
.pw-wrap > button.pw-toggle {
  position: absolute; right: 0; top: 0; bottom: 0;
  background: transparent; color: var(--muted); border: 0;
  padding: 0 16px; min-width: 72px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.16em;
  text-transform: uppercase;
  font-family: inherit; line-height: 1; cursor: pointer;
  border-radius: 0;
}
.pw-wrap > button.pw-toggle:hover {
  color: var(--fg); background: transparent; opacity: 1;
}

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 20px; font-size: 14px; font-weight: 500;
  letter-spacing: -0.005em;
  border-radius: 980px; border: 0;
  cursor: pointer;
  background: var(--blue); color: #fff;
  font-family: inherit;
  transition: background 0.2s ease, opacity 0.2s ease;
  text-decoration: none; text-align: center;
}
button:hover, .btn:hover {
  background: var(--blue-hi); color: #fff; text-decoration: none;
}
button:active, .btn:active { opacity: 0.85; }
button[disabled], .btn[disabled] {
  opacity: 0.4; cursor: not-allowed;
  background: var(--blue); color: #fff;
}
button.secondary, .btn.secondary {
  background: transparent; color: var(--fg);
  border: 1px solid var(--hair);
}
button.secondary:hover, .btn.secondary:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--hover-line);
}

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

.code-display {
  font-family: var(--mono); font-size: 24px; letter-spacing: 0.2em;
  padding: 14px; border: 1px solid var(--hair); border-radius: 10px;
  text-align: center;
  background: var(--feature); color: var(--fg); margin: 4px 0 8px;
}

.balance-hero {
  border-bottom: 1px solid var(--hair);
  padding-bottom: 28px; margin-bottom: 28px;
}
.balance-num {
  font-size: 56px; font-weight: 600; letter-spacing: -0.035em; line-height: 1;
  color: var(--fg); margin: 4px 0;
  background: linear-gradient(180deg, #fff, #7e7e8a);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  font-variant-numeric: tabular-nums;
}
.balance-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.18em;
  color: var(--muted); text-transform: uppercase; margin-bottom: 0;
}

.history { list-style: none; padding: 0; margin: 0; }
.history li {
  display: grid; grid-template-columns: 1fr auto auto; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--hair); font-size: 14px;
  align-items: baseline;
}
.history li:last-child { border-bottom: none; }
.history .reason { color: var(--fg); }
.history .when { color: var(--muted); font-size: 12px; }
.history .delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.history .delta.neg { color: var(--muted); }
.history .delta.pos { color: var(--fg); }

.cta-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }

footer.foot, .foot {
  max-width: 1100px; width: 100%; margin: 0 auto;
  padding: 32px var(--pad) 56px;
  border-top: 1px solid var(--hair);
  font-size: 12px; color: var(--muted);
}
.foot-row {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 16px; margin-bottom: 12px;
}
.brand-foot {
  font-weight: 600; letter-spacing: 0.04em; font-size: 13px;
  margin: 0; color: var(--fg);
}
.foot-nav { display: flex; gap: 18px; font-size: 12px; flex-wrap: wrap; }
.foot a, .foot-nav a { color: var(--muted); transition: color 0.2s ease; }
.foot a:hover, .foot-nav a:hover { color: var(--fg); }
.foot-fine { font-size: 11px; color: var(--muted); margin: 0 0 8px; }

/* Hide legacy "Light mode" toggle button (dark-only now) */
.theme-toggle { display: none !important; }

@media (max-width: 600px) {
  main { padding: 32px var(--pad); }
  .card { padding: 28px 20px; }
  h1 { font-size: 24px; }
  .balance-num { font-size: 44px; }
}

/* ---------- Login form: remember-me checkbox */
.remember-me {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted); margin: 0 0 14px;
  cursor: pointer; user-select: none;
}
.remember-me input { width: auto; margin: 0; padding: 0; }

/* ---------- Password strength meter */
.pw-meter { margin: -8px 0 16px; }
.pw-meter[hidden] { display: none; }
.pw-bar { height: 4px; background: var(--hair); border-radius: 999px; position: relative; overflow: hidden; }
.pw-bar span {
  display: block; height: 100%; width: 0%;
  background: var(--muted); transition: width 0.15s, background 0.15s;
  border-radius: 999px;
}
.pw-bar[data-strength="1"] span { width: 25%; background: var(--error); }
.pw-bar[data-strength="2"] span { width: 50%; background: #ffa64d; }
.pw-bar[data-strength="3"] span { width: 75%; background: #39d36b; }
.pw-bar[data-strength="4"] span { width: 100%; background: #39d36b; }
.pw-rules {
  list-style: none; padding: 0; margin: 10px 0 0;
  font-size: 12px; color: var(--muted);
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px;
}
.pw-rules li { padding-left: 14px; position: relative; }
.pw-rules li::before { content: "—"; position: absolute; left: 0; color: var(--muted); }
.pw-rules li.pass { color: var(--fg); }
.pw-rules li.pass::before { content: "+"; color: #39d36b; font-weight: 700; }

/* ---------- /status page */
.status-overall { font-size: 18px; font-weight: 600; margin: 12px 0 28px; letter-spacing: -0.015em; }
.status-overall.ok { color: #39d36b; }
.status-overall.bad { color: var(--error); }
.status-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--hair); }
.status-row {
  display: grid; grid-template-columns: 14px 1fr auto; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--hair); align-items: center;
  font-size: 14px;
}
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.status-dot.ok { background: #39d36b; box-shadow: 0 0 8px #39d36b; }
.status-dot.bad { background: var(--error); box-shadow: 0 0 8px var(--error); }
.status-name { color: var(--fg); font-weight: 500; }
.status-state { color: var(--muted); font-size: 11px; letter-spacing: 0.10em; text-transform: uppercase; }

/* ---------- /buy page (Paddle checkout) */
.buy-grid {
  display: grid; grid-template-columns: 1fr; gap: 12px; margin: 24px 0;
}
@media (min-width: 600px) {
  .buy-grid { grid-template-columns: 1fr 1fr 1fr; }
}
.buy-card {
  background: var(--card-2);
  border-radius: 18px;
  padding: 24px 20px;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
}
.buy-card.featured {
  background: linear-gradient(180deg, #171b2a, #0e0f15);
  box-shadow: inset 0 0 0 1px rgba(125,108,255,0.30);
}
.buy-name {
  font-size: 11px; font-weight: 600; letter-spacing: 0.10em;
  color: var(--muted); margin: 0; text-transform: uppercase;
}
.buy-tokens { margin: 0; font-size: 13px; color: var(--muted); }
.buy-tokens .num {
  font-size: 36px; font-weight: 600; letter-spacing: -0.035em;
  color: var(--fg); margin-right: 4px; font-variant-numeric: tabular-nums;
}
.buy-cost { margin: 0 0 4px; font-size: 16px; font-weight: 500; color: var(--fg); font-variant-numeric: tabular-nums; }
.buy-breakdown {
  margin: 0 0 8px; font-size: 12px;
  color: var(--muted); font-variant-numeric: tabular-nums;
}
.buy-card .btn { width: 100%; }
.buy-status {
  padding: 14px 16px; margin: 0 0 20px; font-size: 14px; line-height: 1.45;
  border-radius: 10px;
  border-left: 3px solid var(--muted);
  background: var(--feature);
}
.buy-status.success { border-left-color: #39d36b; color: var(--fg); }
.buy-status.error   { border-left-color: var(--error); color: var(--fg); }
.buy-status.info    { border-left-color: var(--blue); color: var(--fg); }

/* ---------- /account page */
.acct-head {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px;
  margin-bottom: 8px;
}
.acct-head h1 { margin: 0; }
.acct-email {
  margin: 0; color: var(--muted); font-size: 14px;
  flex-basis: 100%;
}
.badge-row { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  display: inline-block; padding: 3px 10px; font-size: 10px;
  font-weight: 600; letter-spacing: 0.10em; text-transform: uppercase;
  border: 1px solid var(--hair); color: var(--muted);
  background: rgba(255,255,255,0.03); border-radius: 980px;
  font-variant-numeric: tabular-nums;
}
.badge-warn {
  border-color: rgba(255,102,121,0.40); color: var(--fg);
  background: rgba(255,102,121,0.08);
}

.acct-grid {
  display: grid; grid-template-columns: 1fr; gap: 0;
  border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair);
  margin: 28px 0;
}
@media (min-width: 600px) {
  .acct-grid { grid-template-columns: 1fr 1fr; }
  .acct-grid .metric:first-child { border-right: 1px solid var(--hair); }
}
.metric { padding: 24px 0 24px; }
@media (min-width: 600px) {
  .metric { padding: 24px; }
  .metric:first-child { padding-left: 0; }
  .metric:last-child { padding-right: 0; }
}
.metric-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.18em;
  color: var(--muted); text-transform: uppercase; margin: 0 0 6px;
}
.metric-num {
  font-size: 56px; font-weight: 600; letter-spacing: -0.035em; line-height: 1;
  margin: 4px 0; font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff, #7e7e8a);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.metric-hint { font-size: 13px; color: var(--muted); margin: 0; }
.metric-muted .metric-num {
  background: none; -webkit-background-clip: initial; color: var(--muted); font-weight: 600;
}
.spark { margin-top: 10px; color: var(--muted); }
.spark svg { display: block; max-width: 100%; height: auto; }

.acct-banner {
  padding: 12px 16px; margin: 0 0 20px; font-size: 14px; line-height: 1.45;
  border-radius: 10px;
  border-left: 3px solid var(--muted);
  background: var(--feature); color: var(--fg);
}
.acct-banner.success { border-left-color: #39d36b; }
.acct-banner.warn { border-left-color: var(--error); }
.acct-banner a { color: var(--blue); }

@media (max-width: 600px) {
  .metric-num { font-size: 44px; }
}
@media (prefers-reduced-motion: no-preference) {
  #balance-num.is-changing { display: inline-block; position: relative; }
  #balance-num.is-changing::after {
    content: ''; position: absolute;
    left: 0; right: 0; bottom: -6px; height: 2px;
    background: var(--blue);
    transform-origin: left center;
    animation: balance-underline 900ms ease-out forwards;
  }
  @keyframes balance-underline {
    0%   { transform: scaleX(0); opacity: 1; }
    55%  { transform: scaleX(1); opacity: 1; }
    100% { transform: scaleX(1); opacity: 0; }
  }
}

/* ---------- /account/settings page */
.settings-block { border-top: 1px solid var(--hair); padding: 24px 0; }
.settings-block:first-of-type { margin-top: 28px; }
.settings-block.danger { border-color: var(--error); }
.eyebrow.danger { color: var(--error); }
.btn.danger {
  background: var(--error); color: #fff;
}
.btn.danger:hover { background: #e6485a; opacity: 1; }
.link-btn {
  background: none; border: none; padding: 0; color: var(--blue);
  font: inherit; text-decoration: underline; cursor: pointer;
  border-radius: 0;
}
.link-btn:hover { color: var(--fg); background: none; }
form input + button, form button { margin-top: 4px; }
