/* ============================================================
   AI Designer OS — Design System
   Inspired by Linear / Raycast / Notion / Apple
   ============================================================ */

/* === Theme System === */
/* Light Theme (default) */
:root,
[data-theme="light"] {
  /* Background layers */
  --bg: #F5F5F7;
  --bg-gradient: radial-gradient(ellipse 80% 60% at 50% -20%, rgba(107,92,230,0.06), transparent);
  --surface: #FFFFFF;
  --surface-2: #F8F8FA;
  --surface-3: #F0F0F5;
  --surface-hover: #EAEAEF;

  /* Borders */
  --border: #E5E5EA;
  --border-strong: #D1D1D6;
  --border-focus: #7C6FF0;

  /* Text */
  --text: #1D1D1F;
  --text-2: #6B6B75;
  --text-3: #9B9BA5;
  --text-4: #C0C0C8;

  /* Accent */
  --accent: #6B5CE6;
  --accent-2: #9B59E8;
  --accent-soft: rgba(107,92,230,0.10);
  --accent-glow: rgba(107,92,230,0.18);
  --accent-gradient: linear-gradient(135deg, #6B5CE6, #9B59E8);

  /* Status */
  --success: #22C55E;
  --success-soft: rgba(34,197,94,0.10);
  --warning: #F59E0B;
  --warning-soft: rgba(245,158,11,0.10);
  --danger: #EF4444;
  --danger-soft: rgba(239,68,68,0.10);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.10);
  --shadow-glow: 0 0 24px rgba(107,92,230,0.15);
}

/* Dark Theme */
[data-theme="dark"] {
  --bg: #08090A;
  --bg-gradient: radial-gradient(ellipse 80% 60% at 50% -20%, rgba(124,111,240,0.08), transparent);
  --surface: #111114;
  --surface-2: #17171C;
  --surface-3: #1E1E24;
  --surface-hover: #22222A;

  --border: #232328;
  --border-strong: #34343E;
  --border-focus: #7C6FF0;

  --text: #F0F0F2;
  --text-2: #A0A0A8;
  --text-3: #6B6B75;
  --text-4: #4A4A52;

  --accent: #7C6FF0;
  --accent-2: #B96CFF;
  --accent-soft: rgba(124,111,240,0.12);
  --accent-glow: rgba(124,111,240,0.25);
  --accent-gradient: linear-gradient(135deg, #7C6FF0, #B96CFF);

  --success: #34D399;
  --success-soft: rgba(52,211,153,0.12);
  --warning: #FBBF24;
  --warning-soft: rgba(251,191,36,0.12);
  --danger: #F87171;
  --danger-soft: rgba(248,113,113,0.12);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 24px rgba(124,111,240,0.20);
}

/* Auto Theme — fallback to light for now, JS handles system preference */
[data-theme="auto"] { /* inherits :root (light) by default, JS overrides */ }

/* Smooth theme transition */
.theme-transitioning,
.theme-transitioning *,
.theme-transitioning *::before,
.theme-transitioning *::after {
  transition-property: background-color, border-color, color, box-shadow, fill, stroke !important;
  transition-duration: 350ms !important;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* === Variables (shared) === */
:root {
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-full: 999px;

  /* Transitions */
  --t-fast: 150ms cubic-bezier(0.4,0,0.2,1);
  --t-normal: 250ms cubic-bezier(0.4,0,0.2,1);
  --t-slow: 500ms cubic-bezier(0.4,0,0.2,1);

  /* Layout */
  --sidebar-w: 240px;
  --content-max: 1100px;
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  background-image: var(--bg-gradient);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }
ul { list-style: none; }
::selection { background: var(--accent-soft); }

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

/* ============================================================
   Layout
   ============================================================ */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

/* === Sidebar === */
#sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: var(--sp-5) var(--sp-3);
  overflow-y: auto;
  z-index: 10;
}

.sb-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-2) var(--sp-5);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-4);
}

