/* 구조: 상단 텍스트 메뉴 + 한 단 본문. 홈은 "이어 보기"의 큰 시간 표시가 주인공이고, 나머지는 조용하게.
   색: 차가운 회색 바탕, 잉크색 글자, 소나무 초록은 시청 위치와 현재 위치에만 씀.
   글꼴: 굵은 디스플레이(제목, 시간 숫자) + 본문 고딕. 고정폭 글꼴은 쓰지 않음. */

:root {
  --bg: #eceeeb;
  --surface: #f7f8f6;
  --surface-2: #dde1dc;
  --ink: #111412;
  --muted: #59615c;
  --line: #cbd0cb;
  --accent: #0f7b57;
  --accent-ink: #ffffff;
  --danger: #b8352b;
  --display: "Black Han Sans", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --font: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  --gl: max(20px, env(safe-area-inset-left, 0px));
  --gr: max(20px, env(safe-area-inset-right, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d100e;
    --surface: #151917;
    --surface-2: #1d2220;
    --ink: #e8ebe7;
    --muted: #8a928d;
    --line: #272c29;
    --accent: #55d4a6;
    --accent-ink: #06140e;
    --danger: #ff8176;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d100e;
  --surface: #151917;
  --surface-2: #1d2220;
  --ink: #e8ebe7;
  --muted: #8a928d;
  --line: #272c29;
  --accent: #55d4a6;
  --accent-ink: #06140e;
  --danger: #ff8176;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); background: var(--bg); z-index: 40; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }

.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding-left: var(--gl); padding-right: var(--gr); }

/* ---------- 상단 ---------- */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 34px; height: 62px; }
.brand { font: 400 23px/1 var(--display); letter-spacing: -0.02em; white-space: nowrap; }
.topnav { display: flex; gap: 26px; align-self: stretch; }
.topnav a { position: relative; display: flex; align-items: center; color: var(--muted); font-weight: 500; }
.topnav a:hover { color: var(--ink); }
.topnav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.topnav a[aria-current="page"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--accent); }
.search { margin-left: auto; flex: 0 1 340px; min-width: 0; }
.search input {
  width: 100%; height: 38px; padding: 0 2px;
  background: none; border: 0; border-bottom: 1.5px solid var(--line); border-radius: 0; outline: none;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-bottom-color: var(--ink); }
#acct { flex: none; }

.textbtn { background: none; border: 0; padding: 6px 0; color: var(--accent); font-weight: 600; }
.textbtn:hover { text-decoration: underline; text-underline-offset: 3px; }
.acctbtn { display: inline-flex; align-items: center; max-width: 150px; padding: 6px 0; background: none; border: 0; font-weight: 600; }
.acctbtn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acctbtn::after { content: ""; flex: none; margin: -3px 0 0 8px; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 38px; padding: 0 18px;
  background: transparent; border: 1.5px solid var(--ink); border-radius: 2px;
  font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--ink); color: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.1); background: var(--accent); color: var(--accent-ink); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: var(--bg); }
.btn[disabled] { opacity: 0.55; cursor: default; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 46px; z-index: 50; width: 268px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 3px;
  box-shadow: 0 10px 28px rgba(8, 10, 9, 0.16);
}
.menu .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 10px; background: none; border: 0; border-radius: 2px; text-align: left; }
.menu button.row:hover { background: var(--surface-2); }
.menu .row.danger { color: var(--danger); }
.menu .hint { padding: 0 10px 8px; color: var(--muted); font-size: 12.5px; }
.menu .sep { height: 1px; margin: 4px 0; background: var(--line); }
.switch { flex: none; position: relative; width: 36px; height: 20px; padding: 0; border: 0; border-radius: 999px; background: var(--line); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); transition: transform 0.15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); background: var(--accent-ink); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 4px 10px; font-size: 12.5px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* ---------- 본문 ---------- */
.page { padding-top: 44px; padding-bottom: 120px; min-height: 70vh; }
.sec { margin-bottom: 68px; }
.sec-head { margin-bottom: 24px; }
.sec-head h2, .page-title { font: 400 31px/1.15 var(--display); letter-spacing: -0.02em; }
.page-title { margin-bottom: 26px; }
.page-title .q { color: var(--accent); }
.prompt { margin-bottom: 48px; color: var(--muted); }

