/* =========================
   Global
========================= */
:root { 
  --strip-h: 56px; 
  --panel-w: 420px;   /* 오른쪽 패널 너비 */
  --gap: 16px;        /* 패널과 드로어 사이 여백 */
  --drawer-w: 320px;  /* 드로어 너비 (원하면 조절) */
  --drawer-top: 100px; /* 상단 여백(헤더/툴바 높이에 맞춰 조절) */
  }
  
html, body {
  margin: 0;
  height: 100%;
  font-family: ui-sans-serif, system-ui, 'Noto Sans KR', Arial;
  overflow: hidden;
}

#app { display: grid; grid-template-columns: 1fr 420px; height: calc(100vh - var(--strip-h)); }
#map { position: relative; width: 100%; height: 100%; }

/* =========================
   Layout / Utilities
========================= */
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.g-6 { gap: 6px; }
.mt-2 { margin-top: 2px; }

.badge { font-size: 13px; border: 1px solid #e5e7eb; border-radius: 999px; padding: 4px 10px; }
button, select { font-size: 14px; cursor: pointer; }
h3, h4 { margin: 0; }

/* =========================
   Panel / Cards
========================= */
#panel {
  border-left: 1px solid #e5e7eb;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 10px;
  padding: 14px;
  overflow: hidden;
}

.card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  overflow: auto;
  z-index: 600;
}

.muted { color: #6b7280; }
.section-title { margin-top: 10px; font-weight: 600; }

/* =========================
   Buttons
========================= */
.primary-btn {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
}
.primary-btn:disabled { opacity: .5; cursor: not-allowed; }

.ghost-btn {
  background: #fff;
  color: #374151;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 12px;
}

.icon-btn {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 6px 10px;
  line-height: 1;
}

.toggled { background: #111827; color: #fff; border-color: #111827; }
:root[data-theme="dark"] .toggled { background: #f1f5f9; color: #0b0f19; border-color: #f1f5f9; }

/* =========================
   Search Drawer
========================= */
#authorListDrawer {
  position: fixed;
  /* 패널 왼쪽에 오도록, 오른쪽에서 패널 너비만큼 비우고 gap만큼 추가 여백 */
  top: var(--drawer-top); right: calc(var(--panel-w) + var(--gap));
  width: var(--drawer-w); max-height: calc(100vh - var(--drawer-top) - 24px); height: 72vh;
  overflow: auto;
  z-index: 100; display: none;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
  border-radius: 14px; overflow: hidden; background: #fff;
  padding-bottom: 64px;
}

/* 드로어 안에서 스크롤을 실제로 담당할 영역 */
#authorListDrawer .drawer-body{
  overflow:auto;          /* 여기가 스크롤 */
  min-height:0;           /* 중요: 내부 스크롤 허용 */
}

/* 오른쪽 패널이 grid 영역이라면, 내부 스크롤 허용 처리 */
#panel{
  overflow:hidden;        /* 패널은 숨김 유지해도 OK */
}
#panel > *{
  min-height:0;           /* 자식들이 스크롤 가질 수 있게 */
}

#authorListDrawer .drawer-header {
  padding: 10px 12px;
  display: flex; justify-content: space-between; align-items: center;
  background: #f8fafc; border-bottom: 1px solid #e5e7eb;
}
#authorListPane { height: 100%; display: flex; flex-direction: column; }
#authorList { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 10px; overflow: auto; text-align: left; }

