/* =========================================================================
   방사선생물학 학습 사이트 — 공유 디자인 시스템
   Korea University KHES301 Radiation Biology (Lectures 9–15)
   ========================================================================= */

:root {
  /* Palette — 의학/방사선 테마: teal primary + amber accent */
  --brand: #0e7c86;
  --brand-dark: #0a5d65;
  --brand-light: #15a0ac;
  --brand-50: #e8f6f7;
  --brand-100: #cdebed;
  --amber: #d97706;
  --amber-50: #fdf3e7;

  --ink: #142328;
  --ink-soft: #36474d;
  --muted: #6a7a80;
  --line: #e3eaeb;
  --line-strong: #cdd8d9;
  --bg: #ffffff;
  --bg-soft: #f5f9f9;
  --bg-sunken: #eaf1f1;

  --ok: #1f9d57;
  --ok-bg: #e6f6ed;
  --warn: #c2410c;
  --warn-bg: #fdf0e7;
  --bad: #c02929;
  --bad-bg: #fbeaea;
  --info: #1f6feb;
  --info-bg: #e7f0fd;

  /* 난이도 색 */
  --lv1: #1f9d57;   /* 입문 green */
  --lv1-bg: #e6f6ed;
  --lv2: #c98a04;   /* 중급 amber */
  --lv2-bg: #fbf2d9;
  --lv3: #b3357a;   /* 전문 magenta */
  --lv3-bg: #fbe9f3;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16,32,36,.06), 0 1px 3px rgba(16,32,36,.08);
  --shadow: 0 4px 16px rgba(16,32,36,.08), 0 2px 6px rgba(16,32,36,.05);
  --shadow-lg: 0 18px 48px rgba(16,32,36,.16);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
          "Noto Sans KR", "Malgun Gothic", Roboto, sans-serif;

  --maxw: 1080px;
}

[data-theme="dark"] {
  --ink: #e4ebec;
  --ink-soft: #c0cccd;
  --muted: #93a3a5;
  --line: #25333650;
  --line: #283538;
  --line-strong: #3a484b;
  --bg: #0d1416;
  --bg-soft: #131d1f;
  --bg-sunken: #1a2629;
  --brand: #3ec6d2;
  --brand-light: #5ed8e2;
  --brand-dark: #2aa7b3;
  --brand-50: #112a2d;
  --brand-100: #16363a;
  --amber: #f0a23c;
  --ok-bg: #102a1c;
  --warn-bg: #2a1a0f;
  --bad-bg: #2a1414;
  --info-bg: #0f1f33;
  --lv1-bg: #102a1c;
  --lv2-bg: #2a2410;
  --lv3-bg: #2a1422;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 6px 20px rgba(0,0,0,.45);
  --shadow-lg: 0 18px 48px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 78px; }
body {
  margin: 0; font-family: var(--sans); color: var(--ink); background: var(--bg);
  line-height: 1.7; -webkit-font-smoothing: antialiased; letter-spacing: -0.01em;
}

/* ---------- Top navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: var(--maxw); margin: 0 auto; padding: 11px 20px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; color: var(--ink); text-decoration: none; font-size: 1.02rem; white-space: nowrap; }
.brand .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); }
.topnav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; align-items: center; }
.topnav a { color: var(--ink-soft); text-decoration: none; font-size: .86rem; font-weight: 600; padding: 6px 10px; border-radius: 8px; }
.topnav a:hover { background: var(--bg-sunken); color: var(--brand); }
.topnav a.active { color: var(--brand); background: var(--brand-50); }
.theme-toggle { border: 1px solid var(--line-strong); background: var(--bg-soft); color: var(--ink-soft); width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; }
.theme-toggle:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- Layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
main.wrap { padding-bottom: 96px; }
section[id] { scroll-margin-top: 80px; padding-top: 26px; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background: radial-gradient(1100px 380px at 78% -12%, var(--brand-50), transparent 60%), linear-gradient(180deg, var(--bg-soft), var(--bg));
  border-bottom: 1px solid var(--line);
}
.hero-inner { max-width: var(--maxw); margin: 0 auto; padding: 54px 20px 44px; }
.eyebrow { display: inline-flex; align-items: center; gap: 7px; font-size: .8rem; font-weight: 700; color: var(--brand); background: var(--brand-50); border: 1px solid var(--brand-100); padding: 5px 12px; border-radius: 999px; letter-spacing: .02em; }
.hero h1 { font-size: clamp(1.9rem, 4.4vw, 3rem); line-height: 1.18; margin: 18px 0 10px; font-weight: 850; }
.hero h1 .accent { color: var(--brand); }
.hero p.lead { font-size: 1.08rem; color: var(--ink-soft); max-width: 64ch; margin: 0; }

/* ---------- Headings ---------- */
h2.sec-title { font-size: clamp(1.4rem, 2.6vw, 1.85rem); font-weight: 820; margin: 8px 0 4px; display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
h2.sec-title .num { font-size: .78rem; font-weight: 800; color: var(--brand); background: var(--brand-50); border: 1px solid var(--brand-100); border-radius: 8px; padding: 3px 9px; font-variant-numeric: tabular-nums; }
.sec-sub { color: var(--muted); margin: 2px 0 20px; font-size: 1rem; }
h3.sub { font-size: 1.18rem; font-weight: 750; margin: 30px 0 12px; }
h4.sub { font-size: 1.02rem; font-weight: 720; margin: 22px 0 8px; color: var(--ink); }

/* ---------- Cards ---------- */
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); }
.card.soft { background: var(--bg-soft); }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 820px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

