:root {
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-card: #242424;
  --bg-hover: #2f2f2f;
  --accent: #ffa116;
  --accent-dim: rgba(255,161,22,0.15);
  --text-primary: #e5e7eb;
  --text-muted: #8a8a8a;
  --border: #333333;
  --easy: #00b8a3;
  --medium: #ffc01e;
  --hard: #ef4743;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4a4a4a; }

/* Top Nav */
#topnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
}
#topnav .logo {
  font-size: 18px; font-weight: 800;
  color: var(--accent); letter-spacing: 1px; white-space: nowrap;
}
#search-input {
  flex: 1; max-width: 360px;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: 8px;
  padding: 7px 14px; font-size: 13px; outline: none;
  transition: border-color 0.2s;
}
#search-input:focus { border-color: var(--accent); }
#search-input::placeholder { color: var(--text-muted); }

.nav-select {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: 8px;
  padding: 7px 12px; font-size: 13px; cursor: pointer; outline: none;
}
.nav-select:focus { border-color: var(--accent); }

#hamburger {
  display: none; background: none; border: none;
  color: var(--text-primary); cursor: pointer; padding: 6px;
}

/* Layout */
#layout {
  display: flex;
  margin-top: 56px;
  height: calc(100vh - 56px);
}

/* Sidebar */
#sidebar {
  width: 220px; min-width: 220px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto; padding: 16px 12px;
  display: flex; flex-direction: column; gap: 20px;
}
.sidebar-section h3 {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--text-muted); text-transform: uppercase;
  margin: 0 0 8px 4px;
}
.filter-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: 6px; cursor: pointer;
  transition: background 0.15s; user-select: none; font-size: 13px;
}
.filter-item:hover { background: var(--bg-hover); }
.filter-item input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }
.filter-item .count {
  margin-left: auto; font-size: 11px; color: var(--text-muted);
  background: var(--bg-card); padding: 1px 6px; border-radius: 10px;
}

/* Progress bar */
#progress-wrap { padding: 4px 0; }
#progress-bar-bg {
  background: var(--border); border-radius: 4px; height: 6px; margin: 6px 0;
}
#progress-bar-fill {
  background: var(--accent); height: 6px; border-radius: 4px;
  transition: width 0.3s ease;
}
#progress-label { font-size: 12px; color: var(--text-muted); }

/* Main */
#main {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
}

/* Stats bar */
#stats-bar {
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; gap: 20px; align-items: center; flex-wrap: wrap;
  font-size: 12px; color: var(--text-muted);
}
.stat-pill {
  display: flex; align-items: center; gap: 5px;
  background: var(--bg-card); padding: 3px 10px; border-radius: 12px;
}
.stat-pill .dot { width: 8px; height: 8px; border-radius: 50%; }

/* Question Table */
#question-list { padding: 0 16px 16px; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 12px; text-align: left;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--text-muted); text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-primary); z-index: 1;
}
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--accent); }
tbody tr {
  border-bottom: 1px solid rgba(51,51,51,0.75);
  cursor: pointer; transition: background 0.12s;
}
tbody tr:hover { background: var(--bg-hover); }
tbody tr.done { opacity: 0.5; }
tbody td { padding: 10px 12px; }
td.num { color: var(--text-muted); width: 48px; font-size: 12px; }
td.title { font-weight: 500; }
td.title:hover { color: var(--accent); }

/* Difficulty badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.03em;
}
.badge-Easy { color: var(--easy); background: rgba(0,184,163,0.12); }
.badge-Medium { color: var(--medium); background: rgba(255,192,30,0.12); }
.badge-Hard { color: var(--hard); background: rgba(239,71,67,0.12); }

/* Company tags */
.company-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  font-size: 10px; padding: 1px 6px; border-radius: 4px;
  background: var(--bg-card); color: var(--text-muted); border: 1px solid var(--border);
}

/* Done toggle */
.done-btn {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border); background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
}
.done-btn.checked { background: var(--easy); border-color: var(--easy); }
.done-btn.checked::after { content: '✓'; color: white; font-size: 11px; font-weight: 700; }

/* Detail View */
#detail-view {
  display: none;
  flex: 1;
  overflow: hidden;
}
#detail-view.active { display: block; height: 100%; }
#question-list.hidden { display: none; }

.leetcode-shell {
  display: grid;
  grid-template-columns: minmax(380px, 47%) minmax(420px, 53%);
  height: 100%;
  min-height: calc(100vh - 56px);
  background: var(--bg-primary);
}

