:root {
  --bg: #0f1320;
  --bg-soft: #161b2e;
  --card: #1b2236;
  --card-hover: #222b44;
  --border: #2a3350;
  --text: #e8ecf6;
  --text-dim: #9aa6c4;
  --accent: #5b8cff;
  --accent-soft: #2a3a66;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #1c2546 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

code, pre, .mono {
  font-family: "JetBrains Mono", "Fira Code", Consolas, Menlo, monospace;
}

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

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
  background: rgba(15, 19, 32, 0.85);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  white-space: nowrap;
}
.brand .logo {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  font-size: 1rem;
}
.brand small { color: var(--text-dim); font-weight: 500; font-size: .72rem; }

.header-search {
  flex: 1;
  position: relative;
}
.header-search input {
  width: 100%;
  padding: 11px 14px 11px 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: .95rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.header-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.header-search .search-icon {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.donate-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: linear-gradient(135deg, #ffdd55, #ffb300);
  color: #3a2a00;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 999px;
  white-space: nowrap;
  transition: transform .12s, box-shadow .12s;
  box-shadow: 0 4px 14px rgba(255, 179, 0, 0.3);
}
.donate-btn:hover { transform: translateY(-1px); text-decoration: none; box-shadow: 0 6px 18px rgba(255, 179, 0, 0.45); }

/* ---------- Layout ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 30px 0 10px;
}
.hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin: 0 0 10px;
  line-height: 1.25;
}
.hero h1 .grad {
  background: linear-gradient(135deg, #5b8cff, #b06bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p { color: var(--text-dim); max-width: 620px; margin: 0 auto; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 26px 0 10px;
}
.tab {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: .92rem;
  font-weight: 600;
  transition: all .15s;
}
.tab:hover { color: var(--text); border-color: var(--accent); }
.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ---------- Filter chips ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
  margin: 14px 0 6px;
}
.chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  padding: 5px 13px;
  border-radius: 999px;
  cursor: pointer;
  font-size: .82rem;
  transition: all .15s;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }

.result-count {
  text-align: center;
  color: var(--text-dim);
  font-size: .85rem;
  margin: 10px 0 4px;
}

/* ---------- Cards ---------- */
.grid { display: grid; gap: 16px; margin-top: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: #3a4a72; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.card-head h3 { margin: 0; font-size: 1.08rem; }
.badge {
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #bcd0ff;
  white-space: nowrap;
}
.badge.eda { background: #1f3a2e; color: #6ee7b7; }
.badge.전처리 { background: #3a2f1f; color: #fcd34d; }
.badge.시각화 { background: #3a1f33; color: #f9a8d4; }
.badge.머신러닝 { background: #1f2f3a; color: #7dd3fc; }
.badge.딥러닝 { background: #2f1f3a; color: #c4b5fd; }

.card-desc { color: var(--text-dim); font-size: .92rem; margin: 4px 0 12px; }

.problem-box {
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: .93rem;
}
.problem-box b { color: var(--accent); }

pre {
  background: #0b0f1c;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: .86rem;
  margin: 0;
  position: relative;
}
pre code { color: #d6deef; white-space: pre; }

.output-box {
  margin-top: 10px;
  background: #0b0f1c;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: .82rem;
  color: var(--green);
  white-space: pre-wrap;
}
.output-label { color: var(--text-dim); font-size: .72rem; margin-bottom: 4px; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag {
  font-size: .72rem;
  color: var(--text-dim);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 6px;
}

/* ---------- Collapsible (해설/정답) ---------- */
.toggle-btn {
  margin-top: 12px;
  background: var(--accent-soft);
  color: #cfe0ff;
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  transition: background .15s;
}
.toggle-btn:hover { background: #33457a; }
.reveal {
  margin-top: 10px;
  display: none;
  animation: fade .2s ease;
}
.reveal.open { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(-4px);} to {opacity:1; transform:none;} }

.copy-btn {
  position: absolute;
  top: 8px; right: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: .72rem;
  padding: 3px 9px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
}
pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--text); }

/* ---------- Quiz ---------- */
.quiz-options { display: grid; gap: 8px; margin: 10px 0; }
.quiz-option {
  text-align: left;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 9px;
  cursor: pointer;
  font-size: .92rem;
  transition: all .12s;
}
.quiz-option:hover { border-color: var(--accent); }
.quiz-option.correct { border-color: var(--green); background: #15301f; color: #9ef0c4; }
.quiz-option.wrong { border-color: var(--red); background: #311616; color: #f6b0b0; }
.quiz-option .mono { font-size: .85rem; }

.quiz-code-answer {
  background: #0b0f1c;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .86rem;
  color: var(--green);
  margin-top: 8px;
}

.feedback { font-size: .88rem; margin-top: 8px; }
.feedback.ok { color: var(--green); }
.feedback.no { color: var(--red); }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 50px 20px;
}
.empty .big { font-size: 2.5rem; margin-bottom: 8px; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 30px 20px;
  color: var(--text-dim);
  font-size: .85rem;
}
.site-footer .donate-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: var(--yellow);
}

mark {
  background: var(--yellow);
  color: #000;
  padding: 0 2px;
  border-radius: 3px;
}

/* ---------- Responsive ---------- */
@media (max-width: 680px) {
  .header-inner { flex-wrap: wrap; }
  .header-search { order: 3; flex-basis: 100%; }
  .brand small { display: none; }
  .donate-btn span.label { display: none; }
}
