:root{
  --bg: #0b1220;
  --bg2:#0a1020;
  --panel: rgba(255,255,255,.06);
  --panel2: rgba(255,255,255,.08);
  --stroke: rgba(255,255,255,.12);

  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.70);

  /* v2 GREEN THEME */
  --brand: #00ff84;   /* primary green */
  --brand2:#22c55e;   /* secondary green */
  --accent:#00e676;   /* accent green */

  --shadow: 0 18px 60px rgba(0,0,0,.45);
  --radius: 18px;

  --container: 1120px;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
html{ scroll-behavior: smooth; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans KR", "Apple SD Gothic Neo", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1000px 600px at 18% 12%, rgba(0,255,132,.22), transparent 60%),
    radial-gradient(900px 520px at 82% 18%, rgba(34,197,94,.18), transparent 55%),
    radial-gradient(900px 520px at 55% 95%, rgba(0,230,118,.14), transparent 55%),
    linear-gradient(180deg, var(--bg), var(--bg2));
  line-height: 1.55;
}

a{ color: inherit; text-decoration: none; }
a:hover{ text-decoration: none; }

.container{
  width: min(var(--container), calc(100% - 40px));
  margin: 0 auto;
}

/* accessibility */
.skip-link{
  position:absolute;
  left:-9999px;
  top:10px;
  background:#111827;
  border:1px solid var(--stroke);
  padding:10px 12px;
  border-radius: 10px;
}
.skip-link:focus{ left: 12px; z-index: 9999; }

/* header */
.site-header{
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(10,16,32,.55);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.header-inner{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
}
.brand{
  display:flex;
  align-items:center;
  gap: 12px;
  min-width: 240px;
}
.brand-mark{
  width: 14px;
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  box-shadow: 0 0 0 6px rgba(0,255,132,.18);
}
.brand-text strong{ display:block; font-weight: 800; letter-spacing: .2px; }
.brand-text small{ display:block; color: var(--muted); margin-top: 1px; font-size: 12px; }

.nav{
  display:flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}
.nav a{
  padding: 8px 10px;
  border-radius: 999px;
  color: var(--muted);
  border: 1px solid transparent;
}
.nav a:hover{
  color: var(--text);
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.10);
}

/* hero */
.hero{
  position: relative;
  overflow: hidden;
  padding: 54px 0 34px;
}
.hero-bg{
  position:absolute;
  inset: -40px -40px auto -40px;
  height: 360px;
  background: radial-gradient(700px 260px at 30% 30%, rgba(0,255,132,.18), transparent 60%);
  pointer-events:none;
}
.hero-inner{
  display:grid;
  grid-template-columns: 1.35fr .85fr;
  gap: 26px;
  align-items: center;
}
.hero-copy{ min-width: 0; }

.eyebrow{
  display:flex;
  align-items:center;
  gap: 10px;
  color: var(--muted);
  margin: 0 0 10px;
}
.pill{
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0,255,132,.10);
  border: 1px solid rgba(0,255,132,.22);
  color: rgba(255,255,255,.86);
}
.hero h1{
  margin: 0 0 12px;
  font-size: clamp(34px, 4.2vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.6px;
}
.lead{
  margin: 0 0 18px;
  word-break: keep-all;    /* ✅ 한글 글자 단위 분리 방지 */
  color: var(--muted);
  font-size: 16px;
  max-width: 58ch;
}

.hero-buttons{ display:flex; gap: 10px; flex-wrap: wrap; }

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 11px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .15s ease, filter .15s ease;
}
.btn:hover{ background: rgba(255,255,255,.10); }
.btn:active{ transform: translateY(1px); }

.btn-primary{
  border: none;
  color: #04150c;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  box-shadow: 0 16px 40px rgba(0,255,132,.18);
}
.btn-primary:hover{ filter: brightness(1.05); }
.btn-secondary{
  background: rgba(255,255,255,.06);
}

.stats{
  display:flex;
  gap: 18px;
  margin: 18px 0 0;
  padding: 0;
}
.stat{
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.10);
}
.stat dt{ font-size: 12px; color: var(--muted); }
.stat dd{ margin: 0; font-weight: 900; font-size: 18px; }

