/* ─── Design Tokens ────────────────────────────────────── */
:root {
  --bg: #f8f9fb;
  --bg-raised: #ffffff;
  --bg-inset: #f1f3f7;
  --bg-hover: #eef0f4;
  --text-primary: #111318;
  --text-secondary: #5c6070;
  --text-tertiary: #8b8fa3;
  --border: #e2e4ea;
  --border-light: #eeeff3;
  --focus-ring: rgba(67, 97, 238, 0.25);
  --accent: #4361ee;
  --accent-hover: #3751d4;
  --accent-soft: rgba(67, 97, 238, 0.08);
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.08);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --warning-soft: rgba(234, 179, 8, 0.08);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --transition: 150ms ease;
}

/* ─── Reset & Base ─────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg);
}

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

a:hover {
  color: var(--accent-hover);
}

::selection {
  background: var(--accent);
  color: #fff;
}

/* ─── Layout ───────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.container-full {
  width: 100%;
  padding: 0 1.25rem;
}

/* ─── Sidebar Layout ──────────────────────────────────── */
body.has-sidebar {
  display: flex;
  flex-direction: column;
}

body.has-sidebar .nav-wrapper {
  width: 100%;
}

.sidebar {
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 0;
  width: 220px;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 90;
  transition: transform 200ms ease, width 200ms ease;
}

.sidebar-nav {
  padding: 1rem 0;
}

.sidebar-section {
  padding: 0 0 0.5rem;
}

.sidebar-section+.sidebar-section {
  border-top: 1px solid var(--border-light);
  padding-top: 0.5rem;
}

.sidebar-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: 0.35rem 1.25rem 0.25rem;
}

.sidebar-link {
  display: block;
  font-size: 0.8375rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.375rem 1.25rem;
  transition: color var(--transition), background var(--transition);
}

.sidebar-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.sidebar-link.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.sidebar-toggle {
  appearance: none;
  border: none;
  background: none;
  padding: 0.4rem;
  cursor: pointer;
  color: var(--text-tertiary);
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: color var(--transition);
}

.sidebar-toggle:hover {
  color: var(--text-primary);
}

.sidebar-toggle span {
  display: block;
  width: 16px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

.main-content {
  margin-left: 220px;
  padding: 0 1.5rem;
  max-width: 1100px;
}

body.has-sidebar.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
}

body.has-sidebar.sidebar-collapsed .main-content {
  margin-left: 0;
}

