:root {
  --bg: #0b0e14;
  --bg-elevated: #12161f;
  --bg-card: #161b26;
  --border: #232937;
  --text: #e6e9ef;
  --text-dim: #8b94a7;
  --text-faint: #5c6478;
  --brand: #37e2a3;
  --brand-dim: #1f8f68;
  --brand-glow: rgba(55, 226, 163, 0.15);
  --blue: #5b9dff;
  --easy: #37e2a3;
  --medium: #ffb454;
  --hard: #ff6b6b;
  --radius: 10px;
  --max-width: 1400px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 14, 20, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand .logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--blue));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0b0e14;
  font-weight: 800;
  font-size: 0.95rem;
}

.brand .dot { color: var(--brand); }

.nav-links {
  display: flex;
  gap: 28px;
  align-items: center;
}

.nav-links a {
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--text);
}

.nav-cta {
  background: var(--brand);
  color: #04140d !important;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  font-size: 1.1rem;
  cursor: pointer;
}

/* ---------- Hero ---------- */
.hero {
  padding: 88px 0 64px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(600px 300px at 50% -80px, var(--brand-glow), transparent 70%);
}

.eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-glow);
  border: 1px solid var(--brand-dim);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 20px;
  letter-spacing: 0.02em;
}

.hero h1 {
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 0 0 18px;
}

.hero h1 .accent { color: var(--brand); }

.hero p.lead {
  color: var(--text-dim);
  font-size: 1.15rem;
  max-width: 620px;
  margin: 0 auto 32px;
}

.hero-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover { transform: translateY(-1px); }

.btn-primary {
  background: var(--brand);
  color: #04140d;
}
.btn-primary:hover { background: #4bf0b3; }

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover { border-color: var(--text-faint); }

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 48px 0;
}

.stat {
  background: var(--bg-elevated);
  padding: 26px 20px;
  text-align: center;
}

.stat .num {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -0.02em;
}

.stat .label {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* ---------- Sections ---------- */
.section {
  padding: 64px 0;
}

.section-head {
  margin-bottom: 36px;
  text-align: center;
}

.section-head h2 {
  font-size: 2rem;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
}

.section-head p {
  color: var(--text-dim);
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- Feature cards ---------- */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.card:hover {
  border-color: var(--brand-dim);
  transform: translateY(-2px);
}

.card .icon {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: var(--brand-glow);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 14px;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.card p {
  color: var(--text-dim);
  font-size: 0.92rem;
  margin: 0;
}

/* ---------- Roadmap page: flowchart ---------- */
.flow-roadmap {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
}

.flow-roadmap::before {
  content: "";
  position: absolute;
  left: 27px;
  top: 28px;
  bottom: 28px;
  width: 2px;
  background: var(--border);
}

.flow-tier {
  position: relative;
  display: flex;
  gap: 22px;
  margin-bottom: 40px;
  align-items: flex-start;
}
.flow-tier:last-child { margin-bottom: 0; }

.flow-tier-marker {
  position: relative;
  z-index: 1;
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text-dim);
}
.flow-tier.done .flow-tier-marker {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-glow);
}

.flow-tier-body { flex: 1; min-width: 0; padding-top: 6px; }

.flow-tier-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.flow-tier-head h3 {
  margin: 0;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}
.flow-tier-progress {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}
.flow-tier.done .flow-tier-progress { color: var(--brand); }

.flow-nodes {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.flow-node {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  flex: 1 1 160px;
  max-width: 220px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.flow-node:hover { border-color: var(--brand-dim); transform: translateY(-2px); }
.flow-node.done { border-color: rgba(55, 226, 163, 0.35); }

.flow-node .fn-link { display: block; color: inherit; flex: 1; }

.flow-node .fn-title {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 8px;
}

.flow-node .fn-progress {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--bg-elevated);
  border-radius: 999px;
  padding: 3px 9px;
}
.flow-node.done .fn-progress { color: var(--brand); background: var(--brand-glow); }

.flow-node .fn-toggle {
  margin-top: 12px;
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.flow-node .fn-toggle:hover { color: var(--brand); }

.flow-guide {
  position: relative;
  flex: 1 1 100%;
  max-width: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
  font-size: 0.87rem;
}
.flow-guide-overview {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.65;
  padding-right: 24px;
}
.flow-guide h4 {
  margin: 16px 0 8px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand);
}
.flow-guide ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-dim);
  line-height: 1.7;
}
.flow-guide ul li { margin-bottom: 4px; }
.flow-guide-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.flow-guide-close:hover { color: var(--text); }

