/* ── adm-next 디자인 토큰 ───────────────────────────────────────────────────────── */
:root {
  --pure-black-half: #000000AA;
  --black: #3E3A39;
  --dimmed-black: #4F4F4F;
  --grayish-black: #6C6B6B;
  --neutral-black: #9D9D9D;
  --neutral-white: #C2C2C2;
  --grayish-white: #DFDFDF;
  --dimmed-white: #EFEFEF;
  --dimmed-white2: #F9F9F9;
  --white: #FFFFFF;
  --red: #C7000B;
  --yellow: #F3E100;

  --sidebar-w: 240px;
  --toc-card-w: 300px;
  /* 우측 ToC 카드(300) + 좌우 여백(18×2) 만큼 본문 오른쪽을 비운다 */
  --toc-w: 336px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: sans-serif;
  color: var(--black);
  background: var(--white);
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden {
  display: none !important;
}

/* ── 로그인 (adm-next KHRModal 풍 카드) ── */
#login-screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--grayish-white);
}

.login-box {
  background: var(--white);
  border-radius: 8px;
  padding: 20px 16px;
  width: calc(100% - 48px);
  max-width: 268px;
}

.login-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.login-logo {
  flex-shrink: 0;
  width: 70px;
  height: 31px;
  background: url(./logo_header.svg) no-repeat left center / contain;
}

.login-sub {
  font-size: 13px;
  color: var(--grayish-black);
  text-align: right;
}

#g-signin {
  display: flex;
  justify-content: center;
}

/* 브랜드 버튼(시각) 위에 실제 Google 버튼을 투명하게 겹쳐 클릭을 받게 한다 */
.g-btn-wrap {
  position: relative;
  width: 236px;
  height: 48px;
}

.g-btn-wrap .gsi-material-button {
  pointer-events: none;
  /* 시각 전용 */
}

.g-btn-wrap:hover .gsi-material-button {
  background-color: #111111;
}

#g-real {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  cursor: pointer;
}

#login-error {
  display: none;
  margin-top: 16px;
  color: var(--red);
  font-size: 13px;
  line-height: 20px;
  text-align: center;
}

/* ── Google 브랜드 가이드 버튼 ── */
.gsi-material-button {
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -webkit-appearance: none;
  background-color: #333333;
  background-image: none;
  border-radius: 8px;
  border: none;
  box-sizing: border-box;
  color: #ffffff;
  cursor: pointer;
  font-family: 'Roboto', arial, sans-serif;
  font-size: 16px;
  font-weight: bold;
  height: 48px;
  outline: none;
  overflow: hidden;
  padding: 1px 16px 0;
  position: relative;
  text-align: center;
  transition: background-color .218s, border-color .218s, box-shadow .218s;
  vertical-align: middle;
  white-space: nowrap;
  width: 236px;
  max-width: 400px;
  min-width: min-content;
}

.gsi-material-button .gsi-material-button-icon {
  height: 20px;
  margin-right: 10px;
  min-width: 20px;
  width: 20px;
}

.gsi-material-button .gsi-material-button-content-wrapper {
  align-items: center;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  height: 100%;
  justify-content: space-between;
  position: relative;
  width: 100%;
}

.gsi-material-button .gsi-material-button-contents {
  flex-grow: 1;
  font-family: 'Roboto', arial, sans-serif;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}

.gsi-material-button .gsi-material-button-state {
  transition: opacity .218s;
  bottom: 0;
  left: 0;
  opacity: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.gsi-material-button:disabled {
  cursor: default;
  background-color: #ffffff61;
  border-color: #1f1f1f1f;
}

.gsi-material-button:disabled .gsi-material-button-contents {
  opacity: 38%;
}

.gsi-material-button:disabled .gsi-material-button-icon {
  opacity: 38%;
}

.gsi-material-button:not(:disabled):active .gsi-material-button-state,
.gsi-material-button:not(:disabled):focus .gsi-material-button-state {
  background-color: #303030;
  opacity: 12%;
}

.gsi-material-button:not(:disabled):hover {
  background-color: #111111;
}

.gsi-material-button:not(:disabled):hover .gsi-material-button-state {
  background-color: #303030;
  opacity: 8%;
}

/* ── 앱 레이아웃 ── */
#app {
  height: 100%;
}

