/* AII design system — dark, typography-first, zero dependencies. */

/* ═══ DARK MODE (default) ═══ */
:root {
  --bg-base: #050507;
  --bg: #08080C;
  --bg-elev: #101018;
  --bg-hover: #181822;
  --bg-active: #202030;
  --border: #1C1C28;
  --border-bright: #2A2A3A;

  --text-primary: #F0F4F8;
  --text-secondary: #9099A8;
  --text-muted: #505868;

  --accent: #06E0C8;
  --accent-soft: #22C55E;
  --accent-deep: #059669;
  --accent-glow: rgba(6, 224, 200, 0.35);
  --accent-subtle: rgba(6, 224, 200, 0.08);

  --cyan: #06E0C8;
  --cyan-glow: rgba(6, 224, 200, 0.4);
  --green: #22C55E;
  --green-glow: rgba(34, 197, 94, 0.35);

  --success: #22C55E;
  --warn: #F59E0B;
  --danger: #EF4444;

  /* Translucent status tints, for badges and inline banners. */
  --success-tint: rgba(34, 197, 94, 0.15);
  --success-border: rgba(34, 197, 94, 0.3);
  --warn-tint: rgba(245, 158, 11, 0.15);
  --warn-border: rgba(245, 158, 11, 0.3);
  --danger-tint: rgba(239, 68, 68, 0.15);
  --danger-border: rgba(239, 68, 68, 0.3);

  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;

  --fast: 150ms ease;
  --slow: 300ms ease;

  /* Retained from the previous token set; consumed by .nav below. */
  --nav-h: 56px;
}

