/* BIBF AI Tutor — dark futurist / obsidian glass design tokens */
:root, [data-theme="dark"] {
  /* Core palette — obsidian */
  --bg-0: #05060a;
  --bg-1: #0a0c14;
  --bg-2: #0f1220;
  --bg-3: #171a2b;
  --surface: rgba(20, 24, 40, 0.55);
  --surface-2: rgba(28, 32, 52, 0.65);
  --surface-glass: rgba(255, 255, 255, 0.03);
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);

  /* Text */
  --text: #e8ebf5;
  --text-2: #a3a8bd;
  --text-3: #6b7089;
  --text-4: #454a63;

  /* Accents — restrained */
  --accent: #7c5cff;      /* iris */
  --accent-2: #00d4ff;    /* cyan pulse */
  --accent-gold: #d4a574; /* muted institutional gold */
  --danger: #ff5e7a;
  --warn: #f5b544;
  --ok: #4ade80;

  /* Glass tint (used in .glass) */
  --glass-tint-a: rgba(255,255,255,0.035);
  --glass-tint-b: rgba(255,255,255,0.008);
  --glass-shadow: 0 24px 60px -20px rgba(0,0,0,0.5);
  --glass-inset: 0 1px 0 rgba(255,255,255,0.04) inset;

  /* Theme-adaptive surface tokens (used inline in components) */
  --panel-dim: rgba(0,0,0,0.3);
  --surface-raise-1: rgba(255,255,255,0.02);
  --surface-raise-2: rgba(255,255,255,0.035);
  --surface-raise-3: rgba(255,255,255,0.05);
  --surface-raise-4: rgba(255,255,255,0.06);
  --track: rgba(255,255,255,0.06);
  --sidebar-bg: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0));
  --avatar-ring: #0a0c14;
  --wb-bg: #0a0c14;
  --wb-grid: rgba(255,255,255,0.04);
  --hover-wash: rgba(255,255,255,0.03);
  --bubble-assistant: rgba(255,255,255,0.035);
}

/* ---------------- Light theme ---------------- */
[data-theme="light"] {
  --bg-0: #f4f5f9;
  --bg-1: #eef0f6;
  --bg-2: #e8ebf3;
  --bg-3: #dee2ec;
  --surface: rgba(255, 255, 255, 0.75);
  --surface-2: rgba(255, 255, 255, 0.9);
  --surface-glass: rgba(255, 255, 255, 0.5);
  --border: rgba(15, 18, 32, 0.08);
  --border-strong: rgba(15, 18, 32, 0.16);

  --text: #1a1d2c;
  --text-2: #4a5069;
  --text-3: #737993;
  --text-4: #a3a8bd;

  --accent: #5b3ee0;
  --accent-2: #0891b2;
  --accent-gold: #8b6a3e;
  --danger: #dc2645;
  --warn: #b7791f;
  --ok: #15803d;

  --glass-tint-a: rgba(255,255,255,0.7);
  --glass-tint-b: rgba(255,255,255,0.4);
  --glass-shadow: 0 10px 40px -12px rgba(15, 18, 32, 0.15);
  --glass-inset: 0 1px 0 rgba(255,255,255,0.9) inset;

  /* Light-mode surfaces */
  --panel-dim: rgba(15,18,32,0.045);
  --surface-raise-1: rgba(255,255,255,0.5);
  --surface-raise-2: rgba(255,255,255,0.65);
  --surface-raise-3: rgba(255,255,255,0.85);
  --surface-raise-4: rgba(15,18,32,0.05);
  --track: rgba(15,18,32,0.08);
  --sidebar-bg: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0.5));
  --avatar-ring: #ffffff;
  --wb-bg: #fbfbfd;
  --wb-grid: rgba(15,18,32,0.06);
  --hover-wash: rgba(15,18,32,0.04);
  --bubble-assistant: rgba(255,255,255,0.7);
}

/* Radii / type / motion — shared across themes.
   NOTE: in the design prototype these lived outside any selector (a CSS bug),
   so they never resolved. Scoped to :root here so the serif/mono/Arabic faces
   and the radius scale actually apply. */
:root {
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;

  --font-sans: 'Inter Tight', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-serif: 'Fraunces', 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  --font-ar: 'IBM Plex Sans Arabic', 'Noto Sans Arabic', sans-serif;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg-0);
  color: var(--text);
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Ambient aurora background */
.aurora {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(60% 50% at 20% 15%, rgba(124, 92, 255, 0.14), transparent 60%),
    radial-gradient(50% 40% at 85% 20%, rgba(0, 212, 255, 0.08), transparent 60%),
    radial-gradient(70% 60% at 50% 100%, rgba(212, 165, 116, 0.06), transparent 60%),
    var(--bg-0);
  transition: background 0.4s var(--ease-out);
}
[data-theme="light"] .aurora {
  background:
    radial-gradient(60% 50% at 20% 15%, rgba(124, 92, 255, 0.10), transparent 60%),
    radial-gradient(50% 40% at 85% 20%, rgba(0, 212, 255, 0.06), transparent 60%),
    radial-gradient(70% 60% at 50% 100%, rgba(212, 165, 116, 0.05), transparent 60%),
    var(--bg-0);
}
.aurora::after {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.5;
}
[data-theme="light"] .aurora::after { opacity: 0.25; }

