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

:root {
  /* Colores principales */
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-primary-light: #dbeafe;
  --color-secondary: #64748b;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #06b6d4;
  --color-mood: #f59e0b;
  --color-breathing: #06b6d4;
  --color-focus: #6366f1;
  --color-games: #8b5cf6;
  
  /* Fondos */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-modal: #ffffff;
  --bg-overlay: rgba(15, 23, 42, 0.5);
  
  /* Textos */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  
  /* Bordes */
  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-focus: #3b82f6;
  
  /* Sombras */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
  
  /* Espaciado */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  
  /* Radio */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  /* Transiciones */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;
  
  /* Tipografía */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  
  /* Z-index */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 300;
  --z-toast: 400;
  --z-loading: 500;
  
  /* Header height */
  --header-height: 64px;
}

/* Tema oscuro */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-card: #1e293b;
  --bg-modal: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border-light: #334155;
  --border-medium: #475569;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.4);
}

/* Base */
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; }
img { max-width: 100%; height: auto; display: block; }
svg { display: block; width: 100%; height: 100%; }
:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* Container */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 var(--space-4); }

/* ===== LOADING SCREEN ===== */
.loading-screen {
  position: fixed; inset: 0; z-index: var(--z-loading);
  background: var(--bg-primary);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-4); color: var(--text-secondary);
}
.loading-spinner {
  width: 40px; height: 40px; border: 3px solid var(--border-light);
  border-top-color: var(--color-primary); border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== HEADER ===== */
.header {
  position: sticky; top: 0; z-index: var(--z-sticky);
  height: var(--header-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
}
.header-content {
  max-width: 1200px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-4); gap: var(--space-4);
}
.logo { display: flex; align-items: center; gap: var(--space-2); font-weight: 700; font-size: var(--text-xl); color: var(--text-primary); }
.logo:hover { text-decoration: none; }
.logo-icon { width: 28px; height: 28px; color: var(--color-primary); }

.main-nav {
  display: flex; gap: var(--space-1); overflow-x: auto;
  padding: var(--space-1) 0; scrollbar-width: thin;
}
.main-nav::-webkit-scrollbar { height: 4px; }
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  color: var(--text-secondary); font-size: var(--text-xs); font-weight: 500;
  white-space: nowrap; transition: all var(--transition-fast);
}
.nav-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav-btn[aria-selected="true"] { background: var(--color-primary-light); color: var(--color-primary); }
.nav-btn svg { width: 20px; height: 20px; }

.header-actions { display: flex; align-items: center; gap: var(--space-2); }
.icon-btn {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full); color: var(--text-secondary);
  transition: all var(--transition-fast);
}
.icon-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.icon-btn svg { width: 22px; height: 22px; }
.moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: none; }
[data-theme="dark"] .moon-icon { display: block; }

/* User menu */
.user-menu { position: relative; }
.user-menu .dropdown {
  position: absolute; top: calc(100% + var(--space-2)); right: 0; z-index: var(--z-dropdown);
  min-width: 220px; background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden;
}
.dropdown-header { padding: var(--space-4); border-bottom: 1px solid var(--border-light); }
.dropdown-header span { display: block; font-weight: 600; }
.dropdown-header small { color: var(--text-muted); font-size: var(--text-xs); }
.dropdown hr { border: none; border-top: 1px solid var(--border-light); margin: 0; }
.dropdown-item {
  display: flex; align-items: center; gap: var(--space-3); width: 100%;
  padding: var(--space-3) var(--space-4); color: var(--text-primary);
  font-size: var(--text-sm); text-align: left; transition: background var(--transition-fast);
}
.dropdown-item:hover { background: var(--bg-tertiary); text-decoration: none; }
.dropdown-item svg { width: 20px; height: 20px; color: var(--text-secondary); flex-shrink: 0; }
.dropdown-item.danger { color: var(--color-danger); }
.dropdown-item.danger svg { color: var(--color-danger); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-md);
  font-weight: 500; font-size: var(--text-sm); white-space: nowrap;
  transition: all var(--transition-fast);
}
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: var(--color-primary-hover); color: white; text-decoration: none; }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-light); }
.btn-secondary:hover { background: var(--border-medium); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.btn-danger { background: var(--color-danger); color: white; }
.btn-danger:hover { background: #dc2626; color: white; }
.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: var(--text-base); }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== MAIN ===== */
.main { flex: 1; padding: var(--space-6) 0; }
.tab-panel { display: none; animation: fadeIn var(--transition-normal); }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.section-header { margin-bottom: var(--space-6); }
.section-header h1 { font-size: var(--text-3xl); font-weight: 700; color: var(--text-primary); }
.section-subtitle { color: var(--text-secondary); margin-top: var(--space-1); }
.section-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.section-header-row h2 { font-size: var(--text-xl); font-weight: 600; }

/* ===== STATS GRID ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-8); }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-lg);
  padding: var(--space-5); display: flex; align-items: center; gap: var(--space-4);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon { width: 48px; height: 48px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.mood { background: #fef3c7; color: #f59e0b; }
.stat-icon.breathing { background: #dbeafe; color: #3b82f6; }
.stat-icon.focus { background: #dcfce7; color: #10b981; }
.stat-icon.games { background: #fce7f3; color: #ec4899; }
.stat-icon.sleep { background: #e0e7ff; color: #6366f1; }
[data-theme="dark"] .stat-icon.mood { background: #78350f; color: #fde047; }
[data-theme="dark"] .stat-icon.breathing { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .stat-icon.focus { background: #14532d; color: #86efac; }
[data-theme="dark"] .stat-icon.games { background: #831843; color: #f9a8d4; }
[data-theme="dark"] .stat-icon.sleep { background: #312e81; color: #c7d2fe; }
.stat-value { font-size: var(--text-3xl); font-weight: 700; line-height: 1; color: var(--text-primary); }
.stat-label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ===== QUICK ACTIONS ===== */
.dashboard-section { margin-bottom: var(--space-8); }
.dashboard-section h2 { font-size: var(--text-xl); font-weight: 600; margin-bottom: var(--space-4); }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-4); }
.quick-action {
  display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4);
  background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-lg);
  text-align: left; transition: all var(--transition-fast);
}
.quick-action:hover { border-color: var(--color-primary); transform: translateY(-2px); box-shadow: var(--shadow-md); text-decoration: none; }
.quick-icon { width: 48px; height: 48px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.quick-icon svg { width: 24px; height: 24px; }
.quick-icon.breathing { background: #dbeafe; color: #3b82f6; }
.quick-icon.sleep { background: #e0e7ff; color: #6366f1; }
.quick-icon.focus { background: #dcfce7; color: #10b981; }
.quick-icon.mood { background: #fef3c7; color: #f59e0b; }
[data-theme="dark"] .quick-icon.breathing { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .quick-icon.sleep { background: #312e81; color: #c7d2fe; }
[data-theme="dark"] .quick-icon.focus { background: #14532d; color: #86efac; }
[data-theme="dark"] .quick-icon.mood { background: #78350f; color: #fde047; }
.quick-info h3 { font-size: var(--text-base); font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.quick-info p { font-size: var(--text-sm); color: var(--text-muted); }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: var(--space-10); color: var(--text-muted); }
.empty-state svg { width: 64px; height: 64px; margin: 0 auto var(--space-4); opacity: 0.5; }
.empty-state p { margin-bottom: var(--space-4); }

/* ===== ARTICLES CAROUSEL ===== */
.articles-carousel { display: flex; gap: var(--space-4); overflow-x: auto; padding: var(--space-2) 0; scrollbar-width: thin; }
.article-card {
  flex: 0 0 280px; background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); overflow: hidden; transition: transform var(--transition-fast);
}
.article-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.article-card-content { padding: var(--space-4); }
.article-meta { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--text-muted); margin-bottom: var(--space-2); }
.article-category { background: var(--color-primary-light); color: var(--color-primary); padding: 2px 8px; border-radius: var(--radius-full); font-weight: 500; }
.article-title { font-size: var(--text-base); font-weight: 600; color: var(--text-primary); margin-bottom: var(--space-2); line-height: 1.4; }
.article-summary { font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.5; margin-bottom: var(--space-3); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.article-footer { display: flex; align-items: center; justify-content: space-between; font-size: var(--text-xs); color: var(--text-muted); }
.article-read-time { display: flex; align-items: center; gap: 4px; }
.article-fav { width: 32px; height: 32px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; color: var(--text-muted); transition: all var(--transition-fast); }
.article-fav:hover { background: var(--bg-tertiary); color: var(--color-danger); }
.article-fav.active { color: var(--color-danger); }
.article-fav svg { width: 18px; height: 18px; }

/* ===== BREATHING ===== */
.breathing-techniques { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--space-4); }
.breathing-card {
  background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-lg);
  padding: var(--space-6); transition: all var(--transition-fast);
}
.breathing-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); }
.breathing-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.breathing-icon { width: 56px; height: 56px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.breathing-icon svg { width: 28px; height: 28px; }
.breathing-icon.box { background: #dbeafe; color: #3b82f6; }
.breathing-icon.breathing-478 { background: #e0e7ff; color: #6366f1; }
.breathing-icon.coherent { background: #dcfce7; color: #10b981; }
.breathing-fav { width: 36px; height: 36px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.breathing-fav:hover { background: var(--bg-tertiary); color: var(--color-danger); }
.breathing-fav.active { color: var(--color-danger); }
.breathing-fav svg { width: 18px; height: 18px; }
.breathing-title { font-size: var(--text-xl); font-weight: 600; color: var(--text-primary); margin-bottom: var(--space-1); }
.breathing-pattern { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--color-primary); background: var(--color-primary-light); padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); display: inline-block; margin-bottom: var(--space-2); }
[data-theme="dark"] .breathing-pattern { background: #1e3a5f; color: #93c5fd; }
.breathing-desc { font-size: var(--text-sm); color: var(--text-secondary); margin-bottom: var(--space-4); }
.breathing-benefits { font-size: var(--text-xs); color: var(--text-muted); margin-bottom: var(--space-4); }
.breathing-btn { width: 100%; }

/* Breathing Player */
.breathing-player { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; align-items: center; justify-content: center; padding: var(--space-4); }
.player-overlay { position: absolute; inset: 0; background: var(--bg-overlay); backdrop-filter: blur(4px); }
.player-content { position: relative; width: 100%; max-width: 400px; background: var(--bg-modal); border-radius: var(--radius-xl); padding: var(--space-6); box-shadow: var(--shadow-xl); animation: slideUp var(--transition-normal); }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.player-close { position: absolute; top: var(--space-3); right: var(--space-3); width: 36px; height: 36px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.player-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.player-close svg { width: 20px; height: 20px; }
.player-header { text-align: center; margin-bottom: var(--space-6); }
.player-header h2 { font-size: var(--text-xl); font-weight: 600; }
.player-header p { color: var(--text-secondary); font-size: var(--text-sm); }
.breathing-circle { width: 240px; height: 240px; margin: 0 auto var(--space-6); position: relative; }
.circle-ring { position: absolute; inset: 0; border-radius: 50%; border: 4px solid var(--border-light); transition: border-color var(--transition-normal); }
.circle-ring.active { border-color: var(--color-primary); box-shadow: 0 0 0 4px var(--color-primary-light); }
.circle-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#phase-label { font-size: var(--text-2xl); font-weight: 600; color: var(--text-primary); text-transform: capitalize; }
#phase-timer { font-size: var(--text-4xl); font-weight: 700; font-family: var(--font-mono); color: var(--color-primary); line-height: 1; }
#cycle-counter { font-size: var(--text-sm); color: var(--text-muted); margin-top: var(--space-1); }
.player-controls { display: flex; gap: var(--space-3); justify-content: center; }
.player-controls .btn { width: 56px; height: 56px; border-radius: var(--radius-full); padding: 0; }
.player-controls .btn svg { width: 24px; height: 24px; }

/* ===== MOOD ===== */
.mood-layout { display: grid; grid-template-columns: 1fr; gap: var(--space-6); }
@media (min-width: 900px) { .mood-layout { grid-template-columns: 380px 1fr; } }
.mood-form-card, .mood-history-card { background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: var(--space-6); }
.mood-form-card { position: sticky; top: calc(var(--header-height) + var(--space-6)); height: fit-content; }
.form-group { margin-bottom: var(--space-5); }
.form-group label { display: block; font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); margin-bottom: var(--space-2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], textarea, select {
  width: 100%; padding: var(--space-3) var(--space-4); border: 1px solid var(--border-medium); border-radius: var(--radius-md);
  background: var(--bg-primary); color: var(--text-primary); font-size: var(--text-base);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--color-primary-light); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { resize: vertical; min-height: 80px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748b'%3E%3Cpath d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right var(--space-3) center; background-size: 20px; padding-right: 40px; }

/* Mood Scale */
.mood-scale { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.mood-btn { width: 44px; height: 44px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; border: 2px solid var(--border-light); background: var(--bg-primary); transition: all var(--transition-fast); }
.mood-btn:hover { border-color: var(--color-primary); transform: scale(1.05); }
.mood-btn[aria-pressed="true"] { border-color: var(--color-primary); background: var(--color-primary-light); transform: scale(1.1); box-shadow: 0 0 0 4px var(--color-primary-light); }
.mood-btn span { font-size: var(--text-xl); }

/* Sliders */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px; background: var(--border-light); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--color-primary); cursor: pointer; box-shadow: 0 2px 4px rgba(0,0,0,0.2); transition: transform var(--transition-fast); }
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.1); }
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--color-primary); border: none; cursor: pointer; }
.slider-value { color: var(--color-primary); font-weight: 600; }

/* Mood Chart */
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.card-header h3 { font-size: var(--text-lg); font-weight: 600; }
.select-sm { padding: var(--space-1) var(--space-3); border: 1px solid var(--border-medium); border-radius: var(--radius-md); background: var(--bg-primary); color: var(--text-primary); font-size: var(--text-sm); }
.mood-chart { height: 280px; position: relative; }
.mood-chart canvas { width: 100%; height: 100%; }
.mood-stats { display: flex; justify-content: space-around; margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border-light); }
.stat-mini { text-align: center; }
.stat-mini-value { display: block; font-size: var(--text-2xl); font-weight: 700; color: var(--text-primary); }
.stat-mini-label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ===== GAMES ===== */
.games-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-4); }
.game-card { background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.game-icon { width: 56px; height: 56px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; }
.game-icon svg { width: 28px; height: 28px; }
.game-icon.memory { background: #fef3c7; color: #f59e0b; }
.game-icon.simon { background: #dbeafe; color: #3b82f6; }
.game-icon.stroop { background: #e0e7ff; color: #6366f1; }
[data-theme="dark"] .game-icon.memory { background: #78350f; color: #fde047; }
[data-theme="dark"] .game-icon.simon { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .game-icon.stroop { background: #312e81; color: #c7d2fe; }
.game-info h3 { font-size: var(--text-lg); font-weight: 600; }
.game-info p { font-size: var(--text-sm); color: var(--text-secondary); }
.game-stats { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-1); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; align-items: center; justify-content: center; padding: var(--space-4); }
.modal::before { content: ''; position: absolute; inset: 0; background: var(--bg-overlay); backdrop-filter: blur(4px); }
.modal-content { position: relative; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; background: var(--bg-modal); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); animation: slideUp var(--transition-normal); }
.game-modal-content { max-width: 600px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-light); }
.modal-header h2 { font-size: var(--text-xl); font-weight: 600; }
.modal-close { width: 36px; height: 36px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.modal-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.modal-close svg { width: 20px; height: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border-light); }

/* ===== FOCUS / TIMER ===== */
.focus-layout { display: grid; grid-template-columns: 1fr; gap: var(--space-6); }
@media (min-width: 900px) { .focus-layout { grid-template-columns: 420px 1fr; } }
.timer-card, .focus-stats-card { background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: var(--space-6); }
.timer-modes { display: flex; gap: var(--space-2); margin-bottom: var(--space-6); overflow-x: auto; }
.timer-mode-btn { padding: var(--space-2) var(--space-4); border-radius: var(--radius-full); font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); background: var(--bg-tertiary); white-space: nowrap; transition: all var(--transition-fast); }
.timer-mode-btn:hover { color: var(--text-primary); }
.timer-mode-btn.active { background: var(--color-primary); color: white; box-shadow: var(--shadow-sm); }
.timer-display { position: relative; width: 280px; height: 280px; margin: 0 auto var(--space-6); }
.timer-ring { width: 100%; height: 100%; }
.timer-ring-bg { fill: none; stroke: var(--border-light); stroke-width: 8; }
.timer-ring-progress { fill: none; stroke: var(--color-primary); stroke-width: 8; stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; transition: stroke-dashoffset 1s linear, stroke var(--transition-normal); }
.timer-time { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; font-family: var(--font-mono); font-size: var(--text-4xl); font-weight: 700; color: var(--text-primary); }
.timer-task { margin-top: var(--space-4); }
#timer-task-input { width: 100%; padding: var(--space-2) var(--space-3); border: 1px solid var(--border-medium); border-radius: var(--radius-md); background: var(--bg-primary); color: var(--text-primary); font-size: var(--text-sm); text-align: center; }
.timer-controls { display: flex; justify-content: center; gap: var(--space-3); }
.timer-controls .btn-lg { width: 56px; height: 56px; border-radius: var(--radius-full); padding: 0; }
.timer-controls .btn-lg svg { width: 24px; height: 24px; }
.timer-presets { display: flex; align-items: center; justify-content: center; gap: var(--space-3); margin-top: var(--space-4); }
.timer-presets label { font-size: var(--text-sm); color: var(--text-secondary); }
.timer-presets input { width: 80px; padding: var(--space-2); border: 1px solid var(--border-medium); border-radius: var(--radius-md); text-align: center; }

/* Focus Stats */
.focus-stats-card h3 { font-size: var(--text-lg); font-weight: 600; margin-bottom: var(--space-4); }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); margin-bottom: var(--space-6); }
.stat-box { text-align: center; padding: var(--space-4); background: var(--bg-tertiary); border-radius: var(--radius-md); }
.stat-box span:first-child { display: block; font-size: var(--text-3xl); font-weight: 700; color: var(--text-primary); }
.stat-box span:last-child { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.focus-chart { height: 200px; }
.focus-chart canvas { width: 100%; height: 100%; }

/* ===== HABITS ===== */
.habits-filters { display: flex; gap: var(--space-2); margin-bottom: var(--space-4); }
.filter-btn { padding: var(--space-2) var(--space-4); border-radius: var(--radius-full); font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); background: var(--bg-tertiary); transition: all var(--transition-fast); }
.filter-btn:hover { color: var(--text-primary); }
.filter-btn.active { background: var(--color-primary); color: white; }
.habits-list { display: flex; flex-direction: column; gap: var(--space-3); }
.habit-item {
  display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4);
  background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
}
.habit-item:hover { border-color: var(--color-primary); }
.habit-color { width: 12px; height: 12px; border-radius: var(--radius-full); flex-shrink: 0; }
.habit-info { flex: 1; min-width: 0; }
.habit-name { font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.habit-meta { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.habit-progress { display: flex; align-items: center; gap: var(--space-3); }
.habit-bar { width: 100px; height: 6px; background: var(--border-light); border-radius: 3px; overflow: hidden; }
.habit-bar-fill { height: 100%; border-radius: 3px; transition: width var(--transition-normal); }
.habit-count { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); min-width: 40px; text-align: right; }
.habit-actions { display: flex; gap: var(--space-1); }
.habit-action { width: 36px; height: 36px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.habit-action:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.habit-action svg { width: 18px; height: 18px; }
.habit-action.done { color: var(--color-success); }
.habit-action.done:hover { background: #dcfce7; color: var(--color-success); }
.habit-action.delete:hover { background: #fef2f2; color: var(--color-danger); }
.habit-action.stats:hover { background: var(--bg-tertiary); color: var(--color-primary); }

/* Habit Form */
.habit-form { padding: var(--space-5); }
.color-picker { display: flex; gap: var(--space-2); }
.color-option { width: 36px; height: 36px; border-radius: var(--radius-full); border: 3px solid transparent; transition: all var(--transition-fast); }
.color-option:hover { transform: scale(1.1); }
.color-option.selected { border-color: var(--text-primary); transform: scale(1.1); box-shadow: 0 0 0 2px var(--bg-modal); }
[data-theme="dark"] .color-option.selected { border-color: var(--text-primary); }

/* Habit Detail Modal */
.habit-detail-content { max-width: 500px; }
.habit-detail-header { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.habit-detail-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); margin-bottom: var(--space-4); }
.habit-detail-stat { text-align: center; padding: var(--space-3); background: var(--bg-tertiary); border-radius: var(--radius-md); }
.habit-detail-stat-value { display: block; font-size: var(--text-2xl); font-weight: 700; color: var(--text-primary); }
.habit-detail-stat-label { font-size: var(--text-xs); color: var(--text-muted); }
.habit-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-day { aspect-ratio: 1; border-radius: var(--radius-sm); background: var(--bg-tertiary); display: flex; align-items: center; justify-content: center; font-size: var(--text-xs); color: var(--text-muted); }
.calendar-day.done { background: var(--color-success); color: white; }
.calendar-day.today { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.calendar-day.empty { background: transparent; }

/* ===== LIBRARY ===== */
.library-toolbar { display: flex; gap: var(--space-3); margin-bottom: var(--space-6); flex-wrap: wrap; }
.search-box { position: relative; flex: 1; min-width: 250px; }
.search-box svg { position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--text-muted); }
.search-box input { width: 100%; padding: var(--space-2) var(--space-3) var(--space-2) 44px; border: 1px solid var(--border-medium); border-radius: var(--radius-md); background: var(--bg-primary); color: var(--text-primary); }
.articles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-4); }
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--space-4); margin-top: var(--space-8); }
.page-info { font-size: var(--text-sm); color: var(--text-secondary); }

/* ===== FOOTER ===== */
.footer { padding: var(--space-8) 0; border-top: 1px solid var(--border-light); margin-top: auto; }
.footer p { text-align: center; color: var(--text-muted); font-size: var(--text-sm); }
.footer strong { color: var(--color-danger); }
.footer-links { margin-top: var(--space-3); font-size: var(--text-sm); }
.footer-links a { color: var(--text-secondary); margin: 0 var(--space-2); }
.footer-links a:hover { color: var(--color-primary); }
.footer-links span { color: var(--border-medium); }

/* ===== TOASTS ===== */
.toast-container { position: fixed; bottom: var(--space-4); right: var(--space-4); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--space-2); }
.toast { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); min-width: 280px; max-width: 400px; animation: slideIn var(--transition-normal); }
@keyframes slideIn { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }
.toast.success { border-left: 4px solid var(--color-success); }
.toast.error { border-left: 4px solid var(--color-danger); }
.toast.info { border-left: 4px solid var(--color-info); }
.toast-icon { width: 20px; height: 20px; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--color-success); }
.toast.error .toast-icon { color: var(--color-danger); }
.toast.info .toast-icon { color: var(--color-info); }
.toast-message { flex: 1; font-size: var(--text-sm); color: var(--text-primary); }
.toast-close { width: 24px; height: 24px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.toast-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.toast-close svg { width: 16px; height: 16px; }

/* ===== MUSIC ===== */
.music-card {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: var(--space-4); padding: var(--space-4);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.10), rgba(6, 182, 212, 0.08));
  border: 1px solid var(--border-light); border-radius: var(--radius-xl);
  margin-bottom: var(--space-4);
}
.music-card.playing { border-color: var(--color-focus); box-shadow: 0 0 0 1px var(--color-focus) inset; }
.music-art {
  width: 84px; height: 84px; border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #6366f1, #06b6d4); color: #fff;
  box-shadow: var(--shadow-md);
}
.music-art svg { width: 38px; height: 38px; }
.music-now { min-width: 0; }
.music-now-title { font-size: var(--text-lg); font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-now-artist { font-size: var(--text-sm); color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-progress-row { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
.music-time { font-size: var(--text-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 42px; text-align: center; }
.music-seek { flex: 1; accent-color: var(--color-focus); height: 4px; }
.music-transport { display: flex; align-items: center; gap: var(--space-2); }
.music-play-btn {
  width: 52px; height: 52px; border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  background: var(--color-focus); color: #fff; box-shadow: var(--shadow-md);
  transition: transform var(--transition-fast), background var(--transition-fast);
}
.music-play-btn:hover { background: #4f46e5; transform: scale(1.04); }
.music-play-btn svg { width: 22px; height: 22px; }
.music-options { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.music-opt-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-light); border-radius: var(--radius-full);
  background: var(--bg-card); color: var(--text-secondary); font-size: var(--text-sm);
  transition: all var(--transition-fast);
}
.music-opt-btn svg { width: 16px; height: 16px; }
.music-opt-btn[aria-pressed="true"] { background: var(--color-primary-light); color: var(--color-primary-hover); border-color: transparent; }
.music-slider-label, .music-timer-label { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-secondary); font-size: var(--text-sm); }
.music-slider-label svg, .music-timer-label svg { width: 16px; height: 16px; }
.music-slider-label input[type="range"] { width: 110px; accent-color: var(--color-focus); }
.music-timer-label select { padding: 6px 10px; border: 1px solid var(--border-light); border-radius: var(--radius-md); background: var(--bg-card); color: var(--text-primary); font-size: var(--text-sm); }
.music-timer-left { font-size: var(--text-sm); color: var(--color-focus); font-weight: 500; }
.music-categories { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-3); }
.music-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full); border: 1px solid var(--border-light);
  background: var(--bg-card); color: var(--text-secondary); font-size: var(--text-sm);
}
.music-chip.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.music-chip .chip-count { opacity: .7; font-size: var(--text-xs); }
.music-list { display: flex; flex-direction: column; gap: 2px; max-height: 520px; overflow-y: auto; border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: var(--space-2); background: var(--bg-card); }
.music-track {
  display: flex; align-items: center; gap: var(--space-3); width: 100%; text-align: left;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); color: var(--text-primary);
  transition: background var(--transition-fast);
}
.music-track:hover { background: var(--bg-tertiary); }
.music-track.active { background: var(--color-primary-light); }
.music-track-play { width: 28px; height: 28px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-full); background: var(--bg-tertiary); color: var(--text-secondary); }
.music-track.active .music-track-play { background: var(--color-primary); color: #fff; }
.music-track-play svg { width: 12px; height: 12px; }
.music-track-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.music-track-title { font-size: var(--text-sm); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-track-meta { font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-track-duration { font-size: var(--text-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.music-license-note { margin-top: var(--space-3); font-size: var(--text-xs); color: var(--text-muted); }
.music-license-note a { color: var(--color-primary); }

@media (max-width: 768px) {
  .music-card { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .music-now { width: 100%; }
  .music-list { max-height: 420px; }
}

[data-theme="dark"] .music-card { background: linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(6, 182, 212, 0.10)); }
[data-theme="dark"] .music-track.active { background: rgba(99, 102, 241, 0.25); }
[data-theme="dark"] .music-track-play { background: rgba(148, 163, 184, 0.18); }
[data-theme="dark"] .music-opt-btn { background: var(--bg-card); }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  :root { --header-height: 56px; }
  .main-nav .nav-btn span { display: none; }
  .main-nav .nav-btn { padding: var(--space-2); }
  .section-header h1 { font-size: var(--text-2xl); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-actions { grid-template-columns: 1fr; }
  .timer-display { width: 240px; height: 240px; }
  .breathing-circle { width: 200px; height: 200px; }
  .modal-content { margin: var(--space-2); max-height: calc(100vh - var(--space-4)); }
  .habit-bar { width: 80px; }
  .habit-progress { flex-wrap: wrap; }
  .habit-count { min-width: auto; text-align: left; }
}

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.text-center { text-align: center; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

/* ===== COMPONENTS v1 (Mindful) ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.main { flex: 1; padding: var(--space-8) 0 var(--space-10); }
.header-flex { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.card { background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-sm); }
.form-label { display: block; font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); margin-bottom: var(--space-2); }
.form-group label { display: block; font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); margin-bottom: var(--space-2); }
input[type="text"], input[type="search"], input[type="number"], input[type="time"], input[type="password"], textarea, select { width: 100%; padding: var(--space-2) var(--space-3); border: 1px solid var(--border-medium); border-radius: var(--radius-md); background: var(--bg-primary); color: var(--text-primary); font-size: var(--text-sm); transition: border-color var(--transition-fast), box-shadow var(--transition-fast); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light); }
.form-group textarea { resize: vertical; min-height: 80px; }
.sun-icon { display: block; }
.moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: none; }
[data-theme="dark"] .moon-icon { display: block; }
.footer-link { background: none; border: none; color: var(--text-secondary); font-size: var(--text-sm); cursor: pointer; padding: 0 var(--space-1); }
.footer-link:hover { color: var(--color-primary); text-decoration: underline; }
.modal { position: fixed; inset: 0; z-index: var(--z-modal); background: var(--bg-overlay); display: flex; align-items: center; justify-content: center; padding: var(--space-4); animation: fadeIn var(--transition-fast); }

/* ----- Breathing ----- */
.techniques-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-8); }
.technique-card { background: var(--bg-card); border: 2px solid var(--border-light); border-radius: var(--radius-lg); padding: var(--space-4); cursor: pointer; transition: all var(--transition-fast); }
.technique-card:hover { border-color: var(--border-medium); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.technique-card.selected { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light); }
.technique-card h3 { font-size: var(--text-lg); font-weight: 600; margin-bottom: var(--space-1); }
.technique-card p { font-size: var(--text-sm); color: var(--text-secondary); margin-bottom: var(--space-3); }
.technique-pattern { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.phase-tag { font-size: var(--text-xs); padding: 2px var(--space-2); border-radius: var(--radius-full); font-weight: 500; background: var(--bg-tertiary); color: var(--text-secondary); }
.phase-tag[data-phase="inhale"] { background: #dbeafe; color: #1d4ed8; }
.phase-tag[data-phase="hold"] { background: #ede9fe; color: #6d28d9; }
.phase-tag[data-phase="exhale"] { background: #dcfce7; color: #15803d; }
.phase-tag[data-phase="hold2"] { background: #fef3c7; color: #b45309; }
[data-theme="dark"] .phase-tag[data-phase="inhale"] { background: rgba(59,130,246,.2); color: #93c5fd; }
[data-theme="dark"] .phase-tag[data-phase="hold"] { background: rgba(139,92,246,.2); color: #c4b5fd; }
[data-theme="dark"] .phase-tag[data-phase="exhale"] { background: rgba(16,185,129,.2); color: #6ee7b7; }
[data-theme="dark"] .phase-tag[data-phase="hold2"] { background: rgba(245,158,11,.2); color: #fcd34d; }
.breathing-stage { display: flex; flex-direction: column; align-items: center; gap: var(--space-6); padding: var(--space-6); background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-xl); }
.breathing-ring, .focus-ring { position: relative; width: 260px; height: 260px; flex-shrink: 0; }
.breathing-ring svg, .focus-ring svg { width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: var(--bg-tertiary); stroke-width: 10; }
.ring-progress { fill: none; stroke: var(--color-primary); stroke-width: 10; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 100px 100px; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-1); text-align: center; padding: 0 var(--space-6); }
.breathing-phase-label { font-size: var(--text-xl); font-weight: 600; color: var(--text-primary); }
.breathing-cycles-label { font-size: var(--text-sm); color: var(--text-muted); }
.phase-indicators { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: center; }
.phase-indicator { font-size: var(--text-xs); font-weight: 500; padding: var(--space-1) var(--space-3); border-radius: var(--radius-full); background: var(--bg-tertiary); color: var(--text-muted); transition: all var(--transition-fast); }
.phase-indicator.active { background: var(--color-primary); color: white; }
.duration-selector { display: flex; gap: var(--space-2); }
.duration-btn { padding: var(--space-1) var(--space-4); border-radius: var(--radius-full); border: 1px solid var(--border-medium); background: transparent; color: var(--text-secondary); font-size: var(--text-sm); transition: all var(--transition-fast); }
.duration-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.duration-btn.active { background: var(--color-primary); border-color: var(--color-primary); color: white; }
.breathing-controls, .focus-controls { display: flex; gap: var(--space-3); flex-wrap: wrap; justify-content: center; }

/* ----- Mood ----- */
.mood-layout { display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--space-5); align-items: start; }
.mood-metrics { display: flex; flex-direction: column; gap: var(--space-4); }
.mood-metric { display: flex; flex-direction: column; gap: var(--space-2); }
.metric-label { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); }
.metric-dot { width: 10px; height: 10px; border-radius: var(--radius-full); display: inline-block; }
.metric-scale { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.scale-btn { aspect-ratio: 1; min-width: 0; display: flex; align-items: center; justify-content: center; font-size: var(--text-xs); font-weight: 500; border: 1px solid var(--border-light); border-radius: var(--radius-sm); background: var(--bg-primary); color: var(--text-secondary); transition: all var(--transition-fast); }
.scale-btn:hover { border-color: var(--border-medium); background: var(--bg-tertiary); }
.scale-btn.active { background: var(--color-primary); border-color: var(--color-primary); color: white; font-weight: 600; }
.mood-emoji { font-size: 2.5rem; text-align: center; margin-top: var(--space-3); }
.tag-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.tag-chip { padding: var(--space-1) var(--space-3); border-radius: var(--radius-full); border: 1px solid var(--border-light); background: var(--bg-tertiary); color: var(--text-secondary); font-size: var(--text-xs); transition: all var(--transition-fast); }
.tag-chip:hover { border-color: var(--color-primary); color: var(--color-primary); }
.tag-chip.active { background: var(--color-primary); border-color: var(--color-primary); color: white; }
.mood-history { display: flex; flex-direction: column; gap: var(--space-3); max-height: 560px; overflow-y: auto; }
.history-item { display: flex; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border-light); border-radius: var(--radius-md); background: var(--bg-secondary); flex-wrap: wrap; }
.history-date-col { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 44px; padding: var(--space-1); background: var(--bg-card); border-radius: var(--radius-sm); border: 1px solid var(--border-light); }
.history-day { font-size: var(--text-xl); font-weight: 700; line-height: 1; }
.history-month { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-top: 2px; }
.history-bars { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.history-bar-row { display: flex; align-items: center; gap: var(--space-2); }
.history-bar-label { font-size: 10px; color: var(--text-muted); width: 56px; flex-shrink: 0; }
.history-bar { flex: 1; height: 6px; background: var(--border-light); border-radius: 3px; overflow: hidden; }
.history-bar-fill { height: 100%; border-radius: 3px; }
.history-bar-value { font-size: 10px; font-weight: 600; width: 16px; text-align: right; color: var(--text-secondary); }
.history-note { flex-basis: 100%; font-size: var(--text-xs); color: var(--text-secondary); font-style: italic; }

/* ----- Games ----- */
.games-player { display: flex; flex-direction: column; gap: var(--space-4); }
.player-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-3) var(--space-4); background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-lg); }
.player-stats { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.player-title { font-weight: 600; }
.player-stat { font-size: var(--text-sm); color: var(--text-secondary); }
.player-stat strong { color: var(--text-primary); }
.game-canvas-wrap { position: relative; display: flex; align-items: center; justify-content: center; background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-xl); padding: var(--space-4); min-height: 480px; overflow: hidden; }
.game-canvas-wrap canvas { max-width: 100%; border-radius: var(--radius-md); touch-action: none; }
.game-icon { width: 48px; height: 48px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; background: var(--color-primary-light); color: var(--color-primary); flex-shrink: 0; }
.game-icon svg { width: 26px; height: 26px; }
.game-icon.memory { background: #e0e7ff; color: #6366f1; }
.game-icon.simon { background: #dcfce7; color: #10b981; }
.game-icon.bubble { background: #dbeafe; color: #3b82f6; }
.game-icon.gratitude { background: #fce7f3; color: #ec4899; }
[data-theme="dark"] .game-icon.memory { background: rgba(99,102,241,.2); }
[data-theme="dark"] .game-icon.simon { background: rgba(16,185,129,.2); }
[data-theme="dark"] .game-icon.bubble { background: rgba(59,130,246,.2); }
[data-theme="dark"] .game-icon.gratitude { background: rgba(236,72,153,.2); }
.game-info { flex: 1; min-width: 0; }
.game-info h3 { font-size: var(--text-lg); font-weight: 600; margin-bottom: 2px; }
.game-info p { font-size: var(--text-sm); color: var(--text-secondary); }
.game-stats { margin-top: var(--space-2); }
.game-best { font-size: var(--text-xs); color: var(--text-muted); font-weight: 500; }
.game-card { cursor: pointer; transition: transform var(--transition-fast), box-shadow var(--transition-fast); }
.game-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.game-result { position: absolute; inset: 0; background: var(--bg-modal); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-4); border-radius: var(--radius-xl); padding: var(--space-6); text-align: center; }
.game-result h3 { font-size: var(--text-2xl); }
.result-stats { display: flex; gap: var(--space-8); }
.result-stats > div { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.result-stats span { font-size: var(--text-2xl); font-weight: 700; color: var(--color-primary); }
.result-stats small { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.gratitude-form { position: absolute; inset: 0; background: var(--bg-modal); border-radius: var(--radius-xl); display: flex; align-items: center; justify-content: center; padding: var(--space-6); }
.gratitude-body { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: var(--space-4); }
.gratitude-prompt { font-size: var(--text-lg); font-weight: 600; text-align: center; }
.gratitude-input { width: 100%; padding: var(--space-2) var(--space-3); border: 1px solid var(--border-medium); border-radius: var(--radius-md); background: var(--bg-primary); color: var(--text-primary); }

/* ----- Focus ----- */
.focus-layout { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.timer-card { display: flex; flex-direction: column; align-items: center; gap: var(--space-5); }
.focus-modes { display: flex; gap: var(--space-1); padding: 4px; background: var(--bg-tertiary); border-radius: var(--radius-full); width: 100%; }
.focus-mode-btn { flex: 1; padding: var(--space-2) var(--space-2); border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 500; color: var(--text-secondary); transition: all var(--transition-fast); }
.focus-mode-btn.active { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.focus-label { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }
.focus-time { font-size: 3rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; color: var(--text-primary); }
.focus-presets { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; justify-content: center; }
.presets-label { font-size: var(--text-xs); color: var(--text-muted); }
.focus-preset-btn { padding: 4px var(--space-3); border-radius: var(--radius-full); border: 1px solid var(--border-medium); background: transparent; color: var(--text-secondary); font-size: var(--text-xs); font-weight: 500; }
.focus-preset-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.focus-preset-btn.active { background: var(--color-primary); border-color: var(--color-primary); color: white; }
.focus-stats-card h3 { font-size: var(--text-lg); font-weight: 600; }
.focus-stats-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); margin-top: var(--space-4); }
.focus-stat { text-align: center; padding: var(--space-3); background: var(--bg-tertiary); border-radius: var(--radius-md); }
.focus-stat-value { display: block; font-size: var(--text-2xl); font-weight: 700; color: var(--text-primary); }
.focus-stat-label { font-size: var(--text-xs); color: var(--text-muted); }
.focus-week-stats { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-3); }

/* ----- Habits ----- */
.habits-today { display: flex; flex-direction: column; gap: var(--space-2); }
.habit-card { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4); background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-lg); transition: all var(--transition-fast); }
.habit-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow-sm); }
.habit-check { width: 32px; height: 32px; border-radius: var(--radius-full); border: 2px solid var(--border-medium); background: transparent; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: transparent; transition: all var(--transition-fast); }
.habit-check svg { width: 18px; height: 18px; }
.habit-check:hover { border-color: var(--color-success); }
.habit-check.done { background: var(--color-success); border-color: var(--color-success); color: white; }
.habit-icon { width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--bg-tertiary); display: flex; align-items: center; justify-content: center; font-size: 1.25rem; flex-shrink: 0; }
.habit-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.habit-head { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.habit-name { font-weight: 600; color: var(--text-primary); }
.habit-streak { font-size: var(--text-xs); color: var(--text-muted); }
.habit-card .habit-bar { width: 100%; height: 6px; }
.habit-meta-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); font-size: var(--text-xs); color: var(--text-muted); }
.habit-menu { display: flex; gap: 2px; flex-shrink: 0; }
.habit-menu .icon-btn { width: 30px; height: 30px; border-radius: var(--radius-md); }
.habit-menu .icon-btn svg { width: 16px; height: 16px; }
.habit-detail-content { max-width: 520px; }
.habit-detail-body { padding: var(--space-5); }
.habit-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); margin-bottom: var(--space-5); }
.habit-stat { text-align: center; padding: var(--space-3); background: var(--bg-tertiary); border-radius: var(--radius-md); }
.habit-stat-value { display: block; font-size: var(--text-2xl); font-weight: 700; color: var(--text-primary); }
.habit-stat-label { font-size: var(--text-xs); color: var(--text-muted); }
.heatmap { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.heatmap-cell { aspect-ratio: 1; border-radius: 4px; background: var(--bg-tertiary); }
.heatmap-cell.active { background: var(--color-success); }
.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, 44px); gap: var(--space-1); }
.icon-picker .icon-btn { width: 44px; height: 44px; border-radius: var(--radius-md); font-size: 1.2rem; }
.icon-picker .icon-btn.active { background: var(--color-primary-light); box-shadow: 0 0 0 2px var(--color-primary) inset; }
[data-theme="dark"] .icon-picker .icon-btn.active { background: rgba(59,130,246,.2); }
.color-btn { width: 32px; height: 32px; border-radius: var(--radius-full); border: 3px solid transparent; cursor: pointer; }
.color-btn.active { border-color: var(--text-primary); transform: scale(1.1); }

/* ----- Library ----- */
.library-categories { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-5); }
.category-chip { display: inline-flex; align-items: center; gap: 6px; padding: var(--space-1) var(--space-3); border-radius: var(--radius-full); border: 1px solid var(--border-light); background: var(--bg-card); color: var(--text-secondary); font-size: var(--text-sm); transition: all var(--transition-fast); }
.category-chip:hover { border-color: var(--color-primary); color: var(--color-primary); }
.category-chip.active { background: var(--color-primary); border-color: var(--color-primary); color: white; }
.chip-count { font-size: 10px; background: rgba(255,255,255,.25); padding: 0 6px; border-radius: var(--radius-full); }
.category-chip:not(.active) .chip-count { background: var(--bg-tertiary); color: var(--text-muted); }
.article-card { cursor: pointer; display: flex; flex-direction: column; overflow: hidden; }
.article-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); font-size: var(--text-xs); margin-bottom: var(--space-2); }
.article-category { text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; color: var(--color-primary); }
.article-title { font-size: var(--text-lg); font-weight: 600; margin-bottom: var(--space-2); line-height: 1.3; }
.article-summary { font-size: var(--text-sm); color: var(--text-secondary); margin-bottom: var(--space-3); }
.article-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: var(--space-2); }
.article-read-time { font-size: var(--text-xs); color: var(--text-muted); }
.article-fav { width: 30px; height: 30px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.article-fav:hover { background: var(--bg-tertiary); color: var(--color-danger); }
.article-fav.active { color: var(--color-danger); }
.article-fav svg { width: 16px; height: 16px; }
.articles-carousel { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-4); }
.carousel-loading { padding: var(--space-6); text-align: center; color: var(--text-muted); font-size: var(--text-sm); }
.article-modal-content { max-width: 720px; }
.article-content { padding: var(--space-5); }
.article-full-meta { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: var(--space-2); }
.article-full-title { font-size: var(--text-2xl); font-weight: 700; margin-bottom: var(--space-4); line-height: 1.25; }
.article-full-body { color: var(--text-secondary); line-height: 1.75; }
.article-full-body h2, .article-full-body h3 { color: var(--text-primary); margin: var(--space-5) 0 var(--space-2); }
.article-full-body p { margin-bottom: var(--space-3); }
.article-full-body ul { margin: 0 0 var(--space-3) var(--space-5); }
.article-full-body li { margin-bottom: var(--space-1); }
.article-sources { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border-light); font-size: var(--text-xs); color: var(--text-muted); }
.evidence-badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-full); text-transform: uppercase; letter-spacing: 0.05em; }
.evidence-badge.high { background: #dcfce7; color: #15803d; }
.evidence-badge.medium { background: #fef3c7; color: #b45309; }
.evidence-badge.low { background: #fee2e2; color: #b91c1c; }
.article-full-actions { display: flex; gap: var(--space-2); padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border-light); }

/* ----- Charts ----- */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--space-4); }
.chart-card { background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: var(--space-4); }
.chart-card h3 { font-size: var(--text-base); font-weight: 600; margin-bottom: var(--space-3); }
.chart-wrap { position: relative; width: 100%; height: 220px; }
.chart-wrap canvas { width: 100%; height: 100%; }

/* ----- Appended responsive tweaks ----- */
@media (max-width: 900px) {
  .mood-layout { grid-template-columns: 1fr; }
  .focus-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .breathing-ring, .focus-ring { width: 210px; height: 210px; }
  .focus-time { font-size: 2.2rem; }
  .metric-scale { gap: 2px; }
  .scale-btn { font-size: 10px; }
  .history-bar-label { display: none; }
  .game-canvas-wrap { min-height: 380px; padding: var(--space-2); }
  .habit-card { flex-wrap: wrap; }
  .breathing-stage { padding: var(--space-4); }
}

/* ----- Stat cards (fix apilado valor/etiqueta) ----- */
.stat-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat-value { font-size: var(--text-2xl); letter-spacing: -0.02em; }
.stat-label { line-height: 1.2; }

/* ----- Buscador de la biblioteca ----- */
.search-box input[type="search"],
.search-box input[type="text"] {
  padding-left: 44px;
  -webkit-appearance: none;
  appearance: none;
}

/* ----- Estadísticas de foco: cuadrícula más compacta ----- */
.focus-stats-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
.focus-week-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-top: var(--space-3);
}
.focus-week-stats .focus-stat {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
}
.stat-value { font-size: var(--text-2xl); letter-spacing: -0.02em; }
.stat-label { line-height: 1.2; }
@media (max-width: 480px) {
  .stat-card { padding: var(--space-4); gap: var(--space-3); }
  .stat-icon { width: 40px; height: 40px; }
  .stat-icon svg { width: 20px; height: 20px; }
  .stat-value { font-size: var(--text-xl); }
}

/* ----- Sonido guiado (respiración) ----- */
.breathing-controls { flex-wrap: wrap; justify-content: center; }
#breathing-sound, #breathing-music { order: 9; }
#breathing-music { order: 10; }
#breathing-sound[aria-pressed="true"],
#breathing-music[aria-pressed="true"] {
  background: var(--color-primary-light);
  color: var(--color-primary-hover);
  border: 1px solid transparent;
}
#breathing-sound[aria-pressed="false"],
#breathing-music[aria-pressed="false"] { color: var(--text-muted); }
#breathing-sound .sound-icon, #breathing-music .sound-icon { width: 18px; height: 18px; margin-right: 6px; vertical-align: -3px; flex-shrink: 0; }
[data-theme="dark"] #breathing-sound[aria-pressed="true"],
[data-theme="dark"] #breathing-music[aria-pressed="true"] {
  background: rgba(99, 102, 241, 0.18);
  color: #c7d2fe;
}
