/* 최신순 — 레이아웃: 고정 머리(로고·탭) → 날짜별 구분선 아래 카드 격자. 시간이 구조다.
   색: 차분한 청회색 바탕, 시간 신호용 주황 하나. */
:root {
  --bg: #f1f2f4; --surface: #ffffff; --ink: #15181d; --muted: #5d6470; --faint: #8b929c;
  --line: #dcdfe4; --accent: #d9481a; --accent-ink: #ffffff; --accent-soft: #fbe7df;
  --danger: #b42318;
  --display: "Do Hyeon", "IBM Plex Sans KR", "Apple SD Gothic Neo", sans-serif;
  --body: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101216; --surface: #191c21; --ink: #e8eaed; --muted: #a0a6b0; --faint: #747b86;
    --line: #2a2e35; --accent: #ff7343; --accent-ink: #160a05; --accent-soft: #3a1f15;
    --danger: #ff8a7a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101216; --surface: #191c21; --ink: #e8eaed; --muted: #a0a6b0; --faint: #747b86;
  --line: #2a2e35; --accent: #ff7343; --accent-ink: #160a05; --accent-soft: #3a1f15;
  --danger: #ff8a7a; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 var(--body); -webkit-font-smoothing: antialiased; }
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: inherit; }

.wrap {
  max-width: 1240px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* 머리 */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--surface); }
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 14px; padding-block: 12px 6px; }
.logo { font-family: var(--display); font-size: 30px; line-height: 1; text-decoration: none; letter-spacing: .01em; }
.logo::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 4px; border-radius: 50%; background: var(--accent); vertical-align: top; }
.tagline { margin: 0; color: var(--muted); font-size: 13px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-block: 6px 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; font: 500 14px var(--body); color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; cursor: pointer; white-space: nowrap;
}
.tab .n { font: 500 11px var(--mono); color: var(--faint); margin-left: 4px; }
.tab[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.tab[aria-current="page"] .n { color: inherit; opacity: .7; }
.tab.sub { border-color: var(--accent); }
.tab.sub[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tab-sep { flex: none; width: 1px; background: var(--line); margin: 4px 2px; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; gap: 6px; font: 500 14px var(--body); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 13px; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn .count { font: 500 12px var(--mono); background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 0 7px; }
.btn:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 안내 */
#notices { display: grid; gap: 10px; padding-top: 18px; }
.notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; font-size: 14px;
}
.notice p { margin: 0; min-width: 0; flex: 1 1 280px; }
.notice.accent { border-color: var(--accent); background: var(--accent-soft); }
.notice.warn { border-style: dashed; color: var(--muted); }

.viewbar { padding-top: 16px; display: flex; justify-content: flex-end; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { font: 500 13px var(--body); color: var(--muted); background: none; border: 0; padding: 6px 14px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* 날짜 구분 + 격자 */
.day { margin-top: 26px; }
.day h2 {
  display: flex; align-items: baseline; gap: 10px; margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
  font: 400 22px/1.2 var(--display);
}
.day h2 small { font: 500 12px var(--mono); color: var(--faint); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 22px 16px; }

.card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; min-width: 0; cursor: pointer; }
.card.seen { opacity: .55; }
.thumb { position: relative; aspect-ratio: 16 / 9; max-width: 100%; border-radius: 8px; overflow: hidden; background: var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font: 400 20px var(--display);
  background: repeating-linear-gradient(-45deg, var(--line) 0 10px, var(--surface) 10px 20px); }
.badge-time { position: absolute; right: 6px; bottom: 6px; font: 500 11.5px var(--mono); color: #fff; background: rgba(8, 10, 12, .8); padding: 1px 6px; border-radius: 4px; }
.prog { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .35); }
.prog i { display: block; height: 100%; background: var(--accent); }
.thumb .badge-time { bottom: 9px; }
.rank { position: absolute; left: 6px; top: 6px; font: 400 18px var(--display); color: #fff; background: rgba(8, 10, 12, .75); min-width: 28px; text-align: center; padding: 0 6px; border-radius: 4px; }
.title { margin: 0; font-weight: 700; font-size: 14.5px; line-height: 1.42; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 2px 8px; margin: 0; font-size: 12.5px; color: var(--muted); }
.meta .num, .meta time { font-variant-numeric: tabular-nums; }
.src { font-weight: 500; color: var(--faint); }
.src.sub { color: var(--accent); }

/* 타임라인 — 왼쪽 시각, 가운데 세로 축, 오른쪽 가로형 카드 */
#notices, .viewbar, #feed { max-width: 960px; margin-inline: auto; }
.day-head {
  position: sticky; top: calc(var(--head, 0px) + env(safe-area-inset-top, 0px)); z-index: 10;
  background: var(--bg); padding-block: 12px 8px; margin-bottom: 4px !important;
}
.tl { --tcol: 64px; --acol: 20px; list-style: none; margin: 0; padding: 0; position: relative; }
.tl::before {
  content: ""; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--line);
  left: calc(var(--tcol) + 12px + var(--acol) / 2 - 1px);
}
.tl > li { display: grid; grid-template-columns: var(--tcol) var(--acol) minmax(0, 1fr); column-gap: 12px; align-items: start; }
.tl-item { padding-block: 8px; }
.tl-time { text-align: right; font: 500 13px/1.3 var(--mono); color: var(--ink); padding-top: 4px; font-variant-numeric: tabular-nums; }
.tl-time small { display: block; font: 400 11px var(--body); color: var(--faint); margin-top: 2px; }
.tl-dot {
  justify-self: center; position: relative; z-index: 1; width: 11px; height: 11px; margin-top: 6px;
  border-radius: 50%; background: var(--bg); border: 2px solid var(--faint);
}
.tl-item.sub .tl-dot { background: var(--accent); border-color: var(--accent); }
.tl-hour { padding-top: 14px; }
.tl-hour span { grid-column: 1; text-align: right; font: 400 15px var(--display); color: var(--muted); }
.tl-now { padding-block: 4px 6px; align-items: center !important; }
.tl-now .tl-time { color: var(--accent); padding-top: 0; }
.tl-now .tl-dot { margin-top: 0; width: 13px; height: 13px; background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.tl-now-label { font: 400 16px var(--display); color: var(--accent); }

.tl-card {
  display: grid; grid-template-columns: 208px minmax(0, 1fr); gap: 14px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px;
}
.tl-card:hover { border-color: var(--faint); }
.tl-card .thumb { border-radius: 6px; }
.tl-body { min-width: 0; display: flex; flex-direction: column; gap: 6px; padding-top: 2px; }
.tl-body .title { font-size: 15px; }
.chip { font: 500 11.5px var(--body); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; }
.chip.sub { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* 탭 아래 도구 줄: 정렬 / 이어보기·공유·편집 */
.viewbar { gap: 10px; flex-wrap: wrap; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.share-out { max-width: 960px; margin: 10px auto 0; }
.share-url {
  display: block; width: 100%; margin-top: 6px; font: 12.5px var(--mono); color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}

/* 관리 시트: 섹션, 묶음 목록, 체크 목록 */
.mgr-view { display: flex; flex-direction: column; gap: 14px; }
.add-to { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.add-to label { font-weight: 500; }
select, #gName, #gFilter {
  font: 14px var(--body); color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0;
}
#gName { font-size: 15px; width: 100%; }
#groupEditor > label { font-weight: 700; font-size: 14px; }
.mgr-sec { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.mgr-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mgr-sec-head h3 { margin: 0; font: 400 18px var(--display); }
.mgr-sec-head h3 b { font: 500 12px var(--mono); color: var(--faint); margin-left: 4px; }
#gFilter { flex: 1 1 160px; }
.group-list, .check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.group-list li { display: flex; align-items: center; gap: 6px; padding: 6px 4px; border-radius: 6px; }
.group-list li:hover { background: var(--bg); }
.group-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; text-decoration: none; }
.group-list .n { font: 500 12px var(--mono); color: var(--faint); margin-right: 4px; }
.group-list .x, .mgr-list .x { border: 0; background: none; color: var(--muted); font: 13px var(--body); cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.group-list .x:hover { color: var(--ink); background: var(--line); }
.group-list .none, .check-list .none { color: var(--muted); font-size: 13.5px; padding: 8px 4px; }
.group-list .share-row { display: block; font-size: 12.5px; color: var(--muted); padding: 0 4px 8px; }
.check-list { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.check-list label { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 6px; cursor: pointer; }
.check-list label:hover { background: var(--bg); }
.check-list input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.check-list .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }

/* 재생 대기열 */
.frame #ytp, .frame iframe { width: 100%; height: 100%; border: 0; }
.player-queue { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 0 16px 14px; }
.q-pos { font: 500 13px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.q-auto { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-left: auto; cursor: pointer; }
.q-auto input { accent-color: var(--accent); }

.empty { text-align: center; color: var(--muted); padding: 56px 16px; }
.empty b { display: block; font: 400 22px var(--display); color: var(--ink); margin-bottom: 6px; }
.skeleton .thumb { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.more { display: flex; margin: 28px auto 0; }

.foot { color: var(--faint); font-size: 12.5px; padding-block: 36px 40px; }
.foot p { margin: 4px 0; }

/* 시트 (채널 관리) */
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(8, 10, 12, .45); display: flex; justify-content: flex-end; }
.sheet-panel {
  width: min(440px, 100%); height: 100%; overflow-y: auto; background: var(--surface); border-left: 1px solid var(--line);
  padding: max(18px, env(safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) 18px;
  display: flex; flex-direction: column; gap: 14px;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font: 400 26px var(--display); }
.add label { font-weight: 700; font-size: 14px; }
.add-row { display: flex; gap: 8px; margin-top: 6px; }
.add-row input {
  flex: 1; min-width: 0; font: 15px var(--body); color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px;
}
.hint { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.hint.err { color: var(--danger); }
.hint.ok { color: var(--accent); }
.mgr-list-head { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }
.mgr-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 42vh; overflow-y: auto; }
.mgr-list li { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 6px; }
.mgr-list li:hover { background: var(--bg); }
.mgr-list img, .mgr-list .av { width: 28px; height: 28px; border-radius: 50%; flex: none; background: var(--line); object-fit: cover; }
.mgr-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.mgr-list .x { border: 0; background: none; color: var(--faint); font-size: 13px; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.mgr-list .x:hover { color: var(--danger); }
.mgr-list .none { color: var(--muted); font-size: 13.5px; padding: 8px 4px; }
.mgr-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.help { font-size: 13px; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.help summary { cursor: pointer; color: var(--ink); font-weight: 500; }
.help ol { margin: 8px 0 2px; padding-left: 18px; display: grid; gap: 4px; }

/* 재생 */
.player { justify-content: center; align-items: center; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); background: rgba(8, 10, 12, .8); }
.player-box { width: min(980px, 100%); background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.frame { aspect-ratio: 16 / 9; max-width: 100%; background: #000; color: #c9ced5; display: grid; place-items: center; text-align: center; padding: 0 20px; }
.frame iframe { width: 100%; height: 100%; border: 0; }
.player-info { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; padding: 14px 16px; }
.player-text { min-width: 0; }
.player-text h2 { margin: 0 0 4px; font-size: 16px; overflow-wrap: anywhere; }
.player-text a { color: var(--accent); }

@media (max-width: 560px) {
  .tagline { display: none; }
  .top-row { justify-content: space-between; }
  .grid { grid-template-columns: 1fr; }
  .tl { --tcol: 42px; --acol: 12px; }
  .tl > li { column-gap: 8px; }
  .tl-time { font-size: 12px; }
  .tl-time small { display: none; }
  .tl-hour span { font-size: 13px; }
  .tl-card { grid-template-columns: 118px minmax(0, 1fr); gap: 10px; padding: 6px; }
  .tl-body .title { font-size: 13.5px; -webkit-line-clamp: 3; }
  .tl-body .meta .num { display: none; }
  .sheet { align-items: flex-end; }
  .sheet-panel { height: 88%; border-left: 0; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; padding-left: max(18px, env(safe-area-inset-left, 0px)); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
