/* styles.css - fasterwayai SaaS Platform - Mobile-First Professional Design */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@600;700;800&display=swap');

:root {
  --color-primary: #004ac6;
  --color-primary-container: #2563eb;
  --color-on-primary: #ffffff;
  --color-surface: #f7f9fb;
  --color-surface-container: #eceef0;
  --color-surface-container-low: #f2f4f6;
  --color-surface-container-high: #e6e8ea;
  --color-surface-lowest: #ffffff;
  --color-on-surface: #191c1e;
  --color-on-surface-variant: #434655;
  --color-outline: #737686;
  --color-outline-variant: #c3c6d7;
  --font-headline: 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Inter', sans-serif;
  --bottom-nav-height: 64px;
  --header-height: 56px;
}

/* Shared brand lockup: keeps the mark optically aligned with the wordmark
   everywhere it appears (header, auth, footer, and compact mobile layouts). */
.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-width: max-content;
}

.brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 4px 8px rgb(37 99 235 / .14));
  transition: transform .2s ease, filter .2s ease;
}

.brand-lockup:hover .brand-mark {
  transform: scale(1.05);
  filter: drop-shadow(0 5px 10px rgb(37 99 235 / .22));
}

.brand-name {
  font-family: var(--font-headline);
  font-weight: 800;
  letter-spacing: -.025em;
  white-space: nowrap;
}

@media (max-width: 420px) {
  .brand-mark { width: 2rem; height: 2rem; }
  .brand-name { font-size: 1rem; }
}

/* =====================================================
   BASE RESET & GLOBAL MOBILE RULES
   ===================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-surface);
  color: var(--color-on-surface);
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
  /* Prevent content from being hidden behind bottom nav on mobile */
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 16px);
}

main, .view-section {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

@media (min-width: 768px) {
  body {
    padding-bottom: 0;
  }
  :root {
    --header-height: 64px;
  }
}

/* Touch-friendly minimum tap targets */
button, a, input, select, textarea {
  -webkit-appearance: none;
  appearance: none;
}

button {
  cursor: pointer;
  min-height: 44px;
}

input, select, textarea {
  min-height: 44px;
  font-size: 16px; /* Prevents iOS zoom on focus */
  font-family: var(--font-body);
}

/* =====================================================
   CUSTOM SCROLLBAR
   ===================================================== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--color-surface-container-low); }
::-webkit-scrollbar-thumb { background: var(--color-outline-variant); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-outline); }

/* =====================================================
   GLASSMORPHISM HEADER
   ===================================================== */
.glass-nav {
  background: rgba(247, 249, 251, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.glass-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(195, 198, 215, 0.4);
}

/* =====================================================
   DYNAMIC AMBIENT LIGHTING & GLOW ANIMATIONS
   ===================================================== */
@keyframes ambientOrbFloat1 {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.45; }
  50% { transform: translate(40px, -30px) scale(1.15); opacity: 0.75; }
}

@keyframes ambientOrbFloat2 {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.35; }
  50% { transform: translate(-50px, 40px) scale(1.2); opacity: 0.65; }
}

@keyframes ambientOrbFloat3 {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.3; }
  50% { transform: translate(35px, 35px) scale(1.1); opacity: 0.6; }
}

.ambient-glow-orb {
  position: absolute;
  border-radius: 9999px;
  filter: blur(70px);
  pointer-events: none;
  z-index: 1;
}

@media (max-width: 768px) {
  .ambient-glow-orb {
    display: none !important;
  }
}

.ambient-glow-orb.orb-1 {
  top: -8rem;
  left: -6rem;
  width: 26rem;
  height: 26rem;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.38) 0%, rgba(56, 189, 248, 0.15) 70%, transparent 100%);
  animation: ambientOrbFloat1 8s infinite ease-in-out;
}

.ambient-glow-orb.orb-2 {
  top: 35%;
  right: -8rem;
  width: 28rem;
  height: 28rem;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.35) 0%, rgba(129, 140, 248, 0.2) 70%, transparent 100%);
  animation: ambientOrbFloat2 10s infinite ease-in-out;
}

.ambient-glow-orb.orb-3 {
  bottom: -6rem;
  left: 30%;
  width: 22rem;
  height: 22rem;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.28) 0%, rgba(37, 99, 235, 0.12) 70%, transparent 100%);
  animation: ambientOrbFloat3 9s infinite ease-in-out;
}

/* Animated Light Sweep Text Gradient */
@keyframes textLightSweep {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.animated-light-gradient {
  background: linear-gradient(135deg, #004ac6 0%, #2563eb 25%, #38bdf8 50%, #818cf8 75%, #004ac6 100%);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: textLightSweep 6s ease infinite;
}

/* Light Beam Card Aura */
@keyframes cardBeamGlow {
  0%, 100% { box-shadow: 0 10px 30px -10px rgba(37, 99, 235, 0.25), 0 0 15px rgba(56, 189, 248, 0.15); }
  50% { box-shadow: 0 15px 40px -5px rgba(37, 99, 235, 0.45), 0 0 25px rgba(56, 189, 248, 0.35); }
}

.light-beam-card {
  animation: cardBeamGlow 4s infinite ease-in-out;
  position: relative;
}

/* Glowing Lighting CTA Button */
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 15px rgba(37, 99, 235, 0.4), 0 4px 14px rgba(37, 99, 235, 0.3); }
  50% { box-shadow: 0 0 28px rgba(56, 189, 248, 0.65), 0 6px 20px rgba(37, 99, 235, 0.5); }
}

.glow-button-lighting {
  animation: pulseGlow 3s infinite ease-in-out;
}

/* Full Home Page Card Hover Lighting Effect */
.glow-card-hover {
  position: relative;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease, border-color 0.3s ease;
}

.glow-card-hover:hover {
  transform: translateY(-4px);
  border-color: rgba(37, 99, 235, 0.45) !important;
  box-shadow: 0 12px 32px -8px rgba(37, 99, 235, 0.25), 0 0 16px rgba(56, 189, 248, 0.15) !important;
}

/* Bottom CTA Banner Lighting Animation */
@keyframes bannerGlowPulse {
  0%, 100% {
    box-shadow: 0 20px 50px -10px rgba(37, 99, 235, 0.4), inset 0 0 40px rgba(255, 255, 255, 0.15);
  }
  50% {
    box-shadow: 0 25px 65px -5px rgba(56, 189, 248, 0.55), inset 0 0 60px rgba(255, 255, 255, 0.25);
  }
}

.animated-banner-lighting {
  animation: bannerGlowPulse 5s infinite ease-in-out;
}

/* Step Number Lighting Glow */
.step-number-glow {
  box-shadow: 0 0 16px rgba(37, 99, 235, 0.45);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.step-number-glow:hover {
  transform: scale(1.1);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.7);
}

/* =====================================================
   HEADER - MOBILE FIRST
   ===================================================== */
header {
  height: var(--header-height);
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 0.75rem;
  max-width: 1280px;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
}

/* HARD RULE: Desktop profile bar must NEVER show in mobile header */
@media (max-width: 767px) {
  #user-profile-bar {
    display: none !important;
  }
}

@media (min-width: 768px) {
  .header-inner {
    padding: 0 1.5rem;
  }
  #user-profile-bar:not(.hidden) {
    display: flex !important;
  }
}

/* =====================================================
   MOBILE HAMBURGER MENU BUTTON
   ===================================================== */
#btn-mobile-menu {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--color-surface-container-low);
  border: 1px solid var(--color-outline-variant);
  color: var(--color-on-surface);
  transition: background 0.2s;
  flex-shrink: 0;
}

#btn-mobile-menu:active {
  background: var(--color-surface-container-high);
  transform: scale(0.95);
}

@media (min-width: 768px) {
  #btn-mobile-menu {
    display: none;
  }
}

/* =====================================================
   MOBILE SLIDE-DOWN NAV DRAWER
   ===================================================== */
#mobile-nav-drawer {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--color-surface-lowest);
  border-bottom: 1px solid var(--color-outline-variant);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  pointer-events: none;
}

#mobile-nav-drawer.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}

.mobile-nav-links {
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  gap: 0.25rem;
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: 12px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-on-surface-variant);
  text-decoration: none;
  transition: all 0.15s ease;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
}

.mobile-nav-link:active,
.mobile-nav-link.active {
  background: #eff2ff;
  color: var(--color-primary);
  font-weight: 600;
}

.mobile-nav-link .material-symbols-outlined {
  font-size: 22px;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  #mobile-nav-drawer {
    display: none;
  }
}

/* Mobile nav backdrop overlay */
#mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(0,0,0,0.25);
}

#mobile-nav-overlay.open {
  display: block;
}

