/*
 * Commentarius Design System
 * "Classical Codex" - Refined Academic Luxury
 * Where ancient wisdom meets modern precision
 */

/* ========================================
   Google Fonts Import
   ======================================== */
@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=Crimson+Pro:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ========================================
   CSS Custom Properties (Design Tokens)
   ======================================== */
:root {
  /* Colors - Antiquarian Palette */
  --color-ink: #0d1117;
  --color-ink-rich: #1a1f26;
  --color-ink-muted: #3d4450;
  --color-ink-subtle: #5c6370;

  --color-parchment: #faf7f2;
  --color-parchment-warm: #f5f0e8;
  --color-vellum: #fffdf8;
  --color-cream: #fefcf7;

  /* Primary - Pompeii Terracotta */
  --color-terracotta: #a04030;
  --color-terracotta-light: #c25545;
  --color-terracotta-dark: #7a3025;
  --color-terracotta-muted: rgba(160, 64, 48, 0.12);

  /* Accent - Illumination Gold */
  --color-gold: #c49b2a;
  --color-gold-light: #dbb33d;
  --color-gold-dark: #9a7820;
  --color-gold-muted: rgba(196, 155, 42, 0.15);
  --color-gold-glow: rgba(196, 155, 42, 0.25);

  /* Secondary - Manuscript Olive */
  --color-olive: #4a5043;
  --color-olive-light: #5f6858;
  --color-olive-muted: rgba(74, 80, 67, 0.12);

  /* Neutrals - Warm Stone */
  --color-stone: #8b8579;
  --color-stone-light: #b5b0a6;
  --color-stone-lighter: #e0ddd6;
  --color-stone-lightest: #eceae5;

  /* Semantic */
  --color-success: #4a5043;
  --color-error: #a04030;
  --color-warning: #c49b2a;

  /* Gradients */
  --gradient-gold: linear-gradient(135deg, var(--color-gold) 0%, var(--color-gold-light) 100%);
  --gradient-terracotta: linear-gradient(135deg, var(--color-terracotta) 0%, var(--color-terracotta-light) 100%);
  --gradient-ink: linear-gradient(135deg, var(--color-ink) 0%, var(--color-ink-rich) 100%);
  --gradient-parchment: linear-gradient(180deg, var(--color-parchment) 0%, var(--color-parchment-warm) 100%);
  --gradient-shimmer: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.4) 50%, transparent 100%);
  --gradient-border-gold: linear-gradient(90deg, transparent, var(--color-gold), transparent);

  /* Typography */
  --font-display: 'Cormorant Garamond', 'Garamond', 'Times New Roman', serif;
  --font-body: 'Crimson Pro', 'Georgia', serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;

  /* Font Sizes - Modular Scale (1.25) */
  --text-xs: 0.64rem;
  --text-sm: 0.8rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.563rem;
  --text-3xl: 1.953rem;
  --text-4xl: 2.441rem;
  --text-5xl: 3.052rem;
  --text-6xl: 3.815rem;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;
  --space-5xl: 8rem;

  /* Shadows - Layered Depth */
  --shadow-xs: 0 1px 2px rgba(13, 17, 23, 0.04);
  --shadow-sm: 0 2px 4px rgba(13, 17, 23, 0.04), 0 1px 2px rgba(13, 17, 23, 0.02);
  --shadow-md: 0 4px 16px rgba(13, 17, 23, 0.06), 0 2px 4px rgba(13, 17, 23, 0.03);
  --shadow-lg: 0 12px 32px rgba(13, 17, 23, 0.08), 0 4px 12px rgba(13, 17, 23, 0.04);
  --shadow-xl: 0 24px 48px rgba(13, 17, 23, 0.12), 0 8px 24px rgba(13, 17, 23, 0.06);
  --shadow-inner: inset 0 2px 4px rgba(13, 17, 23, 0.03);
  --shadow-glow-gold: 0 0 24px var(--color-gold-glow), 0 0 48px rgba(196, 155, 42, 0.1);
  --shadow-glow-terracotta: 0 0 20px rgba(160, 64, 48, 0.15);

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --transition-fast: 150ms var(--ease-out);
  --transition-base: 250ms var(--ease-out);
  --transition-slow: 400ms var(--ease-out);
  --transition-slower: 600ms var(--ease-out);

  /* Layout */
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1200px;
  --container-2xl: 1400px;

  /* Z-index Scale */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal: 400;
  --z-toast: 500;
}

