/* Aurora 배포 페이지 — 스타일.
   앱과 같은 18개 역할 토큰(--bg-*, --text-*, --accent …) 위에서만 색을 고른다.
   themes.js 가 :root 에 주입하는 값이 유일한 출처이므로 여기서 hex 를 새로 박지 않는다.
   예외는 코드블록 구문 강조(앱과 동일한 의미 팔레트)와 그림자용 rgba 뿐이다. */

@font-face {
  font-family: 'Pretendard';
  src: url('fonts/Pretendard-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Pretendard';
  src: url('fonts/Pretendard-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  /* 기본값은 라이트 테마. 페이지가 열리면 themes.js 가 실제 앱 값으로 덮어쓴다. */
  --bg-primary: #ffffff;
  --bg-secondary: #fafafa;
  --bg-tertiary: #f3f3f3;
  --bg-hover: #f0f0f0;
  --bg-active: #e8f0fe;
  --border: #e8e8e8;
  --text-primary: #1a1a1a;
  --text-secondary: #333333;
  --text-tertiary: #666666;
  --text-muted: #999999;
  --accent: #4a9eff;
  --accent-bg: #e0ecff;
  --danger: #e74c3c;
  --code-bg: #1e1e1e;
  --code-text: #d4d4d4;
  --highlight: #fff3a8;
  --selection: #c2dbff;
  --scrollbar: #dddddd;
  /* 액센트 위에 놓는 글자색. themes.js 가 테마마다 대비가 높은 쪽으로 다시 계산한다.
     앱은 이 자리에 흰색을 고정으로 쓰지만, 37개 테마 중 밝은 액센트에서 흰 글자가
     2.7:1 까지 떨어진다. 이 페이지에서 가장 중요한 버튼이라 계산해서 고른다. */
  --on-accent: #1a1a1a;

  --app-font: 'Pretendard', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'Consolas', 'SFMono-Regular', ui-monospace, monospace;

  --rail-w: 48px;
  --side-w: 236px;

  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-pill: 999px;

  --d-instant: 90ms;
  --d-fast: 140ms;
  --d-base: 200ms;
  --d-slow: 260ms;
  --e-out: cubic-bezier(0.16, 1, 0.3, 1);
  --e-std: cubic-bezier(0.4, 0, 0.2, 1);

  --shadow-pop: 0 4px 16px rgba(0, 0, 0, 0.18);
  --shadow-modal: 0 16px 48px rgba(0, 0, 0, 0.2);

  color-scheme: light;
}
:root[data-dark='true'] { color-scheme: dark; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--app-font);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow: hidden;
  transition: background var(--d-base) var(--e-std), color var(--d-base) var(--e-std);
}

::selection { background: var(--selection); color: var(--text-primary); }

button { font-family: inherit; }

a { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 3000;
  background: var(--accent);
  color: var(--on-accent);
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  text-decoration: none;
  transition: top var(--d-fast) var(--e-out);
}
.skip-link:focus { top: 8px; }

/* ───────────────────────── 창 골격 ───────────────────────── */

.win {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-primary);
}

/* 왼쪽 아이콘 레일 — 앱과 같은 48px, 34×34 고스트 버튼 */
.rail {
  flex: 0 0 var(--rail-w);
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  z-index: 10;
}

.rail-btn {
  position: relative;
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--d-fast) var(--e-std), color var(--d-fast) var(--e-std);
}
.rail-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }
.rail-btn[aria-current='true'] { background: var(--accent-bg); color: var(--accent); }
.rail-btn svg { width: 18px; height: 18px; }

.rail-sep {
  width: 22px; height: 1px;
  margin: 6px 0;
  background: var(--border);
}
.rail-spacer { flex: 1 1 auto; }

.rail-mark {
  width: 26px; height: 26px;
  margin-bottom: 6px;
  border-radius: var(--r-sm);
  object-fit: contain;
}

/* 레일 툴팁 — 앱과 같이 떠 있는 레이어에만 그림자 */
.tip {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 9px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-pop);
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--d-fast) var(--e-out);
  z-index: 1100;
}
.rail-btn:hover .tip,
.rail-btn:focus-visible .tip { opacity: 1; }