/* =====================================================
   DESKTOP NAV
   ===================================================== */
.desktop-nav {
  display: none;
}

@media (min-width: 768px) {
  .desktop-nav {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--color-surface-container-low);
    padding: 0.375rem;
    border-radius: 12px;
    border: 1px solid var(--color-surface-container);
  }
}

/* Desktop nav links */
.nav-link {
  transition: all 0.2s ease-in-out;
  border-radius: 8px;
  padding: 0.375rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-on-surface-variant);
  text-decoration: none;
  white-space: nowrap;
  min-height: 36px;
  display: flex;
  align-items: center;
}

.nav-link:hover {
  background: var(--color-surface-container);
  color: var(--color-on-surface);
}

.nav-link.active {
  background-color: #2563eb;
  color: #ffffff !important;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

/* =====================================================
   BOTTOM NAVIGATION BAR (MOBILE ONLY)
   ===================================================== */
#bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  height: var(--bottom-nav-height);
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--color-outline-variant);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  padding: 0 0.25rem;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (min-width: 768px) {
  #bottom-nav {
    display: none;
  }
}

.bottom-nav-item {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0.35rem 0.1rem;
  border: none;
  background: transparent;
  color: var(--color-on-surface-variant);
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.2s ease;
  min-height: auto;
  position: relative;
}

.bottom-nav-item .material-symbols-outlined {
  font-size: 22px;
  transition: all 0.2s ease;
}

.bottom-nav-item.active {
  color: var(--color-primary);
}

.bottom-nav-item.active .nav-icon-bg {
  background: #dbe4ff;
  transform: scaleX(1);
}

.bottom-nav-item:active {
  transform: scale(0.92);
}

.nav-icon-bg {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 26px;
  border-radius: 13px;
  background: transparent;
  transform: scaleX(0.7);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.bottom-nav-item.active .nav-icon-bg {
  background: #dbe4ff;
  transform: scaleX(1);
}

.nav-label {
  font-size: 0.65rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Dark mode bottom navbar */
body.dark #bottom-nav,
body.dark-theme #bottom-nav,
[data-theme="dark"] #bottom-nav {
  background: rgba(18, 20, 24, 0.96) !important;
  border-top-color: rgba(51, 65, 85, 0.8) !important;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4) !important;
}

body.dark .bottom-nav-item.active .nav-icon-bg,
body.dark-theme .bottom-nav-item.active .nav-icon-bg,
[data-theme="dark"] .bottom-nav-item.active .nav-icon-bg {
  background: #1e3a8a !important;
  color: #93c5fd !important;
}

/* =====================================================
   MAIN CONTENT OFFSET
   ===================================================== */
main {
  padding-top: var(--header-height);
}

/* =====================================================
   LANDING PAGE - MOBILE
   ===================================================== */
.hero-section {
  padding: 2rem 1rem 3rem;
}

@media (min-width: 640px) {
  .hero-section {
    padding: 3rem 1.5rem 4rem;
  }
}

@media (min-width: 1024px) {
  .hero-section {
    padding: 4rem 2rem 5rem;
  }
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1.5rem;
}

.hero-title {
  font-family: var(--font-headline);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.1;
  font-size: 2.25rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 640px) {
  .hero-title { font-size: 3rem; }
}

@media (min-width: 1024px) {
  .hero-title { font-size: 3.75rem; }
}

.hero-subtitle {
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 2rem;
}

@media (min-width: 640px) {
  .hero-subtitle { font-size: 1.125rem; }
}

/* CTA Buttons */
.hero-cta-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}

@media (min-width: 480px) {
  .hero-cta-group {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
}

.btn-primary-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 2rem;
  background: var(--color-primary);
  color: #fff;
  border-radius: 16px;
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 1rem;
  border: none;
  box-shadow: 0 4px 16px rgba(0, 74, 198, 0.3);
  transition: all 0.2s ease;
  min-height: 52px;
}

.btn-primary-cta:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(0, 74, 198, 0.2);
}

.btn-secondary-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 2rem;
  background: var(--color-surface-container-high);
  color: var(--color-on-surface);
  border-radius: 16px;
  font-family: var(--font-headline);
  font-weight: 600;
  font-size: 1rem;
  border: 1px solid var(--color-surface-container);
  transition: all 0.2s ease;
  min-height: 52px;
}

.btn-secondary-cta:active {
  transform: scale(0.97);
}