/* ========================================
   Dark Mode (Optional)
   ======================================== */
@media (prefers-color-scheme: dark) {
  :root {
    --color-ink: #f0ebe3;
    --color-ink-rich: #e5ded3;
    --color-ink-muted: #b5aea3;
    --color-ink-subtle: #8a8378;

    --color-parchment: #0d1117;
    --color-parchment-warm: #151b22;
    --color-vellum: #1a2028;
    --color-cream: #1e252e;

    --color-stone: #6b665c;
    --color-stone-light: #4a463e;
    --color-stone-lighter: #2d2a26;
    --color-stone-lightest: #1f1c19;
  }
}

/* ========================================
   Reset & Base
   ======================================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.7;
  color: var(--color-ink);
  background: var(--color-parchment);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Paper Texture Overlay */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  opacity: 0.025;
  pointer-events: none;
  z-index: -1;
}

/* ========================================
   Custom Scrollbar
   ======================================== */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--color-parchment-warm);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--color-gold) 0%, var(--color-terracotta) 100%);
  border-radius: 6px;
  border: 3px solid var(--color-parchment-warm);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--color-gold-light) 0%, var(--color-terracotta-light) 100%);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-gold) var(--color-parchment-warm);
}

/* ========================================
   Selection
   ======================================== */
::selection {
  background: var(--color-gold-muted);
  color: var(--color-ink);
}

/* ========================================
   Typography
   ======================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.2;
  color: var(--color-ink);
  letter-spacing: -0.02em;
}

h1 {
  font-size: var(--text-5xl);
  font-weight: 400;
  letter-spacing: -0.03em;
}

h2 {
  font-size: var(--text-4xl);
  font-weight: 400;
}

h3 {
  font-size: var(--text-2xl);
  font-weight: 500;
}

h4 {
  font-size: var(--text-xl);
  font-weight: 600;
}

p {
  color: var(--color-ink-muted);
  line-height: 1.8;
}

/* Italic Latin Text Style */
.latin-text,
em {
  font-style: italic;
  color: var(--color-terracotta);
}

/* Drop Cap - Illuminated Initial */
.drop-cap::first-letter {
  float: left;
  font-family: var(--font-display);
  font-size: 4rem;
  line-height: 0.8;
  font-weight: 600;
  color: var(--color-terracotta);
  margin-right: 0.5rem;
  margin-top: 0.1rem;
}

/* Label / Eyebrow Text */
.eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-stone);
}

/* Gradient Text */
.text-gradient {
  background: linear-gradient(135deg, var(--color-gold) 0%, var(--color-terracotta) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

a {
  color: var(--color-terracotta);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-terracotta-light);
}

/* ========================================
   Layout
   ======================================== */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

.container-narrow { max-width: var(--container-md); }
.container-wide { max-width: var(--container-2xl); }

/* ========================================
   Decorative Elements
   ======================================== */

/* Classical Ornament Divider */
.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  margin: var(--space-3xl) 0;
}

.ornament::before,
.ornament::after {
  content: '';
  flex: 1;
  max-width: 200px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-stone-lighter), transparent);
}

.ornament-symbol {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-gold);
}

/* Gold Accent Line */
.accent-line {
  width: 60px;
  height: 3px;
  background: var(--gradient-gold);
  border-radius: 2px;
}

.accent-line-sm {
  width: 40px;
  height: 2px;
}

/* Border Top Accent */
.accent-border-top {
  position: relative;
}

.accent-border-top::before {
  content: '';
  position: absolute;
  top: 0;
  left: var(--space-xl);
  width: 48px;
  height: 3px;
  background: var(--gradient-gold);
  border-radius: 0 0 2px 2px;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.875rem 1.75rem;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, transparent 100%);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn:hover::after {
  opacity: 1;
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}

/* Primary Button - Dark Ink */
.btn-primary {
  background: var(--gradient-ink);
  color: var(--color-parchment);
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Secondary Button */
.btn-secondary {
  background: var(--color-cream);
  color: var(--color-ink);
  border: 1.5px solid var(--color-stone-lighter);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--color-parchment-warm);
  border-color: var(--color-stone-light);
  transform: translateY(-1px);
}

/* Gold Accent Button */
.btn-gold {
  background: var(--gradient-gold);
  color: white;
  box-shadow: var(--shadow-md), var(--shadow-glow-gold);
}

.btn-gold:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 32px var(--color-gold-glow);
}

/* Ghost Button */
.btn-ghost {
  background: transparent;
  color: var(--color-ink-muted);
  padding: 0.75rem 1.25rem;
}

.btn-ghost:hover {
  background: var(--color-stone-lightest);
  color: var(--color-ink);
}

/* Button Sizes */
.btn-sm {
  padding: 0.5rem 1rem;
  font-size: var(--text-sm);
}

.btn-lg {
  padding: 1.125rem 2.25rem;
  font-size: var(--text-lg);
}

/* ========================================
   Cards
   ======================================== */
.card {
  background: var(--color-cream);
  border: 1px solid var(--color-stone-lighter);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  transition: all var(--transition-base);
}

.card-elevated {
  box-shadow: var(--shadow-md);
  border: none;
}

.card-interactive {
  cursor: pointer;
}

.card-interactive:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-stone-light);
}

/* Card with Gold Accent */
.card-accent {
  position: relative;
}

.card-accent::before {
  content: '';
  position: absolute;
  top: 0;
  left: var(--space-xl);
  width: 48px;
  height: 3px;
  background: var(--gradient-gold);
  border-radius: 0 0 2px 2px;
}

/* Glass Card */
.card-glass {
  background: rgba(255, 253, 248, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(224, 221, 214, 0.6);
  box-shadow: var(--shadow-lg);
}

/* ========================================
   Forms
   ======================================== */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-ink);
  margin-bottom: var(--space-sm);
  letter-spacing: 0.02em;
}

.form-hint {
  font-size: var(--text-sm);
  color: var(--color-stone);
  margin-top: var(--space-xs);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.875rem 1.125rem;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-ink);
  background: var(--color-cream);
  border: 1.5px solid var(--color-stone-lighter);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-inner);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-gold);
  box-shadow: 0 0 0 4px var(--color-gold-muted), var(--shadow-inner);
  background: var(--color-vellum);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-stone);
}

.form-textarea {
  min-height: 140px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
}

/* Legacy form support */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 0.875rem 1.125rem;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-ink);
  background: var(--color-cream);
  border: 1.5px solid var(--color-stone-lighter);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-inner);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-gold);
  box-shadow: 0 0 0 4px var(--color-gold-muted), var(--shadow-inner);
  background: var(--color-vellum);
}

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-ink);
  margin-bottom: var(--space-sm);
}

.label-hint {
  font-weight: 400;
  color: var(--color-stone);
  font-size: var(--text-sm);
  display: block;
  margin-top: var(--space-xs);
}

/* ========================================
   Navigation
   ======================================== */
.nav-header {
  padding: var(--space-lg) 0;
  background: var(--color-cream);
  border-bottom: 1px solid var(--color-stone-lighter);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  transition: all var(--transition-base);
}

.nav-header.scrolled {
  background: rgba(254, 252, 247, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md);
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--container-xl);
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

.nav-logo {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 500;
  color: var(--color-ink);
  text-decoration: none;
  letter-spacing: -0.03em;
  transition: color var(--transition-fast);
}

.nav-logo:hover {
  color: var(--color-terracotta);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.nav-link {
  padding: 0.625rem 1rem;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-ink-muted);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0.375rem;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--gradient-gold);
  transform: translateX(-50%);
  transition: width var(--transition-fast);
  border-radius: 1px;
}

.nav-link:hover {
  color: var(--color-ink);
}

.nav-link:hover::after {
  width: 50%;
}

.nav-link.active {
  color: var(--color-ink);
  background: var(--color-parchment-warm);
}

/* ========================================
   Badges
   ======================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.3125rem 0.75rem;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--radius-full);
  transition: transform var(--transition-fast);
}

.badge:hover {
  transform: scale(1.05);
}

.badge-gold {
  background: var(--color-gold-muted);
  color: var(--color-gold-dark);
  border: 1px solid rgba(196, 155, 42, 0.25);
}

.badge-olive {
  background: var(--color-olive-muted);
  color: var(--color-olive);
  border: 1px solid rgba(74, 80, 67, 0.2);
}

.badge-terracotta {
  background: var(--color-terracotta-muted);
  color: var(--color-terracotta);
  border: 1px solid rgba(160, 64, 48, 0.2);
}

/* ========================================
   Alerts
   ======================================== */
