/* ===================================================
   solving.uz — Design System
   Dark Black Default · Compact · Minimal
   =================================================== */

/* ---------- CSS Custom Properties (Dark Black Default) ---------- */
:root {
  /* Requested Premium Variables */
  --bg: #050508;
  --panel: #101017;
  --text: #F3F4F6;
  --muted: #9CA3AF;
  --primary: #8B5CF6;
  --primary-2: #A78BFA;
  --border: #1F2937;
  --success: #10B981;
  --error: #EF4444;
  --warning: #F59E0B;

  /* Legacy Mapping for backward compatibility */
  --bg-primary: var(--bg);
  --bg-secondary: #0A0A0F;
  --bg-card: var(--panel);
  --text-primary: var(--text);
  --text-secondary: var(--muted);
  --accent: var(--primary);
  --accent-hover: var(--primary-2);
  --accent-light: rgba(139, 92, 246, 0.15);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.6);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.7);
  --glow: 0 4px 24px rgba(139, 92, 246, 0.25);

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-h1: 1.6rem;
  --font-h2: 1.2rem;
  --font-body: 0.875rem;
  --font-btn: 0.8rem;
  --font-small: 0.78rem;
  --font-xs: 0.7rem;

  /* Layout — Compact */
  --sidebar-width: 220px;
  --header-height: 52px;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Light Mode Override ---------- */
[data-theme="light"] {
  --bg: #FAFAFA;
  --bg-secondary: #F3F4F6;
  --panel: #FFFFFF;
  --text: #111827;
  --muted: #4B5563;
  --primary: #4F46E5;
  --primary-2: #6366F1;
  --border: #E5E7EB;
  --accent-light: rgba(79, 70, 229, 0.1);
  --success: #059669;
  --error: #DC2626;
  --warning: #D97706;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 10px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 25px rgba(0,0,0,0.12);
  --glow: 0 4px 16px rgba(79, 70, 229, 0.15);
}

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

html {
  height: 100%;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background var(--transition), color var(--transition);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* ---------- Typography ---------- */
h1 { font-size: var(--font-h1); font-weight: 700; line-height: 1.3; }
h2 { font-size: var(--font-h2); font-weight: 600; line-height: 1.4; }
h3 { font-size: 1rem; font-weight: 600; }

/* ================================================================
   HEADER — Compact
   ================================================================ */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
  backdrop-filter: blur(12px);
  transition: background var(--transition), border-color var(--transition);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hamburger {
  display: flex;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: background var(--transition);
}
.hamburger:hover { background: var(--accent-light); }
.hamburger svg { width: 20px; height: 20px; display: block; }

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.logo-icon {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, #7C3AED, #A855F7);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
}
.logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.logo-text span { color: var(--accent); }

.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.header-timer {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--bg-card);
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
  letter-spacing: 0.05em;
}
[data-theme="light"] .header-timer {
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.zoom-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border-radius: 4px;
  font-weight: 600;
  transition: background var(--transition);
}
.zoom-btn:hover { background: var(--accent-light); color: var(--accent); }

.user-greeting {
  font-size: var(--font-small);
  font-weight: 600;
  color: var(--text-primary);
  margin-right: 4px;
  display: none; /* hidden until logged in */
}

.author-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--accent-light);
  border-radius: 14px;
  font-size: var(--font-xs);
  color: var(--text-secondary);
  font-weight: 500;
}
.author-badge .author-dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

/* ---------- Theme Toggle ---------- */
.theme-toggle {
  width: 32px; height: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  color: var(--text-primary);
  font-size: 1.1rem;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--glow);
  transform: translateY(-1px);
}

.theme-toggle .toggle-icon { display: none; }
.theme-toggle .moon { display: block; }
[data-theme="light"] .theme-toggle .moon { display: none; }
[data-theme="light"] .theme-toggle .sun { display: block; }

/* ================================================================
   SIDEBAR — Compact
   ================================================================ */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 12px 8px;
  overflow-y: auto;
  z-index: 900;
  transition: transform var(--transition), background var(--transition), border-color var(--transition), width var(--transition);
}

.sidebar.collapsed {
  transform: translateX(-100%);
}

.sidebar-profile {
  display: none; /* Block when logged in */
  flex-direction: column;
  align-items: center;
  padding: 16px 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.sidebar-profile .avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #A855F7);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 10px;
  box-shadow: var(--shadow-md);
  box-sizing: border-box;
}
.sidebar-profile .name {
  font-size: var(--font-body);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.sidebar-profile .email {
  font-size: var(--font-xs);
  color: var(--text-secondary);
  word-break: break-all;
}

.sidebar-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--font-small);
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
}
.sidebar-nav li a:hover,
.sidebar-nav li a.active {
  background: var(--accent-light);
  color: var(--accent);
}
.sidebar-nav li a .nav-icon {
  width: 16px; height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.sidebar-section-title {
  font-size: var(--font-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  padding: 14px 10px 4px;
  opacity: 0.6;
}

.sidebar-stats {
  margin-top: 16px;
  padding: 12px;
  background: var(--accent-light);
  border-radius: var(--radius);
  text-align: center;
}
.sidebar-stats .stat-number {
  font-size: var(--font-h2);
  font-weight: 700;
  color: var(--accent);
}
.sidebar-stats .stat-label {
  font-size: var(--font-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 899;
}

/* ================================================================
   MAIN CONTENT — Compact
   ================================================================ */
.app-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: 20px 24px 20px;
  min-height: calc(90vh - var(--header-height));
  flex: 1;
  transition: margin-left var(--transition), padding var(--transition);
}

.app-content.sidebar-collapsed {
  margin-left: 0;
}

/* ---------- Search Bar ---------- */
.search-container {
  position: relative;
  margin-bottom: 14px;
  max-width: 480px;
}
.search-container .search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 0.9rem;
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  font-size: var(--font-body);
  font-family: var(--font-family);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition);
}
.search-input::placeholder { color: var(--text-secondary); opacity: 0.5; }
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light), var(--glow);
}

/* ---------- Filter Chips ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
}
.filter-chip {
  padding: 5px 14px;
  font-size: var(--font-xs);
  font-family: var(--font-family);
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.filter-chip:hover { border-color: var(--accent); color: var(--accent); }
.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--glow);
}
.filter-chip .chip-count {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  font-size: var(--font-xs);
  font-weight: 600;
}
.filter-chip:not(.active) .chip-count {
  background: var(--accent-light);
  color: var(--accent);
}

/* ---------- Card Grid ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.exercise-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: all var(--transition);
  cursor: default;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.exercise-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, #7C3AED, #A855F7, #C084FC);
  opacity: 0;
  transition: opacity var(--transition);
}
.exercise-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), var(--glow);
  border-color: rgba(124,58,237,0.3);
}
.exercise-card:hover::before { opacity: 1; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}
.card-badge {
  font-size: var(--font-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--accent-light);
  color: var(--accent);
  white-space: nowrap;
}
.card-badge.solved {
  background: rgba(16,185,129,0.12);
  color: var(--success);
}

.card-description {
  font-size: var(--font-small);
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 12px;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-actions {
  display: flex;
  gap: 8px;
}

/* ---------- Buttons ---------- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 16px;
  font-size: var(--font-btn);
  font-family: var(--font-family);
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--glow);
  color: #fff;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 16px;
  font-size: var(--font-btn);
  font-family: var(--font-family);
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* ---------- Section Headers ---------- */
.section-title {
  font-size: var(--font-h1);
  font-weight: 700;
  margin-bottom: 4px;
}
.section-subtitle {
  font-size: var(--font-small);
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* ---------- No Results ---------- */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 16px;
  color: var(--text-secondary);
}
.no-results .no-results-icon { font-size: 2.5rem; margin-bottom: 8px; opacity: 0.4; }

/* ---------- Footer ---------- */
.app-footer {
  margin-left: var(--sidebar-width);
  padding: 16px 24px;
  text-align: center;
  font-size: var(--font-xs);
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  transition: margin-left var(--transition), border-color var(--transition);
}

.app-footer.sidebar-collapsed {
  margin-left: 0;
}

/* ================================================================
   EXERCISE PAGE
   ================================================================ */
.exercise-content { max-width: 100%; padding-right: 16px; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-small);
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .separator { opacity: 0.3; }

/* Problem Card */
.problem-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  transition: background var(--transition), border-color var(--transition);
}
.problem-card .problem-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  flex-wrap: wrap;
  gap: 8px;
}
.problem-card .problem-title { font-size: var(--font-h2); font-weight: 700; }
.problem-card .problem-category { font-size: var(--font-small); color: var(--accent); font-weight: 500; }
.problem-card .problem-description {
  font-size: var(--font-body);
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 8px;
}

/* Nav */
.exercise-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.exercise-nav a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--font-xs);
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.exercise-nav a:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* Examples */
.examples-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
}
.examples-section h3 { font-size: var(--font-body); margin-bottom: 8px; }
.examples-section ul.examples {
  list-style: none;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: var(--font-xs);
  color: var(--text-secondary);
}
.examples-section ul.examples li {
  padding: 4px 10px;
  background: var(--bg-primary);
  border-radius: 4px;
  margin-bottom: 4px;
  border: 1px solid var(--border);
}

/* Editor */
.editor-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
}
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}
.editor-header h3 { font-size: var(--font-body); }
.editor-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.editor-actions .btn-primary,
.editor-actions .btn-secondary { padding: 6px 14px; font-size: var(--font-xs); }

