/* Preydex — design tokens
   글자: 12·13·14·16·18·20·24·32·48 / 여백: 4·8·12·16·20·24·32·40·48·64·96
   모서리: 8·12·100 / 높이: 상단 바 56, 버튼·입력 40·48 / 아이콘 20 */
:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --surface: #121821;
  --surface-2: #19212c;
  --line: #263243;
  --text: #e9eef3;
  --text-2: #b6c1cc;
  --text-3: #93a0ad;
  --accent: #7fe3a7;
  --accent-ink: #08130d;
  --warm: #ffb27a;

  --fs-12: 12px; --fs-13: 13px; --fs-14: 14px; --fs-16: 16px; --fs-18: 18px;
  --fs-20: 20px; --fs-24: 24px; --fs-32: 32px; --fs-48: 48px;
  --r-8: 8px; --r-12: 12px; --r-pill: 100px;
  --bar: 56px;
  --shadow: 0 2px 12px rgba(0, 0, 0, .12);
  --font: "Inter", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Fraunces", "Noto Serif KR", Georgia, serif;
  --wrap: 1200px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-16)/1.4 var(--font);
  letter-spacing: -0.02em;
  -webkit-font-smoothing: antialiased;
}
html[lang="ko"] body { word-break: keep-all; }
a { color: inherit; }
img, svg { display: block; }
button, input { font: inherit; letter-spacing: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
em.sci, .sci { font-style: italic; }

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 30;
  height: var(--bar);
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px;
  background: rgba(11, 15, 20, .82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.bar.over { position: fixed; left: 0; right: 0; background: linear-gradient(rgba(11,15,20,.72), rgba(11,15,20,0)); border-color: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
.bar.over.solid { background: rgba(11, 15, 20, .82); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-color: var(--line); }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; font: 600 var(--fs-20)/1 var(--font-display); letter-spacing: -0.02em; }
.logo svg { width: 24px; height: 24px; }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a, .lang {
  height: 40px; padding: 0 12px; display: inline-flex; align-items: center;
  border-radius: var(--r-8); text-decoration: none; color: var(--text-2); font-size: var(--fs-14); font-weight: 500;
  background: none; border: 0; cursor: pointer;
}
.nav a:hover, .lang:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--text); }
.lang { border: 1px solid var(--line); margin-left: 8px; gap: 4px; }
.lang b { color: var(--text); font-weight: 600; }

/* ---------- buttons, inputs ---------- */
.btn {
  height: 48px; padding: 0 20px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text); font-size: var(--fs-16); font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--text-3); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.sm { height: 40px; padding: 0 16px; font-size: var(--fs-14); }
.btn svg { width: 20px; height: 20px; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: var(--r-8); border: 1px solid var(--line); background: rgba(18,24,33,.88); color: var(--text-2); cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--text-3); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

.search { position: relative; }
.search input {
  width: 100%; height: 48px; padding: 0 16px 0 44px;
  border-radius: var(--r-pill); border: 1px solid var(--line); background: rgba(18, 24, 33, .92);
  font-size: var(--fs-16); outline: none;
}
.search input::placeholder { color: var(--text-3); }
.search input:focus { border-color: var(--accent); }
.search > svg { position: absolute; left: 16px; top: 14px; width: 20px; height: 20px; color: var(--text-3); pointer-events: none; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 40;
  list-style: none; margin: 0; padding: 8px; display: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-12); box-shadow: var(--shadow);
  max-height: 360px; overflow: auto;
}
.suggest.open { display: block; }
.suggest li { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: var(--r-8); cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--surface-2); }
.suggest .nm { font-size: var(--fs-16); }
.suggest .sub { font-size: var(--fs-14); color: var(--text-3); margin-left: auto; text-align: right; }
.suggest .empty { color: var(--text-3); cursor: default; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* ---------- type ---------- */
.eyebrow { font-size: var(--fs-14); font-weight: 600; color: var(--accent); letter-spacing: 0; text-transform: uppercase; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 500; letter-spacing: -0.02em; }
h1 { font-size: var(--fs-48); line-height: 1.2; }
h2 { font-size: var(--fs-32); line-height: 1.2; }
h3 { font-size: var(--fs-20); line-height: 1.3; font-family: var(--font); font-weight: 600; }
p { margin: 0; }
.lead { font-size: var(--fs-18); line-height: 1.4; color: var(--text-2); }
.muted { color: var(--text-2); }
.small { font-size: var(--fs-14); color: var(--text-2); }

/* ---------- home ---------- */
.hero { position: relative; height: 100svh; min-height: 640px; overflow: hidden; }
.hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; }
.hero-copy {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 0 24px 48px; pointer-events: none;
  background: linear-gradient(rgba(11,15,20,0), rgba(11,15,20,.78) 55%);
}
.hero-copy .wrap { padding: 0; display: grid; gap: 16px; max-width: var(--wrap); }
.hero-copy h1 { max-width: 760px; }
.hero-copy .lead { max-width: 560px; }
.hero-copy .row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; pointer-events: auto; margin-top: 8px; }
.hero-copy .search { width: min(440px, 100%); }
.hero-stats { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 8px; font-size: var(--fs-14); color: var(--text-2); }
.hero-stats b { color: var(--text); font-size: var(--fs-16); font-weight: 600; font-variant-numeric: tabular-nums; }
.scroll-cue { position: absolute; right: 24px; bottom: 48px; z-index: 2; font-size: var(--fs-13); color: var(--text-3); display: flex; align-items: center; gap: 8px; }
.scroll-cue i { width: 1px; height: 32px; background: linear-gradient(var(--text-3), transparent); animation: cue 2s ease-in-out infinite; }
@keyframes cue { 50% { transform: translateY(8px); opacity: .4; } }

.tip {
  position: fixed; z-index: 50; pointer-events: none; display: none;
  padding: 8px 12px; border-radius: var(--r-8); background: rgba(18,24,33,.94); border: 1px solid var(--line);
  font-size: var(--fs-14); line-height: 1.4; box-shadow: var(--shadow); max-width: 280px;
}
.tip .g { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: var(--fs-13); }

.section { padding: 96px 0; border-top: 1px solid var(--line); }
.section-head { display: grid; gap: 12px; margin-bottom: 40px; max-width: 720px; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-12); padding: 24px; display: grid; gap: 12px; align-content: start; }
.card .ic { width: 40px; height: 40px; border-radius: var(--r-8); background: var(--surface-2); display: grid; place-items: center; color: var(--accent); }
.card .ic svg { width: 20px; height: 20px; }
.card p { color: var(--text-2); }

.legend { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 24px; margin-top: 32px; }
.legend div { display: flex; align-items: center; gap: 8px; font-size: var(--fs-14); color: var(--text-2); padding: 8px 0; border-bottom: 1px solid var(--line); }
.legend span:nth-child(2) { color: var(--text); }
.legend .ct { margin-left: auto; font-variant-numeric: tabular-nums; }

.species-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.sp-card { display: grid; gap: 4px; padding: 16px 20px; border-radius: var(--r-12); background: var(--surface); border: 1px solid var(--line); text-decoration: none; }
.sp-card:hover { border-color: var(--text-3); }
.sp-card .nm { font-size: var(--fs-16); font-weight: 600; }
.sp-card .sci { font-size: var(--fs-14); color: var(--text-2); }
.sp-card .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: var(--fs-13); color: var(--text-3); margin-top: 8px; }