.author-item {
  display: flex; align-items: center; justify-content: flex-start;  /* ✅ 가운데/양끝 정렬 방지 */
  gap: 10px;
  width: 100%; box-sizing: border-box;                              /* ✅ 카드는 항상 같은 폭 */
  border: 1px solid #eee; border-radius: 10px;
  padding: 10px; background: #fff;
  text-align: left; 
}
.author-item[tabindex] { outline: none; }
.author-item.focused { border-color: #2563eb; background: #eff6ff; }
.author-item .meta { display: flex; align-items: center; gap: 8px; }
.author-item.selected { border-color: #2563eb; background-color: #eff6ff; box-shadow: 0 0 0 2px #93c5fd inset; }
.author-item:hover { background-color: #f9fafb; transform: translateY(-1px); } 
.author-item.selected:hover { background-color: #dbeafe; }
#authorList .author-item img.portrait { 
  width: 36px; height: 36px; object-fit: cover; object-position: top;
  border-radius: 8px; flex: 0 0 auto; 
}

/* =========================
   Author Info / Timeline
========================= */
#authorInfo { max-height: 330px; }

.author-actions-bottom { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

/* timeline list */
#timelinePane { min-height: 220px; }
#timeline { list-style: none; margin: 8px 0 0; padding: 0; }
#timeline li {
  border: 1px solid #eee; border-radius: 10px;
  padding: 10px; margin: 8px 0; cursor: pointer;
}
#timeline li.active { border-color: #2563eb; background: #eff6ff; }
#timeline .ord {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 999px;
  background: #111827; color: #fff; font-size: 12px; margin-right: 8px;
}

/* images */
.thumb { width: 90px; height: auto; border-radius: 6px; margin-top: 6px; cursor: pointer; }

/* portrait image inside author info */
img.thumb.portrait {
  width: 92px; height: 92px;
  object-fit: cover; object-position: top;
  float: right; border-radius: 10px; margin-left: 10px; cursor: pointer;
}

/* author text helpers */
.author-name { font-size: 1rem; font-weight: 600; line-height: 1.2; }
.author-bio { margin: 8px 0 0; color: #4b5563; line-height: 1.6; }
.ext-link { color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* link lists */
.link-list { margin: 8px 0 0; padding-left: 16px; }
.link-list li { margin: 4px 0; }

/* =========================
   Lightbox
========================= */
#lightbox {
  position: fixed; inset: 0; display: none;
  background: rgba(0,0,0,.72);
  align-items: center; justify-content: center;
  z-index: 1000; padding: 16px; box-sizing: border-box;
}
#lightbox.show { display: flex; }

#lightboxInner {
  display: grid; grid-template-rows: auto auto; gap: 12px;
  background: #111; color: #f1f5f9;
  border-radius: 12px; padding: 14px; overflow: hidden;
  /* max-width / max-height는 JS에서 계산 */
}

#lightboxImg {
  display: block; width: auto; height: auto; object-fit: contain;
  max-width: 100vw;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  background: #111; border-radius: 10px;
}

#lightboxCaption {
  max-width: min(92vw, 900px);
  margin: 12px auto 0;
  white-space: pre-wrap; line-height: 1.6; text-align: left;
  color: #f1f5f9; overflow: auto;
}

/* =========================
   Year HUD
========================= */
#yearHUD {
  position: absolute; top: 14px; left: 36%; transform: translateX(-50%);
  z-index: 200; pointer-events: none;
}
.yearHUD-inner {
  font-weight: 800; font-size: 56px; line-height: 1; color: #6b7280;
  background: linear-gradient(135deg, rgba(255,255,255,.95), rgba(255,255,255,.78));
  border: 1px solid rgba(0,0,0,.05); border-radius: 16px; padding: 10px 18px;
  box-shadow: 0 10px 24px rgba(17,24,39,.10), inset 0 1px 0 rgba(255,255,255,.6);
  backdrop-filter: blur(8px);
}
.year-pop { animation: yearPop .36s cubic-bezier(.2,.8,.2,1); }
@keyframes yearPop {
  0% { transform: scale(.85); opacity: 0; }
  40% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* =========================
   Bottom Event Strip
========================= */
#eventStrip {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--strip-h);
  background: rgba(255,255,255,.92); backdrop-filter: blur(6px);
  border-top: 1px solid #e5e7eb; padding: 8px 10px; z-index: 61;
  display: flex; align-items: center; gap: 12px;
}
.strip-title { font-weight: 700; }
.strip-left { display: flex; align-items: center; gap: 10px; min-width: 320px; }

.strip-viewport { position: relative; flex: 1; height: 40px; overflow: hidden; }
.strip-track {
  position: absolute; left: 0; right: 0; top: 0; height: 40px;
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap; padding: 0 48vw;
}