/* CodeMirror */
.CodeMirror {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  height: 200px;
  min-height: 150px;
  resize: vertical;
  overflow: auto;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  background: #0D0D14;
  color: #E8E8ED;
}
.CodeMirror-gutters {
  background: #0D0D14;
  border-right-color: var(--border);
}
[data-theme="light"] .CodeMirror {
  background: #FAFAFA;
  color: #1A1A1A;
}
[data-theme="light"] .CodeMirror-gutters {
  background: #FAFAFA;
  border-right-color: var(--border);
}

/* Results */
.results-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 80px 0px 20px;
}

.congrats {
  font-size: var(--font-body);
  font-weight: 600;
  color: var(--success);
  padding: 8px 12px;
  background: rgba(16,185,129,0.08);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.congrats:empty { display: none; }

.errorMessage {
  font-size: var(--font-small);
  color: var(--error);
  padding: 8px 12px;
  background: rgba(239,68,68,0.08);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-family: 'JetBrains Mono', monospace;
  word-break: break-word;
}
.errorMessage:empty { display: none; }

#mySolution {
  font-size: var(--font-xs);
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
}

/* Test Table */
.test-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: var(--font-xs);
}
.test-table th {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: var(--font-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.test-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.test-table tr:last-child td { border-bottom: none; }
.test-table .status-box { width: 24px; text-align: center; font-size: 0.85rem; }

/* Save/Load buttons on index */
#topButtonContainer {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.btn-top {
  padding: 6px 12px;
  font-size: var(--font-xs);
  font-family: var(--font-family);
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-top:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* ---------- Animations ---------- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.exercise-card { animation: fadeInUp 0.35s ease both; }
.exercise-card:nth-child(1) { animation-delay: 0.02s; }
.exercise-card:nth-child(2) { animation-delay: 0.04s; }
.exercise-card:nth-child(3) { animation-delay: 0.06s; }
.exercise-card:nth-child(4) { animation-delay: 0.08s; }
.exercise-card:nth-child(5) { animation-delay: 0.10s; }
.exercise-card:nth-child(6) { animation-delay: 0.12s; }

/* ---------- Responsive: Tablet ---------- */
@media (max-width: 1024px) {
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .app-content { padding: 16px 16px 60px; }
}

/* ---------- Responsive: Mobile ---------- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-overlay.active { display: block; }
  .hamburger { display: flex; }
  .app-content { margin-left: 0; padding: 14px 12px 60px; }
  .app-footer { margin-left: 0; }
  .cards-grid { grid-template-columns: 1fr; }
  .author-badge { display: none; }
  .filter-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .filter-chip { flex-shrink: 0; }
  .exercise-nav { flex-wrap: wrap; }
  div#displayResults { position: static !important; margin-left: 0 !important; }
}

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

::selection { background: var(--accent-light); color: var(--accent); }

.exercise-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 24px;
  max-width: 100%;
  padding-right: 12px;
}

/* Problem & Editor (Left, class exercise-panel-left) */
.exercise-panel-left {
  display: flex;
  flex-direction: column;
}

/* Result Section (Right, class exercise-panel-right) */
.exercise-panel-right {
  position: sticky;
  top: calc(var(--header-height) + 20px);
  max-height: calc(100vh - var(--header-height) - 40px);
  overflow-y: auto;
  border-radius: var(--radius);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.exercise-panel-right::-webkit-scrollbar { width: 4px; }

@media (max-width: 1024px) {
  .exercise-grid { grid-template-columns: 1fr; padding-right: 0; }
  .exercise-panel-right { position: relative; top: auto; max-height: none; overflow-y: visible; }
  .exercise-panel-left { position: relative; top: auto; max-height: none; overflow-y: visible; }
}

/* ================================================================
   MODALS AND AUTH UI
   ================================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
  padding: 24px;
  box-shadow: var(--shadow-lg), var(--glow);
  position: relative;
  animation: modalFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }

.modal-title {
  font-size: var(--font-h2);
  margin-bottom: 20px;
  font-weight: 700;
}

.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: var(--font-xs);
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-control {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: var(--font-body);
  transition: all var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.btn-block {
  width: 100%;
  padding: 10px;
  font-size: var(--font-body);
  font-weight: 600;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

/* ================================================================
   TOAST NOTIFICATIONS
   ================================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: var(--font-small);
  color: var(--text);
  transform: translateX(120%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.show { transform: translateX(0); }
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--error); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast-icon { font-size: 1.1rem; }

/* ================================================================
   PROFILE AND STATS PAGE
   ================================================================ */
.profile-container {
  max-width: 800px;
  margin: 0 auto;
}

.profile-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}
.profile-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--accent-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: var(--primary); font-weight: 700;
}
.profile-info h2 { margin-bottom: 4px; font-size: 1.4rem; }
.profile-info p { color: var(--muted); font-size: var(--font-small); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  transition: transform var(--transition);
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md), var(--glow); border-color: var(--primary); }
.stat-card-icon { font-size: 24px; margin-bottom: 12px; }
.stat-card-value { font-size: 2rem; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.stat-card-label { font-size: var(--font-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }