/* ── TOKENS ── */
:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text2: #8b949e;
  --text3: #6e7681;
  --accent: #58a6ff;
  --accent2: #1f6feb;
  --green: #3fb950;
  --orange: #e3b341;
  --red: #f85149;
  --purple: #a5a0ff;
  --cyan: #39d353;
  --card-bg: #161b22;
  --card-hover: #1c2128;
  --shadow: 0 8px 32px rgba(0,0,0,.4);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 60px;
}

[data-theme="light"] {
  --bg: #f6f8fa;
  --bg2: #ffffff;
  --bg3: #f0f2f5;
  --border: #d0d7de;
  --text: #1f2328;
  --text2: #57606a;
  --text3: #8c959f;
  --accent: #0969da;
  --accent2: #0550ae;
  --card-bg: #ffffff;
  --card-hover: #f6f8fa;
  --shadow: 0 8px 32px rgba(0,0,0,.08);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background .25s, color .25s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
img { max-width: 100%; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── HEADER ── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: rgba(13,17,23,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background .25s;
}
[data-theme="light"] .site-header {
  background: rgba(246,248,250,.9);
}
.header-inner {
  max-width: 1400px; margin: 0 auto;
  height: 100%; padding: 0 20px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-icon { font-size: 22px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-weight: 700; font-size: .9rem; }
.brand-sub { font-size: .7rem; color: var(--text2); }

.nav-domains {
  display: flex; gap: 4px; flex: 1; overflow: hidden;
  flex-wrap: nowrap;
}
.nav-chip {
  padding: 4px 10px; border-radius: 99px; font-size: .75rem;
  font-weight: 500; color: var(--text2); background: transparent;
  border: 1px solid transparent; white-space: nowrap;
  transition: all .2s;
}
.nav-chip:hover { color: var(--text); background: var(--bg3); border-color: var(--border); }
.nav-chip.active { color: var(--accent); background: rgba(88,166,255,.1); border-color: rgba(88,166,255,.3); }

.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.btn-icon {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: grid; place-items: center; color: var(--text2);
  background: transparent; border: 1px solid transparent;
  transition: all .2s;
}
.btn-icon:hover { color: var(--text); background: var(--bg3); border-color: var(--border); }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }

.btn-github {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  font-size: .8rem; font-weight: 600; color: var(--text);
  background: var(--bg3); border: 1px solid var(--border);
  transition: all .2s;
}
.btn-github:hover { background: var(--accent); color: #fff; border-color: var(--accent); text-decoration: none; }
.btn-github svg { flex-shrink: 0; }

/* ── SEARCH OVERLAY ── */
.search-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.7); backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 80px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.search-overlay.open { opacity: 1; pointer-events: all; }
.search-modal {
  width: min(680px, calc(100vw - 40px));
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
  transform: translateY(-10px); transition: transform .2s;
}
.search-overlay.open .search-modal { transform: translateY(0); }
.search-input-wrap {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.search-input-wrap svg { color: var(--text3); flex-shrink: 0; }
#search-input {
  flex: 1; background: none; border: none; outline: none;
  font-family: inherit; font-size: 1rem; color: var(--text);
}
#search-input::placeholder { color: var(--text3); }
.search-esc {
  padding: 2px 7px; border-radius: 4px; font-size: .7rem;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); font-family: inherit;
}
.search-filters {
  display: flex; gap: 8px; padding: 12px 20px;
  border-bottom: 1px solid var(--border); overflow-x: auto;
}
.filter-chip {
  padding: 4px 12px; border-radius: 99px; font-size: .75rem;
  font-weight: 500; color: var(--text2);
  background: var(--bg3); border: 1px solid var(--border);
  white-space: nowrap; transition: all .2s;
}
.filter-chip:hover { color: var(--text); }
.filter-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.search-results { max-height: 420px; overflow-y: auto; }
.search-empty { padding: 40px 20px; text-align: center; color: var(--text3); font-size: .9rem; }
.search-result-item {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .15s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg3); }
.result-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.result-domain {
  font-size: .7rem; font-weight: 600; padding: 2px 8px;
  border-radius: 99px; background: rgba(88,166,255,.15); color: var(--accent);
}
.result-level { font-size: .7rem; font-weight: 700; padding: 2px 7px; border-radius: 99px; }
.lvl-L1 { background: rgba(63,185,80,.15); color: var(--green); }
.lvl-L2 { background: rgba(227,179,65,.15); color: var(--orange); }
.lvl-L3 { background: rgba(248,81,73,.15); color: var(--red); }
.result-q { font-size: .88rem; color: var(--text); font-weight: 500; line-height: 1.4; }
.result-q mark { background: rgba(88,166,255,.25); color: var(--accent); border-radius: 2px; }
.result-count { padding: 10px 20px; font-size: .75rem; color: var(--text3); border-top: 1px solid var(--border); }

/* ── HERO ── */
.hero {
  position: relative; overflow: hidden;
  padding: 100px 20px 80px;
  text-align: center;
}
.hero-bg {
  position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(88,166,255,.12) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(165,160,255,.08) 0%, transparent 60%);
}
.hero-content { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; }
.hero-badge {
  display: inline-block; margin-bottom: 20px;
  padding: 4px 14px; border-radius: 99px; font-size: .75rem; font-weight: 600;
  background: rgba(88,166,255,.12); border: 1px solid rgba(88,166,255,.25); color: var(--accent);
  letter-spacing: .5px; text-transform: uppercase;
}
.hero-title {
  font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 800;
  line-height: 1.15; letter-spacing: -.02em; margin-bottom: 20px;
}
.gradient-text {
  background: linear-gradient(135deg, #58a6ff 0%, #a5a0ff 50%, #3fb950 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.hero-desc {
  font-size: 1.05rem; color: var(--text2); max-width: 580px;
  margin: 0 auto 32px; line-height: 1.7;
}
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 48px; }
.btn-primary {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 24px; border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 600; color: #fff;
  background: var(--accent2);
  border: 1px solid var(--accent);
  transition: all .2s; box-shadow: 0 0 20px rgba(88,166,255,.2);
}
.btn-primary:hover { background: var(--accent); box-shadow: 0 0 30px rgba(88,166,255,.4); transform: translateY(-1px); }
.btn-outline {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 24px; border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 600; color: var(--text);
  background: transparent; border: 1px solid var(--border);
  transition: all .2s;
}
.btn-outline:hover { background: var(--bg3); border-color: var(--text2); text-decoration: none; }
.hero-stats {
  display: flex; justify-content: center; gap: 48px; flex-wrap: wrap;
}
.stat { display: flex; flex-direction: column; align-items: center; }
.stat-num { font-size: 1.8rem; font-weight: 800; color: var(--accent); line-height: 1; }
.stat-label { font-size: .75rem; color: var(--text3); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }

/* ── DOMAINS ── */
.domains-section { padding: 80px 20px; }
.section-inner { max-width: 1200px; margin: 0 auto; }
.section-title {
  font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 700;
  text-align: center; margin-bottom: 8px;
}
.section-sub { text-align: center; color: var(--text2); margin-bottom: 48px; }
.domain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.domain-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  cursor: pointer; transition: all .25s;
  position: relative; overflow: hidden;
}
.domain-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: var(--card-accent, var(--accent));
  transform: scaleX(0); transform-origin: left;
  transition: transform .3s;
}
.domain-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); background: var(--card-hover); border-color: var(--card-accent, var(--accent)); }
.domain-card:hover::before { transform: scaleX(1); }
.card-emoji { font-size: 2rem; margin-bottom: 12px; display: block; }
.card-title { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.card-desc { font-size: .8rem; color: var(--text2); margin-bottom: 16px; line-height: 1.5; }
.card-meta { display: flex; align-items: center; justify-content: space-between; }
.card-count {
  font-size: .75rem; font-weight: 600; padding: 3px 10px;
  border-radius: 99px; background: var(--bg3); color: var(--text2);
}
.card-arrow { color: var(--text3); transition: transform .2s; }
.domain-card:hover .card-arrow { transform: translateX(4px); color: var(--card-accent, var(--accent)); }

/* ── Q&A SECTION ── */
.qa-section { min-height: calc(100vh - var(--header-h)); }
.qa-inner {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: calc(100vh - var(--header-h));
}

/* sidebar */
.qa-sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h)); overflow-y: auto;
  background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar-header { padding: 16px; border-bottom: 1px solid var(--border); }
.back-btn {
  display: flex; align-items: center; gap: 6px;
  font-size: .82rem; color: var(--text2); font-weight: 500;
  padding: 6px 8px; border-radius: var(--radius-sm);
  margin-bottom: 12px; transition: all .2s;
}
.back-btn:hover { color: var(--text); background: var(--bg3); }
.sidebar-domain-info { display: flex; align-items: center; gap: 10px; }
.sidebar-emoji { font-size: 1.5rem; }
.sidebar-domain-name { font-weight: 700; font-size: .95rem; }
.sidebar-domain-count { font-size: .75rem; color: var(--text2); }

.sidebar-search-wrap { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.sidebar-search {
  width: 100%; padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: .82rem; outline: none;
  transition: border-color .2s;
}
.sidebar-search:focus { border-color: var(--accent); }
.sidebar-search::placeholder { color: var(--text3); }

.level-filter {
  display: flex; gap: 6px; padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.level-btn {
  flex: 1; padding: 5px; border-radius: var(--radius-sm); font-size: .75rem;
  font-weight: 600; color: var(--text2); background: var(--bg3);
  border: 1px solid var(--border); transition: all .2s;
}
.level-btn:hover { color: var(--text); }
.level-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.qa-toc { flex: 1; overflow-y: auto; padding: 8px; }
.toc-group { margin-bottom: 4px; }
.toc-group-label {
  font-size: .65rem; font-weight: 700; letter-spacing: .8px;
  text-transform: uppercase; color: var(--text3);
  padding: 8px 8px 4px;
}
.toc-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s; width: 100%;
  text-align: left;
}
.toc-item:hover { background: var(--bg3); }
.toc-item.active { background: rgba(88,166,255,.1); }
.toc-qnum { font-size: .68rem; font-weight: 700; color: var(--text3); flex-shrink: 0; padding-top: 2px; }
.toc-q { font-size: .78rem; color: var(--text2); line-height: 1.35; }
.toc-item.active .toc-q { color: var(--accent); }
.toc-lvl { font-size: .62rem; font-weight: 700; padding: 1px 5px; border-radius: 4px; flex-shrink: 0; margin-left: auto; }
.toc-item.hidden { display: none; }

/* main content */
.qa-main { padding: 40px; max-width: 880px; }
.loading-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 80px; color: var(--text2); }
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.domain-header { margin-bottom: 40px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.domain-header h1 { font-size: 1.8rem; font-weight: 800; margin-bottom: 8px; }
.domain-header p { color: var(--text2); }
.level-legend { display: flex; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--text2); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }

/* Q&A cards */
.qa-group { margin-bottom: 48px; }
.qa-group-title {
  font-size: 1rem; font-weight: 700; margin-bottom: 20px;
  color: var(--text2); display: flex; align-items: center; gap: 10px;
}
.qa-group-title::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.qa-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 16px;
  transition: border-color .2s;
  scroll-margin-top: calc(var(--header-h) + 20px);
}
.qa-card:hover { border-color: var(--text3); }
.qa-card-header {
  padding: 20px 24px; cursor: pointer;
  display: flex; align-items: flex-start; gap: 14px;
  user-select: none;
}
.qa-num {
  font-size: .7rem; font-weight: 700; color: var(--text3);
  flex-shrink: 0; padding-top: 3px; min-width: 28px;
  font-family: 'JetBrains Mono', monospace;
}
.qa-q-text { flex: 1; font-size: .95rem; font-weight: 600; line-height: 1.5; }
.qa-q-text mark { background: rgba(88,166,255,.2); color: var(--accent); border-radius: 2px; padding: 0 2px; }
.qa-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.qa-level { font-size: .68rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; }
.qa-chevron { color: var(--text3); transition: transform .25s; flex-shrink: 0; }
.qa-card.open .qa-chevron { transform: rotate(180deg); }

.qa-body {
  max-height: 0; overflow: hidden;
  transition: max-height .35s cubic-bezier(0.4,0,0.2,1);
}
.qa-card.open .qa-body { max-height: 9999px; }
.qa-body-inner { padding: 0 24px 24px 66px; border-top: 1px solid var(--border); padding-top: 20px; }

/* interviewer note */
.interviewer-note {
  font-size: .8rem; color: var(--text3); font-style: italic;
  margin-bottom: 14px; padding: 8px 12px;
  background: var(--bg3); border-radius: var(--radius-sm);
  border-left: 3px solid var(--border);
}
.answer-content { font-size: .88rem; color: var(--text2); line-height: 1.8; }
.answer-content p { margin-bottom: 12px; }
.answer-content ul, .answer-content ol { margin: 10px 0 12px 20px; }
.answer-content li { margin-bottom: 6px; }
.answer-content strong { color: var(--text); font-weight: 600; }
.answer-content code {
  font-family: 'JetBrains Mono', monospace; font-size: .82em;
  background: var(--bg3); padding: 2px 6px; border-radius: 4px;
  color: var(--cyan);
}
.answer-content pre {
  background: #010409; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px; margin: 14px 0;
  overflow-x: auto;
}
.answer-content pre code {
  background: none; padding: 0; color: #e6edf3; font-size: .82rem; line-height: 1.6;
}
[data-theme="light"] .answer-content pre { background: #f6f8fa; }
[data-theme="light"] .answer-content pre code { color: #1f2328; }

/* rapid fire */
.rapid-fire .qa-card-header { padding: 14px 24px; }
.rapid-fire .qa-q-text { font-size: .88rem; }
.rapid-fire .qa-body-inner { padding: 0 24px 14px 66px; }
.rapid-fire .answer-content { font-size: .84rem; }

/* ── FOOTER ── */
.site-footer {
  border-top: 1px solid var(--border); padding: 48px 20px;
  background: var(--bg2); text-align: center;
}
.footer-inner { max-width: 600px; margin: 0 auto; }
.footer-brand {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; font-weight: 700; font-size: 1rem; margin-bottom: 12px;
}
.footer-desc { color: var(--text2); font-size: .85rem; margin-bottom: 20px; }
.footer-links { display: flex; justify-content: center; gap: 24px; margin-bottom: 20px; }
.footer-links a { color: var(--text2); font-size: .85rem; }
.footer-links a:hover { color: var(--accent); }
.footer-copy { color: var(--text3); font-size: .78rem; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .nav-domains { display: none; }
  .qa-inner { grid-template-columns: 1fr; }
  .qa-sidebar {
    position: fixed; top: var(--header-h); left: 0; right: 0;
    z-index: 50; transform: translateX(-100%);
    height: calc(100vh - var(--header-h));
    transition: transform .3s;
  }
  .qa-sidebar.open { transform: translateX(0); }
  .qa-main { padding: 24px 16px; }
  .qa-body-inner { padding-left: 24px; }
}
@media (max-width: 600px) {
  .hero { padding: 60px 16px 48px; }
  .hero-stats { gap: 24px; }
  .domain-grid { grid-template-columns: 1fr 1fr; }
  .domain-card { padding: 16px; }
  .card-emoji { font-size: 1.5rem; }
}