.page-content {
  padding: 1.5rem 0 3rem;
  animation: fadeUp 300ms ease both;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Navigation ───────────────────────────────────────── */
.nav-wrapper {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(248, 249, 251, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 56px;
  margin-bottom: 0;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.375rem 0.65rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.nav-links a:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-user {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  padding: 0.375rem 0.65rem;
}

.nav-user strong {
  color: var(--text-secondary);
  font-weight: 600;
}

.nav-toggle {
  display: none;
  appearance: none;
  border: none;
  background: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

.nav-toggle span+span {
  margin-top: 4px;
}

/* ─── Cards ────────────────────────────────────────────── */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition);
}

.card:hover {
  box-shadow: var(--shadow);
}

.card-flat {
  background: var(--bg-raised);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}

/* ─── Hero ─────────────────────────────────────────────── */
.hero {
  position: relative;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  top: -60%;
  right: -20%;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(67, 97, 238, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.hero .chip {
  margin-bottom: 0.75rem;
}

.hero h1 {
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
  margin-bottom: 0.6rem;
  color: var(--text-primary);
}

.hero p.meta {
  max-width: 520px;
  font-size: 0.9375rem;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

/* ─── Typography ───────────────────────────────────────── */
h1,
h2,
h3,
h4 {
  margin-top: 0;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

h3 {
  font-size: 1.05rem;
  margin-bottom: 0.4rem;
}

h4 {
  font-size: 0.95rem;
  margin-bottom: 0.3rem;
}

p {
  margin: 0.4rem 0;
}

.meta {
  color: var(--text-tertiary);
  font-size: 0.8125rem;
}

/* ─── Feature Grid ─────────────────────────────────────── */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.feature-grid .card {
  margin-bottom: 0;
}

.feature-grid .card h3 {
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.feature-grid .card .meta {
  font-size: 0.8125rem;
  line-height: 1.5;
}

/* ─── Chips / Badges ───────────────────────────────────── */
.chip {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: none;
  margin: 0 0.25rem 0.3rem 0;
  letter-spacing: 0.01em;
}

.chip-success {
  color: var(--success);
  background: var(--success-soft);
}

.chip-danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.chip-warning {
  color: #b45309;
  background: var(--warning-soft);
}

/* ─── Buttons ──────────────────────────────────────────── */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 0.95rem;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  background: var(--accent);
  transition: background var(--transition), box-shadow var(--transition), transform 100ms ease;
}

.btn:hover {
  background: var(--accent-hover);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: scale(0.98);
}

.btn.secondary {
  background: var(--bg-raised);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

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

.btn.danger {
  background: var(--danger);
  color: #fff;
}

.btn.danger:hover {
  background: #b91c1c;
}

/* ─── Forms ────────────────────────────────────────────── */
label {
  display: block;
  font-weight: 600;
  font-size: 0.8125rem;
  margin-bottom: 0.3rem;
  color: var(--text-secondary);
}

input,
textarea,
select {
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.55rem 0.75rem;
  font-family: var(--font);
  font-size: 0.875rem;
  line-height: 1.5;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

textarea.code,
pre {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.65;
}

textarea.code {
  min-height: 220px;
  background: #0f1117;
  color: #e2e8f0;
  border-color: #2a2f3a;
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

textarea.code:focus {
  border-color: #4361ee;
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

pre {
  overflow-x: auto;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  background: #0f1117;
  color: #e2e8f0;
  border: 1px solid #2a2f3a;
  margin: 0.5rem 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

/* ─── Flash Messages ───────────────────────────────────── */
.flash {
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideDown 250ms ease both;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.flash.success {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.flash.error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

/* ─── Entry Header / Actions ───────────────────────────── */
.entry-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

/* ─── Markdown Block ───────────────────────────────────── */
.markdown-block {
  background: var(--bg-inset);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.markdown-block p {
  margin: 0.35rem 0;
}

.markdown-block h1,
.markdown-block h2,
.markdown-block h3 {
  margin-top: 1rem;
}

.markdown-block ul,
.markdown-block ol {
  padding-left: 1.25rem;
}

/* ─── Details / Accordion ──────────────────────────────── */
details {
  margin: 0.75rem 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-raised);
  overflow: hidden;
}

details>summary {
  cursor: pointer;
  user-select: none;
  padding: 0.65rem 0.85rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: background var(--transition);
}

details>summary:hover {
  background: var(--bg-hover);
}

details[open]>summary {
  border-bottom: 1px solid var(--border-light);
}

details> :not(summary) {
  padding: 0 0.85rem;
}

details>div,
details>ul {
  padding: 0.75rem 0.85rem;
}

/* ─── Feed Cards ───────────────────────────────────────── */
.feed-card {
  border-color: var(--border-light);
  background: var(--bg-raised);
}

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

/* ─── Heatmap ──────────────────────────────────────────── */
.heatmap {
  display: grid;
  grid-template-columns: repeat(53, 1fr);
  gap: 2px;
}

.heat {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--bg-inset);
  transition: transform 100ms ease;
}

.heat:hover {
  transform: scale(1.6);
  z-index: 1;
}

.heat.lvl0 {
  background: var(--bg-inset);
}

.heat.lvl1 {
  background: #bbf7d0;
}

.heat.lvl2 {
  background: #86efac;
}

.heat.lvl3 {
  background: #4ade80;
}

.heat.lvl4 {
  background: #16a34a;
}

/* ─── Stat Cards ───────────────────────────────────────── */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--border);
  transition: box-shadow var(--transition), transform 100ms ease;
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.stat-card:nth-child(1) {
  border-left-color: var(--accent);
}

.stat-card:nth-child(2) {
  border-left-color: #f59e0b;
}

.stat-card:nth-child(3) {
  border-left-color: var(--success);
}

.stat-card:nth-child(4) {
  border-left-color: #8b5cf6;
}

.stat-card:nth-child(5) {
  border-left-color: #ec4899;
}

.stat-card:nth-child(6) {
  border-left-color: #06b6d4;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

/* ─── Progress Bar ─────────────────────────────────────── */
.progress-track {
  width: 100%;
  height: 8px;
  background: var(--bg-inset);
  border-radius: 99px;
  overflow: hidden;
  margin: 0.4rem 0 0.25rem;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 600ms ease;
}

.progress-fill.success {
  background: var(--success);
}

/* ─── Bar Chart (CSS) ──────────────────────────────────── */
.bar-chart {
  margin: 0.5rem 0;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}

.bar-label {
  width: 90px;
  flex-shrink: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
}

.bar-track {
  flex: 1;
  height: 22px;
  background: var(--bg-inset);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 500ms ease;
  min-width: 2px;
}

.bar-count {
  width: 36px;
  flex-shrink: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-tertiary);
}

/* ─── Timeline ─────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 1.5rem;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 1px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 1rem;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -1.5rem;
  top: 0.5rem;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--bg);
  transform: translateX(0.5px);
}

.timeline-item:first-child::before {
  background: var(--accent);
}

/* ─── Status Badges ────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.status-to_learn {
  color: var(--accent);
  background: var(--accent-soft);
}

.status-in_progress {
  color: #b45309;
  background: var(--warning-soft);
}

.status-done {
  color: var(--success);
  background: var(--success-soft);
}

/* ─── QA Check Row ─────────────────────────────────────── */
.check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-light);
}

.check-row:last-child {
  border-bottom: none;
}

.check-pass {
  color: var(--success);
  font-weight: 700;
  font-size: 0.8125rem;
}

.check-fail {
  color: var(--danger);
  font-weight: 700;
  font-size: 0.8125rem;
}

/* ─── Auth Layout (Login / Register) ───────────────────── */
.auth-wrap {
  max-width: 400px;
  margin: 2rem auto;
}

.auth-wrap .card {
  box-shadow: var(--shadow-md);
}

.auth-wrap h1 {
  text-align: center;
  margin-bottom: 1.25rem;
}

.auth-footer {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

/* ─── Grid Layout ──────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(280px, 2fr);
  gap: 1rem;
}

/* ─── Footer ───────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 1.5rem 0 1.25rem;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border-light);
  margin-top: 1rem;
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.footer-links a {
  color: var(--text-tertiary);
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition);
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-brand {
  margin-top: 0.25rem;
}

/* ─── Inline Checkbox Fix ──────────────────────────────── */
input[type="checkbox"] {
  width: auto;
  margin-bottom: 0;
  margin-right: 0.35rem;
  vertical-align: middle;
}

/* ─── Table (if needed) ────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th,
td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Utilities ────────────────────────────────────────── */
.text-center {
  text-align: center;
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mb-0 {
  margin-bottom: 0;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

/* ─── Responsive ───────────────────────────────────────── */
@media (max-width: 980px) {
  .feature-grid {
    grid-template-columns: 1fr;
  }

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

  .sidebar {
    width: 180px;
  }

  .main-content {
    margin-left: 180px;
  }
}

@media (max-width: 760px) {
  .page-content {
    padding: 1rem 0 2rem;
  }

  .nav {
    height: auto;
    flex-wrap: wrap;
    padding: 0.65rem 0;
  }

  .nav-toggle {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-light);
    margin-top: 0.5rem;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    width: 100%;
    padding: 0.5rem 0.65rem;
  }

  .entry-header {
    flex-direction: column;
  }

  .hero {
    padding: 2rem 1.25rem;
  }

  .hero h1 {
    font-size: 1.35rem;
  }

  .stat-row {
    grid-template-columns: repeat(2, 1fr);
  }

  /* collapse sidebar on mobile */
  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 0 1rem;
  }

  .sidebar-toggle {
    display: none;
  }
}

/* ─── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ─── List Cleanup ─────────────────────────────────────── */
ul,
ol {
  padding-left: 1.25rem;
}

li {
  margin-bottom: 0.3rem;
}

/* ──── bg-noise kept for compat (hidden) ───────────────── */
.bg-noise {
  display: none;
}

/* ─── Empty State ──────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--text-tertiary);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
  display: block;
}

.empty-state p {
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}

.empty-state .btn {
  margin-top: 0.25rem;
}

/* ─── Admin Section Nav ────────────────────────────────── */
.admin-quicknav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.admin-quicknav a {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-inset);
  border-radius: 999px;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.admin-quicknav a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ─── Sidebar User Section ─────────────────────────────── */
.sidebar-user {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-light);
  background: var(--bg-raised);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sidebar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-link {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  text-decoration: none;
}

.sidebar-user-link:hover {
  color: var(--danger);
}

.sidebar-nav {
  padding: 1rem 0 4rem;
}

/* ─── Breadcrumb ───────────────────────────────────────── */
.breadcrumb-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0;
  font-size: 0.8rem;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 1rem;
}

.breadcrumb-bar a {
  color: var(--text-tertiary);
  text-decoration: none;
}

.breadcrumb-bar a:hover {
  color: var(--accent);
}

.breadcrumb-bar .breadcrumb-sep {
  font-size: 0.7rem;
  opacity: 0.5;
}

.breadcrumb-bar .breadcrumb-current {
  color: var(--text-primary);
  font-weight: 600;
}

/* ─── Community Filters ────────────────────────────────── */
.community-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.community-filters-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ─── Landing Full Width Fix ───────────────────────────── */
body.has-sidebar .landing-full-width {
  margin-left: -220px;
  padding-left: calc(220px + 1.5rem);
  max-width: none;
}

/* ─── Settings Page ────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 768px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.settings-avatar-card {
  text-align: center;
}

.settings-avatar-area {
  display: flex;
  justify-content: center;
}

.settings-avatar-img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
}

.settings-avatar-placeholder {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.settings-danger {
  border-color: var(--danger);
  border-left: 3px solid var(--danger);
}

.input-disabled {
  background: var(--bg-inset);
  color: var(--text-tertiary);
  cursor: not-allowed;
}

/* ─── Sidebar Avatar Image ─────────────────────────────── */
.sidebar-avatar-img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.sidebar-user-link:hover {
  color: var(--accent);
}

/* ─── Google OAuth Button ──────────────────────────────── */
.google-btn {
  background: #fff !important;
  color: #3c4043 !important;
  border: 1px solid #dadce0 !important;
  font-weight: 500;
  display: flex;
  align-items: center;
  transition: box-shadow var(--transition), background var(--transition);
}

.google-btn:hover {
  background: #f7f8f8 !important;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.15);
}

/* ─── Auth Divider ─────────────────────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  margin: 1rem 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-divider span {
  padding: 0 0.75rem;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  font-weight: 600;
}

/* ─── Code Compiler ────────────────────────────────────── */
.compiler-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  height: calc(100vh - 140px);
  min-height: 500px;
}

.compiler-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.75rem;
}

.compiler-header h1 {
  margin: 0;
}

.compiler-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.compiler-controls select {
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-primary);
  font-size: 0.85rem;
}

.compiler-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  flex: 1;
  min-height: 0;
}

@media (max-width: 768px) {
  .compiler-body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 200px;
  }
}

.compiler-editor {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  min-height: 300px;
}

.compiler-output {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-inset);
  overflow: hidden;
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  font-size: 0.85rem;
}

.output-content {
  flex: 1;
  padding: 0.75rem;
  margin: 0;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.82rem;
  overflow: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text-secondary);
}

.output-success {
  color: var(--success);
}

.output-error {
  color: var(--danger);
}

.output-warning {
  color: var(--amber-accent, #f59e0b);
}

#run-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* ─── Badge Cards ──────────────────────────────────────── */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem;
}

.badge-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-raised);
  transition: all var(--transition);
}

