/* ═══════════════════════════════════════════
   FrankIELTS Design System v2
   Premium IELTS Writing Platform
   ═══════════════════════════════════════════ */

/* ── Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Noto+Sans+SC:wght@400;500;700;900&display=swap');

/* ── CSS Variables ── */
:root {
  /* Colors */
  --blue-50: #EFF6FF;  --blue-100: #DBEAFE;  --blue-200: #BFDBFE;
  --blue-500: #3B82F6;  --blue-600: #2563EB;  --blue-700: #1D4ED8;  --blue-900: #1E3A5F;
  --slate-50: #F8FAFC;  --slate-100: #F1F5F9;  --slate-200: #E2E8F0;
  --slate-300: #CBD5E1;  --slate-400: #94A3B8;  --slate-500: #64748B;
  --slate-600: #475569;  --slate-700: #334155;  --slate-800: #1E293B;  --slate-900: #0F172A;
  --white: #FFFFFF;
  --amber-500: #F59E0B;  --amber-600: #D97706;
  --emerald-500: #10B981;  --emerald-600: #059669;
  --red-500: #EF4444;  --red-600: #DC2626;
  --violet-500: #8B5CF6;  --violet-600: #7C3AED;

  /* Theme */
  --bg: var(--slate-50);
  --bg-card: var(--white);
  --bg-elevated: var(--white);
  --border: var(--slate-200);
  --border-light: rgba(0,0,0,.06);
  --text: var(--slate-900);
  --text-secondary: var(--slate-600);
  --text-muted: var(--slate-400);
  --accent: var(--blue-600);
  --accent-dark: var(--blue-700);
  --accent-light: var(--blue-50);
  --accent-glow: rgba(37,99,235,.12);
  --gold: var(--amber-500);
  --gold-dark: var(--amber-600);
  --success: var(--emerald-500);
  --danger: var(--red-500);
  --gradient-hero: linear-gradient(135deg, #1E3A5F 0%, #2563EB 50%, #7C3AED 100%);
  --gradient-card: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);

  /* Typography */
  --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;

  /* Spacing */
  --space-xs: 4px; --space-sm: 8px; --space-md: 16px; --space-lg: 24px;
  --space-xl: 32px; --space-2xl: 48px; --space-3xl: 64px;

  /* Radii */
  --radius-sm: 6px; --radius: 10px; --radius-lg: 16px; --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,.06), 0 2px 4px -2px rgba(0,0,0,.04);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.04);
  --shadow-xl: 0 25px 50px -12px rgba(0,0,0,.15);
  --shadow-accent: 0 4px 14px 0 var(--accent-glow);

  /* Layout */
  --max-w: 1100px;
  --header-h: 64px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-dark); }
img, svg { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }

/* ── Typography ── */
h1, h2, h3, h4 { line-height: 1.25; font-weight: 700; letter-spacing: -.02em; }
h1 { font-size: clamp(28px, 5vw, 48px); }
h2 { font-size: clamp(22px, 4vw, 36px); }
h3 { font-size: clamp(18px, 3vw, 24px); }

/* ── Header ── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-light);
}
.header-inner {
  max-width: var(--max-w); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  height: var(--header-h); padding: 0 var(--space-lg);
}
.logo {
  font-size: 20px; font-weight: 800; color: var(--text);
  display: flex; align-items: center; gap: 6px; letter-spacing: -.03em;
}
.logo .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.nav-links { display: flex; gap: 4px; align-items: center; }
.nav-links a {
  padding: 8px 16px; border-radius: var(--radius-full);
  font-size: 14px; font-weight: 500; color: var(--text-secondary);
  transition: all .15s;
}
.nav-links a:hover { background: var(--accent-light); color: var(--accent); text-decoration: none; }
.nav-links a.btn-nav {
  background: var(--slate-900); color: #fff; font-weight: 600;
}
.nav-links a.btn-nav:hover { background: var(--slate-800); }

/* ── Container ── */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 var(--space-lg); }

/* ── Section ── */
.section { padding: var(--space-3xl) 0; }
.section-sm { padding: var(--space-2xl) 0; }
.section-title {
  font-size: clamp(24px, 4vw, 36px); font-weight: 800;
  letter-spacing: -.03em; margin-bottom: var(--space-lg);
}
.section-subtitle { font-size: 18px; color: var(--text-secondary); max-width: 540px; }

