/**
 * DSA Practice page styles
 */

:root {
  --dsa-bg-1: #0f172a;
  --dsa-bg-2: #1a1040;
  --dsa-bg-3: #2d1b69;
  --dsa-text: #e2e8f0;
  --dsa-text-muted: #94a3b8;
  --dsa-accent: #a78bfa;
  --dsa-accent-2: #22d3ee;
  --dsa-success: #34d399;
  --dsa-danger: #fb7185;
  --dsa-warning: #fbbf24;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Source Sans 3', 'Roboto', sans-serif;
  color: var(--dsa-text);
  background:
    radial-gradient(circle at 10% 20%, rgba(167, 139, 250, 0.16), transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(34, 211, 238, 0.14), transparent 35%),
    linear-gradient(160deg, var(--dsa-bg-1) 0%, var(--dsa-bg-2) 45%, var(--dsa-bg-3) 100%);
}

body.light-mode {
  --dsa-text: #0f172a;
  --dsa-text-muted: #334155;
  --dsa-accent: #7c3aed;
  --dsa-accent-2: #0369a1;
  background:
    radial-gradient(circle at 10% 20%, rgba(167, 139, 250, 0.2), transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(34, 211, 238, 0.16), transparent 35%),
    linear-gradient(160deg, #f8fafc 0%, #ede9fe 48%, #dbeafe 100%);
}

/* ==================== Layout ==================== */

.dsa-app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.2rem 1rem 3rem;
}

.dsa-hero {
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.dsa-hero h1 {
  margin: 0 0 0.4rem;
  font-family: 'Orbitron', 'Share Tech Mono', monospace;
  letter-spacing: 0.04em;
  font-size: 1.5rem;
}

.dsa-hero p {
  margin: 0;
  color: var(--dsa-text-muted);
}

.progress-snapshot {
  display: inline-block;
  margin-top: 0.9rem;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: var(--dsa-text-muted);
  font-size: 0.82rem;
}

.text-muted { color: var(--dsa-text-muted); }

/* ==================== Category Switcher ==================== */

.category-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 1rem;
}

.category-switcher label {
  font-family: 'Orbitron', monospace;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dsa-accent);
}

.category-switcher select {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.6);
  color: var(--dsa-text);
  font-size: 0.92rem;
}

body.light-mode .category-switcher select {
  background: rgba(255, 255, 255, 0.6);
}

/* ==================== Tabs ==================== */

.dsa-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  padding: 0;
  margin-bottom: 1rem;
  overflow: hidden;
}

.dsa-tab {
  padding: 0.7rem 0.4rem;
  border: none;
  background: transparent;
  color: var(--dsa-text-muted);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  text-align: center;
}

.dsa-tab:hover {
  color: var(--dsa-text);
  background: rgba(167, 139, 250, 0.1);
}

.dsa-tab.active {
  color: var(--dsa-accent);
  background: rgba(167, 139, 250, 0.15);
  border-bottom: 2px solid var(--dsa-accent);
}

/* ==================== Panels ==================== */

.dsa-panel {
  display: none;
  animation: fadeIn 0.2s ease;
}

.dsa-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==================== Overview ==================== */

.overview-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.overview-main { padding: 1.2rem; }
.overview-main h2 {
  margin: 0 0 0.5rem;
  font-family: 'Orbitron', monospace;
  font-size: 1.1rem;
}

.overview-sidebar { padding: 1.2rem; max-height: 600px; overflow-y: auto; }
.overview-sidebar h3 {
  margin: 0 0 0.6rem;
  font-family: 'Orbitron', monospace;
  font-size: 0.95rem;
}

.list-filters { margin-bottom: 0.75rem; }
.list-filters select {
  width: 100%;
  padding: 0.4rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.6);
  color: var(--dsa-text);
  font-size: 0.85rem;
}

.list-filters input {
  width: 100%;
  margin-top: 0.45rem;
  padding: 0.4rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.6);
  color: var(--dsa-text);
  font-size: 0.85rem;
  box-sizing: border-box;
}

body.light-mode .list-filters select {
  background: rgba(255, 255, 255, 0.6);
}

body.light-mode .list-filters input {
  background: rgba(255, 255, 255, 0.6);
}

.list-filters input::placeholder {
  color: var(--dsa-text-muted);
}

.overview-problem-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  transition: background 0.15s;
}

.overview-problem-item:hover {
  background: rgba(167, 139, 250, 0.1);
}

.overview-problem-item:focus-visible {
  outline: 2px solid var(--dsa-accent);
  outline-offset: 1px;
}

.overview-problem-item .solved-icon {
  font-size: 0.75rem;
  width: 1.2rem;
  text-align: center;
}

.category-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.category-stat-card {
  padding: 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(167, 139, 250, 0.06);
}

.category-stat-card .stat-value {
  font-family: 'Orbitron', monospace;
  font-size: 1.3rem;
  color: var(--dsa-accent);
}

.category-stat-card .stat-label {
  font-size: 0.78rem;
  color: var(--dsa-text-muted);
}

/* ==================== Problems Layout ==================== */

.problems-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1rem;
}

.problem-sidebar {
  padding: 0.8rem;
  max-height: 80vh;
  overflow-y: auto;
  position: sticky;
  top: 1rem;
}

.problem-filter-controls {
  margin-bottom: 0.75rem;
}

.problem-filter-controls label {
  font-family: 'Orbitron', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dsa-accent);
  display: block;
  margin-bottom: 0.3rem;
}

.problem-filter-controls select {
  width: 100%;
  padding: 0.4rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.6);
  color: var(--dsa-text);
  font-size: 0.85rem;
}

.problem-filter-controls input {
  width: 100%;
  margin-top: 0.45rem;
  padding: 0.4rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.6);
  color: var(--dsa-text);
  font-size: 0.85rem;
  box-sizing: border-box;
}

body.light-mode .problem-filter-controls select {
  background: rgba(255, 255, 255, 0.6);
}

body.light-mode .problem-filter-controls input {
  background: rgba(255, 255, 255, 0.6);
}

.problem-filter-controls input::placeholder {
  color: var(--dsa-text-muted);
}

.problem-nav-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}

.problem-nav-item:hover {
  background: rgba(167, 139, 250, 0.1);
}

.problem-nav-item:focus-visible {
  outline: 2px solid var(--dsa-accent);
  outline-offset: 1px;
}

.problem-nav-item.active {
  background: rgba(167, 139, 250, 0.18);
  border-left-color: var(--dsa-accent);
}

.problem-nav-item .nav-solved {
  font-size: 0.7rem;
  width: 1rem;
  text-align: center;
}

.problem-nav-item .nav-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== Difficulty Badges ==================== */

.difficulty-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.difficulty-easy {
  background: rgba(52, 211, 153, 0.15);
  color: var(--dsa-success);
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.difficulty-medium {
  background: rgba(251, 191, 36, 0.15);
  color: var(--dsa-warning);
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.difficulty-hard {
  background: rgba(251, 113, 133, 0.15);
  color: var(--dsa-danger);
  border: 1px solid rgba(251, 113, 133, 0.35);
}

body.light-mode .difficulty-easy { color: #047857; background: rgba(16, 185, 129, 0.12); border-color: rgba(16, 185, 129, 0.4); }
body.light-mode .difficulty-medium { color: #92400e; background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.4); }
body.light-mode .difficulty-hard { color: #be123c; background: rgba(244, 63, 94, 0.12); border-color: rgba(244, 63, 94, 0.4); }

/* ==================== Problem Description ==================== */

.problem-description {
  padding: 1.2rem;
  margin-bottom: 1rem;
}

.problem-description h2 {
  margin: 0 0 0.5rem;
  font-family: 'Orbitron', monospace;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

#problem-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
  font-size: 0.82rem;
  color: var(--dsa-text-muted);
}

.problem-tag {
  padding: 0.12rem 0.4rem;
  border-radius: 6px;
  font-size: 0.72rem;
  background: rgba(167, 139, 250, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.3);
  color: var(--dsa-accent);
}

.list-tag {
  padding: 0.12rem 0.4rem;
  border-radius: 6px;
  font-size: 0.68rem;
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.3);
  color: var(--dsa-accent-2);
}

#problem-body { margin-bottom: 1rem; line-height: 1.6; }

.example-block {
  padding: 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.4);
  margin-bottom: 0.6rem;
  font-size: 0.88rem;
}

body.light-mode .example-block {
  background: rgba(241, 245, 249, 0.6);
}

.example-block code {
  font-family: 'Share Tech Mono', monospace;
  color: var(--dsa-accent-2);
}

.example-block strong { color: var(--dsa-accent); }

#problem-constraints {
  margin-bottom: 0.8rem;
  font-size: 0.85rem;
}

#problem-constraints ul {
  margin: 0.3rem 0 0;
  padding-left: 1.2rem;
}

#problem-constraints code {
  font-family: 'Share Tech Mono', monospace;
  color: var(--dsa-accent-2);
  font-size: 0.82rem;
}

.problem-hints-toggle { margin-bottom: 0.5rem; }

.problem-hints {
  padding: 0.6rem;
  border-radius: 8px;
  background: rgba(167, 139, 250, 0.08);
  border: 1px solid rgba(167, 139, 250, 0.2);
  font-size: 0.88rem;
  line-height: 1.5;
}

.problem-hints:empty { display: none; }

/* ==================== Code Editor ==================== */

.editor-container {
  margin-bottom: 1rem;
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.editor-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.82rem;
  color: var(--dsa-text-muted);
}

.editor-actions {
  display: flex;
  gap: 0.4rem;
}

.editor-container .CodeMirror {
  height: 320px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.9rem;
}

/* ==================== Buttons ==================== */

.btn-primary {
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--dsa-accent);
  color: #0f172a;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  padding: 0.45rem 0.85rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 8px;
  background: transparent;
  color: var(--dsa-text);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover { background: rgba(167, 139, 250, 0.1); }

/* ==================== Test Results ==================== */

.test-results {
  padding: 1rem;
  margin-bottom: 1rem;
}

.test-results h3 {
  margin: 0 0 0.6rem;
  font-family: 'Orbitron', monospace;
  font-size: 0.95rem;
}

.test-summary {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.6rem;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.88rem;
}

.test-summary.passed {
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.4);
  color: var(--dsa-success);
}

.test-summary.failed {
  background: rgba(251, 113, 133, 0.12);
  border: 1px solid rgba(251, 113, 133, 0.4);
  color: var(--dsa-danger);
}

.test-case-item {
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
}

.test-case-item.passed {
  border-color: rgba(52, 211, 153, 0.5);
  background: rgba(52, 211, 153, 0.06);
}

.test-case-item.failed {
  border-color: rgba(251, 113, 133, 0.5);
  background: rgba(251, 113, 133, 0.06);
}

.test-case-item code {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.82rem;
  color: var(--dsa-accent-2);
}

.test-case-item .test-error {
  color: var(--dsa-danger);
  margin-top: 0.25rem;
}

.test-case-item .test-time {
  color: var(--dsa-text-muted);
  font-size: 0.75rem;
  margin-top: 0.15rem;
}

/* ==================== Solution Panel ==================== */

.solution-panel {
  padding: 1.2rem;
  margin-bottom: 1rem;
}

.solution-panel h3 {
  margin: 0 0 0.6rem;
  font-family: 'Orbitron', monospace;
  font-size: 0.95rem;
}

#solution-code {
  background: rgba(15, 23, 42, 0.5);
  border-radius: 10px;
  padding: 0.8rem;
  margin-bottom: 0.8rem;
  overflow-x: auto;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.88rem;
  white-space: pre-wrap;
  line-height: 1.5;
}

body.light-mode #solution-code {
  background: rgba(241, 245, 249, 0.7);
}

#solution-explanation {
  margin-bottom: 0.6rem;
  line-height: 1.5;
}

#solution-complexity {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.85rem;
  color: var(--dsa-text-muted);
  margin-bottom: 0.6rem;
}

/* ==================== Patterns / Flashcards ==================== */

.patterns-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
}

.pattern-controls {
  padding: 1rem;
}

.pattern-controls label {
  font-family: 'Orbitron', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dsa-accent);
  display: block;
  margin-bottom: 0.3rem;
}

.pattern-controls select {
  width: 100%;
  padding: 0.4rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.6);
  color: var(--dsa-text);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

body.light-mode .pattern-controls select {
  background: rgba(255, 255, 255, 0.6);
}

.pattern-stats {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.pattern-stage {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.flashcard {
  width: 100%;
  max-width: 500px;
  min-height: 200px;
  perspective: 1200px;
  margin-bottom: 1rem;
  position: relative;
}

.flashcard-face {
  position: absolute;
  width: 100%;
  min-height: 200px;
  padding: 1.5rem;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.5);
  backface-visibility: hidden;
  transition: transform 0.35s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1rem;
  line-height: 1.6;
  box-sizing: border-box;
}

body.light-mode .flashcard-face {
  background: rgba(255, 255, 255, 0.6);
}

.flashcard-back {
  transform: rotateY(180deg);
}

.flashcard.show-back .flashcard-front {
  transform: rotateY(180deg);
}

.flashcard.show-back .flashcard-back {
  transform: rotateY(360deg);
}

.flash-actions {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.flash-btn {
  padding: 0.5rem 1.2rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 10px;
  background: transparent;
  color: var(--dsa-text);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s;
}

.flash-btn:hover { background: rgba(167, 139, 250, 0.12); }

.flash-grade {
  display: flex;
  gap: 0.4rem;
}

.pattern-grade-btn {
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: transparent;
  color: var(--dsa-text);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.pattern-grade-btn:hover { background: rgba(167, 139, 250, 0.1); }

.pattern-grade-btn[data-quality="1"]:hover { border-color: var(--dsa-danger); }
.pattern-grade-btn[data-quality="2"]:hover { border-color: var(--dsa-warning); }
.pattern-grade-btn[data-quality="4"]:hover { border-color: var(--dsa-success); }
.pattern-grade-btn[data-quality="5"]:hover { border-color: var(--dsa-accent-2); }

/* ==================== Progress ==================== */

.progress-layout {
  display: grid;
  gap: 1rem;
}

.readiness-card {
  padding: 1.2rem;
}

.readiness-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.readiness-top h3 {
  margin: 0;
  font-family: 'Orbitron', monospace;
  font-size: 1rem;
}

#readiness-score {
  font-family: 'Orbitron', monospace;
  font-size: 1.4rem;
  color: var(--dsa-accent);
}

.readiness-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

#readiness-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--dsa-accent), var(--dsa-success));
  transition: width 0.25s ease;
  width: 0%;
}

.progress-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.stat-card {
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(167, 139, 250, 0.06);
  text-align: center;
}

.stat-card .stat-value {
  font-family: 'Orbitron', monospace;
  font-size: 1.3rem;
  color: var(--dsa-accent);
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--dsa-text-muted);
  margin-top: 0.2rem;
}

.mastery-card, .streak-card {
  padding: 1.2rem;
}

.mastery-card h3, .streak-card h3 {
  margin: 0 0 0.8rem;
  font-family: 'Orbitron', monospace;
  font-size: 0.95rem;
}

.mastery-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.mastery-row label {
  min-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mastery-row input[type="range"] {
  flex: 1;
  accent-color: var(--dsa-accent);
}

.mastery-row .mastery-value {
  min-width: 35px;
  text-align: right;
  font-family: 'Share Tech Mono', monospace;
  color: var(--dsa-accent);
}

.streak-display-grid {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.streak-number {
  font-family: 'Orbitron', monospace;
  font-size: 2rem;
  color: var(--dsa-accent);
}

.streak-label {
  font-size: 0.85rem;
  color: var(--dsa-text-muted);
}

.progress-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  padding: 0.5rem 0;
}

/* ==================== Resources ==================== */

#resource-list {
  display: grid;
  gap: 0.6rem;
}

.resource-item {
  display: block;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(167, 139, 250, 0.06);
  color: var(--dsa-accent);
  text-decoration: none;
  font-size: 0.92rem;
  transition: background 0.15s;
}

.resource-item:hover {
  background: rgba(167, 139, 250, 0.12);
}

/* ==================== Responsive ==================== */

@media (max-width: 1080px) {
  .overview-layout,
  .problems-layout,
  .patterns-layout {
    grid-template-columns: 1fr;
  }

  .problem-sidebar {
    max-height: 250px;
    position: static;
  }

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

  .editor-toolbar {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .mastery-row label {
    min-width: 140px;
  }
}

@media (max-width: 780px) {
  .dsa-app {
    padding: 0.8rem 0.6rem 2rem;
  }

  .dsa-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dsa-tab {
    font-size: 0.8rem;
    padding: 0.6rem 0.3rem;
  }

  .progress-stats {
    grid-template-columns: 1fr;
  }

  .category-stat-grid {
    grid-template-columns: 1fr;
  }

  .category-switcher {
    flex-direction: column;
    align-items: stretch;
  }

  .category-switcher select {
    min-width: unset;
  }

  .overview-sidebar {
    max-height: 400px;
  }

  .problem-description {
    padding: 0.9rem;
  }

  .problem-description h2 {
    font-size: 1rem;
  }

  #problem-meta {
    font-size: 0.78rem;
  }

  .example-block {
    font-size: 0.84rem;
    padding: 0.6rem;
    overflow-x: auto;
  }

  .example-block code {
    word-break: break-all;
  }

  #solution-code {
    font-size: 0.82rem;
    padding: 0.6rem;
  }

  .flashcard {
    max-width: 100%;
  }

  .flashcard-face {
    font-size: 0.92rem;
    padding: 1rem;
  }

  .flash-grade {
    flex-wrap: wrap;
    justify-content: center;
  }

  .streak-display-grid {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .mastery-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.3rem;
  }

  .mastery-row label {
    min-width: unset;
  }

  .mastery-row input[type="range"] {
    width: 100%;
  }

  .pattern-controls {
    padding: 0.8rem;
  }

  .pattern-stage {
    padding: 1rem;
  }

  .test-results {
    padding: 0.75rem;
  }

  .test-case-item {
    font-size: 0.82rem;
    overflow-x: auto;
  }

  .test-case-item code {
    word-break: break-all;
  }
}

@media (max-width: 480px) {
  .dsa-app {
    padding: 0.5rem 0.4rem 1.5rem;
  }

  .dsa-hero {
    padding: 1rem;
  }

  .dsa-hero h1 {
    font-size: 1.15rem;
  }

  .dsa-hero p {
    font-size: 0.88rem;
  }

  .dsa-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dsa-tab {
    font-size: 0.76rem;
    padding: 0.55rem 0.2rem;
  }

  .editor-container .CodeMirror {
    height: 220px;
    font-size: 0.82rem;
  }

  .editor-toolbar {
    padding: 0.4rem 0.5rem;
  }

  .editor-label {
    font-size: 0.75rem;
  }

  .editor-actions {
    flex-wrap: wrap;
    gap: 0.3rem;
  }

  .btn-primary,
  .btn-secondary {
    font-size: 0.76rem;
    padding: 0.4rem 0.6rem;
  }

  .problem-sidebar {
    max-height: 200px;
  }

  .problem-nav-item {
    font-size: 0.82rem;
    padding: 0.4rem;
  }

  .problem-description h2 {
    font-size: 0.95rem;
  }

  #problem-body {
    font-size: 0.9rem;
  }

  .example-block {
    font-size: 0.8rem;
  }

  .flashcard {
    min-height: 170px;
  }

  .flashcard-face {
    min-height: 170px;
    font-size: 0.88rem;
    padding: 0.8rem;
    line-height: 1.5;
  }

  .flash-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.82rem;
  }

  .pattern-grade-btn {
    font-size: 0.76rem;
    padding: 0.35rem 0.6rem;
  }

  .stat-card .stat-value {
    font-size: 1.1rem;
  }

  .stat-card .stat-label {
    font-size: 0.7rem;
  }

  .readiness-top h3 {
    font-size: 0.9rem;
  }

  #readiness-score {
    font-size: 1.2rem;
  }

  .streak-number {
    font-size: 1.6rem;
  }

  .solution-panel {
    padding: 0.9rem;
  }

  .solution-panel h3 {
    font-size: 0.88rem;
  }

  #solution-code {
    font-size: 0.78rem;
  }

  .test-results h3 {
    font-size: 0.88rem;
  }

  .resource-item {
    font-size: 0.85rem;
    padding: 0.7rem 0.8rem;
  }

  .progress-actions {
    justify-content: center;
  }

  .overview-main {
    padding: 0.9rem;
  }

  .overview-sidebar {
    padding: 0.9rem;
  }

  .mastery-card,
  .streak-card {
    padding: 0.9rem;
  }

  .mastery-card h3,
  .streak-card h3 {
    font-size: 0.88rem;
  }
}