.evt {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border: 1px solid #e5e7eb; border-radius: 999px;
  background: #fff; color: #111827; font-size: 12px;
  opacity: .55;
  transition: transform .16s ease, opacity .16s ease, box-shadow .16s ease, border-color .16s ease;
  user-select: none;
}
.evt .y { font-weight: 800; }
.evt.birth .y { color: #10b981; }
.evt.death .y { color: #ef4444; }
.evt.active {
  opacity: 1; transform: scale(1.08);
  border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.18);
}
.evt .txt { opacity: .85; }
.evt.active .txt { opacity: 1; font-weight: 700; }

.strip-center-marker {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 2px; transform: translateX(-1px);
  background: rgba(37,99,235,.85); border-radius: 2px; pointer-events: none;
}
.muted-tip { font-size: 12px; color: #6b7280; }

/* =========================
   Chips
========================= */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border: 1px solid #e5e7eb; border-radius: 999px;
  font-size: 12px; color: #374151; background: #fff; cursor: pointer; user-select: none;
}
.chip:hover { background: #f9fafb; }
.chip.selected { border-color: #2563eb; color: #1d4ed8; background: #eff6ff; }

/* =========================
   Mobile
========================= */
@media (max-width: 960px) {
  #app { grid-template-columns: 1fr; }
  #panel {
    position: absolute; bottom: var(--strip-h); left: 0; right: 0; height: 52vh;
    background: rgba(255,255,255,.98); backdrop-filter: blur(6px);
  }
  :root[data-theme="dark"] #panel { background: rgba(17,24,39,.92); }
}

/* =========================
   Dark Mode
========================= */
:root[data-theme="dark"] body { background: #0b0f19; color: #e5e7eb; }
:root[data-theme="dark"] .card { background: #111827; border-color: #374151; }
:root[data-theme="dark"] #panel { border-left-color: #374151; }
:root[data-theme="dark"] .muted { color: #9ca3af; }
:root[data-theme="dark"] #eventStrip { background: rgba(17,24,39,.86); border-color: #374151; }
:root[data-theme="dark"] .evt { background: #0f172a; border-color: #334155; color: #e5e7eb; }
:root[data-theme="dark"] .evt.active { border-color: #60a5fa; box-shadow: 0 0 0 2px rgba(96,165,250,.25); }
:root[data-theme="dark"] .strip-center-marker { background: rgba(96,165,250,.9); }

/* ========== Tags in search result ========== */
.tags { margin-top: 4px; }
.tag-wrap { display: flex; flex-wrap: wrap; gap: 6px; position: relative; }
.tag {
  font-size: 12px;
  color: #374151;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 2px 8px;
}
.tag-wrap.collapsed {
  max-height: 42px;         /* 약 2줄 */
  overflow: hidden;
}
.tag-wrap.collapsed::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 24px;
  background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,1));
  pointer-events: none;
}
.tag-toggle {
  margin-top: 6px;
  font-size: 12px;
  border: none;
  background: transparent;
  color: #2563eb;
  cursor: pointer;
  padding: 0;
}

.tag.selected {
  background-color: #2563eb; /* 상단 칩 선택 색상 */
  color: white;
  border-color: #2563eb;
}

/* Dark mode */
:root[data-theme="dark"] .tag {
  background: #0f172a;
  border-color: #334155;
  color: #e5e7eb;
}
:root[data-theme="dark"] .tag-wrap.collapsed::after {
  background: linear-gradient(to bottom, rgba(0,0,0,0), rgba(17,24,39,1));
}

/* 칩바: 스크롤바 안 보이게 */
#categoryTabs .chip[aria-selected="true"],
#categoryTabs .chip.selected{
  border-color:#2563eb;
  background:#eff6ff;
  color:#1d4ed8;
  font-weight:700;
  box-shadow:0 0 0 2px rgba(37,99,235,.15) inset;
}

/* 포커스 링(키보드 접근성) */
#categoryTabs .chip:focus-visible{
  outline:2px solid #60a5fa;
  outline-offset:2px;
}

#categoryTabs.chipbar{
  display:flex; gap:8px; overflow-x:auto; padding:6px 2px;
  border-bottom:1px solid #eee; margin-bottom:8px;
  -ms-overflow-style: none;     /* IE/Edge */
  scrollbar-width: none;        /* Firefox */
}
#categoryTabs.chipbar::-webkit-scrollbar{ display:none } /* Chrome/Safari */

#categoryTabs.chipbar.dragging { cursor: grabbing; user-select: none; }

#categoryTabs .chip{
  display: inline-flex;
  align-items: center;
  white-space: nowrap;               /* 줄바꿈 방지 */
  touch-action: manipulation;
  pointer-events: auto;        /* 탭 지연 줄이기 */
}