/* ---------- Problems page ---------- */
.problems-layout {
  display: flex;
  align-items: flex-start;
  gap: 28px;
}
.problems-main { flex: 1; min-width: 0; }

.progress-dashboard {
  flex: 0 0 280px;
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pd-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.pd-ring-card { text-align: center; }

.pd-ring-wrap {
  position: relative;
  width: 132px;
  height: 132px;
  margin: 0 auto 10px;
}
.pd-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.pd-ring-track {
  fill: none;
  stroke: var(--bg-elevated);
  stroke-width: 10;
}
.pd-ring-fill {
  fill: none;
  stroke: var(--brand);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 326.7256;
  stroke-dashoffset: 326.7256;
  transition: stroke-dashoffset 0.5s ease;
}
.pd-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.pd-ring-num { font-size: 1.9rem; font-weight: 800; color: var(--text); line-height: 1; }
.pd-ring-den { font-size: 0.8rem; color: var(--text-faint); margin-top: 2px; }
.pd-ring-title { color: var(--text-dim); font-size: 0.88rem; font-weight: 600; }
.pd-ring-title span { color: var(--text-faint); font-weight: 500; }

.pd-section-title {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-bottom: 12px;
}

.pd-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  margin-bottom: 6px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  border-radius: 6px;
}
.pd-stat-row:hover .pd-stat-label { color: var(--brand); }
.pd-stat-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.86rem;
  color: var(--text-dim);
  transition: color 0.15s ease;
}
.pd-stat-frac { font-size: 0.82rem; font-weight: 700; color: var(--text-dim); }
.pd-stat-row.active .pd-stat-label,
.pd-stat-row.active .pd-stat-frac { color: var(--brand); }

.pd-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.pd-dot.easy { background: var(--easy); }
.pd-dot.medium { background: var(--medium); }
.pd-dot.hard { background: var(--hard); }

.pd-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-elevated);
  overflow: hidden;
  margin-bottom: 14px;
}
.pd-bar:last-child { margin-bottom: 0; }
.pd-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
}
.pd-bar-fill.easy { background: var(--easy); }
.pd-bar-fill.medium { background: var(--medium); }
.pd-bar-fill.hard { background: var(--hard); }
.pd-bar-fill.brand { background: var(--brand); }

.pd-list-row {
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.pd-list-row:first-child { border-top: none; padding-top: 0; }

.list-scope-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 8px;
}
.list-scope-btn {
  font-size: 0.88rem;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  cursor: pointer;
}
.list-scope-btn:hover { border-color: var(--text-faint); color: var(--text); }
.list-scope-btn.active {
  color: var(--brand);
  border-color: var(--brand-dim);
  background: var(--brand-glow);
}
.list-scope-hint {
  color: var(--text-faint);
  font-size: 0.85rem;
}

.core-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--brand);
  background: var(--brand-glow);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 8px;
  vertical-align: middle;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
  position: sticky;
  top: 64px;
  background: var(--bg);
  padding: 16px 0;
  z-index: 30;
  border-bottom: 1px solid var(--border);
}

.search-input {
  flex: 1;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.95rem;
}
.search-input:focus { outline: none; border-color: var(--brand-dim); }

.select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.progress-chip {
  color: var(--text-dim);
  font-size: 0.88rem;
  white-space: nowrap;
}
.progress-chip strong { color: var(--brand); }

.reset-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}
.reset-btn:hover { border-color: var(--hard); color: var(--hard); }

.group-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 30px 0 10px;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
}

.group-heading .sub {
  color: var(--text-faint);
  font-weight: 500;
  font-size: 0.85rem;
}

.problem-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.problem-table th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.problem-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.93rem;
}

.problem-table tr:last-child td { border-bottom: none; }
.problem-table tbody tr:hover { background: rgba(255,255,255,0.02); }