.problem-pane,
.solution-pane {
  min-width: 0;
  overflow-y: auto;
}

.problem-pane {
  border-right: 1px solid var(--border);
  background: var(--bg-primary);
  padding: 22px 26px 28px;
}

.solution-pane {
  background: #121212;
  padding: 22px 24px 28px;
}

.problem-toolbar,
.solution-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

#back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted); font-size: 13px; cursor: pointer;
  background: none; border: none; padding: 0;
  transition: color 0.15s;
}
#back-btn:hover { color: var(--accent); }

#detail-title { font-size: 24px; font-weight: 700; margin: 0 0 10px; }
#detail-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }

.done-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.detail-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.detail-tab {
  position: relative;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
}

.detail-tab:hover,
.detail-tab.active {
  color: var(--text-primary);
}

.detail-tab.active::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

.detail-tab-panel { display: none; }
.detail-tab-panel.active { display: block; }

.detail-section {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 8px; padding: 16px 20px; margin-bottom: 14px;
}
.detail-section h4 {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--accent); margin: 0 0 10px;
}
.detail-section p, .detail-section li { color: var(--text-primary); line-height: 1.7; margin: 0; }
.problem-statement p { font-size: 15px; }

.hints-list { list-style: none; padding: 0; margin: 0; }
.hint-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}
.hint-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 600;
  padding: 10px 12px;
}
.hint-toggle:hover { color: var(--accent); }
.hint-chevron {
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
}
.hint-item .hint-text {
  display: none;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  padding: 10px 12px 12px;
}
.hint-item.revealed .hint-text { display: block; }
.hint-item.revealed .hint-chevron { color: var(--easy); }
.hint-item.revealed .hint-chevron::before { content: '-'; }
.hint-item.revealed .hint-chevron { font-size: 0; }
.hint-item.revealed .hint-chevron::before { font-size: 16px; }

.pane-eyebrow {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0 0 2px;
  text-transform: uppercase;
}

.solution-toolbar h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.language-select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  outline: none;
  padding: 8px 12px;
}

.language-select:focus { border-color: var(--accent); }

.approach-card {
  background: #1f1f1f;
}

.approach-list {
  margin: 0;
  padding-left: 18px;
}

.complexity-row { display: flex; gap: 20px; }
.complexity-item { flex: 1; }
.complexity-item label { font-size: 11px; color: var(--text-muted); display: block; margin-bottom: 4px; }
.complexity-item code {
  background: var(--bg-card); padding: 4px 10px; border-radius: 6px;
  font-family: 'Fira Code', 'JetBrains Mono', monospace; font-size: 13px;
  color: var(--accent); border: 1px solid var(--border);
}

.solution-complexity {
  margin-bottom: 14px;
}

.code-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #0a0a0a;
}

.code-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #1f1f1f;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  padding: 9px 12px;
}

#copy-code-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 9px;
}

#copy-code-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.code-card pre {
  margin: 0;
  max-height: 520px;
  overflow: auto;
  padding: 16px;
}

.code-card code {
  color: #d6deff;
  font-family: 'Fira Code', 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre;
}

/* Mobile sidebar overlay */
#sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); z-index: 90;
}

/* Empty state */
#empty-state {
  display: none; text-align: center; padding: 60px 20px; color: var(--text-muted);
}
#empty-state svg { margin-bottom: 12px; }

/* Responsive */
@media (max-width: 768px) {
  #hamburger { display: flex; }
  #sidebar {
    position: fixed; left: -240px; top: 56px; bottom: 0;
    width: 240px; z-index: 95; transition: left 0.25s ease;
  }
  #sidebar.open { left: 0; }
  #sidebar-overlay.open { display: block; }
  .nav-select { display: none; }
  #search-input { max-width: none; }
  table thead th:nth-child(4),
  table thead th:nth-child(5),
  table tbody td:nth-child(4),
  table tbody td:nth-child(5) { display: none; }
  #detail-view { overflow-y: auto; }
  .leetcode-shell {
    display: block;
    min-height: 0;
  }
  .problem-pane,
  .solution-pane {
    overflow: visible;
    padding: 16px;
  }
  .problem-pane {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .problem-toolbar,
  .solution-toolbar {
    align-items: flex-start;
  }
  #detail-title { font-size: 20px; }
  .complexity-row { flex-direction: column; gap: 10px; }
  .code-card pre { max-height: none; }
}
