/* ============================================================
   OKIMY EVENT — Design tokens + base styles
   Dark-mode first, premium AI-native feel
   ============================================================ */

:root {
  /* Surfaces (dark mode default) */
  --bg: #07070a;
  --bg-2: #0c0c10;
  --surface-1: #111116;
  --surface-2: #16161c;
  --surface-3: #1c1c24;
  --surface-hover: #1f1f28;
  --border: #25252e;
  --border-strong: #353541;
  --border-glow: rgba(167, 139, 250, 0.25);

  /* Text */
  --text: #f4f4f7;
  --text-muted: #a1a1ad;
  --text-dim: #6b6b78;
  --text-faint: #4a4a55;

  /* Accent — purple→blue gradient */
  --accent: #a78bfa;
  --accent-2: #7aa2f7;
  --accent-strong: #8b5cf6;
  --accent-soft: rgba(167, 139, 250, 0.12);
  --accent-softer: rgba(167, 139, 250, 0.06);
  --accent-ring: rgba(167, 139, 250, 0.35);
  --accent-grad: linear-gradient(135deg, #a78bfa 0%, #7aa2f7 100%);
  --accent-grad-soft: linear-gradient(135deg, rgba(167, 139, 250, 0.18) 0%, rgba(122, 162, 247, 0.18) 100%);

  /* Semantic */
  --success: #60a5fa;
  --success-soft: rgba(96, 165, 250, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.12);
  --live: #ef4444;

  /* Speaker palette (subtle, for avatar rings + chips) */
  --sp-1: #a78bfa;
  --sp-2: #38bdf8;
  --sp-3: #fb923c;
  --sp-4: #60a5fa;
  --sp-5: #f472b6;
  --sp-6: #fbbf24;
  --sp-7: #818cf8;

  /* Density-aware spacing */
  --gap: 16px;
  --gap-sm: 10px;
  --gap-lg: 24px;
  --row-pad-y: 14px;
  --row-pad-x: 18px;

  /* Type */
  --font-sans: "Geist", "Inter Tight", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", ui-monospace, monospace;
  --font-display: "Geist", "Inter Tight", system-ui, sans-serif;

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-2xl: 22px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.35), 0 1px 2px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 32px rgba(167, 139, 250, 0.22), 0 0 80px rgba(122, 162, 247, 0.12);
}

/* ===== Light theme overrides ===== */
[data-theme="light"] {
  --bg: #f7f7f5;
  --bg-2: #ffffff;
  --surface-1: #ffffff;
  --surface-2: #faf9f7;
  --surface-3: #f0efec;
  --surface-hover: #ecebe8;
  --border: #e4e3df;
  --border-strong: #d1d0cb;
  --border-glow: rgba(139, 92, 246, 0.18);

  --text: #18181b;
  --text-muted: #52525b;
  --text-dim: #71717a;
  --text-faint: #a1a1aa;

  --accent-soft: rgba(139, 92, 246, 0.10);
  --accent-softer: rgba(139, 92, 246, 0.05);

  --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.06);
  --shadow-md: 0 2px 12px rgba(20, 20, 30, 0.06), 0 1px 2px rgba(20, 20, 30, 0.04);
  --shadow-lg: 0 8px 32px rgba(20, 20, 30, 0.10), 0 2px 8px rgba(20, 20, 30, 0.06);
  --shadow-glow: 0 0 24px rgba(139, 92, 246, 0.18);
}

/* ===== Density ===== */
[data-density="compact"] {
  --gap: 12px;
  --gap-sm: 8px;
  --gap-lg: 18px;
  --row-pad-y: 10px;
  --row-pad-x: 14px;
}
[data-density="spacious"] {
  --gap: 20px;
  --gap-sm: 14px;
  --gap-lg: 32px;
  --row-pad-y: 18px;
  --row-pad-x: 22px;
}

/* ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
  letter-spacing: -0.005em;
  overflow: hidden;
}

#root { height: 100vh; display: flex; flex-direction: column; min-width: 1320px; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: content-box; border: 2px solid transparent; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-size: 13px; font-weight: 500;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(0.5px); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.subtle { background: var(--surface-1); }
.btn.primary {
  background: var(--accent-grad); border-color: transparent; color: #0c0a1a;
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: rgba(248,113,113,0.3); background: var(--danger-soft); }
.btn.icon { padding: 6px; }
.btn.sm { padding: 4px 8px; font-size: 12px; border-radius: var(--r-sm); }
.btn.lg { padding: 10px 16px; font-size: 14px; }

/* ===== Pills / Chips ===== */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.pill.accent { background: var(--accent-soft); border-color: var(--accent-ring); color: var(--accent); }
.pill.success { background: var(--success-soft); border-color: rgba(52,211,153,0.3); color: var(--success); }
.pill.warning { background: var(--warning-soft); border-color: rgba(251,191,36,0.3); color: var(--warning); }
.pill.danger { background: var(--danger-soft); border-color: rgba(248,113,113,0.3); color: var(--danger); }
.pill.info { background: var(--info-soft); border-color: rgba(96,165,250,0.3); color: var(--info); }

/* ===== Cards ===== */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.card.elev { box-shadow: var(--shadow-md); }

/* ===== Inputs ===== */
.input, .search-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-md);
  padding: 8px 12px;
  font: inherit; font-size: 13px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  width: 100%;
}
.input:focus, .search-input:focus {
  border-color: var(--accent-ring);
  box-shadow: 0 0 0 3px var(--accent-softer);
}

/* ===== Utilities ===== */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.flex-1 { flex: 1; min-width: 0; min-height: 0; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--font-mono); font-feature-settings: "ss01", "zero"; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { height: 1px; background: var(--border); }
.v-divider { width: 1px; background: var(--border); align-self: stretch; }

/* ===== Live dot ===== */
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.18);
  animation: pulse 1.6s ease-in-out infinite;
  display: inline-block;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.18); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.06); }
}