.sb-logo {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800;
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
  flex-shrink: 0;
}

.sb-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.sb-subtitle { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.sb-section { margin-bottom: var(--sp-4); }
.sb-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-4);
  padding: 0 var(--sp-3);
  margin-bottom: var(--sp-2);
}

.sb-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 450;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--t-fast);
  position: relative;
}

.sb-item:hover { background: var(--surface-2); color: var(--text); }

.sb-item.active {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 500;
}
.sb-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 16px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.sb-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.sb-item.active .sb-icon { opacity: 1; }

.sb-footer {
  margin-top: auto;
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}

/* Theme toggle in sidebar footer */
.sb-theme-toggle {
  display: flex;
  gap: 4px;
  margin-top: var(--sp-3);
  justify-content: center;
}

.theme-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  font-size: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-3);
  cursor: pointer;
  transition: all var(--t-fast);
}
.theme-btn:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-strong);
}
.theme-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 8px var(--accent-glow);
}

.sb-level-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  cursor: pointer;
  transition: all var(--t-fast);
}
.sb-level-card:hover { border-color: var(--border-strong); }

.sb-level-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-2); }
.sb-level-label { font-size: 12px; font-weight: 600; color: var(--text); }
.sb-level-num { font-family: var(--font-mono); font-size: 12px; color: var(--accent); font-weight: 600; }
.sb-level-bar { height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.sb-level-fill { height: 100%; background: var(--accent-gradient); border-radius: 2px; transition: width var(--t-slow); }
.sb-level-xp { font-size: 10px; color: var(--text-3); margin-top: var(--sp-1); font-family: var(--font-mono); }

/* === Content === */
#content {
  overflow-y: auto;
  padding: var(--sp-8) var(--sp-10);
  scroll-behavior: smooth;
}

.content-inner { max-width: var(--content-max); margin: 0 auto; }

/* Page header */
.page-head { margin-bottom: var(--sp-8); }
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.page-desc { font-size: 14px; color: var(--text-3); margin-top: var(--sp-1); }

/* ============================================================
   Components
   ============================================================ */

/* === Card === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  transition: border-color var(--t-fast);
}
.card:hover { border-color: var(--border-strong); }

.card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: var(--sp-3);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #6B5EE0; box-shadow: 0 2px 12px var(--accent-glow); }
.btn-ghost {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* === Progress bar === */
.progress {
  height: 8px;
  background: var(--surface-3);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 4px;
  transition: width var(--t-slow);
}

/* Progress large (for dashboard) */
.progress-lg { height: 12px; border-radius: 6px; }
.progress-lg .progress-fill { border-radius: 6px; }

/* === Badge / Tag === */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-3);
  color: var(--text-2);
}
.tag-accent { background: var(--accent-soft); color: var(--accent); }
.tag-success { background: var(--success-soft); color: var(--success); }
.tag-warning { background: var(--warning-soft); color: var(--warning); }

/* === Input === */
.input, .textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  color: var(--text);
  font-size: 14px;
  transition: all var(--t-fast);
  outline: none;
}
.input:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
  color: var(--text-3);
}
.empty-state-icon { font-size: 48px; margin-bottom: var(--sp-3); opacity: 0.3; }
.empty-state-text { font-size: 14px; }

/* ============================================================
   Dashboard
   ============================================================ */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}

.dash-hero {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  position: relative;
  overflow: hidden;
}
.hero-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.5;
}

.hero-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }
.hero-value { font-size: 48px; font-weight: 800; letter-spacing: -0.03em; margin: var(--sp-2) 0; font-family: var(--font-mono); }
.hero-value .unit { font-size: 20px; font-weight: 500; color: var(--text-3); }
.hero-sub { font-size: 13px; color: var(--text-2); }

/* Next Best Action card */
.nba-card {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--accent);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  position: relative;
  overflow: hidden;
  grid-column: 1 / -1;
}
.nba-card::after {
  content: '';
  position: absolute;
  top: -50%; right: -20%;
  width: 300px; height: 300px;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
  pointer-events: none;
}

.nba-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: var(--sp-3);
}
.nba-label::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.nba-title { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.4; margin-bottom: var(--sp-2); }
.nba-desc { font-size: 14px; color: var(--text-2); line-height: 1.5; }
.nba-impact { font-size: 13px; color: var(--success); margin-top: var(--sp-3); font-weight: 500; }
.nba-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-4); }

/* AI suggestion */
.ai-suggest {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  display: flex;
  gap: var(--sp-4);
}
.ai-suggest-avatar {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.ai-suggest-content { flex: 1; }
.ai-suggest-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin-bottom: var(--sp-1); }
.ai-suggest-text { font-size: 14px; line-height: 1.5; color: var(--text-2); }

/* Quick actions */
.quick-actions { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.quick-action {
  flex: 1;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  cursor: pointer;
  transition: all var(--t-fast);
}
.quick-action:hover { border-color: var(--accent); background: var(--surface-2); transform: translateY(-1px); }
.quick-action-icon { font-size: 20px; }
.quick-action-label { font-size: 13px; font-weight: 500; }
.quick-action-desc { font-size: 11px; color: var(--text-3); }

/* Streak display */
.streak-display {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 14px;
  font-weight: 600;
}
.streak-flame { font-size: 20px; }

/* ============================================================
   Projects
   ============================================================ */
.project-list { display: flex; flex-direction: column; gap: var(--sp-4); }

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  transition: all var(--t-fast);
  cursor: pointer;
}
.project-card:hover { border-color: var(--border-strong); }

.project-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: var(--sp-4); }
.project-name { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.project-meta { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-1); }
.project-progress-row { display: flex; align-items: center; gap: var(--sp-3); }
.project-progress-num { font-family: var(--font-mono); font-size: 14px; font-weight: 600; min-width: 42px; }

.stages-list { display: flex; flex-direction: column; gap: var(--sp-1); }
.stage-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  transition: background var(--t-fast);
  cursor: pointer;
}
.stage-item:hover { background: var(--surface-2); }
.stage-check {
  width: 20px; height: 20px;
  border: 2px solid var(--border-strong);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--t-fast);
}
.stage-check.done { background: var(--success); border-color: var(--success); }
.stage-check.done::after { content: '✓'; color: #fff; font-size: 12px; font-weight: 700; }
.stage-name { font-size: 14px; flex: 1; }
.stage-item.done .stage-name { color: var(--text-3); text-decoration: line-through; }
.stage-time { font-size: 11px; color: var(--text-4); font-family: var(--font-mono); }

/* ============================================================
   Focus Timer
   ============================================================ */
.focus-container { display: flex; flex-direction: column; align-items: center; padding: var(--sp-8) 0; }

.timer-ring {
  position: relative;
  width: 280px; height: 280px;
  display: flex; align-items: center; justify-content: center;
}
.timer-ring svg { position: absolute; width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring-bg { fill: none; stroke: var(--surface-3); stroke-width: 6; }
.timer-ring-fg { fill: none; stroke: url(#timer-grad); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset 1s linear; }

.timer-display {
  font-family: var(--font-mono);
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -0.02em;
  z-index: 1;
}
.timer-status { font-size: 13px; color: var(--text-3); margin-top: var(--sp-1); z-index: 1; }

.focus-controls { display: flex; gap: var(--sp-3); margin-top: var(--sp-6); }

.focus-session-info {
  display: flex;
  gap: var(--sp-8);
  margin-top: var(--sp-8);
  text-align: center;
}
.focus-stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }
.focus-stat-value { font-size: 24px; font-weight: 700; font-family: var(--font-mono); margin-top: var(--sp-1); }

/* Session end form */
.session-end { max-width: 500px; margin: var(--sp-8) auto; }
.session-end h3 { font-size: 18px; font-weight: 600; margin-bottom: var(--sp-4); }
.session-end .field { margin-bottom: var(--sp-4); }
.session-end label { display: block; font-size: 13px; font-weight: 500; margin-bottom: var(--sp-2); color: var(--text-2); }

/* ============================================================
   Insight
   ============================================================ */
.insight-input-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-6);
}
.insight-input-wrap:focus-within { border-color: var(--accent); }
.insight-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.4;
}
.insight-input::placeholder { color: var(--text-4); }
.insight-meta { display: flex; justify-content: space-between; align-items: center; margin-top: var(--sp-3); }

.insight-timeline { display: flex; flex-direction: column; gap: var(--sp-3); }
.insight-entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  display: flex;
  gap: var(--sp-4);
}
.insight-date {
  flex-shrink: 0;
  width: 56px;
  text-align: center;
}
.insight-date-day { font-size: 20px; font-weight: 700; font-family: var(--font-mono); }
.insight-date-month { font-size: 11px; color: var(--text-3); text-transform: uppercase; }
.insight-text { font-size: 15px; line-height: 1.5; color: var(--text); flex: 1; padding-top: 2px; }

/* ============================================================
   Inspiration Vault
   ============================================================ */
.vault-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--sp-3);
}
.vault-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  transition: all var(--t-fast);
  cursor: pointer;
}
.vault-item:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.vault-type { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-bottom: var(--sp-2); }
.vault-content { font-size: 14px; line-height: 1.5; margin-bottom: var(--sp-3); }
.vault-tags { display: flex; flex-wrap: wrap; gap: 4px; }

.vault-filter { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-5); flex-wrap: wrap; }

/* ============================================================
   Prompt Library
   ============================================================ */
.prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-4);
}
.prompt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  transition: all var(--t-fast);
}
.prompt-card:hover { border-color: var(--border-strong); }
.prompt-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
  font-family: var(--font-mono);
  max-height: 100px;
  overflow: hidden;
  position: relative;
}
.prompt-meta { display: flex; align-items: center; justify-content: space-between; }
.prompt-score { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.prompt-stars { color: var(--warning); font-size: 12px; letter-spacing: 1px; }
.prompt-style-tag { font-size: 11px; color: var(--text-3); }

/* ============================================================
   Statistics
   ============================================================ */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.stat-card { padding: var(--sp-5); }
.stat-value { font-size: 32px; font-weight: 700; font-family: var(--font-mono); }
.stat-label { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.chart-container { position: relative; height: 280px; }

/* ============================================================
   Calendar (Heatmap)
   ============================================================ */
.cal-wrap { display: flex; gap: var(--sp-6); }
.cal-legend { display: flex; align-items: center; gap: var(--sp-2); font-size: 11px; color: var(--text-3); margin-top: var(--sp-3); }
.cal-legend-boxes { display: flex; gap: 3px; }
.cal-legend-box { width: 14px; height: 14px; border-radius: 3px; }

.cal-months { display: flex; gap: 3px; margin-bottom: var(--sp-2); padding-left: 30px; }
.cal-month { font-size: 10px; color: var(--text-3); min-width: 60px; }

.cal-grid-wrap { display: flex; gap: 6px; }
.cal-weekdays { display: flex; flex-direction: column; gap: 3px; justify-content: space-between; padding-top: 0; }
.cal-weekday { font-size: 10px; color: var(--text-4); height: 14px; display: flex; align-items: center; }
.cal-grid { display: flex; flex-direction: column; gap: 3px; }
.cal-row { display: flex; gap: 3px; }
.cal-cell {
  width: 14px; height: 14px;
  border-radius: 3px;
  background: var(--surface-3);
  transition: all var(--t-fast);
  cursor: pointer;
}
.cal-cell:hover { outline: 1px solid var(--text-3); transform: scale(1.3); }
.cal-0 { background: var(--surface-3); }
.cal-1 { background: rgba(124,111,240,0.2); }
.cal-2 { background: rgba(124,111,240,0.4); }
.cal-3 { background: rgba(124,111,240,0.65); }
.cal-4 { background: var(--accent); }

.cal-tooltip {
  position: absolute;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: var(--sp-2) var(--sp-3);
  font-size: 12px;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}

/* ============================================================
   Achievements
   ============================================================ */
.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--sp-3);
}
.ach-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  text-align: center;
  transition: all var(--t-fast);
}
.ach-badge.unlocked { border-color: var(--accent); background: linear-gradient(135deg, var(--surface), var(--surface-2)); }
.ach-badge.locked { opacity: 0.4; filter: grayscale(1); }
.ach-icon { font-size: 36px; margin-bottom: var(--sp-2); }
.ach-name { font-size: 13px; font-weight: 600; margin-bottom: var(--sp-1); }
.ach-desc { font-size: 11px; color: var(--text-3); line-height: 1.3; }

/* ============================================================
   Reflection
   ============================================================ */
.reflection-card { padding: var(--sp-6); margin-bottom: var(--sp-4); }
.reflection-section { margin-bottom: var(--sp-5); }
.reflection-section:last-child { margin-bottom: 0; }
.reflection-h { font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: var(--sp-2); text-transform: uppercase; letter-spacing: 0.06em; }
.reflection-p { font-size: 14px; line-height: 1.6; color: var(--text-2); }
.reflection-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.reflection-list li { font-size: 14px; color: var(--text-2); padding-left: var(--sp-3); position: relative; }
.reflection-list li::before { content: '•'; position: absolute; left: 0; color: var(--accent); }

/* ============================================================
   Modal
   ============================================================ */
#modal-root {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}
#modal-root.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  width: 90%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn var(--t-normal);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } }
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: var(--sp-4); }
.modal-field { margin-bottom: var(--sp-4); }
.modal-field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: var(--sp-2); color: var(--text-2); }
.modal-actions { display: flex; gap: var(--sp-3); justify-content: flex-end; margin-top: var(--sp-6); }

/* === Toast === */
#toast-root {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.toast {
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: toastIn var(--t-normal);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } }
.toast-success { border-color: var(--success); }
.toast-icon { font-size: 16px; }

/* === Utility === */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* === Responsive === */
@media (max-width: 768px) {
  :root { --sidebar-w: 60px; }
  #sidebar { padding: var(--sp-3) var(--sp-1); }
  .sb-header { flex-direction: column; gap: var(--sp-1); padding: 0 0 var(--sp-3); }
  .sb-title, .sb-subtitle, .sb-section-label, .sb-item span:not(.sb-icon), .sb-level-card { display: none; }
  .sb-item { justify-content: center; padding: var(--sp-3); }
  #content { padding: var(--sp-4); }
  .dash-hero, .dash-grid, .stats-grid { grid-template-columns: 1fr; }
  .hero-value { font-size: 36px; }
  .timer-ring { width: 220px; height: 220px; }
  .timer-display { font-size: 42px; }
}

/* ============================================================
   Chat Workspace
   ============================================================ */

.chat-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 760px;
  margin: 0 auto;
}

/* ---- Chat Header ---- */
.chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-4);
}
.chat-status-dot.online {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}
.chat-status-sep {
  opacity: 0.5;
}

/* ---- Messages ---- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  scroll-behavior: smooth;
}

.chat-msg {
  margin-bottom: var(--sp-4);
  animation: chat-msg-in 0.2s ease;
}

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

/* User message */
.chat-msg-user {
  display: flex;
  justify-content: flex-end;
}
.chat-msg-user .chat-msg-content {
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--r-lg) var(--r-lg) 4px var(--r-lg);
  max-width: 75%;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

/* AI message */
.chat-msg-ai {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
}
.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--r-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
}
.chat-msg-body {
  flex: 1;
  min-width: 0;
}
.chat-msg-ai .chat-msg-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
}
.chat-msg-error {
  color: var(--danger);
}

.chat-confidence {
  font-size: 11px;
  color: var(--text-4);
  margin-top: 4px;
  font-family: var(--font-mono);
}

/* ---- Typing indicator ---- */
.chat-typing-dots {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}
.chat-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  animation: chat-typing-bounce 1.2s infinite ease-in-out;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chat-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ---- Warnings ---- */
.chat-warnings {
  margin-top: 6px;
}
.chat-warning {
  font-size: 11px;
  color: var(--warning);
  line-height: 1.4;
}

/* ---- Recommendation Cards ---- */
.chat-cards {
  margin-top: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.rec-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  transition: all var(--t-fast);
}

.rec-card-pending {
  border-color: var(--accent);
  border-left: 3px solid var(--accent);
}

.rec-card-confirmed {
  opacity: 0.7;
  border-color: var(--success);
  border-left: 3px solid var(--success);
}

.rec-card-ignored {
  opacity: 0.4;
}

.rec-card-error {
  border-color: var(--danger);
  border-left: 3px solid var(--danger);
}

.rec-card-processing {
  opacity: 0.6;
}

.rec-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.rec-card-icon {
  font-size: 14px;
}

.rec-card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.rec-card-confidence {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
}

.rec-card-status {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
}
.rec-card-status-done { color: var(--success); }
.rec-card-status-ignored { color: var(--text-4); }
.rec-card-status-error { color: var(--danger); }
.rec-card-status-processing { color: var(--text-3); }

.rec-card-preview {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  word-break: break-word;
}

.rec-card-details {
  margin-bottom: 8px;
}

.rec-card-detail {
  display: flex;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
  padding: 2px 0;
  word-break: break-word;
}

.rec-card-detail-label {
  color: var(--text-3);
  min-width: 48px;
  flex-shrink: 0;
}

.rec-card-error-msg {
  font-size: 12px;
  color: var(--danger);
  margin-bottom: 8px;
}

.rec-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.chat-card-batch-confirm {
  align-self: flex-start;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--r-full);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  margin-top: 4px;
}
.chat-card-batch-confirm:hover {
  background: var(--accent);
  color: #fff;
}

/* ---- Input Area ---- */
.chat-input-area {
  flex-shrink: 0;
  padding: var(--sp-3) var(--sp-5) var(--sp-4);
  border-top: 1px solid var(--border);
}

.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 8px 8px 8px 14px;
  transition: border-color var(--t-fast);
}
.chat-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.chat-input {
  flex: 1;
  border: none;
  background: none;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-sans);
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 120px;
  padding: 4px 0;
}
.chat-input::placeholder {
  color: var(--text-4);
}

.chat-send-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.chat-send-btn:hover:not(:disabled) {
  background: var(--accent-2);
  transform: scale(1.05);
}
.chat-send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.chat-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-4);
  margin-top: 6px;
}

/* ---- Welcome Screen ---- */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: var(--sp-8);
}

.chat-welcome-icon {
  font-size: 48px;
  margin-bottom: var(--sp-4);
}

.chat-welcome-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--sp-2);
}

.chat-welcome-desc {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: var(--sp-8);
}

.chat-welcome-examples {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-width: 520px;
  width: 100%;
}

.chat-example {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  cursor: pointer;
  transition: all var(--t-fast);
  text-align: left;
}
.chat-example:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

/* ---- Chat in mobile ---- */
@media (max-width: 768px) {
  .chat-page {
    max-width: 100%;
  }
  .chat-messages {
    padding: var(--sp-3);
  }
  .chat-input-area {
    padding: var(--sp-2) var(--sp-3) var(--sp-3);
  }
  .chat-msg-user .chat-msg-content {
    max-width: 85%;
  }
}