/* 사이드바 */
.side {
  flex: 0 0 var(--side-w);
  width: var(--side-w);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.side-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 8px 0 12px;
  flex: 0 0 auto;
}
.side-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}
.side-ver {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  border-radius: var(--r-pill);
  padding: 1px 7px;
}
.side-collapse {
  margin-left: auto;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: none; background: transparent;
  color: var(--text-tertiary);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--d-fast) var(--e-std), color var(--d-fast) var(--e-std);
}
.side-collapse:hover { background: var(--bg-hover); color: var(--text-secondary); }
.side-collapse svg { width: 16px; height: 16px; }

.side-body { padding: 2px 8px 16px; }

.side-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 14px 0 4px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.side-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.side-count {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--text-muted);
}

.side-item {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 5px 8px;
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  transition: background var(--d-fast) var(--e-std), color var(--d-fast) var(--e-std);
}
.side-item:hover { background: var(--bg-hover); }
.side-item[aria-current='true'] { background: var(--accent-bg); color: var(--accent); }
.side-item svg { width: 15px; height: 15px; flex: 0 0 auto; opacity: 0.85; }
.side-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 본문 열 */
.main {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

/* 탭 바 */
.tabbar {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 34px;
  padding: 0 8px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 172px;
  max-width: 45vw;
  height: 28px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--r-md) var(--r-md) 0 0;
  background: transparent;
  font-size: 12.5px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background var(--d-fast) var(--e-std), color var(--d-fast) var(--e-std);
}
.tab:hover { background: var(--bg-hover); }
.tab[aria-current='true'] {
  background: var(--bg-primary);
  border-color: var(--border);
  color: var(--text-primary);
}
.tab svg { width: 14px; height: 14px; flex: 0 0 auto; opacity: 0.8; }
.tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 메타 바 — 문서 제목·날짜·태그 + 오른쪽 문서 동작 */
.metabar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  flex: 0 0 auto;
}
.metabar-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.metabar-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--mono);
  white-space: nowrap;
}
.metabar-tags { display: flex; gap: 5px; overflow: hidden; }
.metabar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 11px;
  white-space: nowrap;
}
.chip-meta {
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
}

.icon-btn {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--d-fast) var(--e-std), color var(--d-fast) var(--e-std);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }
.icon-btn[aria-expanded='true'] { background: var(--accent-bg); color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; }

/* 버튼 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--d-fast) var(--e-std), color var(--d-fast) var(--e-std),
    border-color var(--d-fast) var(--e-std);
}
.btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn svg { width: 16px; height: 16px; flex: 0 0 auto; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 86%, var(--on-accent));
  border-color: color-mix(in srgb, var(--accent) 86%, var(--on-accent));
  color: var(--on-accent);
}

.btn-sm { padding: 5px 11px; font-size: 12px; }

/* 팝오버를 여는 텍스트 버튼도 icon-btn 과 같은 활성 표시를 가진다 */
.btn[aria-expanded='true'] {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.metabar-actions .btn { white-space: nowrap; }

/* ───────────────────────── 문서 영역 ───────────────────────── */

.pane {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}
.pane::-webkit-scrollbar { width: 10px; }
.pane::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: var(--r-pill); }
.pane::-webkit-scrollbar-track { background: transparent; }

.note {
  max-width: 760px;
  margin: 0 auto;
  padding: 44px 32px 120px;
}

.sec { scroll-margin-top: 20px; }
.sec + .sec { margin-top: 84px; }

.sec-head { margin-bottom: 18px; }
.sec h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-primary);
}
.sec h3 {
  margin: 28px 0 8px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text-primary);
}
.sec p {
  margin: 0 0 12px;
  color: var(--text-secondary);
  line-height: 1.75;
}
.sec p.lead {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.8;
}
.muted { color: var(--text-tertiary); font-size: 12.5px; line-height: 1.7; }
.scroll-hint { display: none; margin: 8px 0 0; }

.hr {
  height: 1px;
  border: 0;
  background: var(--border);
  margin: 28px 0;
}

/* 표제 — 노트의 h1 */
.hero h1 {
  margin: 0 0 18px;
  font-size: clamp(30px, 5vw, 50px);
  line-height: 1.22;
  font-weight: 700;
  letter-spacing: -1.4px;
  text-wrap: balance;
  color: var(--text-primary);
}
.hero h1 .mark {
  background: var(--highlight);
  padding: 0 4px;
  border-radius: var(--r-xs);
  box-decoration-break: clone;
}
.hero .lead { max-width: 60ch; }

.dl {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 26px 0 12px;
}
.dl-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 18px 11px 15px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-primary);
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--d-fast) var(--e-std), border-color var(--d-fast) var(--e-std),
    color var(--d-fast) var(--e-std);
}
.dl-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.dl-btn svg { width: 22px; height: 22px; flex: 0 0 auto; }
.dl-btn b { display: block; font-size: 14px; font-weight: 700; letter-spacing: -0.2px; }
.dl-btn small {
  display: block;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-tertiary);
  margin-top: 1px;
}
.dl-btn:hover small { color: var(--text-secondary); }
.dl-btn.is-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.dl-btn.is-primary:hover {
  background: color-mix(in srgb, var(--accent) 86%, var(--on-accent));
  border-color: color-mix(in srgb, var(--accent) 86%, var(--on-accent));
  color: var(--on-accent);
}
.dl-btn.is-primary small,
.dl-btn.is-primary:hover small { color: var(--on-accent); }

.dl-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--text-tertiary);
}
.dl-note .mono { font-family: var(--mono); }

/* 목록 */
.list { margin: 0; padding: 0; list-style: none; }
.list li {
  position: relative;
  padding: 0 0 0 20px;
  margin-bottom: 9px;
  color: var(--text-secondary);
  line-height: 1.7;
}
.list li::before {
  content: '';
  position: absolute;
  left: 4px; top: 11px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
}
.list li b { color: var(--text-primary); font-weight: 700; }

.checklist li { padding-left: 26px; }
.checklist li::before {
  left: 0; top: 5px;
  width: 14px; height: 14px;
  border-radius: var(--r-xs);
  background: var(--accent);
}
.checklist li::after {
  content: '';
  position: absolute;
  left: 4px; top: 9px;
  width: 6px; height: 3px;
  border-left: 1.5px solid var(--bg-primary);
  border-bottom: 1.5px solid var(--bg-primary);
  transform: rotate(-45deg);
}

/* ───────────────────────── 재현 화면(데모) ───────────────────────── */

.demo {
  margin: 22px 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-primary);
  overflow: hidden;
}
.demo-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-tertiary);
}
.demo-bar .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}
.demo-bar .grow { flex: 1 1 auto; }
.demo-body { padding: 14px 16px; }
.demo-cap {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--text-tertiary);
  line-height: 1.6;
}

/* 툴바 재현 */
.toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  flex-wrap: wrap;
}
.toolbar .tb {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: none; background: transparent;
  color: var(--text-tertiary);
  border-radius: var(--r-sm);
  font-size: 12px;
}
.toolbar .tb.on { background: var(--accent-bg); color: var(--accent); }
.toolbar .tb svg { width: 15px; height: 15px; }
.toolbar .div { width: 1px; height: 18px; background: var(--border); margin: 0 5px; }

/* 에디터 본문 재현 */
.doc { font-size: 14.5px; line-height: 1.7; color: var(--text-primary); }
.doc h4 { margin: 0 0 10px; font-size: 20px; font-weight: 700; letter-spacing: -0.4px; }
.doc p { margin: 0 0 10px; color: var(--text-primary); }
.doc .hl { background: var(--highlight); border-radius: var(--r-xs); padding: 0 3px; }
.doc .wiki {
  white-space: nowrap;
  color: var(--accent);
  background: var(--accent-bg);
  border-radius: var(--r-pill);
  padding: 1px 8px;
  font-size: 13px;
}
.doc .todo { display: flex; align-items: flex-start; gap: 8px; margin: 3px 0; font-size: 14px; }
.doc .todo i {
  width: 15px; height: 15px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-xs);
  flex: 0 0 auto;
  margin-top: 3px;
  position: relative;
}
.doc .todo.done i { background: var(--accent); border-color: var(--accent); }
.doc .todo.done i::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 6px; height: 3px;
  border-left: 1.5px solid var(--bg-primary);
  border-bottom: 1.5px solid var(--bg-primary);
  transform: rotate(-45deg);
}
.doc .todo.done span { color: var(--text-muted); text-decoration: line-through; }

