/* ===================== 토큰 ===================== */
:root{
  --bg: #050711;
  --bg-soft: #0a0e1c;
  --panel: rgba(20, 26, 48, 0.72);
  --panel-solid: #121830;
  --border: rgba(255,255,255,0.08);
  --text: #eaf0ff;
  --text-dim: #93a0c4;
  --text-faint: #5b6690;

  --project: #4fd1ff;      /* 과제 — 시안 */
  --agency: #38bdf8;       /* 기관 — 스카이 */
  --researcher: #a78bfa;   /* 연구자 — 바이올렛 */
  --result: #34d399;       /* 성과 — 그린 */
  --classification: #fbbf24; /* 분류 — 앰버 */
  --ministry: #f472b6;     /* 부처 — 핑크 */

  --grad: linear-gradient(120deg, #4fd1ff 0%, #a78bfa 50%, #f472b6 100%);
  --radius: 16px;
  --shadow: 0 20px 60px rgba(0,0,0,0.45);
}

*{ box-sizing: border-box; }
html{ scroll-behavior: smooth; }
body{
  margin:0; background: var(--bg); color: var(--text);
  font-family: "Noto Sans KR", -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.55;
}
h1,h2,h3{ font-weight:900; margin:0 0 .5em; letter-spacing:-0.02em; }
p{ margin:0 0 1em; color: var(--text-dim); }
a{ color: inherit; }
.grad{
  background: var(--grad); -webkit-background-clip:text; background-clip:text;
  color: transparent;
}
.eyebrow{
  font: 700 12px/1 "JetBrains Mono", monospace; letter-spacing:.16em;
  text-transform: uppercase; color: var(--project); margin-bottom: 10px;
}

/* ===================== 상단 내비 ===================== */
.topnav{
  position: fixed; top:0; left:0; right:0; z-index: 50;
  display:flex; align-items:center; justify-content:space-between;
  padding: 16px 28px; backdrop-filter: blur(14px);
  background: linear-gradient(to bottom, rgba(5,7,17,.85), rgba(5,7,17,0));
}
.topnav__brand{ font-weight:700; font-size:14px; display:flex; align-items:center; gap:8px; }
.topnav__brand .dot{
  width:8px; height:8px; border-radius:50%; background: var(--project);
  box-shadow: 0 0 12px var(--project);
}
.topnav__links{ display:flex; gap:22px; font-size:14px; }
.topnav__links a{ text-decoration:none; color: var(--text-dim); transition:.2s; }
.topnav__links a:hover{ color: var(--text); }

/* ===================== 히어로 ===================== */
.hero{
  position:relative; min-height: 100vh; display:flex; align-items:center; justify-content:center;
  overflow:hidden; text-align:center; padding: 120px 20px 60px;
}
.hero__canvas{ position:absolute; inset:0; width:100%; height:100%; opacity:.55; }
.hero__vignette{
  position:absolute; inset:0;
  background: radial-gradient(ellipse at center, rgba(5,7,17,0) 0%, var(--bg) 78%),
              linear-gradient(to bottom, rgba(5,7,17,.3), var(--bg) 92%);
}
.hero__content{ position:relative; z-index:2; max-width: 760px; }
.badge{
  display:inline-block; padding:6px 14px; border-radius:999px;
  border:1px solid var(--border); font:600 12px/1 "JetBrains Mono", monospace;
  color: var(--text-dim); margin-bottom:22px; letter-spacing:.04em;
  background: rgba(255,255,255,0.03);
}
.hero h1{ font-size: clamp(34px, 6vw, 62px); line-height:1.15; margin-bottom:20px; }
.hero__lede{ font-size:16px; max-width: 560px; margin:0 auto 30px; color: var(--text-dim); }
.hero__cta{ display:flex; gap:14px; justify-content:center; margin-bottom: 56px; flex-wrap:wrap; }

.btn{
  padding: 13px 26px; border-radius: 999px; text-decoration:none; font-weight:700; font-size:14px;
  transition: transform .18s, box-shadow .18s; display:inline-block;
}
.btn--primary{
  background: var(--grad); color:#04050c;
  box-shadow: 0 10px 30px rgba(79,209,255,0.25);
}
.btn--primary:hover{ transform: translateY(-2px); box-shadow: 0 14px 36px rgba(79,209,255,.4); }
.btn--ghost{ border:1px solid var(--border); color: var(--text); background: rgba(255,255,255,.03); }
.btn--ghost:hover{ border-color: rgba(255,255,255,.25); }

.hero__stats{
  display:flex; gap: 36px; justify-content:center; flex-wrap:wrap;
  padding-top: 26px; border-top: 1px solid var(--border);
}
.hero__stats .stat{ text-align:center; }
.hero__stats b{
  display:block; font: 900 30px/1 "JetBrains Mono", monospace; color:var(--text);
  margin-bottom:4px;
}
.hero__stats span{ font-size:12px; color: var(--text-faint); }

/* ===================== 검색바 ===================== */
.searchbar-wrap{
  position: sticky; top: 64px; z-index: 40; display:flex; justify-content:center;
  padding: 0 20px; margin-top: -34px;
}
.searchbar{
  width:100%; max-width: 640px; display:flex; align-items:center; gap:10px;
  background: var(--panel-solid); border:1px solid var(--border); border-radius: 14px;
  padding: 14px 18px; box-shadow: var(--shadow);
}
.searchbar__icon{ color: var(--text-faint); flex:none; }
.searchbar input{
  flex:1; background:none; border:none; outline:none; color: var(--text); font-size:15px;
  font-family: inherit;
}
.searchbar input::placeholder{ color: var(--text-faint); }
.searchbar__hint{ font:600 11px/1 "JetBrains Mono",monospace; color: var(--text-faint); white-space:nowrap; }

.search-results{
  position:absolute; top: 100%; margin-top:8px; width:100%; max-width:640px;
  background: var(--panel-solid); border:1px solid var(--border); border-radius:14px;
  box-shadow: var(--shadow); overflow:hidden; max-height: 360px; overflow-y:auto;
}
.search-results .sr-item{
  display:flex; align-items:center; gap:10px; padding: 12px 16px; cursor:pointer;
  border-bottom: 1px solid var(--border); transition:.15s;
}
.search-results .sr-item:last-child{ border-bottom:none; }
.search-results .sr-item:hover, .search-results .sr-item.active{ background: rgba(255,255,255,.05); }
.sr-dot{ width:9px; height:9px; border-radius:50%; flex:none; }
.sr-text{ flex:1; min-width:0; }
.sr-title{ font-size:14px; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sr-meta{ font-size:11px; color: var(--text-faint); }

/* ===================== 그래프 섹션 ===================== */
.graph-section{ max-width: 1360px; margin: 130px auto 40px; padding: 0 24px; }
.graph-header{
  display:flex; justify-content:space-between; align-items:flex-end; gap:20px; margin-bottom: 18px;
  flex-wrap:wrap;
}
.legend{ display:flex; gap:8px; flex-wrap:wrap; }
.chip{
  font:600 12px/1 "Noto Sans KR"; padding: 8px 14px; border-radius:999px; cursor:pointer;
  border:1px solid var(--border); background: rgba(255,255,255,.03); color: var(--text-dim);
  transition:.15s; display:flex; align-items:center; gap:7px;
}
.chip::before{ content:""; width:8px; height:8px; border-radius:50%; background: currentColor; }
.chip--project{ color: var(--project); } .chip--agency{ color: var(--agency); }
.chip--researcher{ color: var(--researcher); } .chip--result{ color: var(--result); }
.chip--classification{ color: var(--classification); } .chip--ministry{ color: var(--ministry); }
.chip.is-off{ opacity:.3; }
.chip:hover{ border-color: rgba(255,255,255,.25); }

.graph-stage{
  position:relative; height: 640px; border-radius: var(--radius); overflow:hidden;
  border:1px solid var(--border); background: radial-gradient(ellipse at 50% 30%, #0d1330 0%, #050711 70%);
  box-shadow: var(--shadow);
}
.graph-canvas{ position:absolute; inset:0; }

.loading-overlay{
  position:absolute; inset:0; display:flex; flex-direction:column; gap:14px;
  align-items:center; justify-content:center; color: var(--text-dim); font-size:13px;
  background: var(--bg); z-index: 5; transition: opacity .4s;
}
.spinner{
  width:34px; height:34px; border-radius:50%; border: 3px solid rgba(255,255,255,.12);
  border-top-color: var(--project); animation: spin 0.9s linear infinite;
}
@keyframes spin{ to{ transform: rotate(360deg); } }

.detail-panel{
  position:absolute; top:16px; right:16px; bottom:16px; width: 320px; z-index: 10;
  background: var(--panel); backdrop-filter: blur(16px); border:1px solid var(--border);
  border-radius: 14px; padding: 20px; overflow-y:auto; box-shadow: var(--shadow);
}
.detail-panel__close{
  position:absolute; top:12px; right:12px; background:none; border:none; color: var(--text-faint);
  font-size:16px; cursor:pointer; width:28px; height:28px; border-radius:50%;
}
.detail-panel__close:hover{ background: rgba(255,255,255,.08); color: var(--text); }
.dp-type{ font:700 11px/1 "JetBrains Mono",monospace; letter-spacing:.08em; text-transform:uppercase; margin-bottom:10px; }
.dp-title{ font-size:17px; font-weight:700; margin-bottom:14px; line-height:1.4; }
.dp-row{ display:flex; justify-content:space-between; gap:10px; padding:8px 0; border-top:1px solid var(--border); font-size:13px; }
.dp-row span:first-child{ color:var(--text-faint); }
.dp-row span:last-child{ color: var(--text); text-align:right; }
.dp-summary{ margin-top:14px; font-size:13px; color: var(--text-dim); line-height:1.6; }

.graph-controls{ position:absolute; left:16px; bottom:16px; z-index:10; display:flex; gap:8px; align-items:center; }
.ctrl-btn{
  font:600 12px/1 "Noto Sans KR"; padding:9px 14px; border-radius:10px; cursor:pointer;
  border:1px solid var(--border); background: rgba(10,14,28,.75); color: var(--text-dim);
  backdrop-filter: blur(8px);
}
.ctrl-btn:hover{ color: var(--text); border-color: rgba(255,255,255,.25); }
.ctrl-toggle{
  font-size:12px; color: var(--text-dim); display:flex; align-items:center; gap:6px;
  background: rgba(10,14,28,.75); border:1px solid var(--border); padding:8px 12px; border-radius:10px;
}
.graph-caption{ font-size:12px; color: var(--text-faint); margin-top:14px; max-width:820px; }

/* ===================== 지형(landscape) ===================== */
.landscape{ max-width: 1200px; margin: 100px auto; padding: 0 24px; }
.landscape-grid{ display:grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 24px; }
@media (max-width: 860px){ .landscape-grid{ grid-template-columns: 1fr; } }
.panel{
  background: var(--panel); border:1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px; backdrop-filter: blur(10px);
}
.panel h3{ font-size:14px; margin-bottom:18px; color: var(--text-dim); font-weight:700; }
.bar-row{ display:grid; grid-template-columns: 120px 1fr 70px; align-items:center; gap:10px; margin-bottom:12px; font-size:12px; }
.bar-row .bar-label{ color: var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.bar-track{ height:10px; border-radius:6px; background: rgba(255,255,255,.06); overflow:hidden; }
.bar-fill{ height:100%; border-radius:6px; background: var(--grad); }
.bar-row .bar-val{ text-align:right; color: var(--text-faint); font-family:"JetBrains Mono",monospace; }
.landscape-note{ font-size:12px; color: var(--text-faint); margin-top:18px; }

/* ===================== 챗봇 ===================== */
.chat-section{ max-width: 760px; margin: 100px auto 120px; padding: 0 24px; }
.chat-sub{ font-size:13px; }
.chat-box{
  background: var(--panel); border:1px solid var(--border); border-radius: var(--radius);
  overflow:hidden; backdrop-filter: blur(10px);
}
.chat-log{ height: 380px; overflow-y:auto; padding: 20px; display:flex; flex-direction:column; gap:12px; }
.chat-msg{ max-width: 82%; padding: 12px 15px; border-radius: 14px; font-size:14px; line-height:1.6; }
.chat-msg--bot{ background: rgba(255,255,255,.05); border:1px solid var(--border); align-self:flex-start; border-bottom-left-radius:4px; }
.chat-msg--user{ background: var(--grad); color:#04050c; align-self:flex-end; border-bottom-right-radius:4px; font-weight:600; }
.chat-msg--bot b{ color: var(--project); }
.chat-card{
  display:block; margin-top:8px; padding:10px 12px; border-radius:10px;
  background: rgba(255,255,255,.04); border:1px solid var(--border); cursor:pointer; transition:.15s;
}
.chat-card:hover{ border-color: var(--project); }
.chat-card .cc-title{ font-size:13px; color: var(--text); margin-bottom:3px; }
.chat-card .cc-meta{ font-size:11px; color: var(--text-faint); font-family:"JetBrains Mono",monospace; }
.chat-form{ display:flex; border-top:1px solid var(--border); }
.chat-form input{
  flex:1; background:none; border:none; outline:none; color:var(--text); padding:16px 18px; font-size:14px;
  font-family: inherit;
}
.chat-form button{
  border:none; background: var(--grad); color:#04050c; font-weight:700; padding: 0 22px; cursor:pointer;
}

/* ===================== 푸터 ===================== */
.site-footer{
  text-align:center; padding: 40px 20px 60px; font-size:12px; color: var(--text-faint);
  border-top:1px solid var(--border);
}
.site-footer div{ margin-bottom:4px; }

::-webkit-scrollbar{ width:9px; height:9px; }
::-webkit-scrollbar-thumb{ background: rgba(255,255,255,.12); border-radius:6px; }
::-webkit-scrollbar-track{ background: transparent; }

/* ===================== 모바일 ===================== */
@media (max-width: 640px){
  .topnav{ padding: 12px 16px; }
  .topnav__brand{ font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width: 56vw; }
  .topnav__links{ gap:12px; font-size:12px; }
  .topnav__links a{ white-space:nowrap; }
  .hero{ padding-top: 110px; }
  .hero__stats{ gap: 20px 28px; }
  .searchbar__hint{ display:none; }
  .graph-stage{ height: 460px; }
  .detail-panel{ width: calc(100% - 32px); }
  .graph-header{ align-items:flex-start; }
}
