/* ═══════════════════════════════════════════════════════
   Safyan Design System — سَفيان
   "Speak human. Safyan speaks AI."

   Dark theme with warm gold/amber accent.
   Typography: Cormorant Garamond (display) + Outfit (body)
   ═══════════════════════════════════════════════════════ */

/* ─── GOOGLE FONTS ────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400;1,500&family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── CSS VARIABLES ───────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-deep: #08080D;
  --bg-surface: #111118;
  --bg-elevated: #1A1A24;
  --bg-overlay: #222230;
  --bg-input: #0E0E15;

  /* Gold spectrum */
  --gold: #D4A843;
  --gold-light: #E8BD5A;
  --gold-dim: #A68832;
  --gold-pale: #F5E6C0;
  --gold-glow: rgba(212, 168, 67, 0.12);
  --gold-glow-strong: rgba(212, 168, 67, 0.25);

  /* Text */
  --text-primary: #F0EDE6;
  --text-secondary: #9A96A6;
  --text-muted: #5A5666;
  --text-gold: #D4A843;

  /* Borders */
  --border: rgba(255, 255, 255, 0.07);
  --border-light: rgba(255, 255, 255, 0.12);
  --border-gold: rgba(212, 168, 67, 0.25);
  --border-gold-strong: rgba(212, 168, 67, 0.5);

  /* Semantic */
  --success: #4ADE80;
  --error: #F87171;
  --warning: #FBBF24;

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 0 30px rgba(212, 168, 67, 0.1);
  --shadow-gold-strong: 0 0 60px rgba(212, 168, 67, 0.15);

  /* Typography */
  --font-display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-body: 'Outfit', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 64px;
  --space-3xl: 96px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;

  /* Layout */
  --container-max: 1200px;
  --container-narrow: 800px;
  --nav-height: 64px;
}

/* ─── RESET & BASE ────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg-deep);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

::selection {
  background: var(--gold);
  color: var(--bg-deep);
}

/* ─── SHADER BACKGROUND (shared across all pages) ────── */
#shader-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 128px 128px;
}

/* ─── TYPOGRAPHY ──────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.15;
  color: var(--text-primary);
}

h1 {
  font-size: clamp(2.8rem, 6vw, 5rem);
  font-weight: 300;
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 400;
  letter-spacing: -0.01em;
}

h3 {
  font-size: clamp(1.4rem, 2.5vw, 1.8rem);
  font-weight: 500;
}

h4 {
  font-size: 1.25rem;
  font-weight: 500;
}

p {
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 65ch;
}

a {
  color: var(--gold);
  text-decoration: none;
  transition: color var(--duration-fast) ease;
}

a:hover {
  color: var(--gold-light);
}

small {
  font-size: 0.85rem;
  color: var(--text-muted);
}

code, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.text-gold { color: var(--gold); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-center { text-align: center; }

/* ─── LAYOUT ──────────────────────────────────────────── */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.container--narrow {
  max-width: var(--container-narrow);
}