/* ═══ LIGHT MODE ═══ */
[data-theme="light"] {
  --bg-base: #FAF7F2;
  --bg: #FFFFFF;
  --bg-elev: #FFFFFF;
  --bg-hover: #F5F2EE;
  --bg-active: #EAE6DF;
  --border: #E8E3DA;
  --border-bright: #D4CEC4;

  --text-primary: #1A1814;
  --text-secondary: #5A5548;
  --text-muted: #8A8578;

  --accent: #0EA5A0;
  --accent-soft: #10B981;
  --accent-deep: #0D8580;
  --accent-glow: rgba(14, 165, 160, 0.25);
  --accent-subtle: rgba(14, 165, 160, 0.08);

  --cyan: #0891B2;
  --cyan-glow: rgba(8, 145, 178, 0.2);
  --green: #10B981;
  --green-glow: rgba(16, 185, 129, 0.2);

  --success: #059669;
  --warn: #D97706;
  --danger: #DC2626;

  /* Tints are heavier in light mode: the palette is dark-on-light, so a 0.15
     alpha of a mid-tone reads as a muddy wash rather than a soft badge. */
  --success-tint: rgba(5, 150, 105, 0.12);
  --success-border: rgba(5, 150, 105, 0.35);
  --warn-tint: rgba(217, 119, 6, 0.12);
  --warn-border: rgba(217, 119, 6, 0.35);
  --danger-tint: rgba(220, 38, 38, 0.10);
  --danger-border: rgba(220, 38, 38, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; transition: color var(--fast); }
a:hover { color: var(--text-primary); }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
p { margin: 0; }

::selection { background: var(--accent); color: #000; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Layout ─────────────────────────────────────────── */

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.wrap-narrow { max-width: 760px; }
.stack > * + * { margin-top: var(--s, 16px); }
.row { display: flex; gap: 12px; align-items: center; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.wrap-flex { flex-wrap: wrap; }

/* ── Type ───────────────────────────────────────────── */

.t-12 { font-size: 12px; }
.t-14 { font-size: 14px; }
.t-16 { font-size: 16px; }
.t-20 { font-size: 20px; }
.t-28 { font-size: 28px; }
.t-40 { font-size: 40px; }
.t-56 { font-size: 56px; }

.mono { font-family: var(--font-mono); }
.secondary { color: var(--text-secondary); }
.muted { color: var(--text-muted); }

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.gradient-text {
  background: linear-gradient(96deg, var(--text-primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

/* ── Nav ────────────────────────────────────────────── */

.nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  display: flex; align-items: center;
  background: rgba(10, 10, 10, 0.72);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--slow), background var(--slow);
}
.nav.scrolled { border-bottom-color: var(--border); background: rgba(10, 10, 10, 0.9); }

.nav-inner {
  width: 100%; max-width: 1120px; margin: 0 auto;
  padding: 0 24px;
  display: flex; align-items: center; gap: 24px;
}

.logo {
  display: inline-flex; align-items: baseline; gap: 0;
  font-family: var(--font-mono); font-size: 16px; font-weight: 700;
  letter-spacing: -0.04em; color: var(--text-primary);
}
.logo:hover { color: var(--text-primary); }
/* The brand mark is "Aii" + an accent-coloured period. The span carries a real
   "." glyph, so it must not be styled as the decorative 6px glowing circle. */
.logo .dot {
  width: auto; height: auto; border-radius: 0;
  background: none;
  box-shadow: none;
  animation: none;
  color: var(--accent);
  margin-left: 0;
}

.nav-links { display: flex; gap: 24px; margin-left: 8px; }
.nav-links a {
  font-size: 14px; color: var(--text-secondary);
  transition: color var(--fast);
}
.nav-links a:hover { color: var(--text-primary); }

.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.nav-user {
  font-size: 13px; color: var(--text-secondary);
  font-family: var(--font-mono);
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

@media (max-width: 860px) {
  .nav-links { display: none; }
  .nav-user { display: none; }
}

/* ── Buttons ────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 14px; font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--fast), border-color var(--fast), color var(--fast), opacity var(--fast);
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-bright); }
.btn:active { transform: translateY(0.5px); }

.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #04160B; font-weight: 600;
}
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: #04160B; }

.btn-ghost { background: transparent; border-color: var(--border-bright); color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-sm { font-size: 12px; padding: 5px 10px; }
.btn-lg { font-size: 16px; padding: 12px 22px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--bg-elev); border-color: var(--border); }

/* ── Cards & panels ─────────────────────────────────── */

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px;
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.card-hover { transition: border-color var(--fast), background var(--fast); }
.card-hover:hover { border-color: var(--border-bright); background: var(--bg-hover); }

/* ── Pills / badges / tabs ───────────────────────────── */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--fast), border-color var(--fast), background var(--fast);
}
.pill:hover { color: var(--text-primary); border-color: var(--border-bright); }
.pill[aria-pressed="true"], .pill.is-active {
  background: rgba(34, 197, 94, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}
.pill[disabled] { opacity: 0.4; cursor: not-allowed; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: var(--r-sm);
}
.badge-live { background: rgba(34, 197, 94, 0.12); color: var(--accent); }
.badge-warn { background: rgba(245, 158, 11, 0.12); color: var(--warn); }
.badge-muted { background: var(--bg-hover); color: var(--text-muted); }

.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  font-family: inherit; font-size: 14px; font-weight: 500;
  padding: 12px 14px;
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer; white-space: nowrap;
  transition: color var(--fast), border-color var(--fast);
}
.tab:hover { color: var(--text-primary); }
.tab[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--accent); }

.tabpanel { display: none; }
.tabpanel.is-active { display: block; }

/* ── Forms ──────────────────────────────────────────── */

.field { display: block; }
.label {
  display: block; margin-bottom: 8px;
  font-size: 12px; font-weight: 500; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted);
}

.input, .textarea, .select {
  width: 100%;
  font-family: inherit; font-size: 15px;
  padding: 11px 13px;
  color: var(--text-primary);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color var(--fast);
  appearance: none;
}
.input:hover, .textarea:hover, .select:hover { border-color: var(--border-bright); }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--accent);
}
.textarea { min-height: 108px; resize: vertical; line-height: 1.55; }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238A8A8A' d='M6 8.5 2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
}

input[type="range"] {
  width: 100%; height: 4px; appearance: none;
  background: var(--border-bright); border-radius: 999px; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 0; cursor: pointer;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; border: 0;
  background: var(--accent); cursor: pointer;
}

/* ── Feedback ───────────────────────────────────────── */

.banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  font-size: 14px;
}
.banner-danger { border-color: rgba(239, 68, 68, 0.4); background: rgba(239, 68, 68, 0.08); color: var(--danger); }
.banner-warn { border-color: rgba(245, 158, 11, 0.4); background: rgba(245, 158, 11, 0.08); color: var(--warn); }
.banner-ok { border-color: rgba(34, 197, 94, 0.4); background: rgba(34, 197, 94, 0.08); color: var(--success); }

.empty {
  padding: 48px 24px; text-align: center;
  color: var(--text-muted); font-size: 14px;
}