/* 모바일/협소 화면 토글 버튼 */
#menu-toggle,
#toc-toggle {
  display: none;
  position: fixed;
  top: 6px;
  z-index: 1100;
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--black);
  padding: 6px 8px;
}

#menu-toggle {
  left: 8px;
}

#toc-toggle {
  right: 8px;
}

#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1050;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* ── 좌측 사이드바 ── */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1055;
  width: var(--sidebar-w);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--dimmed-white);
  overflow: hidden;
}

.sidebar-logo {
  flex-shrink: 0;
  width: 70px;
  height: 31px;
  margin: 16px;
  background: url(./logo_header.svg) no-repeat center / contain;
  cursor: pointer;
}

#nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 8px 16px;
}

.sidebar-user {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px 16px;
  background: var(--dimmed-white);
}

.btn-signout {
  width: 100%;
  background: var(--grayish-white);
  border: none;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 16px;
  line-height: 32px;
  color: var(--black);
  cursor: pointer;
  transition: background 0.1s ease;
  font-weight: bold;
}

.btn-signout:hover {
  background: var(--neutral-white);
}

/* ── 트리 (adm-next 텍스트 버튼) ── */
#nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#nav ul ul {
  padding-left: 14px;
}

#nav li {
  margin: 0;
}

/* 폴더 헤더 · 파일 링크 = 동일한 텍스트 버튼 행 (글꼴·높이 통일) */
#nav .folder-header,
#nav a.file-link {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 16px;
  line-height: 32px;
  font-weight: normal;
  color: var(--black);
  text-decoration: none;
  cursor: pointer;
  user-select: none;
}

/*
#nav .folder-header:hover,
#nav a.file-link:hover {
  background: var(--grayish-white);
}
*/

/* 파일은 왼쪽 삼각형이 없으므로 폴더 이름과 세로로 정렬되도록 들여쓰기 보정 */
#nav a.file-link {
  padding-left: 24px;
}

/* 사이드바 맨 위 "문서저장소 홈" — 트리와 한 칸 띄운다 */
#nav .nav-home {
  margin-bottom: 8px;
}

/* adm-next .label 처럼 화살표를 텍스트 바로 오른편에 붙인다(이름이 행을 채우지 않게). */
#nav .folder-name {
  font-weight: bold;
}

/* 라벨 안의 코드 표기(예: 상세 <code>spec</code>) */
#nav .folder-name code,
#nav .file-name code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82em;
  font-weight: normal;
  background: var(--grayish-white);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--grayish-black);
}

#nav .folder-name,
#nav .file-name {
  flex: 0 1 auto;
  min-width: 0;
  padding-top: 2px;
  line-height: 30px;
}

/* 활성(현재 문서) = adm-next primary: 빨강 라벨 + 빨강 화살표
#nav .folder-header.active,
#nav a.file-link.active {
  color: var(--red);
} */

/* 왼쪽 삼각형(▶) = 접기/펴기. 펼치면 90° 회전 */
#nav .chevron {
  flex-shrink: 0;
  fill: var(--neutral-black);
  transition: transform 0.15s ease;
}

#nav .folder.open>.folder-header .chevron {
  transform: rotate(90deg);
}

#nav .chevron:hover {
  fill: var(--grayish-black);
}

/* 오른쪽 화살표(›) = "열어볼 문서 있음". sub=연회색, 활성=빨강 */
#nav .nav-arrow {
  flex-shrink: 0;
  stroke: var(--neutral-white);
  transition: stroke 0.1s ease;
}

#nav .folder-header.active .nav-arrow,
#nav a.file-link.active .nav-arrow {
  stroke: var(--red);
}

/* 접힘 상태에서 자식 숨김 */
#nav .folder>ul {
  display: none;
}

#nav .folder.open>ul {
  display: block;
}

/* 1·2단계(문서 세트 / 저장소) 펼쳤을 때 아래쪽 여백 */
#nav>ul>li.folder.open,
#nav>ul>li>ul>li.folder.open {
  padding-bottom: 12px;
}