/* Glass panel */
.glass {
  background: linear-gradient(180deg, var(--glass-tint-a), var(--glass-tint-b));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  box-shadow: var(--glass-inset), var(--glass-shadow);
  transition: background 0.3s var(--ease-out), border-color 0.3s var(--ease-out);
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--btn-bg, linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02)));
  color: var(--text);
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: all 0.18s var(--ease-out);
  letter-spacing: -0.01em;
}
[data-theme="light"] .btn { background: linear-gradient(180deg, #ffffff, #f4f5f9); border-color: var(--border-strong); }
.btn:hover { border-color: rgba(255,255,255,0.24); background: rgba(255,255,255,0.06); transform: translateY(-1px); }
[data-theme="light"] .btn:hover { background: #ffffff; border-color: rgba(15,18,32,0.24); }
.btn:active { transform: translateY(0); }
.btn:disabled { cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(180deg, #7c5cff, #5b3ee0);
  border-color: rgba(124,92,255,0.6);
  color: #fff;
  box-shadow: 0 8px 20px -6px rgba(124,92,255,0.45), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn.primary:hover { box-shadow: 0 12px 28px -6px rgba(124,92,255,0.6); background: linear-gradient(180deg, #7c5cff, #5b3ee0); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: rgba(255,255,255,0.04); color: var(--text); }
[data-theme="light"] .btn.ghost { background: transparent; }
[data-theme="light"] .btn.ghost:hover { background: rgba(15,18,32,0.05); }

/* Chip */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,0.03);
  font-size: 11px; font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
[data-theme="light"] .chip { background: rgba(255,255,255,0.7); }
.chip.accent { border-color: rgba(124,92,255,0.4); color: #b7a4ff; background: rgba(124,92,255,0.08); }
.chip.gold { border-color: rgba(212,165,116,0.4); color: #e8c99b; background: rgba(212,165,116,0.08); }
.chip.danger { border-color: rgba(255,94,122,0.4); color: #ff9aae; background: rgba(255,94,122,0.08); }
.chip.warn { border-color: rgba(245,181,68,0.4); color: #f5c876; background: rgba(245,181,68,0.08); }
.chip.ok { border-color: rgba(74,222,128,0.4); color: #86efac; background: rgba(74,222,128,0.08); }
[data-theme="light"] .chip.accent { color: #5b3ee0; }
[data-theme="light"] .chip.gold { color: #8b6a3e; }
[data-theme="light"] .chip.danger { color: #b91c3c; }
[data-theme="light"] .chip.warn { color: #a16207; }
[data-theme="light"] .chip.ok { color: #15803d; }

/* Inputs */
.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--input-bg, rgba(0,0,0,0.25));
  color: var(--text);
  font: inherit; font-size: 14px;
  outline: none;
  transition: border-color 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out);
}
[data-theme="light"] .input { background: rgba(255,255,255,0.9); }
.input:focus {
  border-color: rgba(124,92,255,0.6);
  box-shadow: 0 0 0 4px rgba(124,92,255,0.12);
}
.input::placeholder { color: var(--text-4); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(15,18,32,0.12); }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(15,18,32,0.24); }

/* Avatar */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  color: white;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.1);
}

/* Kbd */
kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  vertical-align: middle;
}
[data-theme="light"] kbd { background: rgba(15,18,32,0.05); }

/* Utility */
.mono { font-family: var(--font-mono); font-feature-settings: 'tnum'; }
.serif { font-family: var(--font-serif); }
.ar { font-family: var(--font-ar); direction: rtl; }
.tabular { font-variant-numeric: tabular-nums; }

.dot {
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3);
  vertical-align: middle;
}
.dot.live { background: var(--ok); box-shadow: 0 0 0 3px rgba(74,222,128,0.18); animation: pulse 2s infinite; }
.dot.warn { background: var(--warn); }
.dot.danger { background: var(--danger); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74,222,128,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(74,222,128,0); }
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.6); opacity: 0.5; }
}
@keyframes shimmer {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* Divider */
.hr {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
  border: 0;
  margin: 20px 0;
}

/* Fine label */
.label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 500;
}

.surface-dim { background: rgba(0,0,0,0.25); }
[data-theme="light"] .surface-dim { background: rgba(15,18,32,0.04); }
.surface-raised { background: rgba(255,255,255,0.03); }
[data-theme="light"] .surface-raised { background: rgba(255,255,255,0.7); }

/* Route link (for the shell nav) */
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--hover-wash); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(124,92,255,0.14), rgba(124,92,255,0.02));
  color: var(--text);
  border: 1px solid rgba(124,92,255,0.25);
  padding: 8px 11px;
}
.nav-item .badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  color: var(--text-3);
  font-family: var(--font-mono);
}
[data-theme="light"] .nav-item .badge { background: rgba(15,18,32,0.06); }

select.input-select {
  padding: 6px 10px; border-radius: 6px;
  background: var(--panel-dim);
  border: 1px solid var(--border-strong);
  color: var(--text); font-size: 12px;
  font-family: inherit;
}
