/* ============ 토큰 ============ */
:root {
  color-scheme: light;
  --font: "Pretendard Variable", Pretendard, system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif;
  --page: #f5f5f3; --surface: #fff; --surface-2: #f7f7f5; --surface-3: #efeeeb;
  --text: #0b0b0b; --text-2: #52514e; --text-3: #6e6c66;
  --line: #e7e6e1; --line-2: #d9d8d2;
  --accent: #ffd60a; --accent-ink: #1a1600; --accent-text: #8a6100; --accent-weak: rgba(255, 214, 10, 0.18);
  --link: #1c5cab;
  --good: #0ca30c; --good-text: #006300; --good-weak: rgba(12, 163, 12, 0.1);
  --bad-text: #b42f2f; --bad-weak: rgba(208, 59, 59, 0.09);
  --c-ever: #d99a00; --c-ai: #7c5cff; --c-work: #2f80ed; --c-hot: #1baf7a; --c-info: #eb6834;
  --radius: 10px; --radius-sm: 6px;
  --shadow-pop: 0 12px 32px rgba(11, 11, 11, 0.14), 0 2px 6px rgba(11, 11, 11, 0.06);
  --sidebar-w: 232px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #20201f; --surface-3: #2a2a28;
    --text: #f0efec; --text-2: #c3c2b7; --text-3: #a3a198; --line: #2c2c2a; --line-2: #383835;
    --accent-text: #ffd60a; --accent-weak: rgba(255, 214, 10, 0.12); --link: #86b6ef;
    --good-text: #3fbf3f; --good-weak: rgba(12, 163, 12, 0.16); --bad-text: #ef7d7d; --bad-weak: rgba(208, 59, 59, 0.18);
    --c-ever: #ffd60a; --c-ai: #9d85ff; --c-work: #5a9cf0; --c-hot: #2cc98f; --c-info: #f08a5d;
    --shadow-pop: 0 16px 40px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #20201f; --surface-3: #2a2a28;
  --text: #f0efec; --text-2: #c3c2b7; --text-3: #a3a198; --line: #2c2c2a; --line-2: #383835;
  --accent-text: #ffd60a; --accent-weak: rgba(255, 214, 10, 0.12); --link: #86b6ef;
  --good-text: #3fbf3f; --good-weak: rgba(12, 163, 12, 0.16); --bad-text: #ef7d7d; --bad-weak: rgba(208, 59, 59, 0.18);
  --c-ever: #ffd60a; --c-ai: #9d85ff; --c-work: #5a9cf0; --c-hot: #2cc98f; --c-info: #f08a5d;
  --shadow-pop: 0 16px 40px rgba(0, 0, 0, 0.5);
}

/* ============ 기본 ============ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--c-work); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); }
.skip-link:focus { left: 8px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
svg { flex: none; }

/* ============ 레이아웃 ============ */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand__text { display: flex; flex-direction: column; line-height: 1.25; }
.brand__text strong { font-size: 15px; }
.brand__text small { color: var(--text-3); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.is-active { background: var(--accent-weak); color: var(--text); font-weight: 650; }
.nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav__count { margin-left: auto; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.meta-list { margin: auto 0 0; display: grid; gap: 8px; padding: 12px 8px 0; border-top: 1px solid var(--line); font-size: 12px; }
.meta-list div { display: flex; justify-content: space-between; gap: 8px; }
.meta-list dt { color: var(--text-3); }
.meta-list dd { margin: 0; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); }
.dot--live { background: var(--good); }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 28px; background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.topbar p { margin: 2px 0 0; color: var(--text-3); font-size: 13px; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }
.search { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; width: 260px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm); }
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--text-3); stroke-width: 1.7; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; }
.search kbd { font-size: 11px; color: var(--text-3); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
#main { outline: none; }
.view { padding: 24px 28px 64px; display: grid; gap: 20px; max-width: 1360px; }

/* ============ 공통 블록 ============ */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel__head h2 { margin: 0; font-size: 15px; }
.panel__head a, .panel__head span { font-size: 13px; }
.panel__body { padding: 16px 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { padding: 16px 18px; }
.kpi__label { color: var(--text-3); font-size: 13px; }
.kpi__value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi__sub { color: var(--text-3); font-size: 12px; }
.empty { padding: 28px 18px; text-align: center; color: var(--text-3); }
.empty strong { display: block; color: var(--text-2); margin-bottom: 4px; }

.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--cat, var(--text-3)); }
.chip--plain::before { display: none; }
.chip--good { background: var(--good-weak); color: var(--good-text); }
.chip--bad { background: var(--bad-weak); color: var(--bad-text); }
.chip--accent { background: var(--accent); color: var(--accent-ink); }
.cat-에버그린 { --cat: var(--c-ever); } .cat-AI { --cat: var(--c-ai); } .cat-직장인 { --cat: var(--c-work); } .cat-화제 { --cat: var(--c-hot); } .cat-실용정보 { --cat: var(--c-info); }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) 32px; align-items: center; gap: 10px; font-size: 13px; }
.bar-track { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--cat, var(--text-3)); border-radius: 999px; }

/* 툴바·필터 */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.seg { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 8px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; cursor: pointer; color: var(--text-2); font-size: 13px; font-weight: 500; }
.seg button.is-on { background: var(--surface); color: var(--text); font-weight: 650; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.select { height: 32px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); font-size: 13px; }
.toolbar__count { margin-left: auto; color: var(--text-3); font-size: 13px; }

/* 표 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--text-3); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.t-title { font-weight: 600; }
.t-angle { color: var(--text-3); font-size: 12.5px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.td-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.score { font-weight: 700; }

/* 리스트 */
.list { display: grid; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line); color: inherit; }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-item__main { flex: 1; min-width: 0; }
.list-item__title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 콘텐츠 갤러리 */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; text-align: left; padding: 0; transition: transform .15s ease, box-shadow .15s ease; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }
.card__cover { position: relative; aspect-ratio: 4 / 5; background: var(--surface-3); }
.card__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card__count { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.card__body { padding: 12px 14px 14px; display: grid; gap: 6px; }
.card__title { font-weight: 650; line-height: 1.35; }
.card__meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--text-3); font-size: 12px; }
.mini-gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 16px 18px; }
.mini-gallery .card__body { padding: 8px 10px 10px; }
.mini-gallery .card__title { font-size: 13px; }

/* 스캔 기록 */
.run { overflow: hidden; }
.run__head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.run__head h3 { margin: 0; font-size: 15px; }
.funnel { display: flex; gap: 6px; align-items: center; color: var(--text-2); font-size: 13px; margin-left: auto; }
.funnel b { color: var(--text); }
.run details { border-bottom: 1px solid var(--line); }
.run details:last-child { border-bottom: 0; }
.run summary { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto 44px; gap: 10px; align-items: center; padding: 10px 18px; cursor: pointer; list-style: none; }
.run summary::-webkit-details-marker { display: none; }
.run summary:hover { background: var(--surface-2); }
.run .note { padding: 0 18px 14px 98px; color: var(--text-2); font-size: 13px; }

/* 드로어 */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 21; box-shadow: var(--shadow-pop); overflow-y: auto; }
.drawer__inner { padding: 22px 24px 48px; display: grid; gap: 18px; }
.drawer__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.drawer h2 { margin: 6px 0 0; font-size: 22px; line-height: 1.3; letter-spacing: -0.02em; }
.close-btn { border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--radius-sm); width: 32px; height: 32px; cursor: pointer; font-size: 18px; line-height: 1; flex: none; }
.sec h4 { margin: 0 0 6px; font-size: 12px; color: var(--text-3); font-weight: 600; letter-spacing: .02em; }
.sec p { margin: 0; }
.sec ul, .sec ol { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.lead { font-size: 15px; font-weight: 550; }
.callout { background: var(--accent-weak); border-radius: var(--radius-sm); padding: 10px 12px; }
.score-grid { display: grid; gap: 7px; }
.score-row { display: grid; grid-template-columns: 82px minmax(0, 1fr) 54px; gap: 10px; align-items: center; font-size: 13px; }
.score-row .bar-fill { background: var(--c-ever); }
.votes { display: flex; gap: 12px; font-weight: 600; }
.comment { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 13px; color: var(--text); }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn--accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--accent:hover { background: #f5cc00; }

/* 콘텐츠 뷰어 */
.viewer { position: fixed; inset: 0; z-index: 30; background: rgba(8,8,8,.92); display: grid; grid-template-columns: minmax(0, 1fr) 380px; color: #f0efec; }
.viewer__stage { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px 64px; min-height: 0; }
.viewer__img { max-height: calc(100vh - 140px); max-width: 100%; aspect-ratio: 4 / 5; object-fit: contain; border-radius: 6px; background: #000; }
.viewer__nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; font-size: 22px; cursor: pointer; }
.viewer__nav:hover { background: rgba(255,255,255,.26); }
.viewer__nav:disabled { opacity: .25; cursor: default; }
.viewer__nav--prev { left: 14px; } .viewer__nav--next { right: 14px; }
.thumbs { display: flex; gap: 6px; overflow-x: auto; max-width: 100%; padding-bottom: 2px; }
.thumbs button { flex: none; width: 44px; aspect-ratio: 4 / 5; padding: 0; border: 2px solid transparent; border-radius: 4px; overflow: hidden; cursor: pointer; background: #222; opacity: .6; }
.thumbs button.is-on { border-color: #ffd60a; opacity: 1; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewer__side { background: var(--surface); color: var(--text); overflow-y: auto; padding: 22px 22px 40px; display: grid; gap: 16px; align-content: start; }
.viewer__side h2 { margin: 6px 0 0; font-size: 19px; line-height: 1.35; }
.caption { white-space: pre-wrap; background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; font-size: 13px; line-height: 1.6; max-height: 340px; overflow-y: auto; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* 취향 프로필 */
.md h2 { font-size: 16px; margin: 22px 0 8px; }
.md h1 { font-size: 18px; margin: 0 0 8px; }
.md ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.md p { margin: 0 0 8px; }

/* ============ 반응형 ============ */
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; gap: 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand__text small, .meta-list { display: none; }
  .nav { flex-direction: row; overflow-x: auto; width: 100%; }
  .nav a { flex: none; padding: 6px 10px; }
  .nav a svg { display: none; }
  .topbar { position: static; padding: 14px 16px; flex-wrap: wrap; }
  .search { width: auto; flex: 1; }
  .topbar__actions { width: 100%; }
  .view { padding: 16px 16px 48px; }
  .mini-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .viewer { display: block; overflow-y: auto; }
  .viewer__stage { padding: 16px 12px; }
  .viewer__img { width: 100%; max-height: none; height: auto; }
  .viewer__nav { top: calc(16px + (100vw - 24px) * 0.625); transform: translateY(-50%); }
  .viewer__nav--prev { left: 20px; } .viewer__nav--next { right: 20px; }
  .viewer__side { overflow: visible; }
  .run summary { grid-template-columns: 56px minmax(0, 1fr) 40px; }
  .run summary .chips { display: none; }
  .run .note { padding-left: 18px; }
}
@media (max-width: 560px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi__value { font-size: 22px; } .hide-sm { display: none; } }
