/* ============================================
   CDG StudyMind - Editorial Calm Design
   Inspired by anthropic.com aesthetic
   ============================================ */

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

:root {
  /* Colors - Warm editorial palette */
  --bg-primary: #F5F1EA;
  --bg-secondary: #EFE9DD;
  --bg-tertiary: #E8E1D2;
  --bg-card: #FBF8F2;
  --bg-card-hover: #F1ECE1;
  --bg-glass: rgba(245, 241, 234, 0.85);

  --text-primary: #1F1B16;
  --text-secondary: #57534E;
  --text-tertiary: #7A736B;
  --text-muted: #A89E91;

  --accent: #C4633F;
  --accent-light: #D9784F;
  --accent-deep: #9B4D30;
  --accent-soft: #E8C9B5;

  --success: #5C7A50;
  --warning: #B8893D;
  --error: #A84C3A;

  --border: #DCD3C2;
  --border-hover: #C4B79F;
  --border-accent: #C4633F;

  --shadow-sm: 0 1px 2px rgba(60, 45, 30, 0.04);
  --shadow-md: 0 2px 8px rgba(60, 45, 30, 0.06);
  --shadow-lg: 0 8px 24px rgba(60, 45, 30, 0.08);

  /* Typography */
  --font-serif: 'Source Serif 4', 'Source Serif Pro', 'Georgia', 'Songti SC', 'Noto Serif TC', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'JetBrains 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: 72px;
  --space-4xl: 96px;

  /* Border Radius - sharper, more editorial */
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-xl: 8px;
  --radius-full: 9999px;

  /* Transitions - subtle */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.35s ease;
}

/* ---------- Dark Theme ---------- */
[data-theme="dark"] {
  --bg-primary: #1A1714;
  --bg-secondary: #221E1A;
  --bg-tertiary: #2B2620;
  --bg-card: #221E1A;
  --bg-card-hover: #2B2620;
  --bg-glass: rgba(26, 23, 20, 0.85);

  --text-primary: #F0EBE3;
  --text-secondary: #B5AC9E;
  --text-tertiary: #8A8175;
  --text-muted: #6B6359;

  --accent: #D9784F;
  --accent-light: #E08858;
  --accent-deep: #C4633F;
  --accent-soft: #4A3528;

  --success: #7A9E6E;
  --warning: #D4A55C;
  --error: #CC6B58;

  --border: #3A342D;
  --border-hover: #4D4640;
  --border-accent: #D9784F;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] body {
  color-scheme: dark;
}

[data-theme="dark"] .nav {
  background: rgba(26, 23, 20, 0.82);
}

[data-theme="dark"] .bg-grid {
  background-image:
    linear-gradient(to right, rgba(240, 235, 227, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(240, 235, 227, 0.03) 1px, transparent 1px);
}

[data-theme="dark"] .bg-glow-1 {
  background: radial-gradient(circle at center, rgba(217, 120, 79, 0.10) 0%, transparent 60%);
}

[data-theme="dark"] .bg-glow-2 {
  background: radial-gradient(circle at center, rgba(196, 99, 63, 0.07) 0%, transparent 65%);
}

[data-theme="dark"] .mockup-bubble.user .mockup-line {
  background: rgba(240, 235, 227, 0.45);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.65;
  overflow-x: hidden;
  font-feature-settings: "ss01", "cv01";
}

/* ---------- Background Effects (restrained editorial layers) ---------- */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(31, 27, 22, 0.022) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(31, 27, 22, 0.022) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, #000 40%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, #000 40%, transparent 100%);
}

.bg-glow-1 {
  position: fixed;
  top: -20vh;
  right: -10vw;
  width: 60vw;
  height: 60vw;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(196, 99, 63, 0.07) 0%, transparent 60%);
  filter: blur(8px);
}

.bg-glow-2 {
  position: fixed;
  bottom: -25vh;
  left: -15vw;
  width: 55vw;
  height: 55vw;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(155, 77, 48, 0.05) 0%, transparent 65%);
  filter: blur(8px);
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  text-wrap: balance;
}