.problem-table tr.solved td.title { color: var(--text-faint); text-decoration: line-through; text-decoration-color: var(--text-faint); }

.chk {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
  cursor: pointer;
}

.title-cell a {
  font-weight: 500;
}
.title-cell a:hover { color: var(--brand); }

.diff {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  display: inline-block;
}
.diff.Easy { color: var(--easy); background: rgba(55,226,163,0.12); }
.diff.Medium { color: var(--medium); background: rgba(255,180,84,0.12); }
.diff.Hard { color: var(--hard); background: rgba(255,107,107,0.12); }

.yt-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}
.yt-link:hover {
  color: #fff;
  background: #ff0033;
  border-color: #ff0033;
}

.lc-link {
  color: var(--text-dim);
  font-size: 0.85rem;
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 7px;
}
.lc-link:hover { color: var(--blue); border-color: var(--blue); }

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

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--border);
  padding: 36px 0;
  margin-top: 60px;
  color: var(--text-faint);
  font-size: 0.85rem;
  text-align: center;
}
footer a { color: var(--text-dim); }
footer a:hover { color: var(--brand); }

/* ---------- Problem detail page ---------- */
.breadcrumb {
  color: var(--text-faint);
  font-size: 0.85rem;
  margin-bottom: 14px;
}
.breadcrumb a:hover { color: var(--brand); }

.problem-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 28px 0 24px;
  border-bottom: 1px solid var(--border);
}

.problem-head h1 {
  margin: 0 0 8px;
  font-size: 1.7rem;
  letter-spacing: -0.02em;
}

.problem-head .meta {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.pattern-tag {
  font-size: 0.8rem;
  color: var(--blue);
  background: rgba(91, 157, 255, 0.12);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
}

/* ---------- Company tags ---------- */
.company-tags-label {
  color: var(--text-faint);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
  align-self: center;
}

.company-tag {
  font-size: 0.78rem;
  color: #ffb454;
  background: rgba(255, 180, 84, 0.12);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}

.company-tag-sm {
  font-size: 0.72rem;
  color: #ffb454;
  background: rgba(255, 180, 84, 0.1);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}

.company-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.company-more {
  font-size: 0.72rem;
  color: var(--text-faint);
  align-self: center;
}

.solved-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.solved-toggle.is-solved {
  color: var(--brand);
  border-color: var(--brand-dim);
  background: var(--brand-glow);
}
.solved-toggle input { accent-color: var(--brand); width: 16px; height: 16px; }

.problem-page-layout {
  display: flex;
  align-items: flex-start;
  gap: 28px;
}
.problem-main { flex: 1; min-width: 0; }
.problem-page-layout .progress-dashboard { display: none; }

.problem-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 28px 0 60px;
  align-items: start;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.panel-tab {
  padding: 12px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-faint);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.panel-tab.active {
  color: var(--text);
  border-bottom-color: var(--brand);
}

.panel-body { padding: 20px; }
.panel-body.no-pad { padding: 0; }

.desc-block p { color: var(--text-dim); font-size: 0.94rem; line-height: 1.7; }
.desc-block h4 { margin: 22px 0 10px; font-size: 0.9rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.desc-block h4:first-of-type { margin-top: 22px; }

.example-block {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
  font-size: 0.88rem;
}
.example-block .ex-label {
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  font-size: 0.85rem;
}
.example-block code {
  font-family: "SF Mono", Menlo, Consolas, "Courier New", monospace;
  font-size: 0.85rem;
  color: var(--text);
  word-break: break-word;
}
.example-block .ex-row { margin-bottom: 4px; }
.example-block .ex-row:last-child { margin-bottom: 0; }
.example-block .ex-key { color: var(--text-faint); margin-right: 6px; }
.example-block .ex-explain { color: var(--text-dim); font-family: -apple-system, BlinkMacSystemFont, sans-serif; margin-top: 4px; }

.constraints-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.constraints-list li {
  font-family: "SF Mono", Menlo, Consolas, "Courier New", monospace;
  font-size: 0.82rem;
  color: var(--text-dim);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 6px;
  display: inline-block;
  margin-right: 6px;
}

.lc-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 14px 16px;
  margin-top: 18px;
}
.lc-callout p { margin: 0; font-size: 0.85rem; }

.video-source-row {
  display: flex;
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.video-source-btn {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-dim);
  cursor: pointer;
}
.video-source-btn:hover { color: var(--text); border-color: var(--text-faint); }
.video-source-btn.active {
  color: var(--brand);
  border-color: var(--brand-dim);
  background: var(--brand-glow);
}

.video-wrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #000;
}
.video-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.editor-toolbar .select { padding: 7px 10px; font-size: 0.85rem; }

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