/* ── Cards ── */
.card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  padding: var(--space-lg); box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: all .2s ease;
}
.card:hover { box-shadow: var(--shadow); }
.card-interactive { cursor: pointer; }
.card-interactive:hover { box-shadow: var(--shadow-accent); border-color: var(--blue-200); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border-radius: var(--radius-full); font-size: 15px;
  font-weight: 600; border: none; transition: all .2s ease;
  white-space: nowrap; letter-spacing: -.01em;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--slate-900); color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--slate-800); box-shadow: var(--shadow-md); color: #fff; }
.btn-accent {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-accent:hover { background: var(--accent-dark); box-shadow: 0 4px 16px var(--accent-glow); color: #fff; }
.btn-outline {
  background: transparent; color: var(--text-secondary);
  border: 2px solid var(--border);
}
.btn-outline:hover { border-color: var(--slate-400); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--slate-100); color: var(--text); }
.btn-lg { padding: 16px 32px; font-size: 17px; }
.btn-sm { padding: 8px 16px; font-size: 13px; border-radius: var(--radius-full); }
.btn-gold {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #fff; box-shadow: 0 2px 12px rgba(245,158,11,.3); font-weight: 700;
}
.btn-gold:hover { box-shadow: 0 4px 20px rgba(245,158,11,.45); color: #fff; transform: translateY(-2px); }

/* ── Hero ── */
.hero {
  background: var(--gradient-hero);
  color: #fff;
  padding: var(--space-3xl) var(--space-lg);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at 50% 100%, rgba(123,97,255,.3) 0%, transparent 60%);
  pointer-events: none;
}
.hero-content { position: relative; z-index: 1; max-width: 800px; margin: 0 auto; }
.hero h1 {
  font-size: clamp(32px, 6vw, 56px); font-weight: 900;
  line-height: 1.1; margin-bottom: var(--space-md);
  letter-spacing: -.04em;
}
.hero p {
  font-size: clamp(16px, 2.5vw, 20px);
  opacity: .85; max-width: 560px; margin: 0 auto var(--space-xl);
  line-height: 1.6;
}
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero .btn-accent { background: #fff; color: var(--accent); font-size: 17px; padding: 16px 36px; }
.hero .btn-accent:hover { background: var(--slate-100); box-shadow: 0 8px 30px rgba(255,255,255,.2); }
.hero .btn-outline-white {
  background: transparent; color: #fff; border: 2px solid rgba(255,255,255,.3);
  font-size: 17px; padding: 16px 36px; border-radius: var(--radius-full); font-weight: 600;
}
.hero .btn-outline-white:hover { border-color: #fff; background: rgba(255,255,255,.1); text-decoration: none; }

/* ── Stats Bar ── */
.stats-bar {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg);
  margin-top: -40px; position: relative; z-index: 2;
}
.stat-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  padding: var(--space-lg); text-align: center;
  box-shadow: var(--shadow-md); border: 1px solid var(--border-light);
}
.stat-card .stat-num {
  font-size: 36px; font-weight: 900; color: var(--accent);
  letter-spacing: -.03em;
}
.stat-card .stat-label { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }

/* ── Feature grid ── */
.feature-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg);
}
@media (max-width: 768px) { .feature-grid { grid-template-columns: 1fr; } }
.feature-card {
  text-align: left; padding: var(--space-xl);
  border-radius: var(--radius-lg); border: 1px solid var(--border-light);
  background: var(--bg-card); transition: all .25s ease;
}
.feature-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.feature-icon {
  width: 48px; height: 48px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; margin-bottom: var(--space-md);
  background: var(--accent-light);
}
.feature-card h3 { font-size: 18px; margin-bottom: 8px; }
.feature-card p { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }

/* ── Article Grid ── */
.article-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--space-lg);
}
@media (max-width: 640px) { .article-grid { grid-template-columns: 1fr; } }
.article-card { display: flex; flex-direction: column; padding: var(--space-xl); }
.article-card .art-tag {
  display: inline-block; padding: 4px 12px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600; background: var(--accent-light); color: var(--accent);
  margin-bottom: var(--space-md); align-self: flex-start;
}
.article-card h3 { font-size: 18px; margin-bottom: var(--space-sm); line-height: 1.4; }
.article-card h3 a { color: var(--text); }
.article-card h3 a:hover { color: var(--accent); }
.article-card p { font-size: 14px; color: var(--text-secondary); line-height: 1.6; flex: 1; }
.article-card .art-meta {
  font-size: 12px; color: var(--text-muted); margin-top: var(--space-md);
  padding-top: var(--space-md); border-top: 1px solid var(--border-light);
}

/* ── Blog Detail ── */
.article-header { margin-bottom: var(--space-xl); }
.article-header h1 {
  font-size: clamp(26px, 5vw, 40px); font-weight: 800;
  letter-spacing: -.03em; margin-bottom: var(--space-md);
}
.article-body {
  font-size: 17px; line-height: 1.85; color: var(--slate-700);
}
.article-body h2 {
  font-size: 24px; font-weight: 700; margin: var(--space-2xl) 0 var(--space-md);
  padding-top: var(--space-lg); border-top: 1px solid var(--border-light);
}
.article-body h3 { font-size: 20px; font-weight: 600; margin: var(--space-xl) 0 var(--space-sm); }
.article-body p { margin-bottom: var(--space-md); }
.article-body ul, .article-body ol { margin: var(--space-md) 0; padding-left: 24px; }
.article-body li { margin-bottom: var(--space-sm); }
.article-body strong { color: var(--slate-900); }
.article-body blockquote {
  border-left: 4px solid var(--accent); padding: var(--space-md) var(--space-lg);
  margin: var(--space-lg) 0; background: var(--accent-light);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic; color: var(--slate-600);
}

/* ── Practice Page ── */
.practice-layout {
  display: grid; grid-template-columns: 1fr 340px; gap: var(--space-lg);
  align-items: start;
}
@media (max-width: 900px) { .practice-layout { grid-template-columns: 1fr; } }

.topic-panel {
  position: sticky; top: calc(var(--header-h) + var(--space-lg));
  max-height: calc(100vh - var(--header-h) - var(--space-xl));
  overflow-y: auto;
  border-radius: var(--radius-lg); border: 1px solid var(--border-light);
  background: var(--bg-card);
}
.topic-panel-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-light);
  font-weight: 700; font-size: 15px;
  position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
.topic-item {
  padding: 12px var(--space-lg); border-bottom: 1px solid var(--border-light);
  cursor: pointer; transition: all .15s; font-size: 13px;
  border-left: 3px solid transparent;
}
.topic-item:hover { background: var(--accent-light); border-left-color: var(--accent); }
.topic-item.active { background: var(--accent-light); border-left-color: var(--accent); font-weight: 500; }
.topic-item .topic-type {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 600; background: var(--accent-light); color: var(--accent);
}

.topic-display {
  background: linear-gradient(135deg, var(--accent-light), #F0F7FF);
  border: 1px solid var(--blue-200); border-radius: var(--radius-lg);
  padding: var(--space-lg); margin-bottom: var(--space-lg);
}
.topic-display .topic-badge { font-size: 12px; color: var(--accent); font-weight: 600; margin-bottom: 8px; }
.topic-display h3 { font-size: 18px; margin-bottom: 8px; }

.writing-toolbar {
  display: flex; gap: 10px; align-items: center; padding: 12px 0;
  flex-wrap: wrap;
}
.writing-toolbar .stat {
  padding: 8px 14px; border-radius: var(--radius-full);
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--bg); border: 1px solid var(--border-light);
}
.stat.timer { font-size: 20px; font-weight: 800; min-width: 70px; text-align: center; font-family: var(--font-mono); }
.stat.warning { color: var(--amber-600); border-color: var(--amber-500); background: #FFFBEB; }
.stat.danger { color: var(--red-600); border-color: var(--red-500); background: #FEF2F2; }

.essay-textarea {
  width: 100%; min-height: 450px; border: 2px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-lg);
  font-size: 16px; line-height: 1.8; resize: vertical;
  background: var(--bg-card); color: var(--text);
  transition: border-color .2s; font-family: var(--font-sans);
}
.essay-textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--shadow-accent); }