/* ===== AI Orb (signature element) ===== */
.ai-orb {
  position: relative;
  display: inline-block;
  background: radial-gradient(circle at 30% 30%, #c4b5fd 0%, #8b5cf6 40%, #4c1d95 80%, #1e1b4b 100%);
  border-radius: 50%;
  box-shadow:
    inset 0 0 12px rgba(255,255,255,0.2),
    inset 6px -6px 18px rgba(76, 29, 149, 0.5),
    0 0 24px rgba(167, 139, 250, 0.35),
    0 0 56px rgba(122, 162, 247, 0.18);
  overflow: hidden;
}
.ai-orb::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(167,139,250,0.4) 90deg, transparent 180deg, rgba(122,162,247,0.4) 270deg, transparent 360deg);
  animation: spin 8s linear infinite;
  opacity: 0.5;
}
.ai-orb::after {
  content: "";
  position: absolute;
  top: 12%; left: 18%;
  width: 30%; height: 30%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.6), transparent 70%);
}
.ai-orb.listening {
  animation: orb-breathe 2.4s ease-in-out infinite;
}
@keyframes orb-breathe {
  0%, 100% { transform: scale(1); box-shadow: inset 0 0 12px rgba(255,255,255,0.2), inset 6px -6px 18px rgba(76, 29, 149, 0.5), 0 0 24px rgba(167, 139, 250, 0.35), 0 0 56px rgba(122, 162, 247, 0.18); }
  50% { transform: scale(1.04); box-shadow: inset 0 0 14px rgba(255,255,255,0.25), inset 6px -6px 18px rgba(76, 29, 149, 0.5), 0 0 32px rgba(167, 139, 250, 0.55), 0 0 80px rgba(122, 162, 247, 0.28); }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Indeterminate loading bar ===== */
.loadbar-track {
  position: relative;
  width: 100%;
  height: 3px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.loadbar-track::before {
  content: "";
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 40%;
  background: var(--accent-grad, linear-gradient(90deg, #a78bfa, #7aa2f7));
  border-radius: 999px;
  animation: loadbar 1.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes loadbar {
  0%   { transform: translateX(-100%); }
  50%  { transform: translateX(120%); }
  100% { transform: translateX(260%); }
}

/* ===== Shimmer (skeleton lines while generating) ===== */
.shimmer {
  background: linear-gradient(90deg,
    var(--surface-2) 0%,
    var(--surface-3) 40%,
    var(--surface-2) 80%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Spinner ===== */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}
.spinner.sm { width: 11px; height: 11px; border-width: 1.5px; }
.spinner.lg { width: 22px; height: 22px; border-width: 2.5px; }

/* ===== Typing dots (avatar chat) ===== */
.typing-dot { display: inline-block; animation: typing-bounce 1s ease-in-out infinite; }
@keyframes typing-bounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ===== Avatars ===== */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.01em;
  position: relative;
  background: var(--surface-3);
}
.avatar.ring {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px currentColor;
}
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }
.avatar.md { width: 32px; height: 32px; font-size: 12px; }
.avatar.lg { width: 44px; height: 44px; font-size: 14px; }
.avatar.xl { width: 64px; height: 64px; font-size: 22px; }

/* ===== Gradient text ===== */
.grad-text {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ===== Streaming text "typewriter caret" ===== */
.streaming-caret::after {
  content: "▍";
  color: var(--accent);
  margin-left: 2px;
  animation: caret-blink 0.9s steps(2) infinite;
}
@keyframes caret-blink { 50% { opacity: 0; } }

/* ===== Fade-in for streaming utterances ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-up { opacity: 1; animation: fadeUp 350ms cubic-bezier(0.16, 1, 0.3, 1); }

/* ===== Slide-in for AI insights ===== */
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}
.slide-in { opacity: 1; animation: slideInRight 400ms cubic-bezier(0.16, 1, 0.3, 1); }

/* ===== Section labels ===== */
.section-label {
  text-transform: uppercase;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

/* ===== Headings ===== */
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }
p { margin: 0; }

/* ===== Layout primitives ===== */
.app-shell { display: flex; flex: 1; min-height: 0; }
.main-scroll { flex: 1; min-height: 0; overflow-y: auto; }

/* ===== Top bar ===== */
.topbar {
  height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}

/* ===== Sidebar nav ===== */
.sidebar {
  width: 68px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 4px;
  flex-shrink: 0;
}
.sidebar .nav-item {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  color: var(--text-dim);
  cursor: pointer;
  position: relative;
  transition: all 120ms ease;
}
.sidebar .nav-item:hover { background: var(--surface-2); color: var(--text); }
.sidebar .nav-item.active { background: var(--accent-soft); color: var(--accent); }
.sidebar .nav-item.active::before {
  content: ""; position: absolute; left: -14px; top: 12px; bottom: 12px; width: 2px;
  background: var(--accent-grad); border-radius: 999px;
}
.sidebar .nav-item .label {
  position: absolute; left: 56px; top: 50%; transform: translateY(-50%);
  background: var(--surface-3); border: 1px solid var(--border);
  padding: 4px 8px; border-radius: var(--r-sm);
  font-size: 12px; color: var(--text);
  opacity: 0; pointer-events: none;
  white-space: nowrap;
  transition: opacity 120ms ease;
  z-index: 10;
}
.sidebar .nav-item:hover .label { opacity: 1; }

/* ===== Logo ===== */
.logo-wrap {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-grad);
  color: #0c0a1a;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 6px;
  letter-spacing: -0.04em;
}

/* ===== Tweaks panel ambient overrides (matches our tokens) ===== */
:where(.tweaks-panel) {
  --tw-bg: var(--surface-1);
  --tw-border: var(--border);
  --tw-text: var(--text);
}