/* 영상 한 칸 */
.thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dur { position: absolute; right: 0; bottom: 0; padding: 1px 7px; background: rgba(8, 10, 9, 0.84); color: #fff; font: 600 12px/1.7 var(--font); font-variant-numeric: tabular-nums; }
.has-bar .dur { bottom: 4px; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(8, 10, 9, 0.55); }
.bar i { display: block; height: 100%; background: var(--accent); }
.tc { position: absolute; left: 0; bottom: 4px; padding: 10px 18px 6px 16px; background: var(--bg); color: var(--ink); font: 400 46px/1 var(--display); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.tc small { margin-left: 9px; color: var(--muted); font: 500 15px var(--font); letter-spacing: 0; }

.who { margin-top: 5px; font-size: 13px; font-weight: 500; }
.stat { display: flex; flex-wrap: wrap; gap: 0 14px; margin-top: 1px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.why { margin-top: 6px; color: var(--accent); font-size: 12.5px; font-weight: 500; }

.card { display: block; min-width: 0; }
.card h3, .row h3 { font: 600 15px/1.4 var(--font); letter-spacing: -0.01em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card h3 { margin-top: 11px; }
.card:hover h3, .row a:hover h3 { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.card:focus-visible { outline: none; }
.card:focus-visible .thumb { outline: 2px solid var(--accent); outline-offset: 3px; }

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 40px 24px; }
.grid.lead .card:first-child { grid-column: span 2; grid-row: span 2; }
.grid.lead .card:first-child h3 { margin-top: 15px; font-size: 24px; line-height: 1.3; }
.grid.lead .card:first-child .who { font-size: 14px; }

/* 이어 보기 */
.resume { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 40px; align-items: start; }
.resume.solo { grid-template-columns: minmax(0, 680px); }
.resume .card h3 { margin-top: 15px; font-size: 24px; line-height: 1.3; }
.resume .card .who { font-size: 14px; }
.resume-side { display: flex; flex-direction: column; gap: 22px; }

/* 목록 (검색, 기록, 옆 영상) */
.row { display: grid; grid-template-columns: 272px minmax(0, 1fr) auto; gap: 22px; align-items: start; }
.list .row { padding: 20px 0; border-top: 1px solid var(--line); }
.list .row:first-child, .list .day + .row { padding-top: 0; border-top: 0; }
.row .tl { display: block; }
.row h3 { font-size: 17px; }
.row .who { margin-top: 7px; }
.row.mini, .side .row { grid-template-columns: 136px minmax(0, 1fr); gap: 14px; padding: 0; border: 0; }
.row.mini h3, .side .row h3 { font-size: 14px; }
.rm { padding: 4px 0 4px 12px; background: none; border: 0; color: var(--muted); font-size: 13px; }
.rm:hover { color: var(--danger); text-decoration: underline; text-underline-offset: 3px; }
.day { margin: 38px 0 12px; color: var(--muted); font-weight: 600; }
.day:first-child { margin-top: 0; }
.toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: -6px 0 28px; }
.toolbar .note { color: var(--muted); }

/* 인기 순위 */
.rank { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 56px; }
.rank .row { grid-template-columns: 42px 168px minmax(0, 1fr); gap: 16px; align-items: center; padding: 0; border: 0; }
.rank .n { font: 400 36px/1 var(--display); color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* 안내 */
.notice { max-width: 580px; padding: 4px 0; color: var(--muted); }
.notice b { display: block; margin-bottom: 4px; color: var(--ink); font-weight: 600; }
.notice p + p { margin-top: 6px; }
.notice code { padding: 1px 5px; background: var(--surface-2); border-radius: 2px; color: var(--ink); font-size: 13px; }
.notice.warn { padding: 18px 20px; border: 1.5px solid var(--danger); border-radius: 2px; color: var(--ink); }
.more { display: flex; margin: 36px 0 0; }

/* 로딩 뼈대 */
.sk .thumb { background: var(--surface-2); }
.sk .l1, .sk .l2 { height: 12px; margin-top: 12px; background: var(--surface-2); }
.sk .l2 { width: 55%; height: 10px; margin-top: 8px; }

/* ---------- 재생 ---------- */
.watch { display: grid; grid-template-columns: minmax(0, 1fr); gap: 44px; }
@media (min-width: 1120px) { .watch { grid-template-columns: minmax(0, 1fr) 360px; } }
.player { position: relative; aspect-ratio: 16 / 9; background: #000; }
.player iframe, .player > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.player .fail { display: grid; place-content: center; gap: 12px; padding: 24px; text-align: center; color: #d2d8d3; }
.player .fail a { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.watch h1 { margin-top: 22px; font: 700 23px/1.4 var(--font); letter-spacing: -0.015em; text-wrap: balance; }
.watch .who { margin-top: 10px; font-size: 15px; }
.watch .stat { font-size: 13.5px; }
.desc { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.desc.open { display: block; }
.side h2 { margin-bottom: 18px; font: 400 21px/1.2 var(--display); letter-spacing: -0.01em; }
.side .list { display: flex; flex-direction: column; gap: 18px; }

/* ---------- 로그인 ---------- */
dialog { padding: 0; width: min(400px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 4px; }
dialog::backdrop { background: rgba(8, 10, 9, 0.6); }
.dlg { padding: 24px 26px 26px; }
.dlg .tabs { display: flex; gap: 22px; margin-bottom: 8px; }
.dlg .tabs button { padding: 0 0 6px; background: none; border: 0; border-bottom: 3px solid transparent; font: 400 24px/1.2 var(--display); color: var(--muted); }
.dlg .tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.dlg label { display: block; margin-top: 16px; font-size: 13px; font-weight: 500; color: var(--muted); }
.dlg input { display: block; width: 100%; height: 42px; margin-top: 5px; padding: 0 12px; background: var(--bg); border: 1.5px solid var(--line); border-radius: 2px; outline: none; }
.dlg input:focus { border-color: var(--ink); }
.dlg .err { min-height: 22px; margin-top: 12px; color: var(--danger); font-size: 13px; }
.dlg .actions { display: flex; gap: 10px; margin-top: 4px; }
.dlg .actions .primary { flex: 1; }
.dlg .fine { margin-top: 16px; color: var(--muted); font-size: 12.5px; }

#toast { position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60; max-width: calc(100vw - 32px); padding: 11px 18px; background: var(--ink); color: var(--bg); border-radius: 2px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: opacity 0.18s; }
#toast.on { opacity: 1; }

.tabbar { display: none; }

/* ---------- 화면 크기별 ---------- */
@media (max-width: 1100px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .resume { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 28px; }
}
@media (max-width: 900px) {
  .rank { grid-template-columns: minmax(0, 1fr); }
  .list .row { grid-template-columns: 200px minmax(0, 1fr) auto; }
}
@media (max-width: 860px) {
  .topnav { display: none; }
  .top-in { gap: 16px; height: 58px; }
  .page { padding-top: 30px; padding-bottom: 112px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 16px; }
  .grid.lead .card:first-child { grid-row: span 1; }
  .resume, .resume.solo { grid-template-columns: minmax(0, 1fr); }
  .sec { margin-bottom: 54px; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--bg); border-top: 1px solid var(--line);
    padding: 0 var(--gr) calc(0px + env(safe-area-inset-bottom, 0px)) var(--gl);
  }
  .tabbar a { position: relative; flex: 1; padding: 15px 4px 14px; text-align: center; color: var(--muted); font-weight: 500; }
  .tabbar a[aria-current="page"] { color: var(--ink); font-weight: 600; }
  .tabbar a[aria-current="page"]::before { content: ""; position: absolute; left: 20%; right: 20%; top: -1px; height: 3px; background: var(--accent); }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .grid.lead .card:first-child { grid-column: span 1; }
  .grid.lead .card:first-child h3, .resume .card h3 { font-size: 20px; }
  .tc { font-size: 34px; padding: 8px 14px 5px 12px; }
  .list .row { grid-template-columns: 128px minmax(0, 1fr); gap: 14px; }
  .list .row .rm { grid-column: 2; justify-self: start; padding-left: 0; }
  .row h3 { font-size: 15px; }
  .rank .row { grid-template-columns: 30px 120px minmax(0, 1fr); gap: 12px; }
  .rank .n { font-size: 26px; }
  .search { flex-basis: 0; flex-grow: 1; }
  .brand { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