/* ── Grade Report ── */
.overall-score {
  text-align: center; padding: var(--space-2xl);
  background: var(--gradient-hero); color: #fff;
  border-radius: var(--radius-xl); margin-bottom: var(--space-xl);
}
.overall-score .big-score { font-size: 80px; font-weight: 900; line-height: 1; letter-spacing: -.05em; }
.overall-score .big-label { font-size: 14px; opacity: .8; margin-top: 8px; text-transform: uppercase; letter-spacing: .1em; }

.score-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-md);
  margin-bottom: var(--space-xl);
}
@media (max-width: 640px) { .score-grid { grid-template-columns: repeat(2, 1fr); } }
.score-card {
  text-align: center; padding: var(--space-lg) var(--space-md);
  border-radius: var(--radius-lg); background: var(--bg-card);
  border: 1px solid var(--border-light); transition: all .2s;
}
.score-card:hover { box-shadow: var(--shadow); }
.score-card .band {
  font-size: 40px; font-weight: 900; color: var(--accent);
  letter-spacing: -.03em; line-height: 1;
}
.score-card .band-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted); margin-bottom: 4px;
}
.score-card .comment { font-size: 13px; color: var(--text-secondary); margin-top: 8px; line-height: 1.5; }

.feedback-block {
  background: var(--bg-card); border-radius: var(--radius-lg); padding: var(--space-xl);
  border: 1px solid var(--border-light); margin-bottom: var(--space-lg);
}
.feedback-block h3 { font-size: 18px; margin-bottom: var(--space-md); color: var(--accent); }

.revised-block {
  background: linear-gradient(135deg, var(--accent-light), #F0F7FF);
  border-radius: var(--radius-lg); padding: var(--space-xl);
  border: 2px solid var(--blue-200); margin-bottom: var(--space-lg);
}

.upgrade-cta {
  text-align: center; padding: var(--space-xl);
  background: linear-gradient(135deg, #FFFBEB, #FFF7ED);
  border: 2px solid var(--amber-500); border-radius: var(--radius-lg);
}

/* ── Pricing ── */
.pricing-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg);
  align-items: start;
}
@media (max-width: 800px) { .pricing-grid { grid-template-columns: 1fr; } }
.pricing-card {
  text-align: center; padding: var(--space-2xl) var(--space-xl);
  border-radius: var(--radius-xl); position: relative;
  background: var(--bg-card); border: 1px solid var(--border-light);
  transition: all .25s ease;
}
.pricing-card:hover { box-shadow: var(--shadow-lg); }
.pricing-card.featured {
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  transform: scale(1.03);
}
.pricing-card.featured:hover { transform: scale(1.05); }
.pricing-card .popular-badge {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; padding: 4px 16px;
  border-radius: var(--radius-full); font-size: 12px; font-weight: 700;
}
.pricing-card .plan-name { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.pricing-card .plan-price { font-size: 48px; font-weight: 900; color: var(--accent); letter-spacing: -.03em; }
.pricing-card .plan-price span { font-size: 16px; font-weight: 400; color: var(--text-muted); }
.pricing-card .plan-features {
  list-style: none; text-align: left; margin: var(--space-lg) 0;
  padding: 0;
}
.pricing-card .plan-features li {
  padding: 8px 0; font-size: 14px; color: var(--text-secondary);
  display: flex; align-items: center; gap: 8px;
}
.pricing-card .plan-features li::before {
  content: ''; width: 18px; height: 18px; flex-shrink: 0;
  background: var(--emerald-500); border-radius: 50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='white'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-size: 12px; background-position: center; background-repeat: no-repeat;
}

/* ── Dashboard ── */
.dash-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: var(--space-xl); }
.plan-badge {
  display: inline-block; padding: 6px 16px; border-radius: var(--radius-full);
  font-size: 14px; font-weight: 700;
}
.plan-badge.free { background: var(--slate-100); color: var(--slate-500); }
.plan-badge.monthly, .plan-badge.annual { background: var(--accent-light); color: var(--accent); }