/* hero right panel */
.hero-panel{ justify-self: end; width: min(420px, 100%); }
.terminal{
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.22);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.terminal-top{
  display:flex;
  align-items:center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(255,255,255,.05);
  border-bottom: 1px solid rgba(255,255,255,.10);
}
.dot{ width:10px; height:10px; border-radius: 999px; opacity:.9; }
.dot.red{ background:#ef4444; }
.dot.yellow{ background:#f59e0b; }
.dot.green{ background:#22c55e; }
.terminal-title{ margin-left: 6px; color: var(--muted); font-size: 12px; }
.terminal-body{
  margin: 0;
  padding: 14px 14px 16px;
  color: rgba(255,255,255,.86);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.45;
}

/* sections */
.section{ padding: 34px 0; }
.section-head{ margin-bottom: 14px; }
.section-head h2{
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: -0.2px;
}
.muted{ color: var(--muted); margin: 0; }

.cards{
  display:grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.grid{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.grid-2{ grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card{
  position: relative;
  border-radius: var(--radius);
  padding: 16px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.10);
  box-shadow: 0 1px 0 rgba(255,255,255,.06) inset;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.card:hover{
  border-color: rgba(255,255,255,.16);
  background: rgba(255,255,255,.07);
  transform: translateY(-1px);
}
/* ===== Korean word split fix (동/작 같은 글자 쪼개짐 방지) ===== */

/* 카드 내 텍스트는 한글 단어 단위로만 줄바꿈 */
.card h3,
.card p,
.card .muted{
  word-break: keep-all;    /* ✅ 한글 글자 단위 분리 방지 */
  line-break: strict;      /* ✅ CJK 줄바꿈 규칙을 더 엄격하게 */
  overflow-wrap: normal;   /* ✅ anywhere 때문에 글자 단위로 쪼개지는 것 방지 */
}

/* 다만 URL/영문 긴 토큰이 있으면 카드 밖으로 튈 수 있으니,
   그런 경우에만 깨지도록 예외 클래스(선택) */
.break-anywhere{
  overflow-wrap: anywhere;
  word-break: break-word;
}

.card-kicker{
  display:inline-block;
  font-size: 12px;
  color: rgba(255,255,255,.78);
  opacity: .95;
  margin-bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0,255,132,.10);
  border: 1px solid rgba(0,255,132,.20);
}

.card-linkable{ cursor: pointer; }
.card-linkable:focus,
.card-linkable:focus-visible{
  outline: 2px solid rgba(0,255,132,.60);
  outline-offset: 3px;
}

.card-announce .card-badge{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,255,132,.22);
  background: rgba(0,255,132,.10);
  color: rgba(255,255,255,.86);
  margin-bottom: 10px;
}
.card-meta{
  display:flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}
.card-link{ color: rgba(255,255,255,.86); }
.card-link:hover{ text-decoration: underline; }

.card-highlight{
  border-color: rgba(0,255,132,.24);
  background: linear-gradient(180deg, rgba(0,255,132,.08), rgba(255,255,255,.05));
}
.tag{
  position:absolute;
  top: 14px;
  right: 14px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0,255,132,.10);
  border: 1px solid rgba(0,255,132,.22);
  color: rgba(255,255,255,.86);
}

.list{
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
}
.list li{ margin: 6px 0; }

/* footer */
.site-footer{
  padding: 26px 0 34px;
  border-top: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.12);
}
.footer-inner{
  display:flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items:center;
}
.site-footer a{ text-decoration: underline; text-decoration-color: rgba(255,255,255,.28); }
.site-footer a:hover{ text-decoration-color: rgba(255,255,255,.55); }

/* small polish */
::selection{
  background: rgba(0,255,132,.22);
  color: rgba(255,255,255,.95);
}

/* responsive */
@media (max-width: 980px){
  .hero-inner{ grid-template-columns: 1fr; }
  .hero-panel{ justify-self: start; }
  .grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px){
  .nav{ display:none; } /* 필요하면 햄버거 메뉴로 확장 가능 */
  .grid{ grid-template-columns: 1fr; }
  .grid-2{ grid-template-columns: 1fr; }
  .stats{ flex-direction: column; }
}

/* ===== chapter pages v1 (add-on) ===== */
.section{ scroll-margin-top: 90px; }

.breadcrumbs{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items:center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}
.breadcrumbs a{ color: rgba(255,255,255,.82); }
.breadcrumbs a:hover{ text-decoration: underline; }
.breadcrumbs .sep{ opacity: .55; }

.chapter-head{
  display:grid;
  grid-template-columns: 1.35fr .65fr;
  gap: 14px;
  align-items: start;
}
.chapter-title{
  margin: 0 0 10px;
  font-size: clamp(28px, 3.2vw, 44px);
  line-height: 1.12;
  letter-spacing: -0.5px;
}
.chapter-sub{
  font-size: .6em;
  color: var(--muted);
  font-weight: 700;
}

.chapter-aside{
  position: sticky;
  top: 86px;
}

.prose{
  background: rgba(255,255,255,.045);
}
.prose .note{
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.10);
}

/* outline list */
.outline{
  margin: 0;
  padding-left: 18px;
  color: rgba(255,255,255,.86);
}
.outline li{ margin: 8px 0; }
.outline ul, .outline ol{
  margin-top: 8px;
  margin-bottom: 8px;
}

.badge{
  display:inline-flex;
  align-items:center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  margin-right: 6px;
  background: rgba(0,255,132,.10);
  border: 1px solid rgba(0,255,132,.18);
  color: rgba(255,255,255,.86);
}

/* lab cards */
.lab-meta{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.chip{
  display:inline-flex;
  align-items:center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: rgba(255,255,255,.82);
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.10);
}

.lab-placeholder{
  opacity: .9;
}

/* responsive chapter layout */
@media (max-width: 980px){
  .chapter-head{ grid-template-columns: 1fr; }
  .chapter-aside{ position: static; }
}

/* ===== spacing tune for chapter page (fix image8) ===== */

/* 1) 챕터 첫 섹션(hero) 아래 여백을 줄여서 "목차"가 덜 멀게 */
.chapter-hero{
  padding-bottom: 18px; /* 기존 section(34px) 대비 아래쪽만 축소 */
}

/* 2) 바로 다음 섹션(목차)이 hero와 너무 멀지 않게 위쪽 padding 축소 */
.chapter-hero + .section{
  padding-top: 18px;
}

/* 3) 왼쪽(버튼)과 오른쪽(카드) 사이 간격/정렬 개선 */
.chapter-head{
  gap: 18px;            /* 좌우 컬럼 간격 약간 증가 */
  align-items: start;
}

/* 4) 오른쪽 카드가 버튼 바로 아래에 "딱 붙어" 보이는 느낌 완화:
      - 카드 자체에 위 여백을 주고, 살짝 내려오게 */
.chapter-aside{
  margin-top: 18px;
}

/* 5) 작은 화면에서는 margin-top 과해질 수 있으니 완화 */
@media (max-width: 980px){
  .chapter-aside{ margin-top: 12px; }
}