.editor-actions button, .editor-actions a {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.editor-actions button:hover, .editor-actions a:hover { border-color: var(--text-faint); color: var(--text); }
.editor-actions button:disabled { opacity: 0.5; cursor: wait; }
.editor-actions button:disabled:hover { border-color: var(--border); color: var(--text-dim); }
.editor-actions .primary { border-color: var(--brand-dim); color: var(--brand); }
.editor-actions .primary:hover { background: var(--brand-glow); }

.save-indicator {
  font-size: 0.78rem;
  color: var(--text-faint);
  padding: 0 14px 10px;
}

#code-editor {
  width: 100%;
  min-height: 420px;
  background: var(--bg);
  color: var(--text);
  border: none;
  padding: 16px;
  font-family: "SF Mono", Menlo, Consolas, "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
  tab-size: 4;
}
#code-editor:focus { outline: none; }
.CodeMirror {
  height: 420px !important;
  font-family: "SF Mono", Menlo, Consolas, "Courier New", monospace;
  font-size: 0.88rem;
}

.testcase-panel {
  border-top: 1px solid var(--border);
}
.testcase-panel .panel-tabs { border-bottom: 1px solid var(--border); }
.testcase-panel .panel-body { padding: 16px 20px; max-height: 320px; overflow: auto; font-size: 0.88rem; }

.case-pills { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.case-pill {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-dim);
  cursor: pointer;
}
.case-pill.active { border-color: var(--brand-dim); color: var(--brand); background: var(--brand-glow); }
.case-pill.fail { border-color: var(--hard); }
.case-pill.pass-badge::after { content: " ✓"; }