/* chain (좌우로 넘김 → 표시 있음) */
.chains { display: grid; gap: 16px; }
.chain-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-12); padding: 20px 24px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.chain-box h3 { font-size: var(--fs-16); }
.scroller { position: relative; }
.chain { display: flex; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 8px; scroll-snap-type: x proximity; }
.chain a, .chain span.cur {
  flex: none; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--surface-2); text-decoration: none; font-size: var(--fs-14); white-space: nowrap; scroll-snap-align: start;
}
.chain a:hover { border-color: var(--text-3); }
.chain span.cur { border-color: var(--accent); color: var(--text); font-weight: 600; }
.chain .arrow { flex: none; color: var(--text-3); width: 16px; height: 16px; }
.scroller.more::after {
  content: ""; position: absolute; right: 0; top: 0; bottom: 8px; width: 48px; pointer-events: none;
  background: linear-gradient(90deg, rgba(18,24,33,0), var(--surface));
}
.scroll-hint { display: none; align-items: center; gap: 4px; font-size: var(--fs-13); color: var(--text-3); }
.scroller.more + .scroll-hint { display: flex; }

.cta { display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap; }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line); padding: 40px 0 48px; font-size: var(--fs-14); color: var(--text-2); }
.foot .wrap { display: grid; gap: 12px; }
.foot nav { display: flex; gap: 16px; flex-wrap: wrap; }
.foot a { color: var(--text-2); }
.foot a:hover { color: var(--text); }

/* ---------- explorer ---------- */
.explore-page { height: 100svh; display: flex; flex-direction: column; overflow: hidden; }
.stage { position: relative; flex: 1; min-height: 0; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.stage canvas.dragging { cursor: grabbing; }
.stage canvas.pointing { cursor: pointer; }
.ex-top { position: absolute; left: 16px; top: 16px; right: 16px; z-index: 5; display: grid; gap: 12px; pointer-events: none; }
.ex-top > * { pointer-events: auto; }
@media (min-width: 1024px) { .ex-top { right: 412px; } }
.ex-top .search { width: min(440px, 100%); }
.chips-wrap { position: relative; max-width: 100%; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-right: 32px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 36px; padding: 0 12px; display: inline-flex; align-items: center; gap: 8px;
  border-radius: var(--r-pill); border: 1px solid var(--line); background: rgba(18,24,33,.88);
  font-size: var(--fs-14); color: var(--text-2); cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="false"] { opacity: .5; }
.chip[aria-pressed="false"] .dot { background: transparent !important; box-shadow: inset 0 0 0 1px var(--text-3); }
.chips-more { position: absolute; right: 0; top: 0; height: 36px; width: 36px; display: none; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); cursor: pointer; }
.chips-more svg { width: 16px; height: 16px; }
.chips-wrap.more .chips-more { display: grid; }
.ex-tools { position: absolute; left: 16px; bottom: 16px; z-index: 5; display: flex; gap: 8px; }
.ex-hint { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 4; font-size: var(--fs-13); color: var(--text-3); background: rgba(11,15,20,.7); padding: 8px 12px; border-radius: var(--r-pill); white-space: nowrap; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; z-index: 6; color: var(--text-2); font-size: var(--fs-14); background: var(--bg); transition: opacity .4s; }
.loading.done { opacity: 0; pointer-events: none; }
.loading .bar-p { width: 200px; height: 4px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; margin-top: 12px; }
.loading .bar-p i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.labels { position: absolute; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); white-space: nowrap; font-size: var(--fs-12); color: var(--text); padding: 4px 8px; border-radius: var(--r-8); background: rgba(11,15,20,.72); margin-top: -8px; }
.lbl.main { font-size: var(--fs-14); font-weight: 600; border: 1px solid var(--accent); }