/* Feature Cards Grid */
.feature-cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  text-align: left;
}

@media (min-width: 640px) {
  .feature-cards-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* =====================================================
   EMAIL GENERATOR VIEW - MOBILE
   ===================================================== */
.workspace-header {
  padding: 1.25rem 1rem 0;
}

@media (min-width: 768px) {
  .workspace-header {
    padding: 2rem 1.5rem 0;
  }
}

.workspace-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1rem;
}

@media (min-width: 1024px) {
  .workspace-grid {
    grid-template-columns: 5fr 7fr;
    gap: 2rem;
    padding: 2rem 1.5rem;
  }
}

/* Mobile tabs for email generator (Form / Preview) */
.mobile-workspace-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0 1rem;
  margin-bottom: -1px;
}

@media (min-width: 1024px) {
  .mobile-workspace-tabs {
    display: none;
  }
}

.workspace-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-on-surface-variant);
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 10px 10px 0 0;
  min-height: 44px;
}

.workspace-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  background: rgba(0, 74, 198, 0.05);
}

/* Mobile panel visibility */
.workspace-panel-form,
.workspace-panel-preview {
  transition: opacity 0.25s ease;
}

@media (max-width: 1023px) {
  .workspace-panel-form.hidden-mobile,
  .workspace-panel-preview.hidden-mobile {
    display: none;
  }
}

/* =====================================================
   FORM ELEMENTS - MOBILE TOUCH FRIENDLY
   ===================================================== */
.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-on-surface);
  margin-bottom: 0.375rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1.5px solid var(--color-outline-variant);
  background: var(--color-surface-lowest);
  font-size: 16px; /* Prevent iOS zoom */
  font-family: var(--font-body);
  color: var(--color-on-surface);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 48px;
}

.form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 74, 198, 0.12);
}

.form-input::placeholder {
  color: var(--color-outline);
  font-size: 0.875rem;
}

/* Tone pills - touch friendly */
.tone-pill {
  padding: 0.5rem 0.875rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1.5px solid transparent;
  transition: all 0.15s ease;
  min-height: 36px;
  display: flex;
  align-items: center;
}

.tone-pill:active {
  transform: scale(0.95);
}

/* Length buttons - touch friendly */
.length-btn {
  padding: 0.625rem 0.75rem;
  border-radius: 10px;
  border: 1.5px solid var(--color-outline-variant);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: center;
  transition: all 0.15s ease;
  min-height: 44px;
  width: 100%;
  background: transparent;
  color: var(--color-on-surface);
}

.length-btn:active {
  transform: scale(0.95);
}

/* Submit button */
.btn-generate {
  width: 100%;
  padding: 0.875rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 16px rgba(0, 74, 198, 0.3);
  transition: all 0.2s ease;
  min-height: 52px;
}

.btn-generate:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(0, 74, 198, 0.2);
}

.btn-generate:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

/* =====================================================
   EMAIL OUTPUT PANEL - MOBILE
   ===================================================== */
.output-action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-action-sm {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  border-radius: 10px;
  border: none;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 40px;
  white-space: nowrap;
}

.btn-action-sm:active {
  transform: scale(0.95);
}

/* Email Content output area styling */
.output-email-body,
#output-email-body {
  color: var(--color-on-surface);
  background-color: var(--color-surface-container-low, #f2f4f6);
  border: 1px solid var(--color-surface-container, #eceef0);
}

/* =====================================================
   LIGHT MODE OVERRIDES & VARIABLE SUPPORT
   ===================================================== */
:root.light,
:root.light-theme,
[data-theme="light"],
body.light,
body.light-theme {
  --color-primary: #004ac6;
  --color-primary-container: #2563eb;
  --color-on-primary: #ffffff;
  --color-surface: #f8fafc;
  --color-surface-container: #f1f5f9;
  --color-surface-container-low: #ffffff;
  --color-surface-container-high: #e2e8f0;
  --color-surface-lowest: #ffffff;
  --color-on-surface: #0f172a;
  --color-on-surface-variant: #475569;
  --color-outline: #94a3b8;
  --color-outline-variant: #cbd5e1;
}

:root.light body,
:root.light-theme body,
[data-theme="light"] body,
body.light,
body.light-theme {
  background-color: var(--color-surface);
  color: var(--color-on-surface);
}

:root.light .glass-nav,
:root.light-theme .glass-nav,
[data-theme="light"] .glass-nav {
  background: rgba(248, 250, 252, 0.94);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

:root.light .glass-card,
:root.light-theme .glass-card,
[data-theme="light"] .glass-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(226, 232, 240, 0.9);
}

:root.light .output-email-body,
:root.light #output-email-body,
:root.light-theme .output-email-body,
:root.light-theme #output-email-body,
[data-theme="light"] .output-email-body,
[data-theme="light"] #output-email-body {
  color: #0f172a !important;
  background-color: #f8fafc !important;
  border-color: #cbd5e1 !important;
}