h1 { font-size: clamp(2.5rem, 5.5vw, 4.25rem); font-weight: 400; letter-spacing: -0.025em; line-height: 1.1; }
h2 { font-size: clamp(1.875rem, 3.5vw, 2.75rem); letter-spacing: -0.02em; }
h3 { font-size: 1.25rem; font-weight: 500; font-family: var(--font-sans); letter-spacing: 0; }
h4 { font-size: 1.05rem; font-weight: 500; font-family: var(--font-sans); letter-spacing: 0; }

p {
  color: var(--text-secondary);
  font-weight: 400;
  text-wrap: pretty;
}

.text-gradient {
  color: var(--accent-deep);
  font-style: italic;
}

.text-accent { color: var(--accent-deep); }

/* ---------- Layout ---------- */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
  position: relative;
  z-index: 1;
}

section {
  padding: var(--space-4xl) 0;
  position: relative;
  z-index: 1;
}

section:first-of-type {
  padding-top: var(--space-3xl);
}

/* ---------- Navigation ---------- */
.nav {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: var(--space-md) 0;
  backdrop-filter: blur(12px);
  background: rgba(245, 241, 234, 0.82);
  border-bottom: 1px solid var(--border);
}

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

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 500;
  font-size: 1.05rem;
  font-family: var(--font-serif);
  letter-spacing: -0.01em;
}

.logo-icon {
  width: 28px;
  height: 28px;
  background: var(--text-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--bg-primary);
}

.logo-mark {
  flex-shrink: 0;
  color: var(--text-primary);
  display: block;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-2xl);
  list-style: none;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color var(--transition-fast);
}

.nav-links a:hover { color: var(--text-primary); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 11px 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-base);
  position: relative;
  letter-spacing: 0;
}

.btn-primary {
  background: var(--text-primary);
  color: var(--bg-primary);
  border-color: var(--text-primary);
}

.btn-primary:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-hover);
}

.btn-secondary:hover {
  border-color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.btn-google {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-hover);
  font-weight: 500;
}

.btn-google:hover {
  background: var(--bg-primary);
  border-color: var(--text-primary);
}

.btn-sm { padding: 7px 14px; font-size: 0.825rem; }
.btn-lg { padding: 14px 28px; font-size: 0.95rem; }
.btn-icon { padding: 9px; border-radius: var(--radius-sm); }

/* ---------- Header Controls (Theme + Language) ---------- */
.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.icon-btn:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

/* Sun icon hidden in light mode, moon hidden in dark mode */
[data-theme="dark"] .icon-sun { display: inline-flex; }
[data-theme="dark"] .icon-moon { display: none; }
.icon-sun { display: none; }
.icon-moon { display: inline-flex; }