/* Stats row */
.dash-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-md);
  margin-bottom: var(--space-xl);
}
@media (max-width: 640px) { .dash-stats { grid-template-columns: repeat(2, 1fr); } }
.dash-stat-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  padding: var(--space-lg); text-align: center;
  border: 1px solid var(--border-light);
  transition: all .2s;
}
.dash-stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.dash-stat-icon { font-size: 28px; margin-bottom: 6px; }
.dash-stat-num { font-size: 32px; font-weight: 900; color: var(--accent); letter-spacing: -.03em; line-height: 1.1; }
.dash-stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.usage-card {
  background: var(--bg-card); border-radius: var(--radius-lg); padding: var(--space-lg);
  border: 1px solid var(--border-light); margin-bottom: var(--space-lg);
}
.usage-bar-track { height: 10px; background: var(--slate-100); border-radius: 5px; margin: 12px 0; overflow: hidden; }
.usage-bar-fill { height: 100%; border-radius: 5px; background: var(--accent); transition: width .5s ease; }
.usage-bar-fill.warn { background: var(--amber-500); }
.usage-bar-fill.full { background: var(--red-500); }

/* Charts */
.charts-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}
@media (max-width: 768px) { .charts-row { grid-template-columns: 1fr; } }
.chart-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: var(--space-xl);
}
.chart-title { font-size: 16px; font-weight: 700; margin-bottom: var(--space-md); }
.chart-wrap { position: relative; height: 280px; }
.chart-empty { text-align: center; padding: var(--space-xl); color: var(--text-muted); }
.chart-empty p { font-size: 14px; margin-bottom: 8px; }

/* Insight cards */
.insight-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}
@media (max-width: 768px) { .insight-row { grid-template-columns: 1fr; } }
.insight-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: var(--space-xl);
}
.insight-header {
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-light);
}
.insight-header span { font-size: 14px; color: var(--text-muted); }
.insight-header strong { font-size: 17px; color: var(--text); }
.insight-card p { font-size: 14px; color: var(--text-secondary); line-height: 1.7; }
#rec-topics { max-height: 320px; overflow-y: auto; }
#rec-topics .topic-item { cursor: pointer; }

/* Daily challenge */
.daily-challenge {
  background: linear-gradient(135deg, var(--accent-light), rgba(37,99,235,.04));
  border: 2px solid var(--blue-200);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.essay-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.essay-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; padding: 12px var(--space-md); text-align: left; border-bottom: 2px solid var(--border); }
.essay-table td { padding: 14px var(--space-md); border-bottom: 1px solid var(--border-light); }
.essay-table tr:hover td { background: var(--accent-light); }

/* ── Auth ── */
.auth-container { max-width: 420px; margin: 60px auto; padding: var(--space-2xl); }
.auth-container h2 { text-align: center; margin-bottom: var(--space-xl); }
.form-group { margin-bottom: var(--space-md); }
.form-group label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.form-group input, .form-group select {
  width: 100%; padding: 12px 16px; border: 2px solid var(--border);
  border-radius: var(--radius); font-size: 15px; background: var(--bg-card);
  transition: border-color .15s;
}
.form-group input:focus { outline: none; border-color: var(--accent); box-shadow: var(--shadow-accent); }
.auth-tabs { display: flex; margin-bottom: var(--space-lg); border-bottom: 2px solid var(--border-light); }
.auth-tabs button { flex: 1; padding: 12px; border: none; background: none; font-size: 15px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; }
.auth-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Toast ── */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  padding: 12px 24px; border-radius: var(--radius-full);
  background: var(--slate-900); color: #fff; font-size: 14px; font-weight: 600;
  z-index: 9999; opacity: 0; pointer-events: none; transition: all .3s ease;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(4px); }
.toast.success { background: var(--emerald-600); }
.toast.error { background: var(--red-600); }

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border-light); padding: var(--space-2xl) var(--space-lg);
  text-align: center; color: var(--text-muted); font-size: 13px;
  background: var(--bg-card);
}
.footer-links { display: flex; gap: var(--space-lg); justify-content: center; margin-bottom: var(--space-md); flex-wrap: wrap; }
.footer-links a { color: var(--text-secondary); font-size: 14px; }
.footer-links a:hover { color: var(--accent); }