.section {
  padding: var(--space-3xl) 0;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { align-items: center; justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

/* ─── NAVIGATION ──────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  background: rgba(8, 8, 13, 0.8);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  z-index: 1000;
  transition: background var(--duration-normal) ease;
}

.nav__logo {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  text-decoration: none;
}

.nav__logo span {
  color: var(--gold);
}

.nav__links {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  list-style: none;
}

.nav__links a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--duration-fast) ease;
}

.nav__links a:hover {
  color: var(--text-primary);
}

.nav__cta {
  display: flex;
  gap: var(--space-sm);
}

/* ─── BUTTONS ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px 28px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--gold);
  color: var(--bg-deep);
  box-shadow: 0 0 20px rgba(212, 168, 67, 0.2);
}

.btn--primary:hover:not(:disabled) {
  background: var(--gold-light);
  box-shadow: 0 0 30px rgba(212, 168, 67, 0.35);
}

.btn--primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn--secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.btn--secondary:hover:not(:disabled) {
  border-color: transparent;
  background-image: linear-gradient(var(--bg-deep), var(--bg-deep)), linear-gradient(135deg, var(--gold), rgba(212,168,67,0.3));
  background-origin: border-box;
  background-clip: padding-box, border-box;
  color: var(--gold);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
}

.btn--ghost:hover:not(:disabled) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.btn--sm {
  padding: 8px 18px;
  font-size: 0.85rem;
}

.btn--lg {
  padding: 16px 40px;
  font-size: 1.05rem;
  border-radius: var(--radius-sm);
}

.btn--icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* ─── INPUTS ──────────────────────────────────────────── */
.input, .textarea, .select {
  width: 100%;
  padding: 14px 18px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  outline: none;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--border-gold);
  box-shadow: 0 0 0 1px var(--gold-glow);
}

.input::placeholder, .textarea::placeholder {
  color: var(--text-muted);
}

.textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

.select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%239A96A6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-error {
  border-color: var(--error) !important;
}

.input-error-msg {
  font-size: 0.8rem;
  color: var(--error);
  margin-top: 4px;
}

/* ─── CARDS ───────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  transition: border-color var(--duration-normal) ease, box-shadow var(--duration-normal) ease;
}

.card:hover {
  border-color: transparent;
  background-image: linear-gradient(var(--bg-surface), var(--bg-surface)), linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.03));
  background-origin: border-box;
  background-clip: padding-box, border-box;
}

.card--elevated {
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
}

.card--gold {
  border-color: var(--border-gold);
  box-shadow: var(--shadow-gold);
}

.card--gold:hover {
  border-color: var(--border-gold-strong);
  box-shadow: var(--shadow-gold-strong);
}

/* ─── TOAST NOTIFICATIONS ─────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 14px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  color: var(--text-primary);
  animation: toast-in var(--duration-normal) var(--ease-out);
  max-width: 400px;
}

.toast--success { border-left: 3px solid var(--success); }
.toast--error { border-left: 3px solid var(--error); }
.toast--info { border-left: 3px solid var(--gold); }

.toast-exit {
  animation: toast-out var(--duration-fast) ease forwards;
}

/* ─── MODAL ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-normal) ease, visibility var(--duration-normal) ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  max-width: 480px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--duration-normal) var(--ease-out);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

/* ─── LOADING ─────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner--lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 25%,
    var(--bg-overlay) 50%,
    var(--bg-elevated) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-xs);
}

/* ─── BADGE ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
}

.badge--gold {
  background: var(--gold-glow);
  color: var(--gold);
  border: 1px solid var(--border-gold);
}

.badge--free {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.badge--pro {
  background: var(--gold-glow);
  color: var(--gold);
  border: 1px solid var(--border-gold);
}

/* ─── DIVIDER ─────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-xl) 0;
}

.divider--gold {
  background: linear-gradient(90deg, transparent, var(--border-gold), transparent);
}

/* ─── PRICING CARDS ───────────────────────────────────── */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
  max-width: 960px;
  margin: 0 auto;
}

.pricing-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: all var(--duration-normal) var(--ease-out);
}

.pricing-card:hover {
  border-color: transparent;
  background-image: linear-gradient(var(--bg-surface), var(--bg-surface)), linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.03));
  background-origin: border-box;
  background-clip: padding-box, border-box;
}

.pricing-card--featured {
  border-color: var(--border-gold);
  box-shadow: var(--shadow-gold-strong);
  background: linear-gradient(180deg, rgba(212, 168, 67, 0.04) 0%, var(--bg-surface) 40%);
}

.pricing-card--featured:hover {
  border-color: var(--gold-dim);
}

.pricing-card__badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: var(--bg-deep);
  padding: 4px 16px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.pricing-card__name {
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.pricing-card__price {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: var(--space-xs);
}

.pricing-card__price span {
  font-size: 1rem;
  color: var(--text-muted);
  font-family: var(--font-body);
}

.pricing-card__desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

.pricing-card__features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
  flex: 1;
}

.pricing-card__features li {
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding-left: 24px;
  position: relative;
}

.pricing-card__features li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--gold);
  font-weight: 700;
}

/* ─── BEFORE/AFTER EXAMPLES ───────────────────────────── */
.example-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.example-item {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--space-lg);
  align-items: start;
}

.example-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-sm);
}

.example-before .example-label { color: var(--text-muted); }
.example-after .example-label { color: var(--gold); }

.example-before .card {
  border-style: dashed;
  opacity: 0.7;
}

.example-after .card {
  border-color: var(--border-gold);
}

.example-arrow {
  display: flex;
  align-items: center;
  padding-top: 36px;
  color: var(--gold);
  font-size: 1.5rem;
}

