/* 애플리케이션 셸 — LNB 250px + 헤더 63px + 내부 스크롤 (명세서 §6.1) */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  word-break: keep-all;          /* 한국어를 단어(공백) 단위로만 줄바꿈 — 글자 중간에서 끊기던 문제 수정 */
  overflow-wrap: break-word;     /* 공백 없는 긴 문자열(URL 등)은 넘치지 않게 강제 줄바꿈 */
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4, p, dl, dd, dt, figure { margin: 0; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ---------- LNB ---------- */
.lnb {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--lnb-w);
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--line);
  transition: width 0.18s ease, transform 0.18s ease;
  overflow: hidden;
}
.lnb-head { padding: 22px 22px 18px; flex: 0 0 auto; }
.brand { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.brand-logo { display: block; height: 36px; width: auto; max-width: 100%; }
.brand-logo-mark { display: none; height: 28px; width: auto; }
body.nav-collapsed .brand-logo { display: none; }
body.nav-collapsed .brand-logo-mark { display: block; }
.brand-sub { display: block; margin-top: 6px; font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.lnb-nav { flex: 1 1 auto; overflow-y: auto; padding: 4px 12px 16px; }
.lnb-nav > .lnb-item { margin-bottom: 2px; }
.lnb-group { margin: 10px 0 6px; }
.lnb-group-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 6px 10px; margin-bottom: 2px;
  border: 0; border-radius: var(--r-md); background: transparent;
  text-align: left; cursor: pointer;
}
.lnb-group-toggle:hover { background: var(--bg-dim); }
.lnb-group-title {
  flex: 1 1 auto;
  padding: 0;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--ink-3); white-space: nowrap;
}
.lnb-caret { flex: 0 0 auto; font-size: 10px; color: var(--ink-3); transition: transform 0.15s ease; }
.lnb-group-toggle[aria-expanded="false"] .lnb-caret { transform: rotate(-90deg); }
.lnb-group-body[hidden] { display: none; }
.lnb-group-body .lnb-item { padding-left: 20px; }
.lnb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; margin-bottom: 2px;
  border-radius: var(--r-md);
  font-size: 14px; color: var(--ink-2);
  white-space: nowrap;
}
.lnb-item:hover { background: var(--bg-dim); color: var(--ink); }
.lnb-item.active { background: var(--chip); color: var(--ink); font-weight: 700; }
.lnb-item.active .lnb-ico { color: var(--cyan); }
.lnb-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.lnb-ico { flex: 0 0 auto; width: 20px; text-align: center; font-size: 14px; color: var(--ink-3); }
.lnb-badge {
  flex: 0 0 auto;
  padding: 1px 6px; border-radius: var(--pill);
  background: var(--chip); color: var(--ink-3);
  font-size: 10px; font-weight: 700;
}
.lnb-lock { flex: 0 0 auto; display: none; font-size: 11px; }
body.anon .lnb-lock { display: inline; }
.lnb-foot {
  flex: 0 0 auto;
  padding: 14px 22px 20px;
  border-top: 1px solid var(--line);
  font-size: 11px; line-height: 1.6; color: var(--ink-3);
}
.lnb-foot .muted { margin-top: 4px; color: var(--ink-dis); }

.lnb-toggle {
  position: fixed;
  top: 20px;
  left: calc(var(--lnb-w) - 14px);
  z-index: 60;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  color: var(--ink-2);
  font-size: 16px; line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: left 0.18s ease, transform 0.18s ease;
}
.lnb-toggle:hover { background: var(--chip); }
body.nav-collapsed .lnb { width: 0; border-right-color: transparent; }
body.nav-collapsed .lnb-toggle { left: 8px; transform: rotate(180deg); }
body.nav-collapsed .main { margin-left: 0; }

/* ---------- 메인/헤더 ---------- */
.main {
  margin-left: var(--lnb-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.18s ease;
}
.header {
  flex: 0 0 var(--header-h);
  height: var(--header-h);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 560px) auto;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 30;
}
.header-left { display: flex; align-items: center; gap: 12px; min-width: 0; overflow: hidden; }
.header-brand { display: none; }
.header-brand img { display: block; height: 24px; width: auto; }
.header-note { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn {
  display: none;
  width: 34px; height: 34px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--white); cursor: pointer;
}
.search-form {
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 6px 0 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--pill);
}
.search-form:focus-within { border-color: var(--cyan); box-shadow: var(--focus); }
.search-ico { color: var(--ink-3); font-size: 16px; }
.search-form input {
  flex: 1 1 auto; min-width: 0;
  border: 0; background: transparent; outline: none;
  font: inherit; font-size: 14px; color: var(--ink);
}
.search-form input::placeholder { color: var(--ink-dis); }
.search-btn {
  flex: 0 0 auto;
  height: 30px; padding: 0 16px;
  border: 0; border-radius: var(--pill);
  background: var(--ink); color: var(--white);
  font-size: 13px; font-weight: 700; cursor: pointer;
}
.search-btn:hover { background: #2c2b29; }
.header-right { display: flex; align-items: center; justify-content: flex-end; gap: 16px; }
.header-link { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.header-link:hover { color: var(--cyan); }
.auth-email {
  display: inline-block; vertical-align: middle;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; color: var(--ink-2); text-decoration: none;
}
.auth-email:hover { color: var(--ink); text-decoration: underline; }
.auth-email:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 4px; }
.header-notify { font-size: 15px; line-height: 1; position: relative; }
.header-notify[hidden] { display: none; }
.header-notify-badge {
  position: absolute;
  top: -6px; right: -9px;
  min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: var(--pill);
  background: var(--danger, #c0392b); color: var(--white, #fff);
  font-size: 9px; font-weight: 800; line-height: 15px; text-align: center;
  box-sizing: border-box;
}
.header-notify-badge[hidden] { display: none; }
.api-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--ink-dis); flex: 0 0 auto;
}
.api-dot.ok { background: var(--green); }
.api-dot.warn { background: var(--red); }

.content {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
}
.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 24px 28px 72px;
}
.page-wide { max-width: 1190px; }

/* 상단 통합 검색 결과 패널 */
.global-panel {
  position: absolute;
  top: calc(var(--header-h) - 4px);
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 32px));
  z-index: 50;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 14px;
}
.global-panel[hidden] { display: none; }
.global-panel .collect-box { border: 0; padding: 0; background: transparent; }
.global-panel .panel-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.global-panel .panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 반응형: 1100px 이하 LNB 접힘 ---------- */
@media (max-width: 1280px) {
  .header { gap: 12px; }
  .header-right { gap: 12px; }
}
@media (max-width: 1100px) {
  .lnb { transform: translateX(-100%); width: var(--lnb-w); box-shadow: var(--shadow); }
  body.nav-open .lnb { transform: none; }
  .main { margin-left: 0; }
  /* 모바일: ‹ 접기 버튼이 왼쪽 위에서 뒤로가기 버튼처럼 보여 숨긴다. 메뉴는 ☰(.menu-btn)가 연다. */
  .lnb-toggle { display: none; }
  body.nav-collapsed .lnb { width: var(--lnb-w); border-right-color: var(--line); }
  .menu-btn { display: grid; place-items: center; }
  .header-brand { display: inline; }
  .header-note { display: none; }
  .header { grid-template-columns: auto minmax(200px, 1fr) auto; padding: 0 16px; gap: 10px; }
  .header-link { display: none; }
}
@media (max-width: 720px) {
  .header-brand { display: none; }
  .search-btn { padding: 0 12px; }
  .page { padding: 18px 16px 64px; }
}
