/* 앱 셸: 사이드바 · 상단 바 · 본문 · 푸터 · 하단 플레이어 자리 */

/* basic 테마가 잡아둔 구조 id 초기화 (SPA 코어가 쓰는 id는 그대로 유지) */
#wrapper, #container_wr, #container { width: auto; max-width: none; min-height: 0; margin: 0; padding: 0; float: none; background: none; border: 0; }
#container { max-width: 1240px; margin: 0 auto; padding: 8px 32px 0; }

html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
.th-app a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.th-skip { position: absolute; left: -9999px; top: 8px; z-index: 100; padding: 8px 14px; border-radius: var(--r-md); background: var(--surface); }
.th-skip:focus { left: 8px; }
.th-ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.th-app { display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); min-height: 100vh; }
html.th-ready .th-app { transition: grid-template-columns .2s ease; }
html[data-sb="collapsed"] { --sb-w: 72px; }

/* ---- 사이드바 ---- */
.th-sb { position: relative; z-index: 30; background: var(--surface); border-right: 1px solid var(--line); }
.th-sb-in { position: sticky; top: 0; max-height: 100vh; overflow-x: hidden; overflow-y: auto; padding: 20px 12px; }
.th-logo { display: flex; align-items: center; min-height: 44px; margin-bottom: 12px; padding: 0 14px; font-family: var(--font-display); font-size: 21px; font-weight: 700; }
.th-logo-mark { display: none; width: 44px; height: 44px; align-items: center; justify-content: center; border-radius: var(--r-lg); background: var(--accent); color: var(--on-accent); font-family: var(--font); font-size: 18px; }
.th-nav a { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 14px; border-radius: var(--r-md); color: var(--text-2); font-weight: 500; white-space: nowrap; }
.th-nav a:hover { background: var(--surface-2); }
.th-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
.th-group { margin: 20px 14px 6px; color: var(--muted); font-size: 12px; font-weight: 500; }
html[data-topmenu="on"] .th-nav-main { display: none; }

.th-overlay { display: none; }
.th-fold { position: absolute; top: 50%; right: -14px; z-index: 31; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--text-2); cursor: pointer; }
.th-fold svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
html[data-sb="collapsed"] .th-fold svg { transform: rotate(180deg); }

@media (min-width: 901px) {
  /* 접힌 사이드바: 아이콘만 남긴다 */
  html[data-sb="collapsed"] .th-logo { justify-content: center; padding: 0; }
  html[data-sb="collapsed"] .th-logo-text,
  html[data-sb="collapsed"] .th-nav a span { display: none; }
  html[data-sb="collapsed"] .th-logo-mark { display: flex; }
  html[data-sb="collapsed"] .th-nav a { justify-content: center; padding: 0; }
  html[data-sb="collapsed"] .th-group { height: 1px; margin: 10px 12px; background: var(--line); font-size: 0; }
  html[data-sb="collapsed"] .th-nav-main + .th-group { display: none; }
}

/* ---- 상단 바 ---- */
.th-body { min-width: 0; }
.th-top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; height: var(--top-h); padding: 0 32px; background: var(--bg); }
.th-topnav { display: flex; gap: 22px; color: var(--muted); font-weight: 500; }
.th-topnav a { display: flex; align-items: center; height: var(--top-h); box-shadow: inset 0 -2px 0 transparent; }
.th-topnav a:hover { color: var(--text); }
.th-topnav a[aria-current="page"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
html[data-topmenu="off"] .th-topnav { display: none; }
.th-grow { flex: 1; }
.th-search input { width: 220px; height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
.th-icon-btn { display: grid; place-items: center; min-width: 44px; height: 44px; padding: 0; border: 0; border-radius: 22px; background: none; color: var(--text); cursor: pointer; }
.th-icon-btn:hover { background: var(--surface-2); }
.th-burger { display: none; }
.th-btn { display: inline-flex; align-items: center; height: 40px; padding: 0 18px; border: 1px solid var(--accent); border-radius: var(--r-pill); background: var(--accent); color: var(--on-accent) !important; font-size: 14px; font-weight: 500; white-space: nowrap; }
.th-btn-ghost { border-color: var(--line); background: var(--surface); color: var(--text) !important; }

/* ---- 푸터 · 하단 플레이어 자리 ---- */
.th-footer { margin-top: 56px; padding: 32px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.th-footer-nav { display: flex; flex-wrap: wrap; gap: 16px; }
.th-copy { margin: 12px 0 0; }

.th-dock { position: fixed; right: 0; bottom: 0; left: 0; z-index: 40; pointer-events: none; }
.th-dock > * { pointer-events: auto; }
html[data-player-mode="floating"] .th-dock { display: none; }
html[data-player-active="on"] .th-body { padding-bottom: 96px; }
/* 플레이어가 하단 바 모양을 쓸 때 붙이는 클래스 */
.th-dock .dock-bar { display: flex; align-items: center; gap: 12px; height: 72px; margin: 0 16px 16px; padding: 0 16px; border-radius: 18px; background: var(--dock-bg); color: var(--dock-text); box-shadow: var(--shadow); }

/* ---- 테마 옵션 모달 (관리자) ---- */
.th-modal { width: min(720px, 94vw); height: min(86vh, 780px); max-width: none; padding: 0; overflow: hidden; border: 0; border-radius: var(--r-xl); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.th-modal[open] { display: flex; flex-direction: column; }
.th-modal::backdrop { background: rgba(0, 0, 0, .5); }
.th-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 24px; border-bottom: 1px solid var(--line); }
.th-modal-head h2 { margin: 0; font-size: 17px; }
.th-modal-frame { flex: 1; width: 100%; border: 0; background: var(--bg); }

/* ---- 좁은 화면: 사이드바는 서랍으로 ---- */
@media (max-width: 900px) {
  .th-app { grid-template-columns: minmax(0, 1fr); }
  .th-sb { position: fixed; top: 0; bottom: 0; left: 0; width: 272px; transform: translateX(-100%); transition: transform .2s ease; }
  html[data-drawer="open"] .th-sb { transform: none; }
  .th-sb-in { height: 100%; max-height: none; }
  .th-fold, .th-topnav { display: none; }
  .th-nav-main { display: block !important; }
  .th-burger { display: grid; }
  html[data-drawer="open"] .th-overlay { position: fixed; inset: 0; z-index: 20; display: block; background: rgba(0, 0, 0, .45); }
  .th-top { gap: 8px; padding: 0 12px; }
  .th-search input { width: 130px; }
  .th-btn-ghost { display: none; }
  #container { padding: 8px 16px 0; }
  .th-footer { padding: 24px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html.th-ready .th-app, .th-sb { transition: none; }
}
