/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #242736;
  --border:    #2e3245;
  --text:      #e2e4ed;
  --text-dim:  #8b8fa7;
  --accent:    #4285f4;
  --accent-bg: rgba(66,133,244,.12);
  --green:     #34a853;
  --green-bg:  rgba(52,168,83,.12);
  --red:       #ea4335;
  --red-bg:    rgba(234,67,53,.12);
  --yellow:    #fbbc04;
  --yellow-bg: rgba(251,188,4,.12);
  --radius:    10px;
  --sidebar-w: 270px;
  --font:      'Inter', system-ui, -apple-system, sans-serif;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 28px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 0 24px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.sidebar-brand h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -.02em;
}

.sidebar-brand p {
  font-size: .75rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.sidebar nav { flex: 1; padding: 0 12px; }

.nav-section {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
  padding: 16px 12px 6px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: all .15s;
}

.sidebar nav a:hover {
  background: var(--surface2);
  color: var(--text);
}

.sidebar nav a.active {
  background: var(--accent-bg);
  color: var(--accent);
}

.sidebar nav a .icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  font-size: .75rem;
  color: var(--text-dim);
}

.scoreboard {
  display: none;
  background: var(--green-bg);
  color: var(--green);
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 600;
}

/* ── Main Content ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 48px 56px 80px;
  max-width: 920px;
}

.page-header {
  margin-bottom: 40px;
}

.page-header .badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 12px;
}

.badge-blue   { background: var(--accent-bg); color: var(--accent); }
.badge-green  { background: var(--green-bg);  color: var(--green);  }
.badge-yellow { background: var(--yellow-bg); color: #d49e00;       }
.badge-red    { background: var(--red-bg);    color: var(--red);    }

.page-header h2 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.2;
}

.page-header p {
  color: var(--text-dim);
  margin-top: 8px;
  font-size: .95rem;
}

/* ── Cards / Grid ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin: 24px 0 40px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color .2s, transform .15s;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card .card-icon {
  font-size: 1.6rem;
  margin-bottom: 12px;
}

.card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.card p {
  font-size: .85rem;
  color: var(--text-dim);
  line-height: 1.6;
}

.card a {
  display: inline-block;
  margin-top: 14px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.card a:hover { text-decoration: underline; }

/* ── Section Content ── */
section { margin-bottom: 48px; }

section h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

section h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 20px 0 8px;
  color: var(--accent);
}

section p, section li {
  font-size: .9rem;
  color: var(--text-dim);
  line-height: 1.75;
}

section ul, section ol {
  padding-left: 20px;
  margin: 8px 0 16px;
}

section li { margin-bottom: 6px; }

.key-concepts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.concept-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: .85rem;
  font-weight: 500;
}

.concept-chip .label {
  display: block;
  font-size: .7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}

code, .code {
  font-family: 'JetBrains Mono', monospace;
  font-size: .82rem;
  background: var(--surface2);
  padding: 2px 7px;
  border-radius: 4px;
}

pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow-x: auto;
  margin: 12px 0 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: .8rem;
  line-height: 1.7;
  color: var(--text-dim);
}

.tip-box {
  background: var(--accent-bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 16px 20px;
  margin: 16px 0;
  font-size: .85rem;
}

.tip-box strong { color: var(--accent); }

.warn-box {
  background: var(--yellow-bg);
  border-left: 3px solid var(--yellow);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 16px 20px;
  margin: 16px 0;
  font-size: .85rem;
}

.warn-box strong { color: #d49e00; }

/* ── Quiz ── */
.quiz-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin: 32px 0;
}

.quiz-section h3 {
  border: none;
  padding: 0;
  margin-bottom: 24px;
  font-size: 1.1rem;
}

.question {
  margin-bottom: 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.question:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.question .q-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
  margin-bottom: 8px;
}

.question .q-text {
  font-size: .92rem;
  font-weight: 500;
  line-height: 1.7;
  margin-bottom: 16px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
  font-size: .85rem;
  line-height: 1.6;
}

.option:hover { border-color: var(--accent); background: var(--accent-bg); }

.option .letter {
  flex-shrink: 0;
  width: 26px; height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface2);
  font-size: .75rem;
  font-weight: 600;
  margin-top: 1px;
}

