/* =====================================================================
   FFT Robot — design tokens
   Dark is the default. Light is applied with <html data-theme="light">.
   ===================================================================== */
:root {
  color-scheme: dark;
  --bg: #000000;
  --text: #f4f7fb;
  --muted: #8b96a8;
  --line: rgba(255, 215, 0, 0.15);

  --mesh:
    radial-gradient(1200px 600px at 80% -10%, rgba(255, 215, 0, 0.15), transparent 55%),
    radial-gradient(800px 500px at 0% 10%, rgba(255, 215, 0, 0.1), transparent 50%),
    radial-gradient(700px 400px at 50% 100%, rgba(255, 215, 0, 0.08), transparent 50%),
    #000000;

  --header-bg: rgba(0, 0, 0, 0.85);
  --glass-top: rgba(255, 255, 255, 0.07);
  --glass-bottom: rgba(255, 255, 255, 0.03);
  --glass-strong: rgba(10, 10, 10, 0.85);
  --input-bg: rgba(255, 255, 255, 0.04);
  --placeholder: #7d8798;
  --ghost-bg: rgba(255, 255, 255, 0.05);
  --seg-bg: rgba(255, 255, 255, 0.05);
  --seg-on-bg: rgba(255, 215, 0, 0.15);
  --seg-on-text: #FFD700;
  --track: rgba(255, 255, 255, 0.06);
  --tab-text: #7d8798;
  --tab-active-text: #FFD700;
  --tab-active-bg: rgba(255, 215, 0, 0.16);
  --tab-active-icon: #FFD700;
  --option-bg: #0d1422;
  --chip-shadow: none;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar: 72px;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f0;
  --text: #1a1a1a;
  --muted: #64748b;
  --line: rgba(218, 165, 32, 0.15);

  --mesh:
    radial-gradient(1000px 520px at 85% -12%, rgba(218, 165, 32, 0.08), transparent 60%),
    radial-gradient(700px 420px at 0% 6%, rgba(218, 165, 32, 0.06), transparent 55%),
    linear-gradient(#fafaf8, #f0f0e8);

  --header-bg: rgba(245, 245, 240, 0.9);
  --glass-top: #ffffff;
  --glass-bottom: #ffffff;
  --glass-strong: rgba(255, 255, 255, 0.95);
  --input-bg: #ffffff;
  --placeholder: #94a3b8;
  --ghost-bg: #ffffff;
  --seg-bg: #e8e8e0;
  --seg-on-bg: #ffffff;
  --seg-on-text: #DAA520;
  --track: #e2e8f0;
  --tab-text: #64748b;
  --tab-active-text: #DAA520;
  --tab-active-bg: rgba(218, 165, 32, 0.1);
  --tab-active-icon: #DAA520;
  --option-bg: #ffffff;
}

* { -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  min-height: 100%;
}
body { transition: background-color .25s ease, color .25s ease; }
body.app-shell { overscroll-behavior-y: none; }

.num {
  font-family: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

.bg-mesh { background: var(--mesh); }

/* ---------- Surfaces ---------- */
.glass {
  background: linear-gradient(180deg, var(--glass-top), var(--glass-bottom));
  border: 1px solid var(--line);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}
.glass-strong {
  background: var(--glass-strong);
  border: 1px solid var(--line);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
}
html[data-theme="light"] .glass-strong {
  box-shadow: 0 10px 30px -8px rgba(15, 23, 42, 0.18), 0 2px 6px rgba(15, 23, 42, 0.05);
}

.card-press { transition: transform .18s ease, border-color .18s ease, background .18s ease; }
.card-press:active { transform: scale(0.98); }

/* ---------- Buttons ---------- */
.native-btn {
  min-height: 52px;
  border-radius: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: transform .15s ease, opacity .15s ease, box-shadow .15s ease, background .2s ease;
}
.native-btn:active { transform: scale(0.98); }
.native-btn.btn-sm {
  min-height: 40px;
  border-radius: 14px;
  padding: 0 16px;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  flex-shrink: 0;
  object-fit: cover;
  overflow: hidden;
  background: linear-gradient(145deg, #60a5fa, #1d4ed8);
  color: #fff;
  font-weight: 800;
  line-height: 1;
  border: 2px solid rgba(255, 255, 255, 0.14);
}
.avatar-fallback { user-select: none; }
html[data-theme="light"] .avatar { border-color: rgba(15, 23, 42, 0.08); }
.btn-blue {
  background: linear-gradient(180deg, #FFD700 0%, #DAA520 100%);
  box-shadow: 0 10px 28px rgba(255, 215, 0, 0.32);
  color: #000000;
}
html[data-theme="light"] .btn-blue {
  background: linear-gradient(180deg, #FFD700 0%, #DAA520 100%);
  box-shadow: 0 8px 22px rgba(218, 165, 32, 0.28);
  color: #000000;
}
.btn-gold {
  background: linear-gradient(180deg, #FFD700 0%, #DAA520 100%);
  box-shadow: 0 10px 28px rgba(255, 215, 0, 0.25);
  color: #000000;
}
.btn-ghost {
  background: var(--ghost-bg);
  border: 1px solid var(--line);
  color: var(--text);
}
html[data-theme="light"] .btn-ghost { box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05); }

/* ---------- Navigation ---------- */
.tabbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(10px + var(--safe-bottom));
  height: 64px;
  border-radius: 22px;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 6px;
}
.tabbar a {
  flex: 1;
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 650;
  color: var(--tab-text);
  border-radius: 16px;
  transition: .18s ease;
}
.tabbar a.is-active { color: var(--tab-active-text); background: var(--tab-active-bg); }
.tabbar a.is-active svg { color: var(--tab-active-icon); }

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: var(--safe-top);
  background: var(--header-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid transparent;
}

.page-enter { animation: rise .42s cubic-bezier(.22,1,.36,1); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.pulse-dot {
  width: 8px; height: 8px; border-radius: 99px;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34,197,94,.6);
  animation: pulse 1.8s infinite;
}
.pulse-dot.off { background: #f43f5e; box-shadow: none; animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34,197,94,.55); }
  70% { box-shadow: 0 0 0 10px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* ---------- Controls ---------- */
.seg {
  display: flex;
  padding: 4px;
  border-radius: 14px;
  background: var(--seg-bg);
  border: 1px solid var(--line);
}
.seg button, .seg a {
  flex: 1;
  text-align: center;
  padding: 8px 6px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  transition: background .18s ease, color .18s ease;
}
.seg .on { background: var(--seg-on-bg); color: var(--seg-on-text); }
html[data-theme="light"] .seg .on { box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12); }

.progress-track { height: 10px; border-radius: 99px; background: var(--track); overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #2563eb, #60a5fa); }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 99px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.input-native {
  width: 100%;
  min-height: 52px;
  border-radius: 16px;
  background: var(--input-bg);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0 16px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .2s ease;
}
.input-native::placeholder { color: var(--placeholder); }
.input-native:focus {
  border-color: rgba(255, 215, 0, 0.7);
  box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.15);
}
html[data-theme="light"] .input-native { box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04); }
html[data-theme="light"] .input-native:focus { border-color: #FFD700; box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.14); }
.input-native:-webkit-autofill { -webkit-text-fill-color: var(--text); transition: background-color 9999s; }

select.input-native {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238b96a8' stroke-width='2'%3E%3Cpath d='m3 6 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}
select.input-native option { background: var(--option-bg); color: var(--text); }
textarea.input-native { min-height: 96px; }
input[type="datetime-local"].input-native { color-scheme: dark; }
html[data-theme="light"] input[type="datetime-local"].input-native { color-scheme: light; }

/* Theme toggle button (sun in dark, moon in light) */
.ico-moon { display: none; }
html[data-theme="light"] .ico-sun { display: none; }
html[data-theme="light"] .ico-moon { display: block; }
.ico-btn { color: var(--text); transition: background .2s ease, transform .15s ease; }
.ico-btn:active { transform: scale(0.94); }

.hairline { border-color: var(--line) !important; }
.hide-scroll::-webkit-scrollbar { display: none; }
.hide-scroll { -ms-overflow-style: none; scrollbar-width: none; }
.safe-pad { padding-bottom: calc(var(--tabbar) + var(--safe-bottom) + 18px); }

.hero-orb {
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 999px;
  filter: blur(40px);
  opacity: .45;
  pointer-events: none;
}
html[data-theme="light"] .hero-orb { opacity: .16; }

.shimmer {
  background: linear-gradient(110deg, transparent 20%, rgba(255,255,255,.08) 45%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 2.8s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

@media (min-width: 1024px) {
  .tabbar { left: 50%; right: auto; width: 420px; transform: translateX(-50%); }
}

/* =====================================================================
   LIGHT THEME — remaps the Tailwind utilities used across the templates
   (specificity html[data-theme] + .class beats the CDN's single .class)
   ===================================================================== */

/* Cards: white surfaces with a soft, layered shadow instead of translucent glass */
html[data-theme="light"] [class*="bg-white/[0.0"] {
  background-color: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -10px rgba(15, 23, 42, 0.1);
}
/* Raised-on-card chips and rows */
html[data-theme="light"] .bg-white\/5 { background-color: #eef2f7; }
html[data-theme="light"] .bg-white\/10 { background-color: #e2e8f0; }
html[data-theme="light"] .bg-black\/20 { background-color: #eef2f7; }
html[data-theme="light"] .hover\:bg-white\/5:hover { background-color: #eef2f7; }
html[data-theme="light"] .bg-gradient-to-br.from-blue-600\/20 {
  background-image: linear-gradient(135deg, #fff9e6 0%, #ffffff 70%);
}

/* Borders and dividers */
html[data-theme="light"] .border-white\/10 { border-color: var(--line); }
html[data-theme="light"] .border-white\/5 { border-color: rgba(15, 23, 42, 0.06); }
html[data-theme="light"] .divide-white\/10 > :not([hidden]) ~ :not([hidden]) { border-color: var(--line); }
html[data-theme="light"] .divide-white\/5 > :not([hidden]) ~ :not([hidden]) { border-color: rgba(15, 23, 42, 0.06); }
html[data-theme="light"] .border-rose-500\/30 { border-color: rgba(225, 29, 72, 0.28); }
html[data-theme="light"] .border-emerald-500\/30,
html[data-theme="light"] .border-emerald-400\/25 { border-color: rgba(5, 150, 105, 0.3); }
html[data-theme="light"] .border-blue-400\/20 { border-color: rgba(218, 165, 32, 0.2); }
html[data-theme="light"] .border-blue-400\/25 { border-color: rgba(218, 165, 32, 0.25); }
html[data-theme="light"] .border-blue-400\/30 { border-color: rgba(218, 165, 32, 0.3); }
html[data-theme="light"] .border-blue-400\/40 { border-color: rgba(218, 165, 32, 0.45); }
html[data-theme="light"] .border-amber-400\/20 { border-color: rgba(218, 165, 32, 0.25); }
html[data-theme="light"] .border-amber-400\/30 { border-color: rgba(218, 165, 32, 0.35); }
html[data-theme="light"] .border-fft-gold\/35 { border-color: rgba(218, 165, 32, 0.42); }

/* Tinted surfaces (status chips, alerts, callouts) */
html[data-theme="light"] .bg-blue-500\/5 { background-color: rgba(218, 165, 32, 0.05); }
html[data-theme="light"] .bg-blue-500\/10 { background-color: rgba(218, 165, 32, 0.08); }
html[data-theme="light"] .bg-blue-500\/15 { background-color: rgba(218, 165, 32, 0.1); }
html[data-theme="light"] .bg-blue-500\/20 { background-color: rgba(218, 165, 32, 0.13); }
html[data-theme="light"] .bg-emerald-500\/10 { background-color: rgba(5, 150, 105, 0.08); }
html[data-theme="light"] .bg-emerald-500\/15 { background-color: rgba(5, 150, 105, 0.12); }
html[data-theme="light"] .bg-rose-500\/10 { background-color: rgba(225, 29, 72, 0.07); }
html[data-theme="light"] .bg-rose-500\/15 { background-color: rgba(225, 29, 72, 0.1); }
html[data-theme="light"] .bg-amber-500\/10 { background-color: rgba(217, 119, 6, 0.09); }
html[data-theme="light"] .bg-amber-500\/15 { background-color: rgba(217, 119, 6, 0.13); }
html[data-theme="light"] .bg-fft-gold\/15 { background-color: rgba(166, 124, 0, 0.12); }
/* tinted callouts must not pick up the white-card shadow rule */
html[data-theme="light"] [class*="bg-rose-500/10"],
html[data-theme="light"] [class*="bg-amber-500/10"],
html[data-theme="light"] [class*="bg-emerald-500/10"] { box-shadow: none; }

/* Text */
html[data-theme="light"] .text-white,
html[data-theme="light"] .hover\:text-white:hover { color: var(--text); }
html[data-theme="light"] .bg-blue-500.text-white,
html[data-theme="light"] .btn-blue .text-white { color: #000000; }
html[data-theme="light"] .text-slate-200 { color: #1e293b; }
html[data-theme="light"] .text-slate-300 { color: #334155; }
html[data-theme="light"] .text-slate-400 { color: #475569; }
html[data-theme="light"] .text-slate-500 { color: #64748b; }
html[data-theme="light"] .text-slate-600 { color: #94a3b8; }
html[data-theme="light"] .text-blue-100 { color: #1e40af; }
html[data-theme="light"] .text-blue-200 { color: #1d4ed8; }
html[data-theme="light"] .text-blue-300 { color: #DAA520; }
html[data-theme="light"] .text-emerald-100 { color: #065f46; }
html[data-theme="light"] .text-emerald-200 { color: #047857; }
html[data-theme="light"] .text-emerald-300,
html[data-theme="light"] .text-emerald-400 { color: #059669; }
html[data-theme="light"] .text-rose-100 { color: #9f1239; }
html[data-theme="light"] .text-rose-100\/70 { color: rgba(159, 18, 57, 0.78); }
html[data-theme="light"] .text-rose-200 { color: #be123c; }
html[data-theme="light"] .text-rose-300,
html[data-theme="light"] .text-rose-400 { color: #e11d48; }
html[data-theme="light"] .text-amber-50 { color: #78350f; }
html[data-theme="light"] .text-amber-50\/80 { color: rgba(120, 53, 15, 0.88); }
html[data-theme="light"] .text-amber-100 { color: #92400e; }
html[data-theme="light"] .text-amber-200 { color: #b45309; }
html[data-theme="light"] .text-fft-gold { color: #a67c00; }
html[data-theme="light"] .btn-gold { color: #1a1403; }
html[data-theme="light"] .btn-ghost.text-rose-200 { color: #be123c; }

/* Print / forced-light pages */
@media print { .tabbar, .app-header, [data-theme-toggle] { display: none !important; } }

/* =====================================================================
   FFT Preloader & Loading Indicator System
   ===================================================================== */

/* 1. Top Global Glowing Progress Bar */
#fft-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, #DAA520, #FFD700, #FFF099);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.85), 0 0 5px rgba(255, 215, 0, 0.5);
  z-index: 999999;
  transition: width 0.25s cubic-bezier(0.1, 0.9, 0.2, 1), opacity 0.3s ease;
  pointer-events: none;
}

#fft-progress-bar.is-finished {
  opacity: 0;
  width: 100% !important;
}

/* 2. Full-Screen Backdrop Preloader Overlay */
.fft-preloader-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 999998;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
  pointer-events: none;
}

html[data-theme="light"] .fft-preloader-backdrop {
  background: rgba(245, 245, 240, 0.72);
}

.fft-preloader-backdrop.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.fft-preloader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 26px 36px;
  border-radius: 26px;
  background: rgba(14, 14, 14, 0.94);
  border: 1px solid rgba(255, 215, 0, 0.25);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75), 0 0 35px rgba(255, 215, 0, 0.15);
  transform: scale(0.9);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

html[data-theme="light"] .fft-preloader-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(218, 165, 32, 0.35);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.14), 0 0 25px rgba(218, 165, 32, 0.15);
}

.fft-preloader-backdrop.is-active .fft-preloader-card {
  transform: scale(1);
}

.fft-spinner-ring {
  width: 48px;
  height: 48px;
  position: relative;
}

.fft-spinner-svg {
  width: 100%;
  height: 100%;
  animation: fft-spin 1s linear infinite;
  transform-origin: center center;
}

.fft-spinner-track {
  stroke: rgba(255, 215, 0, 0.16);
}

html[data-theme="light"] .fft-spinner-track {
  stroke: rgba(218, 165, 32, 0.2);
}

.fft-spinner-circle {
  stroke: #FFD700;
  stroke-linecap: round;
  stroke-dasharray: 90, 150;
  stroke-dashoffset: 0;
  animation: fft-spinner-dash 1.4s ease-in-out infinite;
}

html[data-theme="light"] .fft-spinner-circle {
  stroke: #DAA520;
}

.fft-preloader-text {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #FFD700;
}

html[data-theme="light"] .fft-preloader-text {
  color: #b8860b;
}

/* 3. Button Preloader (.is-loading) */
.is-loading,
button.is-loading,
.native-btn.is-loading,
a.native-btn.is-loading {
  position: relative !important;
  color: transparent !important;
  pointer-events: none !important;
  cursor: wait !important;
}

.is-loading > * {
  opacity: 0 !important;
  visibility: hidden !important;
}

.is-loading::after,
button.is-loading::after,
.native-btn.is-loading::after,
a.native-btn.is-loading::after {
  content: "" !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  width: 22px !important;
  height: 22px !important;
  margin-top: -11px !important;
  margin-left: -11px !important;
  border-radius: 50% !important;
  border: 2.5px solid rgba(0, 0, 0, 0.88) !important;
  border-top-color: transparent !important;
  animation: fft-spin 0.65s linear infinite !important;
  box-sizing: border-box !important;
  z-index: 10 !important;
}

/* Gold / Blue buttons: dark spinner */
.btn-blue.is-loading::after,
.btn-gold.is-loading::after {
  border-color: rgba(0, 0, 0, 0.88) !important;
  border-top-color: transparent !important;
}

/* Ghost / dark buttons: gold spinner */
.btn-ghost.is-loading::after,
button:not(.btn-blue):not(.btn-gold).is-loading::after,
a.native-btn:not(.btn-blue):not(.btn-gold).is-loading::after {
  border-color: #FFD700 !important;
  border-top-color: transparent !important;
}

html[data-theme="light"] .btn-ghost.is-loading::after,
html[data-theme="light"] button:not(.btn-blue):not(.btn-gold).is-loading::after,
html[data-theme="light"] a.native-btn:not(.btn-blue):not(.btn-gold).is-loading::after {
  border-color: #DAA520 !important;
  border-top-color: transparent !important;
}

.btn-sm.is-loading::after,
.ico-btn.is-loading::after {
  width: 16px !important;
  height: 16px !important;
  margin-top: -8px !important;
  margin-left: -8px !important;
  border-width: 2px !important;
}

/* 4. Click Ripple Effect */
.fft-click-ripple {
  position: fixed;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.45) 0%, rgba(255, 215, 0, 0) 70%);
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
  animation: fft-ripple-fade 0.45s ease-out forwards;
  z-index: 999997;
}

@keyframes fft-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes fft-spinner-dash {
  0% {
    stroke-dasharray: 1, 150;
    stroke-dashoffset: 0;
  }
  50% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -35;
  }
  100% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -124;
  }
}

@keyframes fft-ripple-fade {
  0% {
    width: 0px;
    height: 0px;
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(0);
  }
  100% {
    width: 130px;
    height: 130px;
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
  }
}