/* ── Tabs ── */
.tab-bar { display: flex; gap: 4px; margin-bottom: var(--space-lg); overflow-x: auto; padding-bottom: 4px; }
.tab-bar a, .tab-bar button {
  padding: 8px 18px; border-radius: var(--radius-full);
  font-size: 14px; font-weight: 500; white-space: nowrap;
  border: none; background: transparent; color: var(--text-secondary);
  transition: all .15s;
}
.tab-bar a:hover, .tab-bar button:hover { background: var(--slate-100); color: var(--text); text-decoration: none; }
.tab-bar a.active, .tab-bar button.active { background: var(--slate-900); color: #fff; font-weight: 600; }

/* ── Skeleton / Empty ── */
.empty-state { text-align: center; padding: var(--space-3xl) var(--space-lg); color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: var(--space-md); opacity: .5; }
.empty-state h3 { margin-bottom: var(--space-sm); color: var(--text-secondary); }

/* ── Pagination ── */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: var(--space-xl); }
.pagination a, .pagination span {
  padding: 8px 14px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; border: 1px solid var(--border-light);
  color: var(--text-secondary); transition: all .15s;
}
.pagination a:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pagination .current { background: var(--slate-900); color: #fff; border-color: var(--slate-900); }

/* ── Admin ── */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; padding: 10px var(--space-md); text-align: left; border-bottom: 2px solid var(--border); background: var(--bg-card); position: sticky; top: 0; }
.admin-table td { padding: 10px var(--space-md); border-bottom: 1px solid var(--border-light); font-size: 13px; }
.admin-table tr:hover td { background: var(--accent-light); }

