:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --bg-base: #0a0c10;
  --bg-sidebar: #10131b;
  --bg-topbar: rgba(16, 19, 27, 0.88);
  --bg-card: #141824;
  --bg-card-elevated: #1a1f2e;
  --bg-card-hover: #1e2436;
  --bg-input: #121622;
  --border-subtle: #222838;
  --border-focus: #6366f1;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.3);
  --secondary: #1e2436;
  --secondary-hover: #293147;
  
  --accent-teal: #14b8a6;
  --accent-cyan: #06b6d4;
  --accent-purple: #a855f7;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-emerald: #10b981;
  
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
  --topbar-height: 64px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-base);
  color: var(--text-main);
  overflow-x: hidden;
  min-height: 100vh;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ---------- Loading animation (js/ui/loader.js) ---------- */
.rf-loader { flex: none; display: inline-block; }
.rf-loader svg { display: block; }
/* Without lottie-web, or before it loads: a still brand-gradient ring. */
.rf-loader-fallback {
  border-radius: 50%;
  background: conic-gradient(#6366f1, #8b5cf6, #ec4899, #6366f1);
  -webkit-mask: radial-gradient(farthest-side, transparent 62%, #000 64%);
  mask: radial-gradient(farthest-side, transparent 62%, #000 64%);
}
.rf-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 28px 12px; }
.rf-loading-text { font-size: 13px; color: var(--text-muted); text-align: center; }
.rf-loading-row { display: flex; align-items: center; gap: 10px; }
.rf-loading-row[hidden] { display: none; }

/* Start-up screen */
.app-loader {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at top, rgba(99, 102, 241, 0.18), transparent 60%), #04070d;
  transition: opacity 0.35s ease;
}
.app-loader.done { opacity: 0; pointer-events: none; }
.app-loader-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.app-loader-brand { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; color: #f8fafc; }
.app-loader-brand span {
  background: linear-gradient(120deg, #a5b4fc, #c4b5fd 40%, #f9a8d4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
@media (prefers-reduced-motion: reduce) {
  .app-loader { transition: none; }
}
/* Button spinners play the loader instead of the old border ring. */
.spinner.rf-loader { border: 0; border-radius: 0; animation: none; vertical-align: -3px; }
.spinner.rf-loader-fallback { border-radius: 50%; }
/* Status lines while loading: the loader in front of the message. */
.status-line.loading { display: flex; align-items: center; gap: 8px; }
.status-line.loading .rf-loader { flex: none; }
/* Inside buttons the ring is white, so it stays visible on the brand-gradient buttons. */
.btn .spinner.rf-loader svg path { fill: #fff; }
.btn .spinner.rf-loader-fallback { background: #fff; }
