* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --text2: #8b949e;
  --accent: #58a6ff;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
  --orange: #db6d28;
  --sidebar-w: 280px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.subtitle { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* Session picker */
.session-bar { margin-top: 14px; }

.session-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text2);
  margin-bottom: 6px;
}

.session-controls {
  display: flex;
  gap: 6px;
}

#session-select {
  flex: 1;
  min-width: 0;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  cursor: pointer;
}

#session-select:focus { outline: none; border-color: var(--accent); }

.session-btn {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 30px;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
}

.session-btn:hover { border-color: var(--accent); color: var(--accent); }

.session-btn-danger:hover { border-color: var(--red); color: var(--red); }

/* Profile bar */
.profile-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.profile-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.profile-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.profile-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-email { font-size: 11px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.profile-logout {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  cursor: pointer;
  font-size: 15px;
}

.profile-logout:hover { border-color: var(--red); color: var(--red); }

/* Auth overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 32px;
}

.auth-logo { font-size: 24px; font-weight: 700; color: var(--accent); text-align: center; }
.auth-tagline { font-size: 13px; color: var(--text2); text-align: center; margin: 6px 0 24px; }

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  background: transparent;
  color: var(--text2);
  border: none;
  border-radius: 6px;
  padding: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.auth-tab.active { background: var(--accent); color: #fff; }

.auth-form { display: flex; flex-direction: column; gap: 12px; }

.auth-form input {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 14px;
}

.auth-form input:focus { outline: none; border-color: var(--accent); }

.auth-submit {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}

.auth-submit:hover { filter: brightness(1.08); }

.auth-message {
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  margin-top: 16px;
  min-height: 18px;
  color: var(--text2);
}

.auth-message.error { color: var(--red); }
.auth-message.success { color: var(--green); }
.auth-message a { color: var(--accent); }

/* Sidebar nav (Problems / Challenges) */
.side-nav { padding: 8px; border-bottom: 1px solid var(--border); }

.side-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}

.side-nav-item:hover { background: var(--bg3); }
.side-nav-icon { color: var(--accent); font-size: 12px; width: 14px; text-align: center; }

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Dashboard */
.dashboard { padding: 28px 32px; max-width: 900px; margin: 0 auto; overflow-y: auto; height: 100%; }
.dash-header h1 { font-size: 26px; }
.dash-sub { color: var(--text2); font-size: 14px; margin-top: 4px; }
.dash-section { margin-top: 28px; }
.dash-section h2 { font-size: 16px; margin-bottom: 12px; }
.dash-count { color: var(--text2); font-weight: 400; font-size: 14px; }
.challenge-list { display: flex; flex-direction: column; gap: 10px; }
.challenge-empty { color: var(--text2); font-size: 14px; padding: 16px; background: var(--bg2); border: 1px dashed var(--border); border-radius: 10px; }

.challenge-card {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text2);
  border-radius: 10px;
  padding: 14px 16px;
}

.challenge-card.status-pending { border-left-color: var(--accent); }
.challenge-card.status-completed { border-left-color: var(--green); }
.challenge-card.status-overdue { border-left-color: var(--red); }

.challenge-card-main { min-width: 0; }
.challenge-top { display: flex; align-items: center; gap: 10px; }
.challenge-title { font-weight: 600; font-size: 15px; cursor: pointer; }
.challenge-title:hover { color: var(--accent); text-decoration: underline; }
.challenge-meta { color: var(--text2); font-size: 13px; margin-top: 4px; }
.challenge-msg { color: var(--text); font-size: 13px; margin-top: 8px; font-style: italic; }

.challenge-card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0; }

.challenge-status-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.challenge-status-tag.pending { background: rgba(88,166,255,0.15); color: var(--accent); }
.challenge-status-tag.completed { background: rgba(63,185,80,0.15); color: var(--green); }
.challenge-status-tag.overdue { background: rgba(248,81,73,0.15); color: var(--red); }

.btn-sm { padding: 5px 12px; font-size: 12px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  width: 100%;
  max-width: 440px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 17px; }
.modal-close { background: none; border: none; color: var(--text2); font-size: 24px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }

.modal-body { padding: 20px; }
.modal-problem { font-weight: 600; color: var(--accent); margin-bottom: 16px; }
.modal-label { display: block; font-size: 12px; color: var(--text2); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: 0.4px; }
.modal-label:first-child { margin-top: 0; }

.modal-body input {
  width: 100%;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

.modal-body input:focus { outline: none; border-color: var(--accent); }
.modal-error { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 16px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

/* @-mention picker */
.mention-wrap { position: relative; }

.mention-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
}

.mention-item.active, .mention-item:hover { background: var(--accent); color: #fff; }

.mention-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.mention-item.active .mention-avatar, .mention-item:hover .mention-avatar { background: rgba(255,255,255,0.25); }
.mention-name { font-weight: 600; font-size: 14px; }
.mention-email { font-size: 12px; color: var(--text2); margin-left: auto; }
.mention-item.active .mention-email, .mention-item:hover .mention-email { color: rgba(255,255,255,0.8); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 300;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

#topic-list { padding: 8px; flex: 1; overflow-y: auto; }

.topic-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}

.topic-item:hover { background: var(--bg3); }
.topic-item.active { background: rgba(88,166,255,0.1); color: var(--accent); }

.topic-icon {
  width: 32px;
  height: 32px;
  background: var(--bg3);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  color: var(--accent);
  flex-shrink: 0;
}

.topic-name { font-size: 14px; font-weight: 500; }
.topic-count { font-size: 11px; color: var(--text2); }

/* Main */
#main-content { flex: 1; overflow-y: auto; }

.view { display: none; height: 100%; }
.view.active { display: flex; flex-direction: column; }

/* Grind75 Homepage */
.grind-page {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.grind-sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 16px;
}

.grind-sidebar-section {
  margin-bottom: 24px;
}

.grind-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text2);
  margin-bottom: 10px;
}

.grind-diff-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.grind-diff-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.grind-diff-btn:hover { border-color: var(--text2); color: var(--text); }
.grind-diff-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.grind-topic-filters {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 320px;
  overflow-y: auto;
}

.grind-topic-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--text2);
  transition: color 0.1s;
}

.grind-topic-check:hover { color: var(--text); }

.grind-topic-check input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.grind-topic-check .topic-cnt {
  margin-left: auto;
  font-size: 11px;
  color: var(--border);
  min-width: 18px;
  text-align: right;
}

.grind-group-btns {
  display: flex;
  gap: 4px;
}

.grind-group-btn {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.grind-group-btn:hover { border-color: var(--text2); color: var(--text); }
.grind-group-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.grind-reset-btn {
  width: 100%;
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.grind-reset-btn:hover { border-color: var(--red); color: var(--red); }

/* Grind main content */
.grind-main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.grind-header {
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}

.grind-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.grind-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.grind-subtitle {
  font-size: 14px;
  color: var(--text2);
}

.grind-progress-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.grind-progress-info {
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  min-width: 120px;
}

.grind-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
}

.grind-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Question list */
.grind-questions {
  flex: 1;
  padding: 0;
}

.grind-group {
  border-bottom: 1px solid var(--border);
}

.grind-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 32px;
  background: var(--bg2);
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
  position: sticky;
  top: 0;
  z-index: 1;
}

.grind-group-header:hover { background: var(--bg3); }

.grind-group-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.grind-group-header .group-count {
  font-size: 12px;
  font-weight: 400;
  color: var(--text2);
}

.grind-group-header .group-chevron {
  font-size: 12px;
  color: var(--text2);
  transition: transform 0.2s;
}

.grind-group.collapsed .group-chevron { transform: rotate(-90deg); }
.grind-group.collapsed .grind-group-body { display: none; }

/* Question row */
.grind-q-row {
  display: flex;
  align-items: center;
  padding: 10px 32px;
  border-top: 1px solid var(--border);
  transition: background 0.1s;
  gap: 12px;
  cursor: pointer;
}

.grind-q-row:hover { background: rgba(255,255,255,0.02); }
.grind-q-row.completed { opacity: 0.5; }

.grind-q-check {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
  font-size: 11px;
  color: transparent;
}

.grind-q-check:hover { border-color: var(--accent); }
.grind-q-check.checked {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.grind-q-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grind-q-row.completed .grind-q-name {
  text-decoration: line-through;
  color: var(--text2);
}

.grind-q-diff {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  flex-shrink: 0;
}

.grind-q-diff.easy { background: rgba(63,185,80,0.12); color: var(--green); }
.grind-q-diff.medium { background: rgba(210,153,34,0.12); color: var(--yellow); }
.grind-q-diff.hard { background: rgba(248,81,73,0.12); color: var(--red); }

.grind-q-topic {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(88,166,255,0.1);
  color: var(--accent);
  flex-shrink: 0;
  white-space: nowrap;
}

.grind-q-time {
  font-size: 12px;
  color: var(--text2);
  flex-shrink: 0;
  min-width: 50px;
  text-align: right;
}

.grind-q-arrow {
  color: var(--border);
  font-size: 14px;
  flex-shrink: 0;
  transition: color 0.15s;
}

.grind-q-row:hover .grind-q-arrow { color: var(--accent); }

/* Topic view */
.topic-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}

