/* 공통 상단바 전용 CSS — 메인(app.css와 함께) / 도구(_nav.html에서 단독) 양쪽이 공유.
   상단바 전용 클래스(.appbar, .tb-btn, .drawer, .theme- 계열)만 담아 도구 페이지 콘텐츠와 충돌 없음.
   상단바가 쓰는 테마 변수만 정의(--bg 등 도구 콘텐츠 변수와 겹치는 건 제외).
   주의: 주석 안에 별표+슬래시 글자열을 쓰면 주석이 조기 종료돼 아래 라이트 변수 블록이
   통째로 파싱 탈락한다(도구 페이지 상단바 투명 버그의 원인이었음). */
:root, [data-theme="light"] {
  color-scheme: light;   /* 네이티브 위젯(달력·셀렉트·스크롤바)도 테마를 따르게 — 도구 페이지 포함 전 페이지 공통 */
  --bar:#1f2937; --bar-text:#fff; --accent:#4b5563; --accent-dark:#374151;
  --surface:#fff; --surface-2:#f9fafb; --text:#111827; --muted:#6b7280; --muted2:#9ca3af; --border:#e5e7eb;
  --danger:#dc2626;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bar:#0b1220; --bar-text:#fff; --accent:#64748b; --accent-dark:#475569;
  --surface:#1e293b; --surface-2:#172033; --text:#e5e7eb; --muted:#94a3b8; --muted2:#64748b; --border:#334155;
  --danger:#f87171;
}
[data-theme="basic"] {
  color-scheme: light;
  --bar:#6b5d4f; --bar-text:#fff; --accent:#8a7355; --accent-dark:#6f5b40;
  --surface:#fbf7ef; --surface-2:#efe7d6; --text:#3b3526; --muted:#7c7059; --muted2:#a99e86; --border:#e3d8c2;
}

header.appbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bar); color: var(--bar-text);
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 1px 4px rgba(0,0,0,.15); margin: 0;
}
header.appbar h1 { font-size: 1.05rem; margin: 0; font-weight: 700; flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* 우측 아이콘 버튼 묶음 (홈 · 메뉴) */
.tb-actions { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.tb-btn {
  background: rgba(255,255,255,.16); border: none; color: var(--bar-text);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  -webkit-tap-highlight-color: transparent; transition: background .15s, transform .1s;
}
.tb-btn:hover { background: rgba(255,255,255,.28); }
.tb-btn:active { transform: scale(.92); }
.tb-btn svg { width: 22px; height: 22px; display: block; }

.drawer-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 70; display: none; }
.drawer-back.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 264px; max-width: 82%;
  background: var(--surface); z-index: 71; transform: translateX(100%); transition: transform .22s ease;
  box-shadow: -2px 0 14px rgba(0,0,0,.18); display: flex; flex-direction: column; padding: 14px;
  overflow-y: auto;   /* 메뉴(섹션 라벨 포함)가 화면보다 길면 스크롤 */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
}
.drawer.open { transform: translateX(0); }
.drawer .divider { height: 1px; background: var(--border); margin: 10px 4px; }
.drawer a.danger { color: var(--danger); }
.drawer a { display: flex; align-items: center; gap: 12px; padding: 13px 10px; border-radius: 10px; text-decoration: none; color: var(--text); font-weight: 600; font-size: .95rem; }
.drawer a:active { background: var(--surface-2); }
.drawer a.tb-install { color: var(--accent); font-weight: 700; }   /* 설치 버튼(표시는 JS가 style.display로 제어) */

/* 드로어 상단: 로그인 사용자 + 닫기 */
.drawer-top { display: flex; align-items: center; gap: 8px; padding: 2px 2px 10px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.drawer-user { flex: 1 1 auto; display: flex; align-items: center; gap: 11px; padding: 6px 6px; border-radius: 12px; text-decoration: none; min-width: 0; }
.drawer-user:active { background: var(--surface-2); }
.drawer-avatar { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem; }
.drawer-user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.drawer-user-name { font-weight: 700; font-size: 1rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-user-sub { font-size: .78rem; color: var(--muted); }
.drawer-close { flex: 0 0 auto; background: none; border: none; font-size: 1.5rem; line-height: 1; color: var(--muted2); cursor: pointer; width: 38px; height: 38px; border-radius: 8px; position: relative; }
.drawer-close::after { content: ""; position: absolute; inset: -5px; }   /* 터치 영역 확장 */
.drawer-close:active { background: var(--surface-2); }

/* 드로어 하단으로 밀어내기(설치/로그아웃을 바닥에 고정) */
.drawer-spacer { flex: 1 1 auto; min-height: 8px; }

/* 테마 세그먼트 */
.drawer-section-label { font-size: .74rem; font-weight: 700; color: var(--muted); padding: 2px 6px 5px; margin-top: 10px; letter-spacing: .02em; }
.drawer a { padding: 11px 10px; }   /* 메뉴가 많아 한 줄 높이를 살짝 줄임(터치 44px 근처 유지) */
.theme-seg { display: flex; gap: 6px; padding: 0 2px; }
.theme-btn { flex: 1 1 0; padding: 9px 0; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 9px; font-size: .82rem; font-weight: 600; cursor: pointer; }
.theme-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