.tc-param-label { color: var(--text-faint); font-size: 0.78rem; margin: 10px 0 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.tc-param-label:first-child { margin-top: 0; }
.tc-value {
  font-family: "SF Mono", Menlo, Consolas, "Courier New", monospace;
  font-size: 0.85rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}

.ops-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.ops-table th { text-align: left; color: var(--text-faint); font-weight: 600; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.ops-table td { padding: 4px 8px; font-family: "SF Mono", Menlo, Consolas, monospace; border-bottom: 1px solid var(--border); }

.verdict-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
}
.verdict-banner.pass { color: var(--easy); background: rgba(55,226,163,0.12); }
.verdict-banner.fail { color: var(--hard); background: rgba(255,107,107,0.12); }
.verdict-banner.info { color: var(--text-dim); background: var(--bg-elevated); }

.result-case { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
.result-case.pass { border-color: rgba(55,226,163,0.35); }
.result-case.fail { border-color: rgba(255,107,107,0.35); }
.result-case .rc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 700; font-size: 0.85rem; }
.result-case .rc-head .status { font-size: 0.78rem; padding: 2px 8px; border-radius: 999px; }
.result-case.pass .rc-head .status { color: var(--easy); background: rgba(55,226,163,0.15); }
.result-case.fail .rc-head .status { color: var(--hard); background: rgba(255,107,107,0.15); }

.submission-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.submission-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.verdict-pill { font-size: 0.78rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.verdict-pill.pass { color: var(--easy); background: rgba(55,226,163,0.15); }
.verdict-pill.fail { color: var(--hard); background: rgba(255,107,107,0.15); }
.verdict-pill.info { color: var(--text-dim); background: var(--bg-elevated); }
.submission-meta { font-size: 0.85rem; color: var(--text-dim); }
.submission-restore {
  font-size: 0.8rem;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.submission-restore:hover { border-color: var(--text-faint); color: var(--text); }

.result-stdout {
  margin-top: 12px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  white-space: pre-wrap;
  color: var(--text-dim);
  max-height: 160px;
  overflow: auto;
}
.result-error {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  color: var(--hard);
  background: rgba(255,107,107,0.08);
  border: 1px solid rgba(255,107,107,0.3);
  border-radius: 6px;
  padding: 10px 12px;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
}
.result-placeholder { color: var(--text-faint); font-size: 0.88rem; }

.prev-next {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
}
.prev-next a {
  flex: 1;
  max-width: 300px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.85rem;
}
.prev-next a:hover { border-color: var(--brand-dim); }
.prev-next .dir { color: var(--text-faint); display: block; margin-bottom: 4px; }
.prev-next .next-wrap { text-align: right; margin-left: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .feature-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .problems-layout { flex-direction: column; }
  .problem-page-layout { flex-direction: column; }
  .progress-dashboard {
    position: static;
    flex: 1 1 auto;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .progress-dashboard .pd-card { flex: 1 1 220px; }
}

@media (max-width: 720px) {
  .nav-links { display: none; }
  .nav-toggle { display: block; }
  .nav.open .nav-links {
    display: flex;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    flex-direction: column;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    gap: 16px;
  }
  .problem-table thead { display: none; }
  .problem-table, .problem-table tbody, .problem-table tr, .problem-table td {
    display: block;
    width: 100%;
  }
  .problem-table tr {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
  }
  .problem-table td {
    border: none;
    padding: 4px 0;
  }
  .flow-roadmap::before { left: 23px; }
  .flow-tier { gap: 14px; }
  .flow-tier-marker { width: 48px; height: 48px; font-size: 0.95rem; }
  .flow-node { flex-basis: 100%; max-width: none; }
  .problem-layout { grid-template-columns: 1fr; }
  .prev-next { flex-direction: column; }
  .prev-next .next-wrap { text-align: left; margin-left: 0; }
}

/* ---------- Auth ---------- */
#auth-slot { display: flex; align-items: center; }

.auth-signin-btn { padding: 8px 16px; font-size: 0.85rem; }

.auth-user-wrap { position: relative; }
.auth-user {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px 5px 5px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}
.auth-user:hover { border-color: var(--brand-dim); }
.auth-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand);
  color: #04140d;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  overflow: hidden;
  flex: none;
}
.auth-avatar img { width: 100%; height: 100%; object-fit: cover; }

.auth-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  min-width: 130px;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.auth-dropdown button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.auth-dropdown button:hover { background: var(--bg-card); color: var(--text); }

.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 11, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.auth-overlay[hidden] { display: none; }

.auth-modal {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 28px 24px;
  max-width: 360px;
  width: 100%;
}
.auth-modal h3 { margin: 0 0 6px; font-size: 1.2rem; }
.auth-sub { color: var(--text-dim); font-size: 0.88rem; margin: 0 0 20px; }

.auth-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.auth-close:hover { color: var(--text); }

.auth-google-btn {
  width: 100%;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  margin-bottom: 18px;
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.78rem;
  margin: 0 0 16px;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-divider span { padding: 0 10px; }

.auth-error {
  background: rgba(255,107,107,0.1);
  border: 1px solid rgba(255,107,107,0.3);
  color: var(--hard);
  font-size: 0.82rem;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 14px;
}

.auth-actions { display: flex; gap: 10px; }

.auth-footnote {
  color: var(--text-faint);
  font-size: 0.76rem;
  text-align: center;
  margin: 16px 0 0;
}

/* ---------- Login gate ---------- */
.auth-checking {
  padding: 120px 0;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.9rem;
}
.auth-gate-block {
  padding: 90px 0 110px;
}
.gate-card {
  max-width: 440px;
  margin: 0 auto;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px 36px;
}
.gate-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--brand-glow);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.gate-card h2 { font-size: 1.35rem; margin: 0 0 10px; }
.gate-card p { color: var(--text-dim); font-size: 0.92rem; margin: 0 0 24px; }

/* The imported Dracula CodeMirror theme colors builtins (set, len, range…) the same
   green as variables. It loads after this stylesheet, so match its selector's
   specificity plus one class to win the cascade instead of load order. */
.CodeMirror.cm-s-dracula span.cm-builtin { color: #ffb86c; }