.badge-earned {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.06), rgba(139, 92, 246, 0.06));
}

.badge-earned .badge-icon {
  filter: none;
}

.badge-locked {
  opacity: 0.45;
  filter: grayscale(0.6);
}

.badge-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}

.badge-info {
  min-width: 0;
}

.badge-title {
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.2;
}

.badge-desc {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  line-height: 1.3;
}

/* ─── Markdown Editor ──────────────────────────────────── */
.md-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-raised);
}

.md-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-inset);
}

.md-tab {
  padding: 0.45rem 1rem;
  border: none;
  background: none;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}

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

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

.md-panes {
  display: flex;
  min-height: 200px;
}

@media (max-width: 768px) {
  .md-panes {
    flex-direction: column;
  }
}

.md-panes textarea {
  flex: 1;
  border: none;
  border-radius: 0;
  resize: vertical;
  min-height: 200px;
  padding: 0.75rem;
  margin: 0;
}

.md-preview {
  flex: 1;
  padding: 0.75rem;
  border-left: 1px solid var(--border-light);
  overflow: auto;
  font-size: 0.875rem;
  line-height: 1.7;
  display: none;
}

@media (max-width: 768px) {
  .md-preview {
    border-left: none;
    border-top: 1px solid var(--border-light);
  }
}

