/* EF Study atlas — 2026-2 공용 스타일
   색: 차가운 슬라이드 유리 바탕 + 과목별 염색약 색 (세포=hematoxylin, 미생물=safranin, 생화=Coomassie, 유기=iodine)
   다크: 암시야(dark-field) 현미경 */

@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css");

:root {
  --bg: #EDF1F2;
  --surface: #F8FAFA;
  --surface-2: #E3E9EB;
  --ink: #14222A;
  --ink-2: #485A64;
  --ink-3: #7A8C95;
  --line: #CFD9DD;
  --focus: #1E6FD9;

  --cell: #5A3D9A;
  --micro: #B4304C;
  --bio: #2346A8;
  --org: #9A600A;
  --subj: var(--ink);

  --ok: #1D7350;
  --bad: #B42318;
  --exam: #B45309;

  /* 분자 그림 팔레트 — 채움은 옅게, 선은 진하게 */
  --t-a: #A9CDEB; --t-b: #F3CF8A; --t-c: #EFA9B5; --t-d: #C3B1E8;
  --t-e: #A9DCC0; --t-f: #EBC09D; --t-g: #D7D3C9; --t-h: #9FB7DA;
  --dna-1: #2F5E99; --dna-2: #2E8197; --rna: #C2410C; --protein: #6D4AA8;
  --phos: #D99A00; --mem: #E4D3A6;
  --stage: #FBFCFC;
  --mask: #C9D3D8;

  --r-s: 6px; --r-m: 10px; --r-l: 16px;
  --shadow: 0 1px 0 rgba(20, 34, 42, .04), 0 6px 22px -14px rgba(20, 34, 42, .35);
  --font: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0C1A20; --surface: #122429; --surface-2: #183036; --ink: #E2ECEF; --ink-2: #A3B8C0; --ink-3: #6F878F; --line: #23393F; --focus: #6FB1FF;
    --cell: #B39AF0; --micro: #F27A95; --bio: #86A3F7; --org: #E8AE4E;
    --ok: #57C99A; --bad: #FF8A80; --exam: #F5B04C;
    --t-a: #2C5577; --t-b: #6E5420; --t-c: #6E3340; --t-d: #4A3B78; --t-e: #275840; --t-f: #6A4A2E; --t-g: #4A4F55; --t-h: #2E4670;
    --dna-1: #7FB0EA; --dna-2: #6FD0DE; --rna: #FF9A62; --protein: #BCA2F5; --phos: #FFC94A; --mem: #6A5B35;
    --stage: #0F2126; --mask: #2E464D;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 30px -18px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0C1A20; --surface: #122429; --surface-2: #183036; --ink: #E2ECEF; --ink-2: #A3B8C0; --ink-3: #6F878F; --line: #23393F; --focus: #6FB1FF;
  --cell: #B39AF0; --micro: #F27A95; --bio: #86A3F7; --org: #E8AE4E;
  --ok: #57C99A; --bad: #FF8A80; --exam: #F5B04C;
  --t-a: #2C5577; --t-b: #6E5420; --t-c: #6E3340; --t-d: #4A3B78; --t-e: #275840; --t-f: #6A4A2E; --t-g: #4A4F55; --t-h: #2E4670;
  --dna-1: #7FB0EA; --dna-2: #6FD0DE; --rna: #FF9A62; --protein: #BCA2F5; --phos: #FFC94A; --mem: #6A5B35;
  --stage: #0F2126; --mask: #2E464D;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 30px -18px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

[data-subject="cell"] { --subj: var(--cell); }
[data-subject="micro"] { --subj: var(--micro); }
[data-subject="bio"] { --subj: var(--bio); }
[data-subject="org"] { --subj: var(--org); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.6 var(--font); letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased; word-break: keep-all; overflow-wrap: anywhere;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* 상단 바 */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top .home { font-weight: 800; text-decoration: none; letter-spacing: -0.03em; }
.top .crumb { color: var(--ink-2); text-decoration: none; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .crumb::before { content: "/"; margin-right: 10px; color: var(--ink-3); }
.top .grow { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 10px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; cursor: pointer; font-size: 14px;
}
.icon-btn:hover { border-color: var(--subj); }
.icon-btn[aria-pressed="true"] { background: var(--subj); border-color: var(--subj); color: var(--surface); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* 칩 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; min-height: 28px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: 13px; color: var(--ink-2); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"], .chip.on { background: var(--subj); color: var(--surface); border-color: var(--subj); }
.chip.exam { border-color: var(--exam); color: var(--exam); }

/* ───────── 과정 애니메이션 뷰어 ───────── */
.viewer { display: grid; grid-template-rows: auto 1fr auto; min-height: calc(100dvh - 61px); }
.v-head { padding: 18px 16px 8px; max-width: 1240px; margin: 0 auto; width: 100%; }
.v-head h1 { margin: 0; font-size: clamp(22px, 4.6vw, 34px); line-height: 1.2; font-weight: 800; letter-spacing: -0.035em; }
.v-head .sub { margin: 6px 0 0; color: var(--ink-2); font-size: 15px; }
.v-head .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; align-items: center; }
.v-head .meta .src { font-size: 13px; color: var(--ink-3); }

.v-body {
  display: grid; gap: 16px; padding: 8px 16px 16px; max-width: 1240px; width: 100%; margin: 0 auto;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 960px) {
  .v-body { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
}

.v-stage {
  position: relative; margin: 0; background: var(--stage);
  border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow);
  overflow: hidden; touch-action: pan-y;
}
@media (min-width: 960px) { .v-stage { position: sticky; top: 76px; } }
.v-stage svg { display: block; width: 100%; height: auto; max-height: 72dvh; }
.v-stage .tag {
  position: absolute; left: 12px; top: 10px; font-size: 13px; font-weight: 700; color: var(--subj);
  background: color-mix(in srgb, var(--stage) 85%, transparent); padding: 2px 8px; border-radius: 999px;
}
.v-stage .hint { position: absolute; right: 12px; bottom: 8px; font-size: 12px; color: var(--ink-3); }
.viewer:not(.full) .v-stage { display: flex; flex-direction: column; }
.viewer:not(.full) .v-stage .tag { position: static; order: -1; align-self: flex-start; margin: 8px 10px 0; }
.viewer:not(.full) .v-stage .hint { position: static; align-self: flex-end; margin: 0 12px 6px; }

.v-panel { display: grid; gap: 12px; }
.v-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 16px 18px;
  box-shadow: var(--shadow);
}
.v-card .n { font-size: 13px; color: var(--subj); font-weight: 700; }
.v-card h2 { margin: 2px 0 8px; font-size: 21px; line-height: 1.3; letter-spacing: -0.025em; font-weight: 750; }
.v-card .body { font-size: 16px; line-height: 1.7; }
.v-card .body p { margin: 0 0 8px; }
.v-card .body ul { margin: 4px 0 8px; padding-left: 20px; }
.v-card .body b { font-weight: 700; }
.v-card .body .key { background: color-mix(in srgb, var(--subj) 14%, transparent); padding: 0 3px; border-radius: 4px; }
.memo .v-card .body .key { color: transparent; background: var(--mask); cursor: pointer; user-select: none; }
.memo .v-card .body .key.peek { color: inherit; background: color-mix(in srgb, var(--subj) 14%, transparent); }

.quote {
  margin: 12px 0 0; padding: 10px 12px; border-left: 3px solid var(--subj);
  background: color-mix(in srgb, var(--subj) 7%, var(--surface)); border-radius: 0 var(--r-m) var(--r-m) 0; font-size: 15px;
}
.quote .who { display: block; font-size: 12.5px; color: var(--ink-3); margin-bottom: 2px; }
.quote.exam { border-left-color: var(--exam); }
.quote.exam .who { color: var(--exam); font-weight: 700; }
.refs { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.refs span { font-size: 12.5px; color: var(--ink-3); border: 1px dashed var(--line); padding: 1px 8px; border-radius: 999px; }
.caution { margin-top: 10px; font-size: 14px; color: var(--ink-2); padding: 8px 10px; border-radius: var(--r-m); background: var(--surface-2); }

.v-steps { list-style: none; margin: 0; padding: 0; counter-reset: s; border-top: 1px solid var(--line); }
.v-steps li { border-bottom: 1px solid var(--line); }
.v-steps button {
  width: 100%; text-align: left; display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: baseline;
  padding: 9px 4px; background: none; border: 0; cursor: pointer; font-size: 15px; color: var(--ink-2);
}
.v-steps button .i { font-variant-numeric: tabular-nums; color: var(--ink-3); font-weight: 700; }
.v-steps button .x { font-size: 12px; color: var(--exam); font-weight: 700; }
.v-steps li.cur button { color: var(--ink); font-weight: 700; }
.v-steps li.cur button .i { color: var(--subj); }
.v-steps li.done button .i { color: var(--subj); opacity: .6; }
details.v-list summary { cursor: pointer; font-size: 14px; color: var(--ink-2); padding: 4px 2px; }

.v-ctrl {
  position: sticky; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: auto auto auto 1fr auto; gap: 8px; align-items: center;
  padding: 10px 16px calc(10px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.v-ctrl .big {
  height: 48px; min-width: 48px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font-size: 18px; display: grid; place-items: center;
}
.v-ctrl .big.primary { background: var(--subj); border-color: var(--subj); color: var(--surface); min-width: 64px; }
.v-ctrl .count { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--ink-2); padding: 0 4px; white-space: nowrap; }
.v-prog { display: flex; gap: 4px; align-items: center; min-width: 0; }
.v-prog button { flex: 1; height: 8px; min-width: 6px; border: 0; border-radius: 4px; background: var(--line); cursor: pointer; padding: 0; }
.v-prog button.done { background: color-mix(in srgb, var(--subj) 45%, var(--line)); }
.v-prog button.cur { background: var(--subj); }

/* SVG 요소 */
.atlas svg text { font-family: var(--font); fill: var(--ink); }
.atlas [data-k] { transition: opacity .55s ease, transform .75s cubic-bezier(.2, .75, .2, 1), filter .4s; transform-box: fill-box; transform-origin: center; }
.atlas [data-k].instant { transition: none !important; }
.atlas .dim { opacity: .34 !important; }
.atlas .new { filter: drop-shadow(0 0 5px color-mix(in srgb, var(--subj) 70%, transparent)); }
.atlas .lit { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--subj) 70%, transparent)); }
.atlas .tone-a { --tone: var(--t-a); } .atlas .tone-b { --tone: var(--t-b); } .atlas .tone-c { --tone: var(--t-c); } .atlas .tone-d { --tone: var(--t-d); }
.atlas .tone-e { --tone: var(--t-e); } .atlas .tone-f { --tone: var(--t-f); } .atlas .tone-g { --tone: var(--t-g); } .atlas .tone-h { --tone: var(--t-h); }
.atlas .shape { fill: var(--tone, var(--t-g)); stroke: color-mix(in oklab, var(--tone, var(--t-g)) 55%, var(--ink)); stroke-width: 2; }
.atlas .line { fill: none; stroke: var(--ink-2); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.atlas .dna1 { stroke: var(--dna-1); } .atlas .dna2 { stroke: var(--dna-2); }
.atlas .rung { stroke: color-mix(in oklab, var(--dna-1) 45%, var(--stage)); stroke-width: 2; }
.atlas .rna { fill: none; stroke: var(--rna); stroke-width: 4; stroke-linecap: round; }
.atlas .prot { stroke: var(--protein); }
.atlas .arrow { fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; }
.atlas .arrow.subj { stroke: var(--subj); }
.atlas .arrowhead { fill: var(--ink); } .atlas .arrowhead.subj { fill: var(--subj); }
.atlas .phos circle { fill: var(--phos); stroke: color-mix(in oklab, var(--phos) 60%, var(--ink)); stroke-width: 1.5; }
.atlas .phos text { fill: #1B1300; font-weight: 800; }
.atlas .lbl text { font-weight: 650; }
.atlas .lbl .bg { fill: transparent; }
.atlas .lbl.sub text { font-weight: 500; fill: var(--ink-2); }
.atlas .lbl.subj text { fill: var(--subj); font-weight: 800; }
.atlas .note text { fill: var(--ink-2); font-weight: 500; }
.atlas .region { stroke: color-mix(in oklab, var(--tone) 50%, var(--ink)); stroke-width: 1.5; fill: var(--tone); }
.atlas .bond { stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; fill: none; }
.atlas .atom text { font-weight: 700; }
.atlas .atom .halo { fill: var(--stage); }
/* 빛번짐이 원자 글자 뒤 halo 모양까지 따라가 흰 박스처럼 보이지 않게 (결합선은 글자 앞에서 이미 잘려 있음) */
.atlas .new .atom .halo, .atlas .lit .atom .halo, .atlas .atom.new .halo, .atlas .atom.lit .halo { fill: transparent; }
.atlas .curly { fill: none; stroke: var(--subj); stroke-width: 2.6; stroke-linecap: round; }
.atlas .lp { fill: var(--ink); }
.atlas .charge { font-weight: 800; }

.memo .lbl.maskable text { opacity: 0; }
.memo .lbl.maskable .bg { fill: var(--mask); cursor: pointer; }
.memo .lbl.maskable.peek text { opacity: 1; }
.memo .lbl.maskable.peek .bg { fill: transparent; }

@media (prefers-reduced-motion: reduce) {
  .atlas [data-k] { transition: none !important; }
}

/* 목록·허브 공통 */
.section-h { font-size: 15px; font-weight: 800; color: var(--ink-2); margin: 28px 0 10px; letter-spacing: -0.01em; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.list > li { border-bottom: 1px solid var(--line); }
.list a.row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 13px 4px; text-decoration: none; }
.list a.row:hover .t { color: var(--subj); }
.list .t { font-weight: 700; font-size: 16.5px; letter-spacing: -0.02em; }
.list .d { grid-column: 1 / -1; color: var(--ink-2); font-size: 14px; }
.list .r { color: var(--ink-3); font-size: 13px; white-space: nowrap; align-self: center; }
.v-ctrl .big { font-size: 26px; line-height: 1; }
.v-ctrl .big.primary { font-size: 18px; }
.v-ctrl .big:disabled { opacity: .35; cursor: default; }
.atlas .ghost { filter: opacity(.3) !important; }
.atlas .phos.s2 circle { fill: var(--t-a); stroke: color-mix(in oklab, var(--t-a) 45%, var(--ink)); }
.atlas .phos.s2 text { fill: var(--ink); }

/* 크게 보기: 무대를 전체 화면으로. 세로 화면이면 90° 돌려 가로로 */
.v-stage .full-ctrl { display: none; }
.viewer.full .v-stage {
  position: fixed; inset: 0; z-index: 100; margin: 0; border: 0; border-radius: 0; box-shadow: none;
  display: grid; place-items: center; background: var(--stage);
}
.viewer.full .v-stage svg { width: 100%; height: 100%; max-height: none; }
@media (orientation: portrait) {
  .viewer.full .v-stage { inset: auto; top: 50%; left: 50%; width: 100dvh; height: 100dvw; transform: translate(-50%, -50%) rotate(90deg); }
}
.viewer.full .v-stage .full-ctrl {
  display: flex; gap: 8px; position: absolute; right: 12px; top: 10px;
}
.viewer.full .v-stage .full-ctrl button { height: 44px; min-width: 44px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 22px; cursor: pointer; }
.viewer.full .v-stage .hint { display: none; }
body.no-scroll { overflow: hidden; }
.atlas .wedge { fill: var(--ink); }
.atlas .atom .chg { fill: var(--stage); stroke: var(--ink); stroke-width: 1.6; }
.atlas.molsvg { display: block; width: 100%; height: auto; }
.atlas.molsvg text { font-family: var(--font); fill: var(--ink); }
.atlas .arrow.inhib { stroke-width: 4; stroke-linecap: butt; }
/* 머리 칩: 긴 문구(시험 강조 설명 등)는 줄바꿈해서 화면 폭을 넘지 않게 */
.v-head { min-width: 0; }
.v-head .meta .chip { white-space: normal; max-width: 100%; height: auto; line-height: 1.4; padding-top: 4px; padding-bottom: 4px; }