.back-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.back-btn:hover { border-color: var(--text2); color: var(--text); }

.tab-bar {
  display: flex;
  gap: 0;
  padding: 0 24px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

.tab {
  background: none;
  border: none;
  color: var(--text2);
  padding: 12px 20px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

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

.tab-content { display: none; flex: 1; overflow-y: auto; }
.tab-content.active { display: block; }

/* Study Guide */
.guide-content {
  padding: 32px;
  max-width: 900px;
  line-height: 1.7;
  font-size: 15px;
}

.guide-content h2 { font-size: 22px; margin: 32px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.guide-content h2:first-child { margin-top: 0; }
.guide-content h3 { font-size: 17px; margin: 24px 0 8px; color: var(--accent); }
.guide-content h4 { font-size: 15px; margin: 16px 0 8px; }
.guide-content p { margin-bottom: 12px; color: var(--text2); }
.guide-content strong { color: var(--text); }
.guide-content ul, .guide-content ol { padding-left: 24px; margin-bottom: 12px; color: var(--text2); }
.guide-content li { margin-bottom: 4px; }
.guide-content a { color: var(--accent); text-decoration: none; }
.guide-content a:hover { text-decoration: underline; }

.guide-content code {
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'SF Mono', Monaco, monospace;
}

.guide-content pre {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.guide-content pre code {
  background: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.5;
}

.guide-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.guide-content th, .guide-content td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
}

.guide-content th { background: var(--bg3); font-weight: 600; }
.guide-content td { color: var(--text2); }

.info-box {
  background: rgba(88,166,255,0.08);
  border: 1px solid rgba(88,166,255,0.2);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

/* Problem list */
.problem-list { padding: 24px; }

.problem-section { margin-bottom: 32px; }
.problem-section h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text2);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.problem-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.problem-card:hover { border-color: var(--accent); }

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

.problem-card h4 { font-size: 14px; font-weight: 500; }

.difficulty-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
}

.difficulty-badge.easy { background: rgba(63,185,80,0.15); color: var(--green); }
.difficulty-badge.medium { background: rgba(210,153,34,0.15); color: var(--yellow); }
.difficulty-badge.hard { background: rgba(248,81,73,0.15); color: var(--red); }

/* Problem view */
.problem-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}

.problem-header h2 { font-size: 18px; }

/* Video embed inside solution */
.video-embed {
  margin-bottom: 16px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}

.video-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.problem-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.problem-left {
  width: 40%;
  min-width: 300px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}

.problem-left .panel { padding: 24px; }
.problem-left h3 { font-size: 14px; color: var(--text2); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px; }

.description {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text2);
}

.description code {
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
  color: var(--accent);
}

.description pre {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
  overflow-x: auto;
}

.description pre code { color: var(--text); background: none; padding: 0; }
.description strong { color: var(--text); }
.description p { margin-bottom: 10px; }
.description ul { padding-left: 20px; margin-bottom: 10px; }

.problem-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.lang-selector { display: flex; gap: 4px; }

.lang-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.lang-btn:hover { border-color: var(--text2); color: var(--text); }
.lang-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

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

.btn {
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: #2ea043; }
.btn-primary:disabled { background: var(--border); color: var(--text2); cursor: not-allowed; }
.btn-secondary { background: var(--bg3); border: 1px solid var(--border); color: var(--text2); }
.btn-secondary:hover { border-color: var(--text2); color: var(--text); }

/* Solution section */
.solution-section {
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

.solution-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}

.solution-toggle:hover h3 { color: #79c0ff; }

.solution-toggle h3 {
  margin: 0;
  font-size: 15px;
  color: var(--accent);
  transition: color 0.15s;
}

.solution-toggle-icon {
  font-size: 10px;
  color: var(--accent);
  display: inline-block;
  width: 14px;
}

.solution-body {
  padding-bottom: 16px;
  animation: solFadeIn 0.2s ease;
}

@keyframes solFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.solution-body .description h2 {
  font-size: 16px;
  color: var(--accent);
  margin: 20px 0 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.solution-body .description h3 {
  font-size: 14px;
  color: var(--text);
  margin: 14px 0 6px;
}

.solution-body .description pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.5;
  margin: 8px 0;
}

.solution-body .description code {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 12.5px;
}

.solution-body .description ul,
.solution-body .description ol {
  padding-left: 20px;
  margin: 6px 0;
}

.solution-body .description li {
  margin: 4px 0;
  line-height: 1.5;
}

#editor-container {
  flex: 1;
  position: relative;
  min-height: 200px;
  overflow: hidden;
}

#code-editor { display: none; }

#editor-container .CodeMirror {
  height: 100%;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.6;
}

