:root {
  color-scheme: dark;
  --bg: #080a0b;
  --panel: #101416;
  --panel-active: #171d1f;
  --line: #263033;
  --text: #f2f0ec;
  --muted: #8d989e;
  --accent: #4fe0c0;
  --topbar-h: 68px;
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
body.lightbox-open { overflow: hidden; }
a { color: inherit; }
button, input { font: inherit; }
button { color: inherit; }
* { scrollbar-width: thin; scrollbar-color: #697177 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 99px; background: #697177; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background-color: #8d969c; }

.site-header { height: var(--topbar-h); display: flex; align-items: center; justify-content: flex-end; padding: 0 30px; border-bottom: 1px solid var(--line); background: #0b0e0f; }
.site-header nav { display: flex; align-items: center; height: 100%; gap: 4px; }
.site-header a { display: flex; align-items: center; height: 100%; padding: 0 18px; color: var(--muted); text-decoration: none; font-size: 16px; font-weight: 700; border-bottom: 3px solid transparent; }
.site-header a:hover, .site-header a.active { color: var(--text); border-color: var(--accent); }

.database-page { height: calc(100vh - var(--topbar-h)); min-height: 0; display: flex; flex-direction: column; }
.database-workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(310px, 32%) minmax(0, 1fr); }
.database-workspace > * { min-height: 0; }

.category-tabs { display: flex; align-items: center; gap: 6px; min-height: 62px; overflow-x: auto; padding: 0 26px; border-bottom: 1px solid var(--line); background: #0b0e0f; scrollbar-width: thin; }
.category-tabs button { flex: 0 0 auto; padding: 9px 14px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; }
.category-tabs button:hover { color: var(--text); background: #151b1d; }
.category-tabs button.active { color: var(--text); background: #1a2022; border-color: #3a4447; }

.result-pane { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #090c0d; }
.result-pane > header { padding: 22px 25px 12px; border-bottom: 1px solid var(--line); }
.result-pane h1 { margin: 0; font-size: 25px; letter-spacing: .02em; }
.count { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.search { display: flex; align-items: center; gap: 9px; margin: 14px 18px; padding: 0 12px; height: 42px; border: 1px solid #344043; border-radius: 8px; color: var(--muted); }
.search input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.search input::placeholder { color: #657176; }
.result-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.result-item { width: 100%; display: flex; text-align: left; gap: 14px; padding: 16px 20px; border: 0; border-top: 1px solid var(--line); background: transparent; cursor: pointer; }
.result-item:hover, .result-item.active { background: var(--panel-active); }
.result-item.active { box-shadow: inset 4px 0 0 var(--accent); }
.result-item img { flex: 0 0 84px; width: 84px; height: 62px; border-radius: 8px; object-fit: cover; background: #20282b; }
.result-item.portrait img { flex-basis: 102px; width: 102px; height: 102px; object-fit: cover; }
.result-item-content { display: block; min-width: 0; }
.result-item h2 { margin: 1px 0 7px; font-size: 17px; line-height: 1.35; color: var(--text); }
.result-item.portrait h2 { font-size: 20px; }
.result-item p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.empty-list { padding: 24px; color: var(--muted); }

.detail-pane { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 38px clamp(26px, 4vw, 68px) 72px; background: var(--bg); }
.empty { min-height: 100%; display: grid; place-content: center; gap: 9px; color: var(--muted); text-align: center; }
.empty b { color: var(--text); font-size: 23px; }

.video-detail { max-width: 1140px; margin: 0 auto; }
.detail-cover-button { display: block; width: 100%; max-width: 1100px; padding: 0; border: 0; border-radius: 13px; background: transparent; cursor: zoom-in; }
.video-detail .detail-cover { display: block; width: 100%; max-width: 1100px; aspect-ratio: 16 / 9; object-fit: contain; object-position: center; background: #050607; border: 1px solid var(--line); border-radius: 13px; }
.detail-meta { color: var(--accent); margin: 24px 0 9px; font-size: 14px; font-weight: 800; letter-spacing: .08em; }
.detail-title, .portrait-detail h1 { margin: 0; font-size: clamp(29px, 3.3vw, 48px); line-height: 1.18; letter-spacing: .01em; }
.detail-description, .portrait-copy { margin-top: 25px; white-space: pre-wrap; color: #c8ced0; font-size: 18px; line-height: 1.85; }
.source-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.source-links a { padding: 10px 13px; color: var(--accent); text-decoration: none; border: 1px solid #2e6258; border-radius: 8px; font-weight: 700; }
.source-links a:hover { background: #123a33; }

.portrait-detail { max-width: 1380px; }
.portrait-record { display: grid; grid-template-columns: minmax(260px, 39%) minmax(0, 1fr); column-gap: clamp(26px, 3.5vw, 58px); align-items: start; padding: 0 0 52px; margin: 0 0 52px; border-bottom: 1px solid var(--line); }
.portrait-record:last-child { margin-bottom: 0; border-bottom: 0; }
.portrait-gallery { display: grid; gap: 16px; }
.portrait-gallery button { display: block; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.portrait-gallery img { display: block; width: 100%; height: auto; max-height: none; object-fit: contain; object-position: top center; border-radius: 12px; background: #080a0b; border: 1px solid var(--line); }
.portrait-content .detail-meta { margin: 0 0 11px; }
.tagline { margin: 16px 0 0; color: var(--muted); font-size: 20px; line-height: 1.5; }
.portrait-copy { margin-top: 28px; max-width: 720px; }

.image-lightbox { position: fixed; z-index: 1000; inset: 0; overflow: hidden; background: rgb(0 0 0 / 90%); user-select: none; }
.image-lightbox[hidden] { display: none; }
.image-lightbox-viewport { position: absolute; inset: 0; overflow: auto; padding: 70px max(6vw, 28px) 86px; cursor: grab; text-align: center; touch-action: none; }
.image-lightbox-viewport:active { cursor: grabbing; }
.image-lightbox-viewport img { display: block; min-width: 280px; min-height: 100%; margin: 0 auto; object-fit: contain; filter: drop-shadow(0 28px 48px rgb(0 0 0 / 58%)); }
.image-lightbox-close { position: fixed; z-index: 1; top: 18px; right: 18px; width: 40px; height: 40px; border: 1px solid rgb(255 255 255 / 26%); border-radius: 50%; background: rgb(11 16 23 / 82%); color: #fff; cursor: pointer; font-size: 24px; line-height: 1; }
.image-lightbox-controls { position: fixed; z-index: 1; right: 50%; bottom: 18px; display: flex; min-height: 40px; align-items: center; gap: 6px; border: 1px solid rgb(255 255 255 / 15%); border-radius: 11px; padding: 5px 6px 5px 12px; background: rgb(13 15 18 / 90%); color: #a8adb5; font-size: 11px; transform: translateX(50%); }
.image-lightbox-controls span { margin-right: 5px; white-space: nowrap; }
.image-lightbox-controls strong { min-width: 48px; color: #e4e7eb; font-size: 11px; text-align: center; }
.image-lightbox-controls button { min-width: 30px; height: 30px; border: 1px solid #32363d; border-radius: 7px; padding: 0 8px; background: #17191d; color: #d6dae0; cursor: pointer; }
.image-lightbox-controls button:hover, .image-lightbox-close:hover { border-color: #477c6e; color: var(--accent); }

@media (max-width: 760px) {
  :root { --topbar-h: 57px; }
  .site-header { padding: 0 8px; justify-content: center; }
  .site-header a { padding: 0 14px; font-size: 14px; }
  .database-workspace { grid-template-columns: 1fr; grid-template-rows: minmax(245px, 41vh) minmax(0, 1fr); }
  .result-pane { border-right: 0; border-bottom: 1px solid var(--line); }
  .result-pane > header { padding: 13px 16px 6px; }
  .result-pane h1 { font-size: 21px; }
  .search { margin: 9px 12px; height: 37px; }
  .result-item { padding: 10px 14px; }
  .result-item img { flex-basis: 66px; width: 66px; height: 48px; }
  .result-item.portrait img { flex-basis: 56px; width: 56px; height: 56px; }
  .result-item h2 { font-size: 15px; margin-bottom: 3px; }
  .result-item p { font-size: 13px; }
  .category-tabs { min-height: 50px; padding: 0 8px; }
  .category-tabs button { padding: 7px 9px; font-size: 13px; }
  .detail-pane { padding: 25px 18px 50px; }
  .image-lightbox-controls { bottom: 10px; padding-left: 6px; }
  .image-lightbox-controls span { display: none; }
  .portrait-record { display: block; padding-bottom: 34px; margin-bottom: 34px; }
  .portrait-gallery { display: flex; overflow-x: auto; margin-bottom: 23px; }
  .portrait-gallery button { flex: 0 0 78%; }
  .portrait-copy { margin-top: 22px; }
  .tagline { font-size: 17px; }
  .detail-description, .portrait-copy { font-size: 16px; }
}