/* Language switcher dropdown */
.lang-switcher {
  position: relative;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 36px;
  padding: 0 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.lang-btn:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.lang-btn svg {
  width: 14px;
  height: 14px;
  transition: transform var(--transition-fast);
}

.lang-switcher.open .lang-btn svg {
  transform: rotate(180deg);
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 150px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity var(--transition-fast), transform var(--transition-fast), visibility var(--transition-fast);
  z-index: 200;
}

.lang-switcher.open .lang-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.lang-option:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.lang-option.active {
  color: var(--accent-deep);
  font-weight: 500;
}

.lang-option .lang-flag {
  font-size: 1rem;
  line-height: 1;
}

.lang-option .lang-check {
  margin-left: auto;
  opacity: 0;
  color: var(--accent-deep);
}

.lang-option.active .lang-check {
  opacity: 1;
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  transition: border-color var(--transition-base), background var(--transition-base);
}

.card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.card-glow:hover {
  box-shadow: none;
  border-color: var(--border-hover);
}

.card-icon {
  width: 36px;
  height: 36px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-bottom: var(--space-md);
  border: 1px solid var(--border);
}

/* ---------- Hero Section ---------- */
.hero {
  min-height: 88vh;
  display: flex;
  align-items: center;
  padding-top: var(--space-3xl);
  padding-bottom: var(--space-3xl);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: var(--space-3xl);
  align-items: center;
  width: 100%;
}

.hero-content {
  max-width: 560px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
  letter-spacing: 0.02em;
}

.hero-badge .dot {
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.hero h1 {
  margin-bottom: var(--space-lg);
}

.hero p {
  font-size: 1.1rem;
  margin-bottom: var(--space-2xl);
  max-width: 520px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.hero-visual {
  display: block;
  position: relative;
  perspective: 1200px;
}

/* ---------- Product Mockup ---------- */
.mockup {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow:
    0 1px 2px rgba(60, 45, 30, 0.06),
    0 12px 32px rgba(60, 45, 30, 0.10),
    0 32px 64px rgba(60, 45, 30, 0.06);
  overflow: hidden;
  transform: rotateY(-4deg) rotateX(2deg) translateY(0);
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  opacity: 0;
  animation: mockupIn 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.35s forwards;
}

.mockup:hover {
  transform: rotateY(-1deg) rotateX(0.5deg) translateY(-4px);
}

@keyframes mockupIn {
  from { opacity: 0; transform: rotateY(-8deg) rotateX(4deg) translateY(24px); }
  to { opacity: 1; transform: rotateY(-4deg) rotateX(2deg) translateY(0); }
}

.mockup-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.mockup-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border-hover);
}

.mockup-dot:nth-child(1) { background: #D9784F; opacity: 0.5; }
.mockup-dot:nth-child(2) { background: #B8893D; opacity: 0.5; }
.mockup-dot:nth-child(3) { background: #5C7A50; opacity: 0.5; }

.mockup-url {
  margin-left: 8px;
  padding: 3px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: -0.01em;
}

.mockup-body {
  display: grid;
  grid-template-columns: 64px 1fr;
  min-height: 360px;
}

.mockup-sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.mockup-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.mockup-logo span {
  font-size: 0.55rem;
  font-family: var(--font-serif);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.mockup-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.mockup-nav-item {
  width: 100%;
  height: 24px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
}

.mockup-nav-item.active {
  background: var(--bg-card);
  border-color: var(--border);
}

.mockup-user {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.mockup-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--border);
}

.mockup-user-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
}

.mockup-main {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  background: var(--bg-card);
}

.mockup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

.mockup-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.mockup-bubble {
  max-width: 78%;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mockup-bubble.user {
  align-self: flex-end;
  background: var(--text-primary);
}

.mockup-bubble.user .mockup-line {
  background: rgba(245, 241, 234, 0.55);
}

.mockup-bubble.assistant {
  align-self: flex-start;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.mockup-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 4px;
}

.mockup-input .mockup-line {
  flex: 1;
}

.mockup-send {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  background: var(--text-primary);
  flex-shrink: 0;
}

/* Skeleton line utilities for mockup */
.mockup-line {
  height: 5px;
  border-radius: 2px;
  background: var(--border-hover);
  opacity: 0.6;
}

.mockup-line.thick {
  height: 8px;
  opacity: 0.85;
}

.w-20 { width: 20%; }
.w-30 { width: 30%; }
.w-40 { width: 40%; }
.w-60 { width: 60%; }
.w-70 { width: 70%; }
.w-80 { width: 80%; }
.w-90 { width: 90%; }
.w-100 { width: 100%; }

@media (max-width: 640px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: var(--space-2xl);
  }
  .hero-visual { display: none; }
}

@media (max-width: 880px) {
  .mockup-body { min-height: 300px; }
  .mockup { transform: none; }
  .mockup:hover { transform: translateY(-2px); }
}

@media (max-width: 1024px) {
  .hero-grid {
    gap: var(--space-2xl);
  }
  .mockup-body { min-height: 320px; }
}

/* ---------- Features Grid ---------- */
.section-header {
  text-align: left;
  margin-bottom: var(--space-3xl);
  max-width: 640px;
}

.section-header p {
  max-width: 540px;
  margin: var(--space-md) 0 0;
  font-size: 1.02rem;
  line-height: 1.65;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.features-grid > .card {
  background: var(--bg-card);
  border: none;
  border-radius: 0;
  padding: var(--space-xl);
}

.features-grid > .card:hover {
  background: var(--bg-card-hover);
  border-color: transparent;
}

/* ---------- Stats Section ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-2xl);
  padding: var(--space-3xl) var(--space-2xl);
  background: transparent;
  border: none;
  border-radius: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.stat-item {
  text-align: left;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 400;
  font-family: var(--font-serif);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  background: none;
  -webkit-text-fill-color: currentColor;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
  letter-spacing: 0.01em;
}

/* ---------- Dashboard Layout ---------- */
.app-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg-primary);
}

.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  transition: transform var(--transition-base);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0 var(--space-xl);
  font-weight: 500;
  font-size: 1rem;
  font-family: var(--font-serif);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-lg);
  color: var(--text-primary);
}