/* =====================================================
   SETTINGS MODAL & BACKDROP STYLES
   ===================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  transition: opacity 0.25s ease;
}

.modal-panel {
  background: var(--color-surface-lowest);
  color: var(--color-on-surface);
  border: 1px solid var(--color-outline-variant);
  border-radius: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 480px;
  padding: 1.5rem;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--color-outline-variant);
  border-radius: 9999px;
  margin: 0 auto 1rem;
  display: block;
}

@media (min-width: 640px) {
  .modal-handle {
    display: none;
  }
}

/* =====================================================
   BULLETPROOF THEME OVERRIDES & SPECIFICITY
   ===================================================== */

/* 1. System Dark Mode (only active when OS is dark AND user hasn't forced .light mode) */
@media (prefers-color-scheme: dark) {
  :root:not(.light):not(.light-theme) {
    --color-primary: #3b82f6;
    --color-primary-container: #2563eb;
    --color-on-primary: #ffffff;
    --color-surface: #121418;
    --color-surface-container: #212429;
    --color-surface-container-low: #16181c;
    --color-surface-container-high: #2d3036;
    --color-surface-lowest: #0b0c0e;
    --color-on-surface: #f1f5f9;
    --color-on-surface-variant: #cbd5e1;
    --color-outline: #64748b;
    --color-outline-variant: #334155;
  }

  body:not(.light):not(.light-theme) {
    background-color: #121418 !important;
    color: #f1f5f9 !important;
  }

  body:not(.light):not(.light-theme) .glass-nav {
    background: rgba(18, 20, 24, 0.94) !important;
    border-bottom: 1px solid rgba(51, 65, 85, 0.8) !important;
  }

  body:not(.light):not(.light-theme) .glass-card {
    background: rgba(22, 24, 28, 0.95) !important;
    border: 1px solid rgba(51, 65, 85, 0.8) !important;
  }

  body:not(.light):not(.light-theme) #bottom-nav {
    background: rgba(11, 12, 14, 0.96) !important;
    border-top-color: #334155 !important;
  }

  body:not(.light):not(.light-theme) #mobile-nav-drawer {
    background: #0b0c0e !important;
    border-bottom-color: #334155 !important;
  }

  body:not(.light):not(.light-theme) .card {
    background: #0b0c0e !important;
    border-color: #212429 !important;
  }
}

/* 2. Explicit Dark Mode (.dark, .dark-theme, [data-theme="dark"]) */
:root.dark,
:root.dark-theme,
[data-theme="dark"],
html.dark,
body.dark,
body.dark-theme {
  --color-primary: #3b82f6 !important;
  --color-primary-container: #2563eb !important;
  --color-on-primary: #ffffff !important;
  --color-surface: #121418 !important;
  --color-surface-container: #212429 !important;
  --color-surface-container-low: #16181c !important;
  --color-surface-container-high: #2d3036 !important;
  --color-surface-lowest: #0b0c0e !important;
  --color-on-surface: #f1f5f9 !important;
  --color-on-surface-variant: #cbd5e1 !important;
  --color-outline: #64748b !important;
  --color-outline-variant: #334155 !important;
}

body.dark,
body.dark-theme,
[data-theme="dark"] body {
  background-color: #121418 !important;
  color: #f1f5f9 !important;
}

body.dark .glass-nav,
body.dark-theme .glass-nav {
  background: rgba(18, 20, 24, 0.94) !important;
  border-bottom: 1px solid rgba(51, 65, 85, 0.8) !important;
}

body.dark .glass-card,
body.dark-theme .glass-card {
  background: rgba(22, 24, 28, 0.95) !important;
  border: 1px solid rgba(51, 65, 85, 0.8) !important;
}

body.dark .card,
body.dark-theme .card {
  background: #0b0c0e !important;
  border-color: #212429 !important;
}