.doc table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}
.doc th, .doc td {
  border: 1px solid var(--border);
  padding: 5px 9px;
  text-align: left;
}
.doc th { background: var(--bg-tertiary); font-weight: 700; }

/* 코드 블록 — 모든 테마에서 어두운 면을 유지한다(앱과 동일) */
.code {
  margin: 12px 0;
  border-radius: var(--r-md);
  background: var(--code-bg);
  overflow: hidden;
}
.code-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  font-size: 11px;
  color: var(--code-text);
  opacity: 0.6;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.code pre {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--code-text);
}
/* 구문 강조는 의미 팔레트라 테마를 따르지 않는다(앱과 같은 값) */
.k { color: #cba6f7; }
.s { color: #a6e3a1; }
.n { color: #fab387; }
.c { color: #6c7086; font-style: italic; }
.f { color: #89b4fa; }
.a { color: #89dceb; }

/* 원문 보기 토글 */
.raw-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.raw-toggle button {
  padding: 4px 11px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 11.5px;
  cursor: pointer;
  transition: background var(--d-fast) var(--e-std), color var(--d-fast) var(--e-std);
}
.raw-toggle button:hover { background: var(--bg-hover); }
.raw-toggle button[aria-pressed='true'] { background: var(--accent-bg); color: var(--accent); }

.raw {
  margin: 0;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}
.raw .t { color: var(--text-muted); }

.path {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-tertiary);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-all;
}
.path svg { width: 14px; height: 14px; flex: 0 0 auto; color: var(--text-muted); }

/* 그래프 */
.graph { background: var(--bg-primary); }
.graph svg { display: block; width: 100%; height: auto; }
.graph .edge {
  stroke: var(--text-muted);
  opacity: 0.7;
  stroke-width: 1.5;
  fill: none;
  transition: stroke var(--d-base) var(--e-std), opacity var(--d-base) var(--e-std);
}
.graph .node circle {
  fill: var(--bg-secondary);
  stroke: var(--text-tertiary);
  stroke-width: 1.5;
  transition: fill var(--d-fast) var(--e-std), stroke var(--d-fast) var(--e-std);
}
.graph .node text {
  font-size: 11px;
  fill: var(--text-tertiary);
  text-anchor: middle;
  font-family: var(--app-font);
}
.graph .node { cursor: pointer; }
.graph .node:hover circle { stroke: var(--accent); }
.graph .node.on circle { fill: var(--accent-bg); stroke: var(--accent); }
.graph .node.on text { fill: var(--accent); }
.graph .edge.on { stroke: var(--accent); opacity: 1; }
.graph .edge.off { opacity: 0.25; }
.graph .node circle, .graph .node text { transition: all var(--d-base) var(--e-std); }

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-primary);
}
.seg button {
  padding: 3px 10px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 11.5px;
  border-radius: var(--r-xs);
  cursor: pointer;
}
.seg button[aria-pressed='true'] { background: var(--accent-bg); color: var(--accent); }

/* AI 채팅 */
.chat { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
.chat-scope {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.msg { display: flex; gap: 9px; }
.msg .who {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
}
.msg .who svg { width: 14px; height: 14px; }
.msg.me .who { background: var(--accent-bg); color: var(--accent); }
.msg .body { font-size: 13.5px; line-height: 1.7; color: var(--text-secondary); padding-top: 2px; }
.msg .body b { color: var(--text-primary); }

.approve {
  display: block;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-secondary);
  padding: 11px 13px;
}
.approve .head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 7px;
}
.approve .head svg { width: 14px; height: 14px; color: var(--text-tertiary); }
.approve .op {
  display: block;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  word-break: break-all;
}
.approve .row { display: flex; flex-wrap: wrap; gap: 6px; }
.approve .row .btn { cursor: default; }

.chat-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 13px;
}
.chat-input svg { width: 15px; height: 15px; margin-left: auto; }

/* 플로우 캔버스 */
.flow { position: relative; background: var(--bg-secondary); padding: 0; }
.flow svg { display: block; width: 100%; height: auto; }
.flow .fedge {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.5;
  opacity: 0.7;
}
.flow .fnode-box {
  fill: var(--bg-primary);
  stroke: var(--border);
  stroke-width: 1;
}
.flow .fnode.on .fnode-box { stroke: var(--accent); }
.flow .fnode-title { font-size: 11px; font-weight: 700; fill: var(--text-primary); font-family: var(--app-font); }
.flow .fnode-sub { font-size: 10px; fill: var(--text-tertiary); font-family: var(--app-font); }
.flow .fport { fill: var(--bg-primary); stroke: var(--text-muted); stroke-width: 1.2; }
.flow .fglyph { font-size: 12px; }

/* 시트 */
.sheet { width: 100%; border-collapse: collapse; font-size: 12.5px; font-family: var(--mono); }
.sheet th, .sheet td { border: 1px solid var(--border); padding: 4px 8px; text-align: right; }
.sheet th { background: var(--bg-tertiary); color: var(--text-tertiary); font-weight: 400; text-align: center; }
.sheet td:first-child, .sheet th:first-child { text-align: center; }
.sheet td:nth-child(2) { text-align: left; }
.sheet td.sel { background: var(--accent-bg); color: var(--accent); }
.sheet-formula {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-secondary);
}
.sheet-formula .fx { color: var(--text-muted); }

/* 두 칸 배치 */
.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: 16px;
}