.alert {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  animation: slideDown 0.3s var(--ease-out);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert-success {
  background: var(--color-olive-muted);
  color: var(--color-olive);
  border-left: 4px solid var(--color-olive);
}

.alert-error {
  background: var(--color-terracotta-muted);
  color: var(--color-terracotta);
  border-left: 4px solid var(--color-terracotta);
}

.alert-info {
  background: var(--color-gold-muted);
  color: var(--color-gold-dark);
  border-left: 4px solid var(--color-gold);
}

/* ========================================
   Progress
   ======================================== */
.progress-container {
  display: none;
  padding: var(--space-lg);
  background: var(--color-cream);
  border: 1px solid var(--color-stone-lighter);
  border-radius: var(--radius-xl);
  margin: var(--space-lg) 0;
}

.progress-container.active {
  display: block;
  animation: fadeIn 0.3s var(--ease-out);
}

.progress-bar-track,
.progress-bar-wrapper {
  width: 100%;
  height: 8px;
  background: var(--color-stone-lightest);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-md);
}

.progress-bar-fill,
.progress-bar {
  height: 100%;
  background: var(--gradient-gold);
  border-radius: var(--radius-full);
  transition: width 0.4s var(--ease-out);
  width: 0%;
  position: relative;
}

.progress-bar-fill::after,
.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--gradient-shimmer);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progress-text {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-stone);
  font-weight: 500;
}

/* ========================================
   Preview / Code Blocks
   ======================================== */
.preview-box {
  background: var(--color-ink);
  color: var(--color-stone-lighter);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.8;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  position: relative;
  box-shadow: var(--shadow-xl), inset 0 2px 20px rgba(0,0,0,0.2);
}

.preview-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-gold);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

/* ========================================
   Stats Grid
   ======================================== */
.stats-grid,
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-lg);
  margin: var(--space-lg) 0;
}

.stat-item {
  background: var(--color-cream);
  border: 1px solid var(--color-stone-lighter);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  text-align: center;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.stat-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-gold);
  transform: scaleX(0);
  transition: transform var(--transition-base);
}

.stat-item:hover::before {
  transform: scaleX(1);
}

.stat-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.stat-value,
.stat-number {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: 500;
  background: linear-gradient(135deg, var(--color-gold) 0%, var(--color-terracotta) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: var(--space-sm);
  display: block;
}

.stat-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-stone);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* ========================================
   Results
   ======================================== */
.results {
  display: none;
  margin-top: var(--space-xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--color-stone-lighter);
  animation: fadeIn 0.4s var(--ease-out);
}

.results.active {
  display: block;
}

/* ========================================
   Error Display
   ======================================== */
.error {
  display: none;
  background: var(--color-terracotta-muted);
  color: var(--color-terracotta);
  border-left: 4px solid var(--color-terracotta);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
  font-size: var(--text-base);
}

.error.active {
  display: block;
  animation: shake 0.4s var(--ease-out);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* ========================================
   Info Box / Next Step
   ======================================== */
.next-step,
.info-box {
  margin-top: var(--space-lg);
  padding: var(--space-lg);
  background: var(--color-gold-muted);
  border: 1px solid rgba(196, 155, 42, 0.2);
  border-radius: var(--radius-xl);
  position: relative;
}

.next-step::before,
.info-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--gradient-gold);
  border-radius: var(--radius-xl) 0 0 var(--radius-xl);
}

.next-step p,
.info-box p {
  font-size: var(--text-base);
  color: var(--color-ink);
  margin-bottom: var(--space-md);
}

.info-box h3 {
  color: var(--color-gold-dark);
  font-size: var(--text-base);
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

/* ========================================
   Note Cards
   ======================================== */
.note-card {
  background: var(--color-cream);
  border: 1px solid var(--color-stone-lighter);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  transition: all var(--transition-base);
}

.note-card:hover {
  box-shadow: var(--shadow-md);
}

.note-card.selected {
  border-color: var(--color-olive);
  background: var(--color-olive-muted);
  box-shadow: 0 0 0 3px rgba(74, 80, 67, 0.1);
}

.note-card.skipped {
  opacity: 0.5;
  border-color: var(--color-terracotta);
  background: var(--color-terracotta-muted);
}

.note-lemma {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  font-style: italic;
  color: var(--color-terracotta);
  margin-bottom: var(--space-sm);
}

.note-content {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--color-ink-muted);
  margin-bottom: var(--space-md);
  white-space: pre-wrap;
}

