:root {
  --bg: #0b0d16;
  --panel: #141829;
  --panel-2: #1b2035;
  --border: #2a2f4a;
  --text: #f1f3fb;
  --text-dim: #9aa0c3;
  --purple: #7c6cff;
  --cyan: #38bdf8;
  --radius: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(124, 108, 255, 0.12), transparent 60%),
    radial-gradient(800px 400px at 100% 0%, rgba(56, 189, 248, 0.1), transparent 55%),
    linear-gradient(180deg, #0b0d16 0%, #0e1120 60%, #0b0d16 100%);
  color: var(--text);
  min-height: 100vh;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}

.brand-logo {
  height: 34px;
  width: auto;
  display: block;
  background: #fff;
  border-radius: 8px;
  padding: 4px 8px;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.site-nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
}

.site-nav a:hover { color: var(--text); }

.site-nav a.active {
  background: linear-gradient(135deg, var(--purple), #9b8cff);
  color: white;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.home-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.home-link:hover { color: var(--text); }

.doc-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.doc-nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}

.doc-nav a:hover { color: var(--text); border-color: var(--purple); }
.doc-nav a.current {
  color: white;
  background: linear-gradient(135deg, var(--purple), #9b8cff);
  border-color: transparent;
}

.doc {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px clamp(20px, 4vw, 48px);
}

.doc h1 {
  margin: 0 0 6px;
  font-size: clamp(1.5rem, 3vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.01em;
}

.doc .updated {
  margin: 0 0 28px;
  color: var(--text-dim);
  font-size: 0.82rem;
}

.doc h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 32px 0 10px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.doc h2:first-of-type { border-top: none; padding-top: 0; margin-top: 8px; }

.doc p, .doc li {
  color: #d7dbee;
  font-size: 0.92rem;
  line-height: 1.65;
}

.doc ul, .doc ol {
  margin: 10px 0;
  padding-left: 22px;
}

.doc li { margin-bottom: 6px; }

.doc a { color: var(--cyan); }

.doc strong { color: var(--text); }

.callout {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--purple);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 0.86rem;
  color: var(--text-dim);
  margin: 16px 0;
}

.placeholder {
  color: #ffd76a;
  font-style: italic;
}

.page-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
}

/* --- Theme toggle button --- */
.site-header { flex-wrap: wrap; }
.site-nav { flex: 1 1 auto; justify-content: flex-end; }

.theme-toggle {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  padding: 0;
  margin-left: 8px;
}
.theme-toggle:hover { border-color: var(--purple); }

/* --- Light mode --- */
:root[data-theme="light"] {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-2: #eef0f8;
  --border: #dbdfee;
  --text: #181b2c;
  --text-dim: #5a5f78;
}

:root[data-theme="light"] body {
  background:
    radial-gradient(1100px 520px at 15% -10%, rgba(124, 108, 255, 0.08), transparent 60%),
    radial-gradient(900px 460px at 100% 0%, rgba(56, 189, 248, 0.07), transparent 55%),
    linear-gradient(180deg, #f6f7fb 0%, #eef0f8 60%, #f6f7fb 100%);
}

:root[data-theme="light"] .hero h1 {
  background: linear-gradient(135deg, #181b2c 20%, var(--purple) 65%, var(--cyan) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

:root[data-theme="light"] .content-block p,
:root[data-theme="light"] .doc p,
:root[data-theme="light"] .doc li,
:root[data-theme="light"] .article-card p,
:root[data-theme="light"] .faq-item p,
:root[data-theme="light"] .offer-card p,
:root[data-theme="light"] .contact-card p {
  color: #3a3f57;
}

:root[data-theme="light"] .checkerboard,
:root[data-theme="light"] .ba-frame {
  background-image:
    linear-gradient(45deg, #dfe2ee 25%, transparent 25%),
    linear-gradient(-45deg, #dfe2ee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dfe2ee 75%),
    linear-gradient(-45deg, transparent 75%, #dfe2ee 75%);
  background-color: #eef0f8;
}

:root[data-theme="light"] .placeholder {
  color: #a5760a;
}

/* --- Keep the theme toggle next to the brand on narrow screens, instead
   of stranding it alone below a wrapped nav --- */
@media (max-width: 640px) {
  .site-brand { order: 1; }
  .theme-toggle { order: 2; margin-left: auto; }
  .site-nav {
    order: 3;
    flex-basis: 100%;
    justify-content: flex-start;
  }
}

/* --- Animations & micro-interactions --- */
@media (prefers-reduced-motion: no-preference) {
  .site-brand img.brand-logo {
    transition: transform 0.35s cubic-bezier(.34,1.56,.64,1);
  }
  .site-brand:hover img.brand-logo {
    transform: scale(1.08) rotate(-4deg);
  }

  .site-nav a {
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  }
  .site-nav a:hover {
    transform: translateY(-1px);
  }

  .theme-toggle {
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  }
  .theme-toggle:hover { transform: scale(1.08); }
  .theme-toggle:active { transform: scale(0.92); }
  .theme-toggle.spin { animation: themeSpin 0.5s cubic-bezier(.34,1.56,.64,1); }

  .btn, .tool-cta {
    transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.15s ease;
  }
  .btn-primary, .btn-success, .tool-cta {
    position: relative;
    overflow: hidden;
  }
  .btn-primary::after, .btn-success::after, .tool-cta::after {
    content: "";
    position: absolute;
    top: 0;
    left: -75%;
    width: 40%;
    height: 100%;
    background: linear-gradient(120deg, transparent, rgba(255,255,255,0.35), transparent);
    transform: skewX(-20deg);
    transition: left 0.6s ease;
    pointer-events: none;
  }
  .btn-primary:hover::after, .btn-success:hover::after, .tool-cta:hover::after {
    left: 125%;
  }
  .btn:hover:not(:disabled) { transform: translateY(-1px); }

  .drop-zone { transition: border-color 0.25s ease, background 0.25s ease, transform 0.2s ease; }
  .drop-zone.dragover { animation: dropPulse 1.1s ease-in-out infinite; }

  .tool-card-mini, .article-card {
    transition: transform 0.25s ease, border-color 0.2s ease, box-shadow 0.25s ease;
  }
  .tool-card-mini:hover, .article-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 28px -14px rgba(0,0,0,0.4);
  }

  .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.6s ease, transform 0.6s ease;
  }
  .reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes themeSpin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(1); }
}

@keyframes dropPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.012); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* --- Subheadings, tables and inline code in policy pages --- */
.doc h3 { font-size: 0.96rem; font-weight: 700; margin: 18px 0 4px; color: var(--text); }
.doc code { font-size: 0.85em; background: var(--panel-2); border-radius: 6px; padding: 1px 6px; }
.table-wrap { overflow-x: auto; margin: 12px 0; border: 1px solid var(--border); border-radius: 12px; }
.doc table { width: 100%; border-collapse: collapse; font-size: 0.86rem; min-width: 520px; }
.doc th, .doc td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.doc th { background: var(--panel-2); color: var(--text); font-weight: 700; }
.doc td { color: var(--text-dim); }
.doc tr:last-child td { border-bottom: none; }