.md-preview h1 {
  font-size: 1.4rem;
  margin: 0.5rem 0;
}

.md-preview h2 {
  font-size: 1.2rem;
  margin: 0.4rem 0;
}

.md-preview h3 {
  font-size: 1rem;
  margin: 0.3rem 0;
}

.md-preview code {
  background: var(--bg-inset);
  padding: 0.15em 0.35em;
  border-radius: 3px;
  font-size: 0.85em;
}

.md-preview pre {
  background: var(--bg-inset);
  padding: 0.75rem;
  border-radius: var(--radius);
  overflow-x: auto;
}

.md-preview pre code {
  padding: 0;
  background: none;
}

.md-preview ul,
.md-preview ol {
  padding-left: 1.5rem;
}

.md-preview blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 0.75rem;
  margin-left: 0;
  color: var(--text-secondary);
}

.md-preview a {
  color: var(--accent);
}

.md-preview img {
  max-width: 100%;
  border-radius: var(--radius);
}

/* ─── Inline Code Runner (Entry Form) ─────────────────── */
.code-runner-section {
  margin-top: 0.25rem;
}

.entry-output-wrap {
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-inset);
  overflow: hidden;
}

.entry-output-box {
  max-height: 200px;
  font-size: 0.8rem;
}

/* ─── Markdown Toolbar ────────────────────────────────── */
.md-toolbar {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-inset);
  padding: 0 0.5rem;
  align-items: center;
}