.note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.note-action-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn-keep {
  background: var(--color-olive);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-keep:hover {
  background: var(--color-olive-light);
  transform: translateY(-1px);
}

.btn-skip {
  background: var(--color-terracotta);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-skip:hover {
  background: var(--color-terracotta-light);
  transform: translateY(-1px);
}

.btn-regen {
  background: var(--gradient-gold);
  color: white;
  box-shadow: var(--shadow-sm), var(--shadow-glow-gold);
}

.btn-regen:hover {
  box-shadow: var(--shadow-md), 0 0 24px var(--color-gold-glow);
  transform: translateY(-1px);
}

/* ========================================
   Divider
   ======================================== */
.divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-xl) 0;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-stone-lighter), transparent);
}

.divider-text {
  font-size: var(--text-xs);
  color: var(--color-stone);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 600;
}

/* ========================================
   Notification Badge
   ======================================== */
.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-terracotta);
  color: white;
  border-radius: var(--radius-full);
  padding: 0.125rem 0.5rem;
  font-size: var(--text-xs);
  font-weight: 700;
  min-width: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  animation: popIn 0.3s var(--ease-spring);
}

@keyframes popIn {
  0% { transform: scale(0); }
  80% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ========================================
   Footer
   ======================================== */
.footer {
  padding: var(--space-3xl) 0;
  text-align: center;
  color: var(--color-stone);
  font-size: var(--text-sm);
  border-top: 1px solid var(--color-stone-lighter);
  margin-top: var(--space-4xl);
  position: relative;
}

.footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: var(--gradient-gold);
  border-radius: 2px;
}

/* ========================================
   Legacy Header Support
   ======================================== */
.header {
  padding: var(--space-md) 0;
  margin-bottom: var(--space-xl);
  border-bottom: 1px solid var(--color-stone-lighter);
}

.logo-text {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 500;
  color: var(--color-ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--color-stone);
  font-size: var(--text-base);
  margin-top: var(--space-xs);
}

/* ========================================
   API Status
   ======================================== */
.api-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
}

.api-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.9); }
}

.api-status.enabled {
  background: var(--color-olive-muted);
  color: var(--color-olive);
  border: 1px solid rgba(74, 80, 67, 0.2);
}

.api-status.enabled::before {
  background: var(--color-olive);
  box-shadow: 0 0 8px var(--color-olive);
}

.api-status.disabled {
  background: var(--color-terracotta-muted);
  color: var(--color-terracotta);
  border: 1px solid rgba(160, 64, 48, 0.2);
}

.api-status.disabled::before {
  background: var(--color-terracotta);
}

/* ========================================
   Utilities
   ======================================== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }

.text-muted { color: var(--color-stone); }
.text-gold { color: var(--color-gold); }
.text-terracotta { color: var(--color-terracotta); }

.font-display { font-family: var(--font-display); }
.font-mono { font-family: var(--font-mono); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.hidden { display: none !important; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.grid { display: grid; }

/* Hover Effects */
.hover-lift {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.hover-glow {
  transition: box-shadow var(--transition-base);
}

.hover-glow:hover {
  box-shadow: var(--shadow-glow-gold);
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.animate-fade-in { animation: fadeIn 0.4s var(--ease-out); }
.animate-slide-up { animation: slideUp 0.6s var(--ease-out); }
.animate-slide-down { animation: slideDown 0.6s var(--ease-out); }
.animate-scale-in { animation: scaleIn 0.4s var(--ease-out); }
.animate-float { animation: float 3s ease-in-out infinite; }

/* Staggered Animations */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }
.stagger-6 { animation-delay: 0.6s; }

/* Page Load Animation */
@keyframes pageReveal {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body > *:first-child {
  animation: pageReveal 0.7s var(--ease-out);
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
  :root {
    --space-lg: 1rem;
    --space-xl: 1.5rem;
    --space-2xl: 2rem;
  }

  h1 { font-size: var(--text-3xl); }
  h2 { font-size: var(--text-2xl); }

  .container {
    padding: 0 var(--space-md);
  }

  .nav-container {
    flex-direction: column;
    gap: var(--space-md);
  }

  .nav-links {
    flex-wrap: wrap;
    justify-content: center;
  }

  .stats-grid,
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stats-grid,
  .stats {
    grid-template-columns: 1fr;
  }

  .btn {
    width: 100%;
  }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
  .nav-header,
  .btn,
  .notification-badge {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  body::before {
    display: none;
  }

  .card,
  .preview-box {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}
