/* ══ 유튜브 스타일 · 라이트/다크 자동 ══════════════════ */
:root {
  --bg: #fff;
  --bg-elev: #fff;
  --fg: #0f0f0f;
  --fg2: #606060;
  --fg3: #909090;
  --line: #e5e5e5;
  --chip: #f2f2f2;
  --chip-hover: #e5e5e5;
  --brand: #c8102e;          /* 매일신문 레드 */
  --like: #065fd4;
  --ok: #0f9d58;
  --warn: #d93025;
  --shadow: 0 1px 2px rgba(0,0,0,.1);
  --radius: 12px;
  --header-h: 76px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0f;
    --bg-elev: #212121;
    --fg: #f1f1f1;
    --fg2: #aaa;
    --fg3: #717171;
    --line: #303030;
    --chip: #272727;
    --chip-hover: #3f3f3f;
    --like: #3ea6ff;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Roboto", "Pretendard", -apple-system, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--brand); color: #fff; }

/* ── 헤더 ─────────────────────────────────────────── */
.yt-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid transparent;
}
.yt-header.scrolled { border-bottom-color: var(--line); }
.logo { display: flex; align-items: center; gap: 11px; flex-shrink: 0; }
.logo-mark {
  width: 44px; height: 31px; border-radius: 8px; background: var(--brand);
  display: grid; place-items: center; flex-shrink: 0;
}
.logo-mark::after {
  content: ''; width: 0; height: 0;
  border-left: 11px solid #fff; border-top: 7px solid transparent; border-bottom: 7px solid transparent;
  margin-left: 3px;
}
.logo-text { line-height: 1.15; }
.logo-text b { font-size: 24px; font-weight: 800; letter-spacing: -.9px; display: block; }
.logo-text span { font-size: 14px; color: var(--fg2); letter-spacing: -.3px; }

.searchbar { flex: 1; display: flex; justify-content: center; min-width: 0; }
.searchbar form {
  display: flex; width: 100%; max-width: 760px;
}
.searchbar input {
  flex: 1; min-width: 0;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 40px 0 0 40px; padding: 0 22px; height: 50px;
  outline: none; font-size: 18px;
}
.searchbar input:focus { border-color: var(--like); }
.searchbar button {
  width: 78px; height: 50px; cursor: pointer;
  background: var(--chip); border: 1px solid var(--line); border-left: 0;
  border-radius: 0 40px 40px 0; font-size: 20px;
}
.searchbar button:hover { background: var(--chip-hover); }