/* 테마 */
.themes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin: 20px 0 12px;
}
.theme {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 9px 10px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-primary);
  cursor: pointer;
  text-align: left;
  transition: background var(--d-fast) var(--e-std), border-color var(--d-fast) var(--e-std);
}
.theme:hover { background: var(--bg-hover); }
.theme[aria-pressed='true'] { border-color: var(--accent); background: var(--accent-bg); }
.theme[aria-pressed='true'] .theme-name { color: var(--accent); }
.theme-name {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.theme-strip { display: flex; height: 16px; border-radius: var(--r-xs); overflow: hidden; }
.theme-strip i { flex: 1 1 0; }

/* FAQ */
.faq { border-top: 1px solid var(--border); }
.faq details { border-bottom: 1px solid var(--border); }
.faq summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 28px 13px 2px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  position: relative;
  transition: color var(--d-fast) var(--e-std);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary:hover { color: var(--accent); }
.faq summary::after {
  content: '';
  position: absolute;
  right: 6px; top: 19px;
  width: 7px; height: 7px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform var(--d-base) var(--e-out);
}
.faq details[open] summary::after { transform: rotate(-135deg); top: 22px; }
.faq .ans { padding: 0 2px 15px; color: var(--text-secondary); line-height: 1.75; font-size: 13.5px; }
.faq .ans p { margin: 0 0 9px; }
.faq .ans p:last-child { margin: 0; }

/* 닫는 영역 */
.close-cta {
  margin-top: 84px;
  padding: 30px 0 0;
  border-top: 1px solid var(--border);
}
.close-cta h2 {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-primary);
}
.close-cta > p {
  margin: 0 0 6px;
  color: var(--text-secondary);
}
.foot {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  font-size: 11.5px;
  color: var(--text-tertiary);
}
.foot .mono { font-family: var(--mono); }

/* 테마 팝오버 */
.pop {
  position: absolute;
  right: 14px;
  top: 78px;
  z-index: 1100;
  width: 268px;
  max-height: min(64vh, 460px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-primary);
  box-shadow: var(--shadow-pop);
}
.pop[hidden] { display: none; }
.pop-label {
  padding: 6px 8px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.pop-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 5px 8px;
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
}
.pop-item:hover { background: var(--bg-hover); }
.pop-item[aria-pressed='true'] { background: var(--accent-bg); color: var(--accent); }
.pop-item .swatch {
  display: flex;
  width: 34px; height: 14px;
  border-radius: var(--r-xs);
  overflow: hidden;
  flex: 0 0 auto;
  border: 1px solid var(--border);
}
.pop-item .swatch i { flex: 1 1 0; }
.pop-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 사이드바 오버레이 백드롭(좁은 화면) */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  z-index: 99;
  border: 0;
  padding: 0;
}
.scrim[hidden] { display: none; }

/* ───────────────────────── 등장 모션 ───────────────────────── */