body.dark .output-email-body,
body.dark #output-email-body,
body.dark-theme .output-email-body,
body.dark-theme #output-email-body {
  color: #e2e2e6 !important;
  background-color: #0b0c0e !important;
  border-color: #2d3036 !important;
}

/* 3. Explicit Light Mode (.light, .light-theme, [data-theme="light"]) - Highest Specificity */
:root.light,
:root.light-theme,
[data-theme="light"],
html.light,
body.light,
body.light-theme {
  --color-primary: #004ac6 !important;
  --color-primary-container: #2563eb !important;
  --color-on-primary: #ffffff !important;
  --color-surface: #f8fafc !important;
  --color-surface-container: #f1f5f9 !important;
  --color-surface-container-low: #ffffff !important;
  --color-surface-container-high: #e2e8f0 !important;
  --color-surface-lowest: #ffffff !important;
  --color-on-surface: #0f172a !important;
  --color-on-surface-variant: #475569 !important;
  --color-outline: #94a3b8 !important;
  --color-outline-variant: #cbd5e1 !important;
}

body.light,
body.light-theme,
[data-theme="light"] body {
  background-color: #f8fafc !important;
  color: #0f172a !important;
}

body.light .glass-nav,
body.light-theme .glass-nav {
  background: rgba(248, 250, 252, 0.96) !important;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9) !important;
}

body.light .glass-card,
body.light-theme .glass-card {
  background: rgba(255, 255, 255, 0.98) !important;
  border: 1px solid rgba(226, 232, 240, 0.9) !important;
}

body.light .card,
body.light-theme .card {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
}

body.light .output-email-body,
body.light #output-email-body,
body.light-theme .output-email-body,
body.light-theme #output-email-body {
  color: #0f172a !important;
  background-color: #f8fafc !important;
  border-color: #cbd5e1 !important;
}

/* =====================================================
   GRAMMAR CHECKER - MOBILE
   ===================================================== */
.grammar-workspace-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1rem;
}

@media (min-width: 1024px) {
  .grammar-workspace-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 2rem 1.5rem;
  }
}

/* Grammar textarea - mobile */
#grammar-input-text {
  min-height: 180px;
  resize: vertical;
}

@media (min-width: 768px) {
  #grammar-input-text {
    min-height: 280px;
  }
}

/* Suggestion filter pills - scrollable on mobile */
.suggestion-filter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 0.25rem;
}

.suggestion-filter-row::-webkit-scrollbar {
  display: none;
}

/* =====================================================
   TEMPLATES - MOBILE
   ===================================================== */
.templates-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 0 1rem 1rem;
}

@media (min-width: 640px) {
  .templates-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .templates-grid {
    grid-template-columns: repeat(3, 1fr);
    padding: 0 1.5rem 1.5rem;
  }
}

/* Filter bar - scrollable on mobile */
.template-filter-bar {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 1rem 0.75rem;
  scrollbar-width: none;
}

.template-filter-bar::-webkit-scrollbar {
  display: none;
}

/* =====================================================
   DASHBOARD - MOBILE
   ===================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  padding: 0 1rem 1rem;
}

@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    padding: 0 1.5rem 1.5rem;
  }
}

/* =====================================================
   MODAL - MOBILE FULL-SCREEN
   ===================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  padding: 0;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 1rem;
  }
}

.modal-panel {
  width: 100%;
  background: var(--color-surface-lowest);
  border-radius: 24px 24px 0 0;
  padding: 1.5rem;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.2);
  max-height: 90vh;
  overflow-y: auto;
}

@media (min-width: 640px) {
  .modal-panel {
    border-radius: 20px;
    max-width: 480px;
    margin: auto;
    max-height: none;
  }
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--color-outline-variant);
  border-radius: 9999px;
  margin: 0 auto 1.25rem;
}

@media (min-width: 640px) {
  .modal-handle { display: none; }
}

/* =====================================================
   TOAST - MOBILE BOTTOM (ABOVE BOTTOM NAV)
   ===================================================== */
#toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 0.75rem);
  left: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

@media (min-width: 768px) {
  #toast-container {
    bottom: 1.5rem;
    left: auto;
    right: 1.5rem;
    width: auto;
    max-width: 380px;
  }
}

.toast {
  pointer-events: auto;
  animation: slideInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 12px;
  font-size: 0.875rem;
}

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =====================================================
   AI LOADING ANIMATION
   ===================================================== */
@keyframes aiPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.98); }
}

.ai-loading-pulse {
  animation: aiPulse 1.6s infinite ease-in-out;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.animate-spin {
  animation: spin 0.9s linear infinite;
}

/* =====================================================
   SUGGESTION HIGHLIGHTS
   ===================================================== */
.suggestion-highlight {
  padding: 1px 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.suggestion-highlight.grammar { background-color: rgba(239,68,68,0.15); border-bottom: 2px solid #ef4444; }
.suggestion-highlight.spelling { background-color: rgba(245,158,11,0.15); border-bottom: 2px solid #f59e0b; }
.suggestion-highlight.punctuation { background-color: rgba(168,85,247,0.15); border-bottom: 2px solid #a855f7; }
.suggestion-highlight.clarity { background-color: rgba(59,130,246,0.15); border-bottom: 2px solid #3b82f6; }
.suggestion-highlight.tone { background-color: rgba(16,185,129,0.15); border-bottom: 2px solid #10b981; }
.suggestion-highlight.conciseness { background-color: rgba(236,72,153,0.15); border-bottom: 2px solid #ec4899; }

/* =====================================================
   GLOW EFFECT
   ===================================================== */
.glow-effect {
  position: relative;
}
.glow-effect::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, #2563eb, #38bdf8, #818cf8);
  border-radius: inherit;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.glow-effect:hover::before {
  opacity: 0.6;
}

/* =====================================================
   SECTION PADDING UTILITY (MOBILE-FIRST)
   ===================================================== */
.view-section {
  min-height: calc(100vh - var(--header-height) - var(--bottom-nav-height));
}

@media (min-width: 768px) {
  .view-section {
    min-height: calc(100vh - var(--header-height));
  }
}

/* =====================================================
   SAFE AREA (NOTCH SUPPORT)
   ===================================================== */
#bottom-nav {
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}

/* =====================================================
   RESPONSIVE TYPOGRAPHY UTILITIES
   ===================================================== */
.text-display { font-size: 2.25rem; line-height: 1.1; font-family: var(--font-headline); font-weight: 800; }
.text-headline-lg { font-size: 1.75rem; line-height: 1.2; font-family: var(--font-headline); font-weight: 700; }
.text-headline-md { font-size: 1.375rem; line-height: 1.25; font-family: var(--font-headline); font-weight: 700; }
.text-headline-sm { font-size: 1.125rem; line-height: 1.3; font-family: var(--font-headline); font-weight: 700; }
.text-body-lg { font-size: 1rem; line-height: 1.6; }
.text-body-md { font-size: 0.9375rem; line-height: 1.55; }
.text-body-sm { font-size: 0.8125rem; line-height: 1.5; }
.text-label-lg { font-size: 0.875rem; line-height: 1.4; font-weight: 600; }
.text-label-md { font-size: 0.8125rem; line-height: 1.4; font-weight: 600; }
.text-label-sm { font-size: 0.75rem; line-height: 1.4; font-weight: 500; }

@media (min-width: 768px) {
  .text-display { font-size: 3.5rem; }
  .text-headline-lg { font-size: 2.25rem; }
  .text-headline-md { font-size: 1.75rem; }
}

/* =====================================================
   CARD UTILITIES
   ===================================================== */
.card {
  background: var(--color-surface-lowest);
  border: 1px solid var(--color-surface-container);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

@media (min-width: 768px) {
  .card {
    border-radius: 20px;
    padding: 1.5rem;
  }
}

/* =====================================================
   FLOATING ACTION BUTTON (Mobile only - for generate)
   ===================================================== */
.fab-generate {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 1rem);
  right: 1rem;
  z-index: 40;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  box-shadow: 0 4px 16px rgba(0, 74, 198, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  cursor: pointer;
}

.fab-generate:active {
  transform: scale(0.9);
  box-shadow: 0 2px 8px rgba(0, 74, 198, 0.25);
}

@media (min-width: 1024px) {
  .fab-generate {
    display: none;
  }
}

/* =====================================================
   FAQ ACCORDION & LANDING PAGE ANIMATIONS
   ===================================================== */
.faq-toggle {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
}

.faq-toggle:hover {
  background-color: var(--color-surface-container-low);
}

.faq-item.open .faq-toggle .material-symbols-outlined {
  transform: rotate(180deg);
  color: var(--color-primary);
}

.faq-answer {
  transition: all 0.3s ease-in-out;
}

.shadow-xs {
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