.spinner {
  width: 15px; height: 15px; flex: none;
  border: 2px solid var(--border-bright);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 720ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-line {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: var(--text-secondary);
}

/* ── Table ──────────────────────────────────────────── */

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; padding: 10px 12px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--fast); }
.table tbody tr:hover { background: var(--bg-hover); }
.table .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Meters ─────────────────────────────────────────── */

.meter { height: 5px; background: var(--bg-hover); border-radius: 999px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width var(--slow); }

/* ── Utilities ──────────────────────────────────────── */

.divider { height: 1px; background: var(--border); border: 0; margin: 0; }
.hide { display: none !important; }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pre-wrap { white-space: pre-wrap; word-break: break-word; }

.section { padding: 64px 0; }
.section-sm { padding: 40px 0; }

/* ═══ BACKGROUND LAYERS ═══ */

body {
  background: var(--bg-base);
  position: relative;
  min-height: 100vh;
}

/* Dark mode: layered radial gradients in cyan/green over black */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 15% 10%, rgba(6, 224, 200, 0.10), transparent 60%),
    radial-gradient(ellipse 70% 50% at 85% 20%, rgba(34, 197, 94, 0.08), transparent 55%),
    radial-gradient(ellipse 100% 70% at 50% 100%, rgba(6, 224, 200, 0.06), transparent 65%);
}

/* Light mode: warm pastel gradient, colorful but soft */
[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse 90% 60% at 10% 5%, rgba(255, 220, 200, 0.55), transparent 60%),
    radial-gradient(ellipse 80% 55% at 90% 15%, rgba(200, 230, 255, 0.55), transparent 55%),
    radial-gradient(ellipse 100% 70% at 30% 100%, rgba(220, 255, 245, 0.55), transparent 65%),
    radial-gradient(ellipse 70% 50% at 90% 90%, rgba(255, 225, 245, 0.45), transparent 60%);
  background-color: #FAF7F2;
}

/* Smooth transition on theme change */
body, body::before, .card, .tier, .cap, .nav, .msg, input, button {
  transition: background var(--slow), background-color var(--slow),
              color var(--slow), border-color var(--slow);
}

/* ═══ NAV BLUR ═══ */
.nav {
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: rgba(8, 8, 12, 0.65);
  border-bottom: 1px solid var(--border);
}
.nav.scrolled {
  background: rgba(8, 8, 12, 0.85);
  border-bottom-color: var(--border-bright);
}

[data-theme="light"] .nav {
  background: rgba(255, 255, 255, 0.7);
  border-bottom-color: rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .nav.scrolled {
  background: rgba(255, 255, 255, 0.9);
}

/* ═══ CARD GLOWS ═══ */
.card, .tier, .cap, .hiw > div {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

[data-theme="light"] .card,
[data-theme="light"] .tier,
[data-theme="light"] .cap {
  box-shadow: 0 1px 2px rgba(0,0,0,0.03), 0 4px 12px rgba(0,0,0,0.04);
}

.card.is-featured, .tier.is-featured {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 32px var(--accent-glow);
}

/* ═══ GLOWING ACCENT DOT ═══ */
.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow), 0 0 4px var(--accent);
  animation: pulse-dot 3s ease-in-out infinite;
  vertical-align: middle;
  margin-left: 2px;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.6; transform: scale(0.9); }
}

/* ═══ BUTTONS ═══ */
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--green) 100%);
  color: #051210;
  font-weight: 600;
  border: none;
  box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 4px 20px var(--accent-glow);
  transition: all var(--fast);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset, 0 8px 32px var(--accent-glow);
}

[data-theme="light"] .btn-primary {
  color: #FFFFFF;
}

.btn {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-primary);
  transition: all var(--fast);
}
.btn:hover {
  border-color: var(--border-bright);
  background: var(--bg-hover);
}

/* ═══ INPUTS ═══ */
input, textarea, select {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-primary);
  transition: all var(--fast);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

[data-theme="light"] input,
[data-theme="light"] textarea,
[data-theme="light"] select {
  background: #FFFFFF;
  border-color: #DDD7CC;
}
[data-theme="light"] input::placeholder {
  color: var(--text-muted);
}

/* ═══ THEME TOGGLE ICONS ═══ */
.theme-toggle {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 9px;
  cursor: pointer;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--fast);
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun  { display: block; }
[data-theme="light"] .theme-toggle .icon-sun  { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }
