/* ==========================================================================
   ML Interview Practice - Global Styles
   Dark-mode-first, no framework, pure CSS custom properties
   ========================================================================== */

/* ==========================================================================
   CSS Custom Properties (Design Tokens)
   ========================================================================== */
:root {
  /* Background palette */
  --bg:         #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary:  #16213e;
  --bg-card:    #1e1e3a;

  /* Text */
  --text:       #e0e0e0;
  --text-muted: #8888aa;
  --text-dim:   #555577;

  /* Accent */
  --accent:     #4a9eff;
  --accent-dim: #2a6abf;

  /* Difficulty colors */
  --easy:   #4caf50;
  --medium: #ff9800;
  --hard:   #f44336;

  /* Status */
  --pass-bg:   rgba(76, 175, 80, 0.15);
  --pass-border: #4caf50;
  --fail-bg:   rgba(244, 67, 54, 0.15);
  --fail-border: #f44336;

  /* Borders */
  --border:     #2a2a4a;
  --border-dim: #1e1e38;

  /* Typography */
  --font-mono: 'JetBrains Mono', 'Fira Mono', 'Cascadia Code', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Layout */
  --header-h: 56px;
  --radius:   6px;
  --radius-sm: 3px;
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

a:hover {
  text-decoration: underline;
}

ul, ol {
  list-style: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
}

select, input {
  font-family: inherit;
  font-size: inherit;
}

/* ==========================================================================
   Header Bar
   ========================================================================== */
.header {
  height: var(--header-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.header .tagline {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

/* Problem page header nav */
.header-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.header-nav a,
.header-nav .nav-link {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.header-nav a:hover,
.header-nav .nav-link:hover {
  color: var(--text);
  background: var(--bg-tertiary);
  text-decoration: none;
}

.header-nav .sep {
  color: var(--border);
}

/* ==========================================================================
   Stats Bar
   ========================================================================== */
#stats-bar {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.8rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
  line-height: 1;
}

.stat-value.easy   { color: var(--easy); }
.stat-value.medium { color: var(--medium); }
.stat-value.hard   { color: var(--hard); }

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Progress rings */
.stat-rings {
  display: flex;
  gap: 1rem;
  margin-left: auto;
  align-items: center;
}
.stat-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  --ring-bg: var(--border);
  --ring-fg: var(--accent);
}
.ring-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  max-width: 50px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.progress-ring circle {
  fill: none;
  stroke-width: 3;
}

.progress-ring circle:first-child {
  stroke: var(--bg-tertiary);
}

.progress-ring circle:last-child {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s ease;
}

/* ==========================================================================
   Filter Bar
   ========================================================================== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input[type="text"] {
  background: var(--bg-tertiary);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.7rem;
  outline: none;
  transition: border-color 0.15s;
}

.filter-bar select:focus,
.filter-bar input[type="text"]:focus {
  border-color: var(--accent);
}

.filter-bar select option {
  background: var(--bg-secondary);
  color: var(--text);
}

.filter-bar input[type="text"]::placeholder {
  color: var(--text-dim);
}

/* Difficulty toggle buttons */
.difficulty-filters {
  display: flex;
  gap: 0.3rem;
}

.diff-btn {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.15s, border-color 0.15s, background 0.15s;
}

.diff-btn.easy   { color: var(--easy);   border-color: var(--easy); }
.diff-btn.medium { color: var(--medium); border-color: var(--medium); }
.diff-btn.hard   { color: var(--hard);   border-color: var(--hard); }

.diff-btn.active {
  opacity: 1;
}

.diff-btn.easy.active   { background: rgba(76, 175, 80, 0.15); }
.diff-btn.medium.active { background: rgba(255, 152, 0, 0.15); }
.diff-btn.hard.active   { background: rgba(244, 67, 54, 0.15); }

.filter-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ==========================================================================
   Problem Table (Index Page)
   ========================================================================== */
.table-container {
  padding: 0 1.5rem 2rem;
  overflow-x: auto;
}

.problem-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

.problem-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.problem-table th {
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.6rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.problem-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border-dim);
  font-size: 0.9rem;
  vertical-align: middle;
}

.problem-table tbody tr {
  transition: background 0.1s;
}

.problem-table tbody tr:hover {
  background: var(--bg-card);
}

.problem-table .col-num {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  width: 3rem;
}

.problem-table .col-title a {
  color: var(--text);
  font-weight: 500;
  transition: color 0.15s;
}

.problem-table .col-title a:hover {
  color: var(--accent);
  text-decoration: none;
}

.problem-table .col-status {
  font-size: 0.82rem;
}

.problem-table .col-time {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Difficulty badge */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.easy,   .diff-easy   { color: var(--easy);   }
.badge.medium, .diff-medium { color: var(--medium); }
.badge.hard,   .diff-hard   { color: var(--hard);   }
.badge.easy   { background: rgba(76, 175, 80, 0.12); }
.badge.medium { background: rgba(255, 152, 0, 0.12); }
.badge.hard   { background: rgba(244, 67, 54, 0.12); }
.difficulty-badge.diff-easy   { color: var(--easy);   background: rgba(76, 175, 80, 0.12); }
.difficulty-badge.diff-medium { color: var(--medium); background: rgba(255, 152, 0, 0.12); }
.difficulty-badge.diff-hard   { color: var(--hard);   background: rgba(244, 67, 54, 0.12); }

/* Featured (Samsung Prep) rows */
.featured-row {
  border-left: 3px solid #fbbf24;
}
.featured-star {
  color: #fbbf24;
  font-size: 0.85rem;
}
.featured-btn {
  color: #fbbf24 !important;
  border-color: #fbbf24 !important;
  font-weight: 600;
  opacity: 0.6;
}
.featured-btn:hover {
  opacity: 0.85;
}
.snippets-btn {
  color: #fbbf24 !important;
  border-color: #fbbf24 !important;
  font-weight: 600;
  opacity: 0.6;
  text-decoration: none;
  display: inline-block;
}
.snippets-btn:hover {
  opacity: 1;
  background: rgba(251, 191, 36, 0.15);
}
.featured-btn.active {
  opacity: 1;
  background: rgba(251, 191, 36, 0.15) !important;
  color: #fbbf24 !important;
}

/* Status indicator */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
}

.status-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
}

.status-dot.solved::before  { background: var(--easy); }
.status-dot.attempted::before { background: var(--medium); }

/* ==========================================================================
   Problem Page - Split Layout
   ========================================================================== */
.problem-layout {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

.problem-left {
  width: 40%;
  min-width: 320px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.problem-right {
  flex: 1;
  width: 60%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ==========================================================================
   Problem Description (Left Panel)
   ========================================================================== */
.problem-header {
  padding: 1.25rem 1.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.problem-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text);
  line-height: 1.3;
}

.problem-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.problem-meta .badge,
.problem-meta .difficulty-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--bg);
}

.problem-meta .tag {
  font-size: 0.72rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: var(--bg);
  color: var(--text-muted);
}

.problem-meta .meta-sep {
  color: var(--border);
}

/* Markdown-rendered description */
.problem-description {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.problem-description h1,
.problem-description h2,
.problem-description h3 {
  color: var(--text);
  margin: 1rem 0 0.5rem;
  line-height: 1.3;
}

.problem-description h1 { font-size: 1.1rem; }
.problem-description h2 { font-size: 1rem; }
.problem-description h3 { font-size: 0.9rem; color: var(--text-muted); }

.problem-description p {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--text);
}

.problem-description code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  color: var(--accent);
}

.problem-description pre {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  margin: 0.75rem 0;
}

.problem-description pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.82rem;
  color: var(--text);
}

/* ==========================================================================
   Constraints List
   ========================================================================== */
.constraints-section {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.constraints-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.constraints-list li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  color: var(--text);
}

.constraints-list li::before {
  content: '';
  width: 5px;
  height: 5px;
  min-width: 5px;
  border-radius: 50%;
  background: var(--hard);
  position: relative;
  top: -1px;
}

/* ==========================================================================
   Hints Section
   ========================================================================== */
.hints-section {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.hints-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.hint-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.4rem 0.7rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.83rem;
  transition: color 0.15s, border-color 0.15s;
}

.hint-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}

.hint-toggle .arrow {
  font-size: 0.65rem;
  transition: transform 0.2s;
}

.hint-toggle[aria-expanded="true"] .arrow {
  transform: rotate(180deg);
}

.hint-content {
  display: none;
  padding: 0.6rem 0.7rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.55;
}

.hint-content.open {
  display: block;
}

/* ==========================================================================
   Related Problems Section
   ========================================================================== */
.related-section {
  padding: 1rem 1.5rem;
}

.related-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.4rem;
}

.related-list a {
  font-size: 0.85rem;
  color: var(--accent);
}

/* ==========================================================================
   Action Bar (Right Panel Top)
   ========================================================================== */
.action-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Button base */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Primary - run tests */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

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

/* Secondary - reset, misc */
.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-secondary:not(:disabled):hover {
  color: var(--text);
  border-color: var(--accent);
}

/* Danger - show solution */
.btn-danger {
  background: transparent;
  color: var(--hard);
  border-color: var(--hard);
  opacity: 0.7;
}

.btn-danger:not(:disabled):hover {
  background: rgba(244, 67, 54, 0.1);
  opacity: 1;
}

.btn-accent {
  background: rgba(76, 175, 80, 0.15);
  color: var(--easy);
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.btn-accent:not(:disabled):hover {
  background: rgba(76, 175, 80, 0.25);
}

.btn-accent:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Spacer in action bar */
.action-bar .spacer {
  flex: 1;
}

/* ==========================================================================
   Console Panel
   ========================================================================== */
.console-output {
  padding: 0.5rem 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  min-height: 60px;
  max-height: 50vh;
  overflow-y: auto;
}

.console-line {
  padding: 0.15rem 1rem;
  white-space: pre-wrap;
  word-break: break-all;
}

.console-line.console-input-echo {
  color: var(--text-muted);
}

.console-line.console-output-text {
  color: var(--text);
}

.console-line.console-error {
  color: var(--fail-border);
}

.console-line.console-info {
  color: var(--text-muted);
  font-style: italic;
}

.console-line.console-separator {
  border-top: 1px solid var(--border-dim);
  margin: 0.25rem 0;
  padding: 0;
}

.console-input-row {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 0;
}

.console-prompt {
  padding: 0.4rem 0 0.4rem 1rem;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}

.console-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.4rem 0.5rem;
}

.console-input:disabled {
  opacity: 0.4;
}

.console-input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

/* ==========================================================================
   Timer Display
   ========================================================================== */
.timer-display {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.05em;
  min-width: 5.5ch;
  text-align: right;
}

.timer-display.running {
  color: var(--easy);
}

.timer-display.overtime {
  color: var(--hard);
}

/* ==========================================================================
   Editor Container
   ========================================================================== */
.editor-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}

/* CodeMirror host element takes full height */
.editor-container .cm-editor {
  height: 100%;
}

/* ==========================================================================
   Framework Tabs (NumPy / PyTorch)
   ========================================================================== */
.framework-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.framework-tab {
  padding: 0.4rem 1rem;
  font-size: 0.78rem;
  font-family: var(--font-sans);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

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

.framework-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* PyTorch banner */
.pytorch-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 1rem;
  background: #2a2520;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  color: #e0b860;
  flex-shrink: 0;
}

.pytorch-banner code {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-size: 0.85em;
}

.pytorch-banner .btn-sm {
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  margin-left: auto;
}

/* ==========================================================================
   Output Tabs
   ========================================================================== */
.output-tabs {
  display: flex;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.output-tab {
  padding: 0.4rem 1rem;
  font-size: 0.78rem;
  font-family: var(--font-sans);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

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

.output-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Output panels container */
.output-panels {
  flex-shrink: 0;
  max-height: 50vh;
  overflow: hidden;
}

.output-panel {
  display: none;
  max-height: 50vh;
  overflow-y: auto;
}

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

/* ==========================================================================
   Test Results Panel
   ========================================================================== */
.test-results {
  overflow-y: auto;
  background: var(--bg-secondary);
}

.test-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 1;
}

.test-result {
  border-bottom: 1px solid var(--border-dim);
  font-size: 0.83rem;
}

.test-result:last-child {
  border-bottom: none;
}

.test-result.pass {
  border-left: 3px solid var(--pass-border);
}

.test-result.fail {
  border-left: 3px solid var(--fail-border);
}

/* Clickable header row */
.test-result-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  user-select: none;
}

.test-result-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.test-result-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
  width: 1.2rem;
  text-align: center;
}

.test-result.pass .test-result-icon { color: var(--pass-border); }
.test-result.fail .test-result-icon { color: var(--fail-border); }

.test-result .test-result-name {
  font-weight: 600;
  color: var(--text);
  flex: 1;
  font-size: 0.83rem;
}

.test-result .test-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.test-expand-arrow {
  font-size: 0.6rem;
  color: var(--text-muted);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.test-result.expanded .test-expand-arrow {
  transform: rotate(90deg);
}

/* Expandable details (hidden by default) */
.test-result-details {
  display: none;
  padding: 0 1rem 0.75rem 2.7rem;
}

.test-result.expanded .test-result-details {
  display: block;
}

.test-detail-section {
  margin-bottom: 0.5rem;
}

.test-detail-section:last-child {
  margin-bottom: 0;
}

.test-detail-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.test-detail-code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.2);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
  margin: 0;
}

.test-detail-error {
  color: var(--fail-border);
}

.test-detail-status {
  font-size: 0.8rem;
  font-weight: 700;
}

.test-detail-status.pass { color: var(--pass-border); }
.test-detail-status.fail { color: var(--fail-border); }

/* ==========================================================================
   Solution Panel
   ========================================================================== */
.solution-panel {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
  max-height: 50vh;
  overflow-y: auto;
}