/* Chapter/lecture cards on home */
.chapter-card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); transition: transform .14s, box-shadow .14s, border-color .14s; position: relative; overflow: hidden; }
.chapter-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand); opacity: .85; }
.chapter-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--brand-light); }
.chapter-card .ch-emoji { font-size: 1.7rem; }
.chapter-card .ch-tag { font-size: .76rem; font-weight: 800; color: var(--brand); letter-spacing: .04em; }
.chapter-card h3 { margin: 2px 0 4px; font-size: 1.15rem; font-weight: 780; }
.chapter-card p { margin: 0; color: var(--muted); font-size: .92rem; }
.chapter-card .ch-topics { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Chips / tags / badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; font-weight: 650; padding: 3px 9px; border-radius: 999px; background: var(--bg-sunken); color: var(--ink-soft); border: 1px solid var(--line); }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 800; padding: 2px 8px; border-radius: 6px; letter-spacing: .02em; }
.badge.core { color: var(--bad); background: var(--bad-bg); }
.badge.supp { color: var(--info); background: var(--info-bg); }
/* 난이도 배지 */
.badge.lv1 { color: var(--lv1); background: var(--lv1-bg); }
.badge.lv2 { color: var(--lv2); background: var(--lv2-bg); }
.badge.lv3 { color: var(--lv3); background: var(--lv3-bg); }
.lv-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.lv-dot.lv1 { background: var(--lv1); } .lv-dot.lv2 { background: var(--lv2); } .lv-dot.lv3 { background: var(--lv3); }