.option.selected { border-color: var(--accent); background: var(--accent-bg); }
.option.selected .letter { background: var(--accent); color: #fff; }

.option.correct  { border-color: var(--green); background: var(--green-bg); }
.option.correct  .letter { background: var(--green); color: #fff; }

.option.wrong    { border-color: var(--red); background: var(--red-bg); }
.option.wrong    .letter { background: var(--red); color: #fff; }

.option.disabled { pointer-events: none; opacity: .6; }
.option.correct.disabled, .option.wrong.disabled { opacity: 1; }

.explanation {
  display: none;
  margin-top: 16px;
  padding: 16px 20px;
  background: var(--green-bg);
  border-radius: 8px;
  font-size: .85rem;
  line-height: 1.7;
  color: var(--text);
}

.explanation.visible { display: block; }
.explanation strong { color: var(--green); }

/* ── Progress bar (homepage) ── */
.progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.progress-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.progress-item .title {
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.progress-bar {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width .4s ease;
}

.progress-item .pct {
  font-size: .7rem;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ── Responsive ── */
@media (max-width: 860px) {
  .sidebar { width: 220px; }
  :root { --sidebar-w: 220px; }
  .main { padding: 32px 28px 60px; }
}

@media (max-width: 640px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s;
  }
  .sidebar.open { transform: translateX(0); }
  :root { --sidebar-w: 0px; }
  .main { padding: 24px 20px 60px; }
  .mobile-toggle {
    display: flex !important;
  }
}

.mobile-toggle {
  display: none;
  position: fixed;
  top: 16px; left: 16px;
  z-index: 200;
  width: 40px; height: 40px;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}

/* ── Jump menu (study page section nav) ── */
.jump-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 28px;
  font-size: .82rem;
}
.jump-menu .jump-label {
  color: var(--text-dim);
  font-weight: 600;
  margin-right: 2px;
  flex-shrink: 0;
}
.jump-menu a {
  color: var(--accent);
  text-decoration: none;
  padding: 3px 11px;
  border-radius: 20px;
  background: var(--accent-bg);
  font-weight: 500;
  transition: background .15s;
  white-space: nowrap;
}
.jump-menu a:hover { background: rgba(66,133,244,.25); }
.jump-menu a.jump-practice {
  background: var(--green-bg);
  color: var(--green);
}
.jump-menu a.jump-practice:hover { background: rgba(52,168,83,.25); }

/* ── Study link (quiz → study page) ── */
.study-link-row { margin-top: 14px; }
.study-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid rgba(66,133,244,.2);
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  transition: all .15s;
}
.study-link-btn:hover { background: rgba(66,133,244,.22); }

/* ═══════════════════════════════════════════════════════════════════
   Preview tiers — free/paid gate UI.
   Shared by labs-index.html, lab.html and quiz-app.html so the "you've
   hit the wall" moment looks the same everywhere. Tiers are defined in
   access.js; the enforcement lives in firestore.rules.
   ═══════════════════════════════════════════════════════════════════ */

/* Flag on a lab card: FREE PREVIEW vs PRO */
.card-flag {
  display: inline-block;
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 20px;
  margin-top: 6px;
}
.card-flag.flag-free { background: var(--green-bg); color: var(--green); }
.card-flag.flag-pro  { background: var(--surface2); color: var(--text-dim); }

.lab-card.is-locked .lab-num {
  background: var(--surface2);
  color: var(--text-dim);
}

/* The panel a visitor sees instead of a Pro lab's steps. */
.gate-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  text-align: center;
}
.gate-panel .gate-lock {
  font-size: 2.2rem;
  margin-bottom: 14px;
  line-height: 1;
}
.gate-panel h3 {
  font-size: 1.15rem;
  margin-bottom: 10px;
  border: none;
  padding: 0;
}
.gate-panel .gate-body {
  font-size: .88rem;
  color: var(--text-dim);
  line-height: 1.75;
  max-width: 560px;
  margin: 0 auto 22px;
}
.gate-panel .gate-meta {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.gate-panel .gate-meta span {
  font-size: .7rem;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 20px;
  background: var(--surface2);
  color: var(--text-dim);
}
.gate-cta {
  display: inline-block;
  padding: 13px 30px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.gate-cta:hover { background: #3a7be0; }
.gate-secondary {
  display: block;
  margin-top: 14px;
  font-size: .78rem;
  color: var(--text-dim);
}
.gate-secondary a { color: var(--accent); }

/* Sold-out-of-preview state inside the quiz. */
.preview-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--accent-bg);
  border: 1px solid rgba(66,133,244,.2);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 24px;
  font-size: .82rem;
  font-weight: 600;
}
.preview-banner .pb-spacer { margin-left: auto; }
.preview-banner a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.preview-banner a:hover { text-decoration: underline; }

.gate-inline {
  background: var(--surface);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  padding: 28px 32px;
  text-align: center;
  margin-top: 24px;
}
.gate-inline h4 { font-size: 1rem; margin-bottom: 8px; }
.gate-inline p {
  font-size: .85rem;
  color: var(--text-dim);
  line-height: 1.7;
  max-width: 520px;
  margin: 0 auto 18px;
}