#editor-container .CodeMirror-gutters {
  border-right: 1px solid var(--border);
}

.output-panel {
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
  max-height: 250px;
  overflow-y: auto;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}

.output-header h3 { font-size: 12px; color: var(--text2); text-transform: uppercase; letter-spacing: 1px; }

#output-status { font-size: 12px; font-weight: 600; }
#output-status.pass { color: var(--green); }
#output-status.fail { color: var(--red); }
#output-status.error { color: var(--red); }
#output-status.running { color: var(--yellow); }

#output-content {
  padding: 0;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text2);
  margin: 0;
  min-height: 60px;
}

.output-plain {
  padding: 12px 16px;
  white-space: pre-wrap;
}

/* Test result summary bar */
.result-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.result-bar-pass { background: rgba(63,185,80,0.08); }
.result-bar-fail { background: rgba(248,81,73,0.08); }
.result-bar-partial { background: rgba(210,153,34,0.08); }

.result-summary-icon {
  font-size: 20px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.result-bar-pass .result-summary-icon { background: rgba(63,185,80,0.2); color: var(--green); }
.result-bar-fail .result-summary-icon { background: rgba(248,81,73,0.2); color: var(--red); }
.result-bar-partial .result-summary-icon { background: rgba(210,153,34,0.2); color: var(--yellow); }

.result-summary-text {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-summary-text strong {
  font-size: 14px;
}

.result-bar-pass .result-summary-text strong { color: var(--green); }
.result-bar-fail .result-summary-text strong { color: var(--red); }
.result-bar-partial .result-summary-text strong { color: var(--yellow); }

.result-summary-pct {
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
}

.result-bar-track {
  width: 100%;
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
}

.result-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.result-bar-pass .result-bar-fill { background: var(--green); }
.result-bar-fail .result-bar-fill { background: var(--red); }
.result-bar-partial .result-bar-fill { background: var(--yellow); }

/* Individual test lines */
.result-tests {
  padding: 8px 0;
}

.result-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  transition: background 0.1s;
  flex-wrap: wrap;
}

.result-line:hover { background: rgba(255,255,255,0.02); }

.result-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 11px;
  flex-shrink: 0;
}

.pass-icon { background: rgba(63,185,80,0.15); color: var(--green); }
.fail-icon { background: rgba(248,81,73,0.15); color: var(--red); }

.result-label {
  font-weight: 500;
  color: var(--text);
  font-size: 13px;
}

.result-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.5px;
}

.pass-tag { background: rgba(63,185,80,0.12); color: var(--green); }
.fail-tag { background: rgba(248,81,73,0.12); color: var(--red); }

.result-detail {
  width: 100%;
  padding: 4px 0 2px 28px;
  font-size: 12px;
  color: var(--text2);
  font-family: 'SF Mono', Monaco, monospace;
}

/* Error output */
.result-error {
  padding: 12px 16px;
}

.result-error-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--red);
  margin-bottom: 8px;
  font-size: 14px;
}

.result-error-body {
  background: rgba(248,81,73,0.06);
  border: 1px solid rgba(248,81,73,0.15);
  border-radius: 6px;
  padding: 12px;
  font-size: 12px;
  color: var(--red);
  white-space: pre-wrap;
  margin: 0;
  line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text2); }

/* Responsive */
@media (max-width: 900px) {
  #sidebar { width: 60px; min-width: 60px; }
  .sidebar-header h1 { font-size: 14px; }
  .subtitle, .topic-name, .topic-count, .session-bar { display: none; }
  .topic-item { justify-content: center; padding: 10px; }
  .problem-layout { flex-direction: column; }
  .problem-left { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--border); max-height: 40vh; }
  .grind-sidebar { display: none; }
  .grind-q-row { padding: 10px 16px; }
  .grind-group-header { padding: 12px 16px; }
  .grind-header { padding: 20px 16px 16px; }
  .grind-q-topic { display: none; }
}