.booted .boot {
  animation: rise var(--d-slow) var(--e-out) backwards;
}
.booted .boot-1 { animation-delay: 0ms; }
.booted .boot-2 { animation-delay: 70ms; }
.booted .boot-3 { animation-delay: 140ms; }
.booted .boot-4 { animation-delay: 210ms; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.reveal.seen circle, .reveal.seen .fnode {
  animation: pop var(--d-slow) var(--e-out) backwards;
}
.reveal.seen circle:nth-of-type(n) { animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes pop {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: none; }
}

.draw { stroke-dasharray: var(--len, 300); stroke-dashoffset: var(--len, 300); }
.seen .draw { animation: draw 700ms var(--e-out) both; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.seen .stream { animation: stream 700ms var(--e-out) backwards; }
@keyframes stream {
  from { opacity: 0; clip-path: inset(0 0 100% 0); }
  to { opacity: 1; clip-path: inset(0); }
}

/* ───────────────────────── 반응형 ───────────────────────── */

@media (max-width: 1040px) {
  .side {
    position: fixed;
    left: var(--rail-w);
    top: 0; bottom: 0;
    z-index: 100;
    box-shadow: var(--shadow-modal);
    transform: translateX(calc(-100% - var(--rail-w)));
    transition: transform var(--d-slow) var(--e-out);
  }
  .side.open { transform: none; }
  /* 등장 애니메이션의 transform 이 여기의 숨김 transform 을 덮어쓰므로 꺼 둔다 */
  .side.boot { animation: none !important; opacity: 1; }
  .note { padding: 36px 24px 100px; }
}

@media (min-width: 1041px) {
  .side-toggle { display: none; }
  .scrim { display: none !important; }
}

@media (max-width: 760px) {
  body { overflow: auto; }
  .win { display: block; height: auto; }
  .rail {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    width: auto;
    height: 52px;
    flex-direction: row;
    justify-content: center;
    gap: 2px;
    padding: 0 8px;
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 100;
    overflow-x: auto;
  }
  .rail-mark, .rail-sep, .rail-spacer, .tip { display: none; }
  .side { left: 0; }
  .main { min-height: 100vh; }
  .tabbar { position: sticky; top: 0; z-index: 10; }
  .metabar { position: sticky; top: 34px; z-index: 10; }
  .metabar-meta, .metabar-tags { display: none; }
  .pane { overflow: visible; }
  .sec { scroll-margin-top: 96px; }
  /* 축소하면 노드 라벨이 5px 로 줄어 읽히지 않는다. 원래 크기를 유지하고 가로로 민다 */
  .graph, .flow { overflow-x: auto; }
  .graph svg, .flow svg { min-width: 620px; }
  .scroll-hint { display: block; }
  .note { padding: 28px 18px 120px; }
  .sec + .sec { margin-top: 64px; }
  .cols { grid-template-columns: 1fr; }
  .pop { position: fixed; right: 12px; left: 12px; top: 84px; width: auto; }
  .dl-btn { flex: 1 1 100%; }
}

@media (max-width: 420px) {
  .hero h1 { letter-spacing: -0.8px; }
  .themes { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .pane { scroll-behavior: auto; }
  .draw { stroke-dashoffset: 0; }
  .reveal circle, .reveal .fnode { opacity: 1; }
}

/* ───────────────────────── 인쇄 ───────────────────────── */

@media print {
  body { overflow: visible; }
  .win { display: block; height: auto; }
  .rail, .side, .tabbar, .pop, .scrim, .skip-link { display: none !important; }
  .metabar { border: 0; padding-left: 0; }
  .metabar-actions, .side-toggle { display: none !important; }
  .pane { overflow: visible; }
  .note { max-width: none; padding: 0; }
  .boot { opacity: 1 !important; animation: none !important; }
  .demo, .sec { break-inside: avoid; }
}

/* ─────────────────────────────────────────────────────────────
   Studio Canvas 로 돌아가는 링크 (브랜드 사이트 → 제품 페이지 구조)
   ───────────────────────────────────────────────────────────── */
.side-home {
  margin-bottom: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.side-home span { color: var(--text-primary); }

.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
  text-decoration: none;
}
.btn-quiet:hover {
  background: var(--bg-hover);
  border-color: var(--border-color);
  color: var(--text-primary);
}
@media (max-width: 900px) { .btn-quiet { display: none; } }