.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── 버튼 ─────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 18px;
  background: var(--chip); border: 0; cursor: pointer;
  font-size: 14px; font-weight: 500; white-space: nowrap;
}
.pill:hover { background: var(--chip-hover); }
.pill.on { background: var(--fg); color: var(--bg); }
.pill.outline { background: none; border: 1px solid var(--line); }
.pill.brand { background: var(--brand); color: #fff; }
.pill.brand:hover { filter: brightness(1.1); }
.pill.sm { height: 30px; padding: 0 12px; font-size: 13px; border-radius: 15px; }
.pill.danger { color: var(--warn); }
.pill.danger:hover:not(:disabled) { background: var(--warn); color: #fff; }
.pill:disabled { opacity: .5; cursor: default; }
.pill.liked { color: var(--like); }

/* ── 칩 필터 줄 ───────────────────────────────────── */
.chips {
  position: sticky; top: var(--header-h); z-index: 40;
  display: flex; gap: 12px; overflow-x: auto; padding: 12px 24px;
  background: var(--bg); border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

/* ── 홈 그리드 ────────────────────────────────────── */
.page { padding: 24px; max-width: 2000px; margin: 0 auto; }
.vgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  column-gap: 16px; row-gap: 40px;
}
.vcard { display: flex; flex-direction: column; gap: 12px; cursor: pointer; }
.vthumb {
  position: relative; aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(135deg, #3a3a3a, #1a1a1a);
  display: grid; place-items: center;
}
.vthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vthumb .ph { color: rgba(255,255,255,.6); font-size: 34px; font-weight: 700; letter-spacing: 1px; }
.vthumb .dur {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(0,0,0,.8); color: #fff; font-size: 12px; font-weight: 500;
  padding: 1px 4px; border-radius: 4px;
}
.vthumb .hidden-badge {
  position: absolute; left: 8px; top: 8px;
  background: var(--warn); color: #fff; font-size: 11px; font-weight: 600;
  padding: 2px 6px; border-radius: 4px;
}
.vcard .row { display: flex; gap: 12px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 15px;
}
.vmeta { min-width: 0; }
.vtitle {
  font-size: 16px; font-weight: 500; line-height: 1.4; margin: 0 0 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.vsub { font-size: 14px; color: var(--fg2); line-height: 1.4; }
.vsub .dot::before { content: '·'; margin: 0 4px; }

.empty { grid-column: 1/-1; text-align: center; color: var(--fg2); padding: 80px 0; }
.loading { text-align: center; color: var(--fg2); padding: 60px 0; }

/* ── 페이지 넘기기 ────────────────────────────────── */
.pager {
  display: flex; justify-content: center; align-items: center;
  gap: 6px; flex-wrap: wrap; margin: 40px 0 60px;
}
.pager .pill { min-width: 40px; padding: 0 12px; }
.pager .pill:disabled { opacity: .4; }
.pager .gap { color: var(--fg3); padding: 0 4px; }
@media (max-width: 700px) {
  .pager { gap: 4px; margin: 28px 0 40px; }
  .pager .pill { min-width: 36px; padding: 0 8px; font-size: 13px; }
}

/* ── 시청 페이지 ──────────────────────────────────── */
.watch { display: flex; gap: 24px; padding: 24px; max-width: 1754px; margin: 0 auto; }
.primary { flex: 1; min-width: 0; max-width: 1280px; }
.secondary { width: 402px; flex-shrink: 0; }

.player {
  aspect-ratio: 16/9; background: #000; border-radius: var(--radius); overflow: hidden;
}
.player video, .player iframe { width: 100%; height: 100%; display: block; border: 0; }
.player .fallback {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; color: #aaa; gap: 12px; text-align: center; padding: 20px;
}

h1.wtitle { font-size: 20px; font-weight: 700; line-height: 1.4; margin: 12px 0 0; }

.owner-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 12px 0; padding-bottom: 12px;
}
.owner { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 200px; }
.owner .avatar { width: 40px; height: 40px; font-size: 16px; }
.owner .name { font-size: 16px; font-weight: 500; }
.owner .sub { font-size: 12px; color: var(--fg2); }
.owner-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.infobox {
  background: var(--chip); border-radius: var(--radius); padding: 12px;
  font-size: 14px; margin-bottom: 24px;
}
.infobox .stats { font-weight: 600; margin-bottom: 4px; }
.infobox .note { color: var(--fg2); }

/* 심사 패널 */
.scorebox {
  border: 2px solid var(--brand); border-radius: var(--radius);
  padding: 16px; margin-bottom: 24px; background: var(--bg-elev);
}
.scorebox h3 { margin: 0 0 4px; font-size: 15px; }
.scorebox .hint { color: var(--fg2); font-size: 13px; margin: 0 0 14px; }
.scorerow { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.scorerow input[type=range] { flex: 1; min-width: 180px; accent-color: var(--brand); height: 24px; }
.scoreval { font-size: 32px; font-weight: 700; color: var(--brand); min-width: 62px; text-align: right; font-variant-numeric: tabular-nums; }
.scorebox .memo {
  width: 100%; margin-top: 12px; background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; outline: none;
}

/* 댓글 */
.chead { font-size: 20px; font-weight: 700; margin: 0 0 24px; }
.cinput { display: flex; gap: 16px; margin-bottom: 32px; }
.cinput .fields { flex: 1; min-width: 0; }
.cinput input, .cinput textarea {
  width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: 6px 0; outline: none; resize: none;
}
.cinput input:focus, .cinput textarea:focus { border-bottom: 2px solid var(--fg); }
.cinput input.nick { max-width: 200px; font-size: 13px; color: var(--fg2); margin-bottom: 8px; }
.cinput textarea { min-height: 28px; font-size: 14px; }
.cinput .btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

.clist { display: flex; flex-direction: column; gap: 16px; padding-bottom: 80px; }
.citem { display: flex; gap: 16px; }
.citem .cbody { min-width: 0; flex: 1; }
.citem .chead2 { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.citem .cnick { font-size: 13px; font-weight: 600; }
.citem .ctime { font-size: 12px; color: var(--fg2); }
.citem .ctext { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.citem .cdel {
  margin-left: auto; background: none; border: 0; color: var(--fg2);
  cursor: pointer; font-size: 12px; padding: 2px 6px; border-radius: 4px;
}
.citem .cdel:hover { background: var(--chip); }

/* 사이드바 (다음 영상) */
.sidehead { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.slist { display: flex; flex-direction: column; gap: 8px; }
.sitem { display: flex; gap: 8px; border-radius: 10px; padding: 4px; }
.sitem:hover { background: var(--chip); }
.sthumb {
  position: relative; width: 168px; height: 94px; border-radius: 8px; overflow: hidden; flex-shrink: 0;
  background: linear-gradient(135deg, #3a3a3a, #1a1a1a); display: grid; place-items: center;
}
.sthumb img { width: 100%; height: 100%; object-fit: cover; }
.sthumb .ph { color: rgba(255,255,255,.6); font-size: 20px; font-weight: 700; }
.sthumb .dur {
  position: absolute; right: 4px; bottom: 4px; background: rgba(0,0,0,.8); color: #fff;
  font-size: 11px; padding: 1px 4px; border-radius: 4px;
}
.sitem .stitle {
  font-size: 14px; font-weight: 500; line-height: 1.35; margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sitem .ssub { font-size: 12px; color: var(--fg2); line-height: 1.4; }

/* ── 로그인 카드 ──────────────────────────────────── */
.center-wrap { display: grid; place-items: center; min-height: calc(100vh - var(--header-h)); padding: 24px; }
.loginbox {
  width: 100%; max-width: 400px; background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow);
}
.loginbox h2 { margin: 0 0 6px; font-size: 22px; }
.loginbox p { margin: 0 0 24px; color: var(--fg2); font-size: 14px; }
.loginbox input {
  width: 100%; background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; margin-bottom: 12px; outline: none; font-size: 15px;
}
.loginbox input:focus { border-color: var(--like); }
.loginbox .pill { width: 100%; height: 44px; border-radius: 22px; }

/* ── 관리자 콘솔 ──────────────────────────────────── */
.tabbar {
  display: flex; gap: 4px; overflow-x: auto; padding: 0 24px;
  border-bottom: 1px solid var(--line); background: var(--bg);
  position: sticky; top: var(--header-h); z-index: 40; scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }
.tabbar button {
  background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer;
  padding: 14px 16px; font-size: 14px; font-weight: 500; color: var(--fg2); white-space: nowrap;
}
.tabbar button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--fg); }

.card {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 20px;
}
.card > h3 { margin: 0 0 4px; font-size: 16px; }
.card > .desc { margin: 0 0 16px; color: var(--fg2); font-size: 13px; line-height: 1.6; }
.card textarea, .card input[type=text], .card input[type=number], .card select {
  width: 100%; background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  outline: none; margin-bottom: 10px; font-size: 14px;
}
.card textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; line-height: 1.7; }
.card textarea:focus, .card input:focus { border-color: var(--like); }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* 한 명씩 등록 폼 */
.oneform {
  display: grid; gap: 10px; align-items: end;
  grid-template-columns: 110px 150px minmax(150px, 1fr) minmax(220px, 1.6fr) auto;
}
.oneform label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12px; color: var(--fg2); min-width: 0;
}
.oneform input { margin: 0; }
.oneform .pill { height: 40px; }
@media (max-width: 860px) {
  .oneform { grid-template-columns: 110px 1fr; }
  .oneform label:nth-child(3), .oneform label:nth-child(4) { grid-column: 1 / -1; }
  .oneform .pill { grid-column: 1 / -1; }
}

.detect { display: none; font-size: 13px; margin-top: 8px; }
.detect.on { display: block; color: var(--fg2); }
.detect.ok { color: var(--ok); }
.detect.err { color: var(--warn); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi span { display: block; font-size: 12px; color: var(--fg2); margin-bottom: 2px; }
.kpi b { font-size: 24px; font-variant-numeric: tabular-nums; }
.kpi.warn b { color: var(--warn); }

.tablewrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--bg-elev); color: var(--fg2); font-weight: 600; position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background: var(--chip); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.rank { font-weight: 700; }
td.wrap { white-space: normal; min-width: 140px; }
td input[type=text] { width: 100%; margin: 0; padding: 5px 8px; font-size: 13px; }
code.mono { font-family: ui-monospace, Consolas, monospace; background: var(--chip); padding: 2px 6px; border-radius: 4px; }

.msg { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin: 10px 0; display: none; }
.msg.show { display: block; }
.msg.err { background: rgba(217,48,37,.12); color: var(--warn); }
.msg.ok  { background: rgba(15,157,88,.12); color: var(--ok); }
.log {
  display: none; background: var(--chip); border-radius: 8px; padding: 12px;
  font-family: ui-monospace, Consolas, monospace; font-size: 12px; line-height: 1.7;
  max-height: 260px; overflow: auto; white-space: pre-wrap; margin-top: 10px;
}
.log.show { display: block; }

.banner {
  background: rgba(217,48,37,.12); color: var(--warn);
  padding: 10px 24px; font-size: 13px; text-align: center;
}

/* ── 반응형 ───────────────────────────────────────── */
@media (max-width: 1100px) {
  .watch { flex-direction: column; }
  .secondary { width: 100%; }
  .sthumb { width: 168px; height: 94px; }
}
/* 좁은 화면에서는 로고·검색을 단계적으로 줄인다 (우측 버튼 크기는 유지) */
@media (max-width: 1000px) {
  .logo-text b { font-size: 20px; }
  .logo-text span { font-size: 12px; }
  .logo-mark { width: 38px; height: 27px; }
  .searchbar input { height: 44px; font-size: 16px; padding: 0 18px; }
  .searchbar button { width: 64px; height: 44px; font-size: 18px; }
}
@media (max-width: 700px) {
  /* 로고 + 우측 버튼을 윗줄에, 검색은 아랫줄 전체 폭으로 내린다.
     한 줄에 다 넣으면 검색창이 30px 남짓으로 찌그러지고 버튼과 겹친다. */
  :root { --header-h: 100px; }
  .yt-header {
    flex-wrap: wrap; align-content: center;
    row-gap: 8px; padding: 8px 10px;
  }
  .logo { order: 1; }
  .header-right { order: 2; margin-left: auto; }
  .searchbar { order: 3; flex-basis: 100%; }
  .searchbar form { max-width: none; }

  .page, .watch { padding: 12px; }
  .chips { padding: 10px 12px; gap: 8px; }
  .vgrid { grid-template-columns: 1fr; row-gap: 24px; }
  .logo-text span { display: none; }
  .logo-text b { font-size: 17px; letter-spacing: -.7px; }
  .logo-mark { width: 30px; height: 21px; }
  .logo-mark::after { border-left-width: 8px; border-top-width: 5px; border-bottom-width: 5px; }
  .logo { gap: 7px; }
  .yt-header { gap: 8px; padding: 0 10px; }
  .searchbar input { height: 38px; font-size: 15px; padding: 0 14px; }
  .searchbar button { width: 48px; height: 38px; font-size: 16px; }
  .header-right .label { display: none; }
  .watch { padding: 0 0 24px; }
  .player { border-radius: 0; }
  .primary > *:not(.player) { padding-left: 12px; padding-right: 12px; }
  .secondary { padding: 0 12px; }
  h1.wtitle { font-size: 17px; }
  .sthumb { width: 140px; height: 79px; }
}