.example-text {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.example-after .example-text {
  color: var(--text-primary);
}

/* ─── HERO ────────────────────────────────────────────── */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(var(--nav-height) + var(--space-2xl)) var(--space-lg) var(--space-2xl);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%);
  width: 800px;
  height: 800px;
  background: radial-gradient(
    circle,
    rgba(212, 168, 67, 0.08) 0%,
    rgba(212, 168, 67, 0.03) 30%,
    transparent 70%
  );
  pointer-events: none;
}

.hero::after {
  content: 'سَفيان';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%);
  font-size: 20rem;
  font-weight: 300;
  color: rgba(212, 168, 67, 0.02);
  pointer-events: none;
  white-space: nowrap;
  font-family: serif;
}

.hero__tagline {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: var(--space-lg);
}

.hero h1 {
  margin-bottom: var(--space-lg);
  position: relative;
}

.hero h1 em {
  font-style: italic;
  color: var(--gold);
}

.hero__subtitle {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto var(--space-2xl);
  line-height: 1.7;
}

/* ─── DEMO BOX (Landing Page) ─────────────────────────── */
.demo-box {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  position: relative;
}

.demo-box__input {
  width: 100%;
  min-height: 100px;
  padding: 20px 24px;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  outline: none;
  resize: none;
  line-height: 1.6;
  transition: border-color var(--duration-normal) ease, box-shadow var(--duration-normal) ease;
}

.demo-box__input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow), var(--shadow-gold);
}

.demo-box__input::placeholder {
  color: var(--text-muted);
}

.demo-box__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-md);
}

.demo-box__counter {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─── DEMO RESULT ─────────────────────────────────────── */
.demo-result {
  max-width: 680px;
  margin: var(--space-xl) auto 0;
  text-align: left;
  display: none;
}

.demo-result.active {
  display: block;
  animation: fade-up var(--duration-slow) var(--ease-out);
}

.demo-result__analysis {
  background: linear-gradient(135deg, rgba(212, 168, 67, 0.06), rgba(212, 168, 67, 0.02));
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-md);
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.demo-result__analysis strong {
  color: var(--gold);
  font-weight: 600;
}

.demo-result__translation {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  position: relative;
}

.demo-result__translation-text {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.demo-result__copy {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
}

.demo-result__missing {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: rgba(251, 191, 36, 0.05);
  border: 1px dashed rgba(251, 191, 36, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--warning);
  line-height: 1.6;
}

/* ─── HOW IT WORKS ────────────────────────────────────── */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xl);
  max-width: 900px;
  margin: 0 auto;
}

.step {
  text-align: center;
  position: relative;
}

.step__number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: 2px solid var(--border-gold);
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--gold);
  margin-bottom: var(--space-md);
}

.step h4 {
  margin-bottom: var(--space-sm);
}

.step p {
  font-size: 0.9rem;
  margin: 0 auto;
}

.step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 28px;
  right: -32px;
  width: 24px;
  height: 2px;
  background: linear-gradient(90deg, var(--border-gold), transparent);
}

/* ─── TRANSLATOR APP ──────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  padding-top: var(--nav-height);
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.app-topbar__left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.app-topbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.usage-counter {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 6px 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}

.usage-counter strong {
  color: var(--gold);
  font-weight: 600;
}

.app-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

.app-main--with-history {
  grid-template-columns: 1fr 1fr 280px;
}

/* ─── TRANSLATOR PANELS ───────────────────────────────── */
.panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--nav-height) - 57px);
  border-right: 1px solid var(--border);
}

.panel:last-child {
  border-right: none;
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.panel__title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.panel__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
}

.panel__input {
  width: 100%;
  height: 100%;
  min-height: 200px;
  padding: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-primary);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  line-height: 1.7;
}

.panel__input::placeholder {
  color: var(--text-muted);
}

.panel__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}

.translate-btn-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

/* ─── ANALYSIS CARD (in output panel) ─────────────────── */
.analysis-card {
  background: linear-gradient(135deg, rgba(212, 168, 67, 0.06), rgba(212, 168, 67, 0.02));
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-lg);
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: none;
}

.analysis-card.active {
  display: block;
  animation: fade-up var(--duration-normal) var(--ease-out);
}