.sidebar-nav {
  list-style: none;
  flex: 1;
}

.sidebar-nav li {
  margin-bottom: 2px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 9px var(--space-md);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  transition: all var(--transition-fast);
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.sidebar-nav a.active {
  color: var(--accent-deep);
  font-weight: 500;
}

.sidebar-nav .nav-icon {
  width: 18px;
  text-align: center;
  font-size: 0.95rem;
}

.sidebar-user {
  padding: var(--space-md);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.sidebar-user img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.sidebar-user .user-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
}

.sidebar-user .user-email {
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: var(--space-2xl) var(--space-3xl);
  background: var(--bg-primary);
}

/* ---------- Page Header ---------- */
.page-header {
  margin-bottom: var(--space-2xl);
}

.page-header h1 {
  font-size: 1.875rem;
  margin-bottom: var(--space-xs);
  font-family: var(--font-serif);
  font-weight: 400;
}

.page-header p {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* ---------- Upload Zone ---------- */
.upload-zone {
  border: 1px dashed var(--border-hover);
  border-radius: var(--radius-lg);
  padding: var(--space-3xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
  background: var(--bg-card);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

.upload-zone .upload-icon {
  font-size: 2rem;
  margin-bottom: var(--space-md);
}

.upload-zone p {
  margin-bottom: var(--space-sm);
}

.upload-zone .upload-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------- Chat Interface ---------- */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.chat-message {
  display: flex;
  gap: var(--space-md);
  max-width: 85%;
  animation: fadeIn 0.3s ease;
}

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

.chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.chat-message.user .chat-avatar {
  background: var(--text-primary);
  color: var(--bg-primary);
  border-color: var(--text-primary);
}

.chat-message.assistant .chat-avatar {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
}

.chat-bubble {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.93rem;
  line-height: 1.7;
}

.chat-message.user .chat-bubble {
  background: var(--text-primary);
  color: var(--bg-primary);
}

.chat-message.assistant .chat-bubble {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.chat-bubble strong { color: var(--accent-deep); font-weight: 600; }
.chat-bubble ul, .chat-bubble ol { padding-left: 20px; margin: 8px 0; }
.chat-bubble li { margin-bottom: 4px; }
.chat-bubble code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--accent-deep);
}

.chat-input-area {
  padding: var(--space-md) var(--space-xl);
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

.chat-input-wrapper {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 11px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.93rem;
  resize: none;
  min-height: 44px;
  max-height: 200px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.chat-input:focus {
  border-color: var(--text-primary);
}

.chat-input::placeholder {
  color: var(--text-muted);
}

/* ---------- Documents List ---------- */
.doc-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.doc-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
  cursor: pointer;
}

.doc-item:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.doc-icon {
  width: 38px;
  height: 38px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.doc-info { flex: 1; min-width: 0; }

.doc-title {
  font-weight: 500;
  font-size: 0.93rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-meta {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.doc-actions {
  display: flex;
  gap: var(--space-sm);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.doc-item:hover .doc-actions { opacity: 1; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 2px;
  padding: 0;
  background: transparent;
  border-radius: 0;
  margin-bottom: var(--space-xl);
  width: fit-content;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 9px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  border-radius: 0;
  cursor: pointer;
  transition: color var(--transition-fast);
  position: relative;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
}

.tab:hover { color: var(--text-primary); }

.tab.active {
  background: transparent;
  color: var(--text-primary);
  box-shadow: none;
  border-bottom-color: var(--text-primary);
}

/* ---------- Memory/Goals Section ---------- */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-lg);
}

.memory-category h3 {
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-sans);
  color: var(--text-primary);
}

.memory-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-sm);
  border: 1px solid var(--border);
}

.memory-item p {
  font-size: 0.88rem;
  flex: 1;
}

/* ---------- Loading States ---------- */
.loading {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-deep);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Toast Notifications ---------- */
.toast-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  padding: 11px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.success { border-left: 2px solid var(--success); }
.toast.error { border-left: 2px solid var(--error); }
.toast.info { border-left: 2px solid var(--accent); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 27, 22, 0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.modal h2 { margin-bottom: var(--space-md); font-family: var(--font-serif); font-weight: 400; }
.modal p { margin-bottom: var(--space-xl); }

.modal-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
}

/* ---------- Input Fields ---------- */
.input-group {
  margin-bottom: var(--space-md);
}

.input-label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
  letter-spacing: 0.01em;
}

.input-field {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.93rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.input-field:focus {
  border-color: var(--text-primary);
}

.input-field::placeholder { color: var(--text-muted); }

select.input-field {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357534E' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ---------- Progress Bar ---------- */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-deep);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: var(--space-lg);
  }

  .nav-links { display: none; }

  .mobile-menu-btn {
    display: flex !important;
  }

  .hero-actions { flex-direction: column; }
  .hero-actions .btn { width: 100%; }

  .chat-container { height: calc(100vh - 180px); }
  .chat-message { max-width: 95%; }

  .section-header { text-align: left; }

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

.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------- Utility Classes ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: 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); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.text-center { text-align: center; }
.hidden { display: none !important; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Section Overrides (cleaner inline styles) ---------- */
section[style*="background: var(--bg-secondary)"] {
  background: var(--bg-secondary) !important;
}

.card[style*="linear-gradient"] {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
  padding: var(--space-4xl) !important;
}

.card[style*="linear-gradient"] h2 {
  font-size: clamp(1.875rem, 3.5vw, 2.5rem);
}

.card[style*="linear-gradient"] p {
  color: var(--text-secondary);
}

footer {
  border-top: 1px solid var(--border) !important;
  padding: var(--space-2xl) 0 !important;
}

footer .logo-mark {
  width: 20px;
  height: 20px;
}

footer p {
  font-size: 0.78rem !important;
  color: var(--text-tertiary) !important;
}

/* Steps numbers - editorial feel */
.features-grid .card div[style*="font-size:2rem"] {
  font-family: var(--font-serif) !important;
  font-weight: 400 !important;
  color: var(--accent-deep) !important;
  font-size: 1.5rem !important;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-md) !important;
}

/* Hero badge refinement */
.hero-badge {
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 500;
}

/* ============================================
   Subtle motion — tuned for editorial calm
   ============================================ */

/* Hero entrance — gentle staggered fade-up */
.hero-content > * {
  opacity: 0;
  transform: translateY(14px);
  animation: heroIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.hero-content > *:nth-child(1) { animation-delay: 0.08s; }
.hero-content > *:nth-child(2) { animation-delay: 0.20s; }
.hero-content > *:nth-child(3) { animation-delay: 0.32s; }
.hero-content > *:nth-child(4) { animation-delay: 0.44s; }

@keyframes heroIn {
  to { opacity: 1; transform: translateY(0); }
}

/* Scroll reveal — soft fade-up, no scale */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered grids — children fade in sequence */
.stagger > * {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.stagger.is-visible > *:nth-child(1) { transition-delay: 0.04s; }
.stagger.is-visible > *:nth-child(2) { transition-delay: 0.12s; }
.stagger.is-visible > *:nth-child(3) { transition-delay: 0.20s; }
.stagger.is-visible > *:nth-child(4) { transition-delay: 0.28s; }
.stagger.is-visible > *:nth-child(5) { transition-delay: 0.36s; }
.stagger.is-visible > *:nth-child(6) { transition-delay: 0.44s; }
.stagger.is-visible > * {
  opacity: 1;
  transform: translateY(0);
}

/* Gentle card lift — restrained, no shadow flare */
.features-grid > .card {
  transition: background var(--transition-base),
              border-color var(--transition-base),
              transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.features-grid > .card:hover {
  transform: translateY(-2px);
}

/* CTA card — soft zoom-in on reveal */
.card[data-reveal="zoom"] {
  transform: scale(0.98);
  transform-origin: center;
}
.card[data-reveal="zoom"].is-visible {
  transform: scale(1);
}

/* Accessibility — respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal, .stagger > *, .hero-content > *, .card[data-reveal="zoom"] {
    opacity: 1 !important;
    transform: none !important;
  }
}