/* ── Badges & Tags ── */
.tag {
  display: inline-block; padding: 4px 12px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600; margin: 2px 4px 2px 0;
  background: var(--slate-100); color: var(--text-secondary);
}
a.tag:hover { background: var(--accent-light); color: var(--accent); text-decoration: none; }
.tag-active, a.tag-active { background: var(--slate-900); color: #fff; }
.tag-active:hover, a.tag-active:hover { background: var(--slate-800); color: #fff; }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600;
}
.badge-green { background: #D1FAE5; color: #065F46; }
.badge-gray { background: #F3F4F6; color: #4B5563; }
.badge-gold { background: #FEF3C7; color: #92400E; }

/* ── Golden Tip ── */
.golden-tip {
  background: linear-gradient(135deg, #FFFBEB 0%, #FFF7ED 100%);
  border: 1px solid #FCD34D; border-radius: var(--radius-lg);
  padding: var(--space-lg); margin: var(--space-lg) 0;
  display: flex; align-items: flex-start; gap: 12px;
}
.golden-tip .tip-icon { font-size: 24px; flex-shrink: 0; }

/* ── Social proof / Testimonial ── */
.testimonial-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  padding: var(--space-xl); border: 1px solid var(--border-light);
  text-align: left;
}
.testimonial-card .quote { font-size: 15px; font-style: italic; color: var(--text-secondary); margin-bottom: var(--space-md); line-height: 1.7; }
.testimonial-card .author { font-size: 14px; font-weight: 700; }

/* ── Misc utilities ── */
.text-center { text-align: center; }
.text-gradient { background: var(--gradient-hero); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.mt-1 { margin-top: var(--space-md); }
.mt-2 { margin-top: var(--space-lg); }
.mt-3 { margin-top: var(--space-xl); }
.mt-4 { margin-top: var(--space-2xl); }
.mb-1 { margin-bottom: var(--space-md); }
.mb-2 { margin-bottom: var(--space-lg); }
.mb-3 { margin-bottom: var(--space-xl); }
.mb-4 { margin-bottom: var(--space-2xl); }
.hidden { display: none !important; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--space-md); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

/* ── Motion ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeInUp .5s ease forwards; }

/* ── Mobile Menu ── */
.mobile-toggle {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer;
  padding: 6px; border-radius: var(--radius);
  flex-direction: column; gap: 4px;
}
.mobile-toggle span {
  display: block; width: 20px; height: 2px;
  background: var(--text); border-radius: 2px;
  transition: all .25s ease;
}
.mobile-toggle.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.mobile-toggle.open span:nth-child(2) { opacity: 0; }
.mobile-toggle.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.nav-overlay { display: none; }

/* ── Skeleton Loading ── */
.skeleton {
  background: linear-gradient(90deg, var(--slate-100) 25%, var(--slate-200) 37%, var(--slate-100) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius);
}
@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
.skeleton-text { height: 16px; margin-bottom: 10px; border-radius: 4px; }
.skeleton-text:last-child { width: 60%; }
.skeleton-title { height: 24px; width: 70%; margin-bottom: 16px; border-radius: 4px; }
.skeleton-card { height: 200px; border-radius: var(--radius-lg); }

/* ── Scroll Animations ── */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .6s ease, transform .6s ease;
}
.reveal-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Selection ── */
::selection {
  background: var(--accent);
  color: #fff;
}

/* ── Focus ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); }

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ── Print ── */
@media print {
  .site-header, .site-footer, .btn, .nav-links, #toast, .mobile-toggle { display: none !important; }
  body { font-size: 12pt; color: #000; background: #fff; }
  .container { max-width: 100%; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  a { color: #000; text-decoration: underline; }
  .overall-score { background: #fff; color: #000; border: 2px solid #000; }
}

/* ── Dark Mode ── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1121;
    --bg-card: #1E293B;
    --bg-elevated: #1E293B;
    --border: #334155;
    --border-light: rgba(255,255,255,.08);
    --text: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --accent: #60A5FA;
    --accent-dark: #3B82F6;
    --accent-light: #1E3A5F;
    --accent-glow: rgba(96,165,250,.2);
    --shadow-xs: 0 1px 2px rgba(0,0,0,.3);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
    --shadow: 0 4px 6px -1px rgba(0,0,0,.4), 0 2px 4px -2px rgba(0,0,0,.3);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,.5), 0 4px 6px -4px rgba(0,0,0,.3);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.5), 0 8px 10px -6px rgba(0,0,0,.3);
    --shadow-xl: 0 25px 50px -12px rgba(0,0,0,.6);
    --shadow-accent: 0 4px 14px 0 rgba(96,165,250,.2);
  }
  .site-header { background: rgba(15,23,42,.88); }
  .site-header { border-bottom-color: rgba(255,255,255,.06); }
  .essay-textarea { background: var(--bg-card); color: var(--text); }
  .btn-outline { color: var(--text-secondary); border-color: var(--border); }
  .btn-outline:hover { border-color: var(--text-muted); color: var(--text); }
  .btn-ghost:hover { background: rgba(255,255,255,.05); }
  .topic-panel { background: var(--bg-card); }
  .topic-panel-header { background: var(--bg-card); }
  .stat { background: var(--bg); }
  .article-body { color: var(--text-secondary); }
  .article-body strong { color: var(--text); }
  .article-body blockquote { background: var(--accent-light); color: var(--text-secondary); }
  .hero .btn-accent { background: #fff; color: #1D4ED8; }
  .hero .btn-accent:hover { background: var(--slate-100); }
  .topic-display { background: linear-gradient(135deg, var(--accent-light), rgba(30,58,95,.5)); }
  .revised-block { background: linear-gradient(135deg, var(--accent-light), rgba(30,58,95,.5)); }
  .upgrade-cta { background: linear-gradient(135deg, rgba(245,158,11,.1), rgba(245,158,11,.05)); }
  .golden-tip { background: linear-gradient(135deg, rgba(245,158,11,.1), rgba(245,158,11,.05)); }
  .tab-bar a.active, .tab-bar button.active { background: var(--accent); }
  .pagination .current { background: var(--accent); }
  .nav-links a.btn-nav { background: var(--accent); }
  .nav-links a.btn-nav:hover { background: var(--accent-dark); }
  .plan-badge.free { background: var(--slate-700); color: var(--slate-400); }
  .badge-gray { background: var(--slate-700); color: var(--slate-300); }
  .usage-bar-track { background: var(--slate-700); }
  .btn-primary { background: var(--accent); }
  .btn-primary:hover { background: var(--accent-dark); }
  .btn-accent { background: var(--accent); color: #0F172A; }
  .btn-accent:hover { background: #93C5FD; box-shadow: 0 4px 16px var(--accent-glow); }
  .card-interactive:hover { border-color: var(--accent); }
  .feature-card:hover { box-shadow: var(--shadow-lg); }
  .topic-item:hover { background: var(--accent-light); }
  .topic-item.active { background: var(--accent-light); }
  .skeleton { background: linear-gradient(90deg, var(--slate-700) 25%, var(--slate-600) 37%, var(--slate-700) 63%); background-size: 400% 100%; }
  .dash-stat-card:hover { box-shadow: var(--shadow-md); }
  .chart-card { background: var(--bg-card); }
  .insight-card { background: var(--bg-card); }
  .daily-challenge { background: linear-gradient(135deg, rgba(96,165,250,.08), rgba(96,165,250,.02)); border-color: rgba(96,165,250,.25); }
  .dash-stat-num { color: var(--accent); }
}

/* Manual theme toggle support */
[data-theme="dark"] {
  --bg: #0B1121;
  --bg-card: #1E293B;
  --bg-elevated: #1E293B;
  --border: #334155;
  --border-light: rgba(255,255,255,.08);
  --text: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --accent: #60A5FA;
  --accent-dark: #3B82F6;
  --accent-light: #1E3A5F;
  --accent-glow: rgba(96,165,250,.2);
}
[data-theme="light"] {
  --bg: var(--slate-50);
  --bg-card: var(--white);
  --border: var(--slate-200);
  --border-light: rgba(0,0,0,.06);
  --text: var(--slate-900);
  --text-secondary: var(--slate-600);
  --text-muted: var(--slate-400);
  --accent: var(--blue-600);
  --accent-light: var(--blue-50);
  --accent-glow: rgba(37,99,235,.12);
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .practice-layout { grid-template-columns: 1fr; }
  .topic-panel { position: static; max-height: none; }
}

@media (max-width: 768px) {
  .hero { padding: var(--space-2xl) var(--space-md); }
  .hero h1 { font-size: 28px; }
  .hero p { font-size: 15px; }
  .hero-actions { flex-direction: column; align-items: center; }
  .hero .btn-accent, .hero .btn-outline-white { width: 100%; max-width: 320px; }
  .stats-bar { grid-template-columns: repeat(3, 1fr); gap: var(--space-sm); margin-top: -24px; padding: 0 var(--space-sm); }
  .stat-card { padding: var(--space-md); }
  .stat-card .stat-num { font-size: 24px; }
  .stat-card .stat-label { font-size: 11px; }
  .section { padding: var(--space-2xl) 0; }
  .section-title { font-size: 22px; }
  .pricing-grid { grid-template-columns: 1fr; }
  .pricing-card.featured { transform: none; }
  .pricing-card.featured:hover { transform: none; }
  .nav-links a { padding: 6px 10px; font-size: 12px; }
  .essay-textarea { min-height: 300px; font-size: 15px; }
  .overall-score .big-score { font-size: 56px; }
  .score-card .band { font-size: 32px; }
  .score-grid { grid-template-columns: repeat(2, 1fr); }
  .feature-grid { grid-template-columns: 1fr; }
  .article-grid { grid-template-columns: 1fr; }
  .practice-layout { grid-template-columns: 1fr; }
  .topic-panel { position: static; max-height: none; }
  .flex-between { flex-direction: column; align-items: flex-start; }
  .dash-header { flex-direction: column; align-items: flex-start; }

  /* Mobile nav */
  .mobile-toggle { display: flex; }
  .nav-links {
    position: fixed; top: var(--header-h); left: 0; right: 0; bottom: 0;
    background: var(--bg-card);
    flex-direction: column;
    padding: var(--space-xl);
    transform: translateX(100%);
    transition: transform .3s ease;
    z-index: 99;
  }
  .nav-links.open {
    transform: translateX(0);
    display: flex;
  }
  .nav-links a {
    padding: 14px 20px; font-size: 17px;
    width: 100%; text-align: center;
    border-radius: var(--radius);
  }
  .header-inner { padding: 0 var(--space-md); }

  .writing-toolbar { gap: 6px; }
  .writing-toolbar .stat { padding: 6px 10px; font-size: 12px; }
  .stat.timer { font-size: 16px; min-width: 56px; }
}