.panel {
  position: absolute; right: 16px; top: 16px; bottom: 16px; width: 380px; z-index: 6;
  background: rgba(18, 24, 33, .96); border: 1px solid var(--line); border-radius: var(--r-12); box-shadow: var(--shadow);
  display: none; flex-direction: column; overflow: hidden;
}
.panel.open { display: flex; }
.panel-head { padding: 20px 20px 16px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); position: relative; }
.panel-head h2 { font-size: var(--fs-24); padding-right: 40px; }
.panel-head .close { position: absolute; right: 12px; top: 12px; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { height: 28px; display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: var(--r-pill); background: var(--surface-2); font-size: var(--fs-14); color: var(--text-2); }
.crumbs { font-size: var(--fs-13); color: var(--text-3); line-height: 1.4; }
.panel-body { overflow: auto; padding: 16px 20px 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-content: start; }
.panel-body h3 { font-size: var(--fs-16); display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.panel-body h3 .n { color: var(--text-3); font-weight: 500; font-size: var(--fs-14); }
.rel { list-style: none; margin: 0; padding: 0; display: grid; }
.rel li a, .rel li button {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--r-8); text-align: left;
  background: none; border: 0; cursor: pointer; text-decoration: none; font-size: var(--fs-14);
}
.rel li a:hover, .rel li button:hover { background: var(--surface-2); }
.rel .c { margin-left: auto; color: var(--text-3); font-variant-numeric: tabular-nums; font-size: var(--fs-13); }
.rel .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel .nm small { color: var(--text-3); font-size: var(--fs-13); margin-left: 4px; }
.more-btn { margin-top: 8px; }
.links { display: flex; gap: 8px; flex-wrap: wrap; }
.legend-key { display: flex; gap: 16px; font-size: var(--fs-13); color: var(--text-2); }
.legend-key span { display: inline-flex; align-items: center; gap: 8px; }
.legend-key i { width: 16px; height: 2px; border-radius: 2px; }
.note { font-size: var(--fs-14); color: var(--text-2); background: var(--surface-2); border-radius: var(--r-8); padding: 12px; }

/* ---------- species page ---------- */
.sp-hero { padding: 48px 0 40px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.sp-hero .crumbs { font-size: var(--fs-14); }
.sp-hero h1 .sci { font-weight: 400; }
.sp-hero .sub { font-size: var(--fs-20); color: var(--text-2); }
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-12); padding: 16px 20px; min-width: 160px; display: grid; gap: 4px; }
.stat b { font-size: var(--fs-24); font-weight: 600; font-variant-numeric: tabular-nums; }
.stat span { font-size: var(--fs-14); color: var(--text-2); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.list-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-12); padding: 24px; display: grid; gap: 12px; align-content: start; }
.list-box h2 { font-size: var(--fs-24); }
.list-box .rel li a { padding: 8px 12px; }
.prose { display: grid; gap: 16px; max-width: 760px; color: var(--text-2); }
.prose h2 { color: var(--text); margin-top: 24px; }
.prose a { color: var(--accent); }
.prose ul { margin: 0; padding-left: 20px; display: grid; gap: 8px; }

/* ---------- responsive: 분기는 1024 하나 ---------- */
@media (max-width: 1023px) {
  h1 { font-size: var(--fs-32); }
  h2 { font-size: var(--fs-24); }
  .wrap { padding: 0 16px; }
  .bar { padding: 0 16px; gap: 12px; }
  .nav a { padding: 0 8px; }
  .hero-copy { padding: 0 16px 32px; }
  .scroll-cue { display: none; }
  .section { padding: 64px 0; }
  .cards { grid-template-columns: 1fr; }
  .legend { grid-template-columns: repeat(2, 1fr); }
  .species-grid { grid-template-columns: repeat(2, 1fr); }
  .two { grid-template-columns: 1fr; }
  .panel {
    left: 0; right: 0; bottom: 0; top: auto; width: auto; height: 56svh;
    border-radius: var(--r-12) var(--r-12) 0 0; border-bottom: 0;
  }
  .ex-hint { display: none; }
  .ex-top { left: 12px; right: 12px; top: 12px; }
  .ex-tools { left: 12px; bottom: 12px; }
  .panel.open ~ .ex-tools { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .scroll-cue i { animation: none; }
}