/* ---------- Callouts ---------- */
.callout { border-radius: var(--radius-sm); padding: 14px 16px; margin: 16px 0; border: 1px solid var(--line); border-left-width: 4px; background: var(--bg-soft); font-size: .95rem; }
.callout .co-title { font-weight: 800; display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.callout p:last-child { margin-bottom: 0; }
.callout.exam { border-left-color: var(--bad); background: var(--bad-bg); }
.callout.exam .co-title { color: var(--bad); }
.callout.info { border-left-color: var(--info); background: var(--info-bg); }
.callout.info .co-title { color: var(--info); }
.callout.tip { border-left-color: var(--ok); background: var(--ok-bg); }
.callout.tip .co-title { color: var(--ok); }
.callout.warn { border-left-color: var(--warn); background: var(--warn-bg); }
.callout.warn .co-title { color: var(--warn); }
.callout.supp { border-left-color: var(--info); background: var(--info-bg); }
.callout.supp .co-title { color: var(--info); }
/* 4단 학습 구조 박스 */
.steps4 { display: grid; gap: 0; margin: 16px 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.steps4 > div { padding: 11px 15px; border-top: 1px solid var(--line); }
.steps4 > div:first-child { border-top: none; }
.steps4 .s-lab { font-size: .72rem; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; margin-bottom: 2px; }
.steps4 .s1 { background: var(--lv1-bg); } .steps4 .s1 .s-lab { color: var(--lv1); }
.steps4 .s2 { background: var(--bg-soft); } .steps4 .s2 .s-lab { color: var(--brand); }
.steps4 .s3 { background: var(--info-bg); } .steps4 .s3 .s-lab { color: var(--info); }
.steps4 .s4 { background: var(--warn-bg); } .steps4 .s4 .s-lab { color: var(--warn); }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table.data { border-collapse: collapse; width: 100%; font-size: .92rem; }
table.data th, table.data td { padding: 9px 13px; text-align: left; border-bottom: 1px solid var(--line); }
table.data thead th { background: var(--bg-sunken); font-weight: 750; color: var(--ink); white-space: nowrap; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--brand-50); }
table.data td.c, table.data th.c { text-align: center; }
table.data .yes { color: var(--ok); font-weight: 750; }
table.data .no { color: var(--bad); font-weight: 750; }

/* ---------- Matrix ---------- */
.matrix { border-collapse: separate; border-spacing: 4px; font-size: .9rem; margin: 8px 0; }
.matrix th, .matrix td { width: 56px; height: 44px; text-align: center; border-radius: 8px; font-weight: 700; }
.matrix th { background: var(--bg-sunken); color: var(--ink-soft); }
.matrix td { cursor: pointer; transition: transform .1s; user-select: none; }
.matrix td.t { background: var(--ok-bg); color: var(--ok); }
.matrix td.f { background: var(--bad-bg); color: var(--bad); }
.matrix td:hover { transform: scale(1.08); outline: 2px solid var(--brand); }
.matrix td.hot { outline: 3px solid var(--brand); transform: scale(1.08); }

/* ---------- Code / formula ---------- */
pre, code { font-family: var(--mono); }
code.inline { background: var(--bg-sunken); padding: 1px 6px; border-radius: 5px; font-size: .88em; color: var(--brand-dark); }
pre.code { background: #0d1117; color: #e6edf3; border-radius: var(--radius-sm); padding: 15px 17px; overflow-x: auto; font-size: .86rem; line-height: 1.6; border: 1px solid #1f2630; margin: 14px 0; }
pre.code .cm { color: #8b949e; } pre.code .kw { color: #ff7b72; } pre.code .st { color: #a5d6ff; } pre.code .fn { color: #d2a8ff; }
.formula { background: var(--bg-soft); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius-sm); padding: 13px 17px; margin: 14px 0; font-family: var(--mono); font-size: .98rem; overflow-x: auto; color: var(--ink); }
.formula .hl { color: var(--brand); font-weight: 700; }

/* ---------- Simulator shell ---------- */
.sim { border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; margin: 20px 0; box-shadow: var(--shadow-sm); background: var(--bg); }
.sim-head { display: flex; align-items: center; gap: 9px; padding: 12px 16px; background: linear-gradient(180deg, var(--bg-sunken), var(--bg-soft)); border-bottom: 1px solid var(--line); font-weight: 750; font-size: .95rem; }
.sim-head .tag-int { margin-left: auto; font-size: .68rem; font-weight: 800; letter-spacing: .04em; color: #fff; background: var(--brand); padding: 3px 8px; border-radius: 6px; }
.sim-body { padding: 18px 16px; }
.sim-stage { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; min-height: 80px; }
.sim-controls { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin: 14px 0 4px; }
.sim-note { font-size: .85rem; color: var(--muted); margin-top: 10px; min-height: 1.2em; }
.sim-readout { font-family: var(--mono); font-size: .88rem; background: var(--bg-sunken); border-radius: var(--radius-sm); padding: 10px 13px; margin-top: 12px; white-space: pre-wrap; border: 1px solid var(--line); color: var(--ink-soft); }

/* ---------- Buttons & inputs ---------- */
.btn { font-family: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink); padding: 8px 15px; border-radius: 9px; transition: all .12s; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-50); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-dark); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.sm { padding: 5px 11px; font-size: .82rem; }
.btn.ghost { background: transparent; }
.field { display: inline-flex; flex-direction: column; gap: 3px; font-size: .8rem; color: var(--muted); }
.field label { font-weight: 650; }
.field input[type="number"], .field input[type="text"], .field select { font-family: var(--mono); font-size: .9rem; padding: 6px 9px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink); width: 120px; }
.field input:focus, .field select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
input[type="range"] { accent-color: var(--brand); }
.kpi { display: flex; gap: 14px; flex-wrap: wrap; }
.kpi .k { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; min-width: 110px; }
.kpi .k .lbl { font-size: .74rem; color: var(--muted); font-weight: 650; }
.kpi .k .val { font-size: 1.4rem; font-weight: 820; font-family: var(--mono); color: var(--brand); font-variant-numeric: tabular-nums; }

/* ---------- List / def helpers ---------- */
ul.clean, ol.clean { padding-left: 1.25em; margin: 10px 0; }
ul.clean li, ol.clean li { margin: 6px 0; }
.def { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 12px 0; }
.def dt { font-weight: 750; color: var(--brand); }
.def dd { margin: 0; color: var(--ink-soft); }
@media (max-width: 640px) { .def { grid-template-columns: 1fr; gap: 2px 0; } .def dd { margin-bottom: 8px; } }

/* dots / progress */
.dots { display: inline-flex; gap: 6px; }
.dots .d { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.dots .d.on { background: var(--brand); }

/* footer & pager */
.page-foot { border-top: 1px solid var(--line); margin-top: 56px; padding: 28px 0; color: var(--muted); font-size: .88rem; }
.page-foot a { color: var(--brand); }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; flex-wrap: wrap; }
.pager a { text-decoration: none; color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 16px; flex: 1; min-width: 220px; background: var(--bg-soft); }
.pager a:hover { border-color: var(--brand); }
.pager .dir { font-size: .76rem; color: var(--muted); font-weight: 700; }
.pager .ttl { font-weight: 750; color: var(--brand); }
.pager a.next { text-align: right; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 8px; }

/* svg helpers */
svg .lbl { font-family: var(--sans); font-size: 12px; fill: var(--ink); }
svg .lbl-mono { font-family: var(--mono); font-size: 12px; fill: var(--ink); }
.svg-box { width: 100%; height: auto; overflow: visible; }

/* misc */
.hr { border: none; border-top: 1px solid var(--line); margin: 30px 0; }
.center { text-align: center; } .muted { color: var(--muted); } .nowrap { white-space: nowrap; }
.fade-in { animation: fadeIn .4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.pulse { animation: pulse .6s ease; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