.md-toolbar-btns {
  display: flex;
  gap: 0.25rem;
  padding: 0.4rem 0;
  overflow-x: auto;
}

.md-tool-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  border-radius: var(--radius);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  transition: all var(--transition);
}

.md-tool-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.md-tool-sep {
  width: 1px;
  background: var(--border-light);
  margin: 0 0.25rem;
  height: 20px;
}

.md-toolbar .md-tabs {
  border-bottom: none;
  background: none;
}

.md-toolbar .md-tab {
  border-bottom: none;
  padding: 0.4rem 0.75rem;
}


/* ─── Video Call Interface ────────────────────────────────── */
.video-header {
  padding: 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.video-grid {
  flex: 1;
  background: var(--bg-body);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  padding: 1rem;
  overflow-y: auto;
}

.video-card {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  aspect-ratio: 16/9;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.video-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-card .video-label {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.video-controls {
  padding: 1rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.ctrl-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
}

.ctrl-btn:hover {
  transform: scale(1.1);
}

.ctrl-btn.off {
  background: var(--error);
}

/* Whiteboard Overlay */
.whiteboard-container {
  position: absolute;
  top: 60px;
  /* Below header */
  left: 0;
  right: 0;
  bottom: 80px;
  /* Above controls */
  background: rgba(255, 255, 255, 0.95);
  z-index: 100;
  border: 4px solid var(--primary);
}

.wb-toolbar {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  padding: 0.5rem;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  gap: 0.5rem;
  align-items: center;
  border: 1px solid var(--border-light);
}

.wb-toolbar button {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #fff;
  cursor: pointer;
  box-shadow: 0 0 0 1px #ddd;
}

.wb-toolbar button.wb-btn-text {
  width: auto;
  height: auto;
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  background: var(--bg-hover);
  border: none;
  box-shadow: none;
}

/* ─── Video Call Enhancements ────────────────────────────── */
.video-lobby {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-body);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lobby-preview {
  width: 100%;
  max-width: 500px;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius);
  margin-bottom: 2rem;
  overflow: hidden;
  position: relative;
}

.lobby-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lobby-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}

.participant-list {
  position: absolute;
  top: 60px;
  right: 0;
  bottom: 80px;
  width: 250px;
  background: var(--bg-card);
  border-left: 1px solid var(--border-light);
  z-index: 50;
  padding: 1rem;
  transform: translateX(100%);
  transition: transform 0.3s;
  overflow-y: auto;
}

.participant-list.active {
  transform: translateX(0);
}

.p-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border-light);
}

.rejoin-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
}