/* 6단계 이상(가장 깊은 항목: 문서세트/repo/spec/섹션/그룹/파일) 폰트 14px */
#nav>ul>li>ul>li>ul>li>ul>li>ul>li>ul li>.folder-header,
#nav>ul>li>ul>li>ul>li>ul>li>ul>li>ul li>a.file-link {
  font-size: 14px;
}

/* ── 본문 ── */
main {
  margin-left: var(--sidebar-w);
  margin-right: var(--toc-w);
  height: 100dvh;
  overflow-y: auto;
}

#app.no-toc main {
  margin-right: 0;
}

#content {
  padding: 32px 20px 96px;
  font-size: 14px;
  color: var(--black);
}

#content .hint {
  color: var(--grayish-black);
}

#content .error {
  color: var(--red);
}

.markdown-body .mermaid {
  background: var(--white);
  text-align: center;
}

/* adm-next 풍 본문 강조 (github-markdown 위에 살짝 덧입힘) */
.markdown-body h1 {
  font-family: 'Iropke Batang', serif;
  border-bottom: 2px solid var(--dimmed-white);
  font-weight: normal;
}

.markdown-body a {
  color: var(--red);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  scroll-margin-top: 60px;
  margin-top: 3rem !important;
}

.markdown-body table {
  margin: 1.5rem 0 !important;
}

.markdown-body hr {
  margin: 3rem 0 !important;
}

.markdown-body p>img {
  margin: 1.5rem auto !important;
}

.markdown-body p:has(img + img) {
  text-align: left;

  >img {
    display: inline-block;
    margin: 0.25rem 0.25rem 0.25rem 0 !important;
    vertical-align: middle;
  }
}

/* ── 우측 ToC (adm-next .ADMPage .right 풍 카드) ── */
#toc {
  position: fixed;
  top: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 1055;
  width: var(--toc-card-w);
  padding: 12px;
  background: var(--dimmed-white);
  border: 1px solid var(--grayish-white);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#app.no-toc #toc {
  display: none;
}

.toc-title {
  flex-shrink: 0;
  padding: 8px 6px;
  font-size: 16px;
  font-weight: bold;
  color: var(--grayish-black);
}

#toc-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.toc-item {
  display: block;
  padding: 2px 0;
  font-size: 15px;
  line-height: 32px;
  color: var(--dimmed-black);
  text-decoration: none;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toc-item.level-h2 {
  margin-left: 8px;
}

.toc-item.level-h3 {
  margin-left: 8px;
  padding-left: 12px;
  border-radius: 0;
  border-left: 2px solid var(--grayish-white);
  line-height: 22px;
  font-size: 14px;
}

.toc-item.level-h3+.toc-item.level-h2,
.toc-item.level-h2+.toc-item.level-h3 {
  margin-top: 4px;
}

.toc-item.active {
  color: var(--red);
  font-weight: bold;
}

/* ── 협소 화면: ToC 오프캔버스 ── */
@media (max-width: 1100px) {
  #overlay {
    display: block;
  }

  #overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }

  #toc-toggle {
    display: block;
  }

  #app.no-toc #toc-toggle {
    display: none;
  }

  main {
    margin-right: 0;
    padding-top: 4px;
  }

  /* 카드는 그대로 떠 있되, 토글 버튼(상단)을 피해 내려오고 평소엔 화면 밖으로 */
  #toc {
    top: 44px;
    transform: translateX(calc(100% + 24px));
    transition: transform 0.3s ease;
  }

  #toc.open {
    transform: translateX(0);
  }

  #app.no-toc #toc {
    display: flex;
  }
}

/* ── 모바일: 좌측 사이드바도 오프캔버스 ── */
@media (max-width: 767px) {
  #menu-toggle {
    display: block;
  }

  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    padding-top: 24px;
    /* 좌상단 ☰ 토글과 겹치지 않게 */
  }

  #sidebar.open {
    transform: translateX(0);
  }

  /* 좁은 화면에선 카드 폭을 화면에 맞춘다(좌우 18px 여백) */
  #toc {
    width: calc(100vw - 36px);
    transform: translateX(calc(100% + 24px));
  }

  #toc.open {
    transform: translateX(0);
  }

  main {
    margin-left: 0;
    padding-top: 36px;
  }

  #content {
    padding: 16px 20px 80px;
  }
}