/* 재사용: media grid (이미 있으면 생략) */
.media-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(140px,1fr));
  gap:10px;
}
.media-card{border:1px solid #e5e7eb;border-radius:10px;overflow:hidden;background:#fff;display:flex;flex-direction:column}
.media-card .thumb{width:100%;aspect-ratio:4/3;object-fit:cover;display:block}
.media-card .body{padding:8px}
.media-card .title{font-size:13px;font-weight:600;line-height:1.3}
.media-card .desc{font-size:12px;color:#6b7280;margin-top:4px}
.link-card{display:flex;align-items:center;gap:8px;padding:10px;text-decoration:none}
.link-card:hover{background:#f9fafb}
.link-card .favicon{width:16px;height:16px;flex:0 0 16px}

/* 음악 상세 */
.media-detail h2 { margin: 0 0 10px; font-size: 20px; line-height: 1.35; }
.media-detail .desc { margin: 8px 0 14px; opacity: .95; }

.yt-embed iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 10px;
  display: block;
  background: #000;
}

    .empty-state {
    padding: 16px 20px;
    border: 1px dashed #e5e7eb;
    border-radius: 12px;
    background: #fafafa;
    color: #333;
  }
  .empty-title {
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 15px;
  }
  .empty-desc {
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
  }
  .empty-detail {
    font-size: 12px;
    color: #777;
    margin-bottom: 12px;
    line-height: 1.4;
  }
  .empty-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .btn-empty {
    background: #111;
    color: #fff;
    border: 1px solid #111;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s;
  }
  .btn-empty:hover { background: #333; }
  .btn-empty.btn-outline {
    background: #fff;
    color: #111;
  }
  .btn-empty.btn-outline:hover {
    background: #f3f4f6;
  }

    /* 제안 카드 영역을 일반 목록과 같은 플로우로 */
  .empty-suggestions .sugg-list.as-cards {
    display: grid;
    grid-template-columns: 1fr; /* 한 줄형: 필요하면 1fr 1fr 로 2열 */
    gap: 8px;
    margin-top: 8px;
  }

  /* compact 카드 사이즈 */
  .author-item.compact .portrait.tiny {
    width: 36px; height: 36px; border-radius: 6px; object-fit: cover;
  }
  .author-item.compact .tags,
  .author-item.compact .tag-toggle { display: none; }  /* compact는 태그 숨김 */
  .author-item.compact .author-name { font-weight: 600; }


:root[data-theme="dark"] .media-detail .link-btn {
  background: #0f172a; border-color: #334155; color: #e5e7eb;
  }


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

/* Lightbox width up */
#lightbox .lb-inner,
#lightbox #lightboxInner {
  max-width: 980px;   /* 기존보다 넉넉하게 */
}

#miniNowPlaying {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 500;
  width: min(360px, 38vw);
  box-shadow: 0 8px 18px rgba(0,0,0,.28);
  border-radius: 12px;
  background: var(--card-bg, #fff);
  border: 1px solid rgba(0,0,0,.06);
  overflow: hidden;
}

#miniNowPlaying .mnp-inner { display: grid; grid-template-rows: auto 1fr; }
#miniNowPlaying .mnp-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: rgba(0,0,0,.04);
}
#miniNowPlaying .mnp-icon { opacity:.75 }
#miniNowPlaying .mnp-title {
  flex: 1; font-size: 13px; line-height: 1.2; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; color: #111827;
}
#miniNowPlaying .mnp-actions { display:flex; gap:6px; }
#miniNowPlaying .mnp-frame { aspect-ratio: 16/9; background:#000; }

@media (max-width: 560px){
  #miniNowPlaying { width: min(300px, 70vw); right: 8px; bottom: 8px; }
}

#miniNowPlaying iframe {
  position:absolute; inset:0; width:100%; height:100%;
  border:0;
}