.solution-panel.visible {
  display: block;
}

.solution-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hard);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 1;
}

.solution-panel pre {
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text);
  white-space: pre;
  overflow-x: auto;
}

/* ==========================================================================
   Loading Overlay
   ========================================================================== */
.loading-overlay {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: none;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 1000;
}

.loading-overlay.visible {
  display: flex;
}

/* Spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* ==========================================================================
   Error / Empty State
   ========================================================================== */
.error-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
  text-align: center;
  gap: 0.5rem;
}

.error-msg .error-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--hard);
}

.error-msg .error-detail {
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* ==========================================================================
   Navigation Links (breadcrumb / inline)
   ========================================================================== */
.nav-link-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: color 0.15s;
}

.nav-link-back:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ==========================================================================
   Study Assistant Panel
   ========================================================================== */
.btn-study {
  background: rgba(138, 99, 210, 0.15);
  color: #b388ff;
  border: 1px solid rgba(138, 99, 210, 0.3);
}

.btn-study:not(:disabled):hover {
  background: rgba(138, 99, 210, 0.25);
}

.btn-study.active {
  background: rgba(138, 99, 210, 0.3);
  border-color: #b388ff;
}

.study-panel {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  min-width: 360px;
  max-width: 600px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  z-index: 50;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
}

.study-panel.visible {
  display: flex;
}

.study-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #b388ff;
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.study-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
}

/* Collapsible sections */
.study-section {
  border-bottom: 1px solid var(--border-dim);
}

.study-section:last-child {
  border-bottom: none;
}

.study-section-title {
  display: flex;
  align-items: center;
  padding: 0.65rem 1rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: background 0.1s;
}

.study-section-title::-webkit-details-marker {
  display: none;
}

.study-section-title::before {
  content: '\25B6';
  font-size: 0.55rem;
  margin-right: 0.6rem;
  color: var(--text-muted);
  transition: transform 0.15s;
}

details.study-section[open] > .study-section-title::before {
  transform: rotate(90deg);
}

.study-section-title:hover {
  background: rgba(255, 255, 255, 0.03);
}

.study-section-content {
  padding: 0 1rem 1rem;
  font-size: 0.87rem;
  color: var(--text);
  line-height: 1.7;
}

/* Markdown inside study panel */
.study-section-content h1,
.study-section-content h2,
.study-section-content h3 {
  color: var(--text);
  margin: 0.8rem 0 0.4rem;
  line-height: 1.3;
}

.study-section-content h1 { font-size: 1rem; }
.study-section-content h2 { font-size: 0.95rem; }
.study-section-content h3 { font-size: 0.88rem; color: var(--text-muted); }

.study-section-content p {
  margin-bottom: 0.6rem;
}

.study-section-content ul,
.study-section-content ol {
  padding-left: 1.2rem;
  margin-bottom: 0.6rem;
}

.study-section-content li {
  list-style: disc;
  margin-bottom: 0.3rem;
}

.study-section-content ol li {
  list-style: decimal;
}

.study-section-content code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  color: var(--accent);
}

.study-section-content pre {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  overflow-x: auto;
  margin: 0.6rem 0;
}

.study-section-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.8rem;
  color: var(--text);
}

/* Hint items inside study panel */
.study-hint-item {
  margin-bottom: 0.5rem;
}

.study-hint-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.4rem 0.7rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.83rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.study-hint-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.study-hint-btn.revealed {
  color: var(--text);
  border-color: #b388ff;
}

.study-hint-text {
  display: none;
  padding: 0.5rem 0.7rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.55;
}

.study-hint-text.visible {
  display: block;
}

/* Solution code in study panel */
.study-solution-code {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text);
  white-space: pre;
  overflow-x: auto;
  margin-top: 0.5rem;
}

.study-solution-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 0.5rem;
}

/* Make problem-right relative for overlay positioning */
.problem-right {
  position: relative;
}

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

/* Stack panels vertically on medium screens */
@media (max-width: 1024px) {
  .problem-layout {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .problem-left {
    width: 100%;
    min-width: unset;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 50vh;
  }

  .problem-right {
    width: 100%;
    height: 60vh;
  }
}

/* Hide category and time columns on small screens */
@media (max-width: 768px) {
  .problem-table .col-category,
  .problem-table th:nth-child(4),
  .problem-table td:nth-child(4),
  .problem-table .col-time,
  .problem-table th:nth-child(6),
  .problem-table td:nth-child(6) {
    display: none;
  }

  .filter-bar {
    gap: 0.5rem;
  }

  #stats-bar {
    gap: 1rem;
    flex-wrap: wrap;
  }

  .header h1 {
    font-size: 0.95rem;
  }

  .header .tagline {
    display: none;
  }
}