.analysis-card__label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold-dim);
  margin-bottom: 6px;
}

/* ─── CURES APPLIED (7 Cures display) ────────────────── */
.cures-applied {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 0 12px;
}

.cure-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(212, 168, 67, 0.08);
  color: var(--gold);
  border: 1px solid rgba(212, 168, 67, 0.12);
}

.cure-tag__num {
  font-size: 0.6rem;
  font-weight: 400;
  color: var(--gold-dim);
  opacity: 0.7;
}

.cure-tag--mod {
  background: rgba(154, 150, 166, 0.08);
  color: var(--text-secondary);
  border-color: rgba(154, 150, 166, 0.12);
}

/* ─── CURE EXPLANATIONS (Fitrah Model: every optimization is a micro-lesson) ── */
.cures-explained {
  padding: 10px 0;
}

.cures-explained__toggle {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  font-family: var(--font-body);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}

.cures-explained__toggle:hover { color: var(--gold-bright, #E8C36A); }

.cures-explained__list {
  margin-top: 8px;
}

.cures-explained__item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.06));
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.cures-explained__item:last-child { border-bottom: none; }

.cures-explained__cure-name {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gold);
  display: block;
  margin-bottom: 2px;
}

/* ─── GROWTH SIGNAL (Fitrah Model: affirm when user is improving) ── */
.growth-signal {
  padding: 8px 12px;
  margin: 8px 0;
  background: rgba(74, 222, 128, 0.06);
  border: 1px solid rgba(74, 222, 128, 0.15);
  border-radius: 8px;
  font-size: 0.78rem;
  color: #4ADE80;
  line-height: 1.5;
}

/* ─── FLAG GUIDANCE (Fitrah Model: educational, not punitive) ── */
.flag-guidance {
  padding: 12px 14px;
  margin: 8px 0;
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.15);
  border-radius: 8px;
  font-size: 0.82rem;
  color: #F59E0B;
  line-height: 1.6;
}

/* ─── TRANSLATION OUTPUT ──────────────────────────────── */
.output-text {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  display: none;
}

.output-text.active {
  display: block;
  animation: fade-up var(--duration-normal) var(--ease-out);
}

.output-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--text-muted);
  gap: var(--space-md);
}

.output-placeholder__icon {
  font-size: 3rem;
  opacity: 0.3;
}

.output-placeholder__text {
  font-size: 0.95rem;
  max-width: 280px;
}

/* ─── RATING ──────────────────────────────────────────── */
.rating-group {
  display: none;
  align-items: center;
  gap: var(--space-sm);
}

.rating-group.active {
  display: flex;
}

.rating-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  transition: all var(--duration-fast) ease;
}

.rating-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-glow);
}

.rating-btn.active {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-glow);
}

/* ─── HISTORY SIDEBAR ─────────────────────────────────── */
.history-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--nav-height) - 57px);
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
}

.history-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm);
}

.history-item {
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast) ease;
  border-bottom: 1px solid var(--border);
}

.history-item:hover {
  background: var(--bg-elevated);
}

.history-item:last-child {
  border-bottom: none;
}

.history-item__preview {
  font-size: 0.85rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.history-item__meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.history-item__platform {
  font-weight: 600;
  color: var(--text-secondary);
}

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: var(--space-lg);
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ─── AUTH PAGES ──────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl) var(--space-lg);
  background: transparent;
  position: relative;
  z-index: 10;
}

.auth-page::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(212,168,67,0.03) 0%, transparent 70%);
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: rgba(10, 10, 8, 0.6);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border: 1px solid rgba(212, 168, 67, 0.12);
  border-top: 2px solid var(--gold-dim);
  border-radius: var(--radius-md);
  padding: var(--space-xl) var(--space-xl) var(--space-lg);
  position: relative;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.6), 0 0 200px -60px rgba(212,168,67,0.06);
}

.auth-card__logo {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.auth-card__logo a {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.auth-card__logo a span {
  color: var(--gold);
}

.auth-card__title {
  text-align: center;
  margin-bottom: var(--space-xs);
  font-size: 1.4rem;
}

.auth-card__subtitle {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.auth-form .btn {
  margin-top: var(--space-sm);
}

.auth-card__footer {
  text-align: center;
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.auth-card__footer a {
  color: var(--gold);
  font-weight: 500;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-md) 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── FOOTER ──────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  padding: var(--space-2xl) 0;
  background: var(--bg-surface);
  position: relative;
  z-index: 10;
}

.footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer__brand {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.footer__brand span {
  color: var(--gold);
}

.footer__tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer__links {
  display: flex;
  gap: var(--space-lg);
  list-style: none;
}

.footer__links a {
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: color var(--duration-fast) ease;
}

.footer__links a:hover {
  color: var(--text-primary);
}

/* ─── ACCOUNT MENU ────────────────────────────────────── */
.account-menu {
  position: relative;
}

.account-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 6px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.account-btn:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
}

.account-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--duration-fast) var(--ease-out);
  z-index: 100;
}

.account-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.account-dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}

.account-dropdown__item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.account-dropdown__divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-xs) 0;
}

/* ─── PLATFORM SELECTOR ───────────────────────────────── */
.platform-select {
  padding: 8px 36px 8px 14px;
  font-size: 0.85rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-primary);
}

.platform-select:focus {
  border-color: var(--border-gold);
}

/* ─── SIGNUP PROMPT (anonymous users) ─────────────────── */
.signup-prompt {
  background: linear-gradient(135deg, rgba(212, 168, 67, 0.08), rgba(212, 168, 67, 0.02));
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  text-align: center;
  display: none;
}

.signup-prompt.active {
  display: block;
  animation: fade-up var(--duration-normal) var(--ease-out);
}

.signup-prompt h4 {
  margin-bottom: var(--space-sm);
  color: var(--gold);
}

.signup-prompt p {
  font-size: 0.9rem;
  margin: 0 auto var(--space-md);
}

/* ─── ANIMATIONS ──────────────────────────────────────── */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(30px);
  }
}

@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 168, 67, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(212, 168, 67, 0); }
}

/* Staggered reveal */
.reveal { opacity: 0; transform: translateY(20px); }
.reveal.visible {
  animation: fade-up 0.6s var(--ease-out) forwards;
}
.reveal-delay-1 { animation-delay: 0.1s; }
.reveal-delay-2 { animation-delay: 0.2s; }
.reveal-delay-3 { animation-delay: 0.3s; }
.reveal-delay-4 { animation-delay: 0.4s; }
.reveal-delay-5 { animation-delay: 0.5s; }

/* ─── SCROLLBAR ───────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-overlay);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ─── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 1024px) {
  .app-main--with-history {
    grid-template-columns: 1fr 1fr;
  }

  .history-panel {
    display: none;
  }

  .history-panel.mobile-visible {
    display: flex;
    position: fixed;
    top: var(--nav-height);
    right: 0;
    bottom: 0;
    width: 300px;
    z-index: 500;
    box-shadow: var(--shadow-lg);
  }
}

@media (max-width: 768px) {
  :root {
    --space-lg: 20px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;
  }

  .nav__links { display: none; }

  .pricing-grid {
    grid-template-columns: 1fr;
    max-width: 400px;
  }

  .steps-grid {
    grid-template-columns: 1fr;
    gap: var(--space-xl);
  }

  .step:not(:last-child)::after { display: none; }

  .example-item {
    grid-template-columns: 1fr;
  }

  .example-arrow {
    justify-content: center;
    padding: 0;
    transform: rotate(90deg);
  }

  .app-main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .panel {
    height: auto;
    min-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .footer__inner {
    flex-direction: column;
    gap: var(--space-lg);
    text-align: center;
  }

  .footer__links {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  h1 { font-size: 2.2rem; }

  .hero { padding-left: var(--space-md); padding-right: var(--space-md); }

  .demo-box__input { padding: 16px; min-height: 80px; }

  .auth-card { padding: var(--space-lg); }
}

/* ─── UTILITY ─────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden { display: none !important; }
.visible { display: block; }

/* ─── ACCESSIBILITY ──────────────────────────────────── */

/* Skip link — keyboard users jump past nav */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-md);
  background: var(--gold);
  color: var(--bg-deep);
  padding: 12px 24px;
  border-radius: var(--radius-xs);
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 10000;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: var(--space-md);
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Focus rings — visible for keyboard, hidden for mouse */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Reduced motion — respect user preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  :root {
    --border: rgba(255, 255, 255, 0.2);
    --border-light: rgba(255, 255, 255, 0.3);
    --text-muted: #8A8680;
  }
}
