﻿/* My TV. 폰이 기준이고, 넓은 화면은 같은 것을 가운데로 모을 뿐이다. 영상 앱이라 어둡게. */

:root {
    --bg: #0b0c10;
    --surface: #16181f;
    --surface-2: #1f222b;
    --line: #2a2e39;
    --text: #f2f3f5;
    --muted: #9aa0ad;
    --accent: #e8a33d;
    --accent-ink: #1a1204;
    --danger: #ef5b5b;
    --warn: #e8a33d;
    --radius: 14px;
    --tabbar: 64px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.app {
    max-width: 640px;
    margin: 0 auto;
    min-height: 100vh;
    padding-bottom: calc(var(--tabbar) + var(--safe-bottom) + 24px);
}

/* 위 막대 */
.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 56px;
    padding: env(safe-area-inset-top, 0px) 16px 0;
    background: rgba(11, 12, 16, .88);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}
.topbar__title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-left: -8px;
    border-radius: 50%;
}
.icon-btn svg { width: 24px; height: 24px; }

.content { padding: 8px 16px 0; }

/* 아래 탭 */
.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    background: rgba(22, 24, 31, .94);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding-bottom: var(--safe-bottom);
}
.tabbar__inner {
    max-width: 640px;
    margin: 0 auto;
    height: var(--tabbar);
    display: flex;
    align-items: center;
    justify-content: space-around;
}
.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 11px;
    color: var(--muted);
}
.tab svg { width: 24px; height: 24px; }
.tab--on { color: var(--text); }
.tab--add span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: var(--accent);
    color: var(--accent-ink);
}

/* 구획 */
.section { margin-top: 24px; }
.section__title {
    margin: 0 0 12px;
    font-size: 17px;
    font-weight: 700;
}
.count { color: var(--muted); font-weight: 500; margin-left: 4px; }

/* 이어 보기: 옆으로 넘기는 선반 */
.shelf {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin: 0 -16px;
    padding: 0 16px 4px;
    scrollbar-width: none;
}
.shelf::-webkit-scrollbar { display: none; }
.poster {
    flex: 0 0 62%;
    max-width: 260px;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
}
.poster__art {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius) var(--radius) 0 0;
    background: linear-gradient(135deg, #2b2f3b, #171920);
    font-size: 36px;
    font-weight: 800;
    color: rgba(255, 255, 255, .5);
}
.poster__bar {
    display: block;
    height: 4px;
    background: var(--line);
    border-radius: 0 0 4px 4px;
    overflow: hidden;
}
.poster__bar span { display: block; height: 100%; background: var(--accent); }
.poster__title {
    margin-top: 8px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.poster__sub { font-size: 13px; color: var(--muted); }

/* 목록 */
.list {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}
.row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    min-height: 64px;
}
.row + .row { border-top: 1px solid var(--line); }
.row__art {
    flex: 0 0 auto;
    width: 56px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2b2f3b, #171920);
    font-weight: 800;
    color: rgba(255, 255, 255, .55);
}
.row__main { display: flex; flex-direction: column; min-width: 0; }
.row__title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.row__sub { font-size: 13px; color: var(--muted); }

.tag {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    line-height: 20px;
}
.tag:first-child { margin-left: 0; }
.tag--warn { color: var(--warn); }

/* 비어 있을 때 */
.empty {
    text-align: center;
    padding: 56px 16px;
}
.empty h2 { margin: 12px 0 6px; font-size: 20px; }
.empty p { margin: 0 0 20px; color: var(--muted); }
.empty__mark svg, .splash__mark svg { width: 64px; height: 64px; color: var(--accent); }

/* 재생 */
.player {
    margin: 0 -16px;
    background: #000;
}
.player video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}
video::cue {
    background: rgba(0, 0, 0, .55);
    font-family: inherit;
}
.watch__title { margin: 0; font-size: 20px; line-height: 1.35; word-break: keep-all; }
.watch__sub { margin: 6px 0 0; }
.actions { display: flex; gap: 8px; margin-top: 16px; }
.actions .btn { flex: 1; }

.toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--surface-2);
    font-size: 14px;
}
.link {
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-weight: 600;
    padding: 4px 0;
}

/* 폼 */
.form { display: flex; flex-direction: column; gap: 20px; margin-top: 8px; }
.field { display: flex; flex-direction: column; gap: 8px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field__label { font-weight: 600; font-size: 15px; padding: 0; }
.field__help { font-size: 13px; color: var(--muted); }
.field__or { font-size: 13px; color: var(--muted); text-align: center; }
.optional { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 4px; }

input[type=url], input[type=text] {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 16px; /* 16px 보다 작으면 iOS 가 입력할 때 화면을 확대한다 */
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=file] { color: var(--muted); font-size: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }

/* 버튼 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    padding: 0 20px;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: var(--accent-ink);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.btn--block { width: 100%; }
.btn--soft { background: var(--surface-2); color: var(--text); font-weight: 600; }
.btn--danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.stack { margin-top: 24px; }

.alert {
    margin: 8px 0 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(239, 91, 91, .12);
    color: #ffb4b4;
    font-size: 14px;
}

.card { background: var(--surface); border-radius: var(--radius); padding: 4px 16px; }
.lines { list-style: none; margin: 0; padding: 0; }
.lines li { padding: 12px 0; font-size: 14px; color: var(--muted); }
.lines li + li { border-top: 1px solid var(--line); }
.lines strong { color: var(--text); font-weight: 600; }

/* 로그인 */
.splash {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px;
    min-height: 100vh;
}
.splash__body { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.splash h1 { margin: 16px 0 8px; font-size: 28px; line-height: 1.3; }
.splash__lead { margin: 0; color: var(--muted); }
.splash__foot { text-align: center; color: var(--muted); font-size: 13px; }
.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 52px;
    border-radius: 14px;
    background: #fff;
    color: #1f1f1f;
    font-weight: 600;
    margin-bottom: 16px;
}

/* 라이브러리 — 폴더는 타일, 영상은 목록 */
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}
.tile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.tile__art {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 10;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #2b2f3b, #171920);
    color: var(--accent);
}
.tile__art svg { width: 36px; height: 36px; }
.tile__title {
    margin-top: 6px;
    font-weight: 600;
    font-size: 15px;
    line-height: 1.3;
    word-break: keep-all;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.tile__sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.crumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--muted);
}
.crumbs a { color: var(--text); }

.row { position: relative; }
.row--seen .row__title { color: var(--muted); }
.row__bar {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 6px;
    height: 3px;
    border-radius: 2px;
    background: var(--line);
    overflow: hidden;
}
.row__bar span { display: block; height: 100%; background: var(--accent); }
.row--choice { cursor: pointer; }
.row--choice input { width: 20px; height: 20px; accent-color: var(--accent); flex: 0 0 auto; }
form.row { margin: 0; }

.tag--app { color: var(--accent); }
.link--danger { color: var(--danger); margin-left: auto; }

/* 플레이어 고르기 */
.players {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}
.players .btn { width: 100%; }
.players__ios { margin-top: 12px; }

/* ---- v3: 썸네일 · 이어서 보기 · 접는 양식 ---- */

/* 선반 첫 카드가 왼쪽 끝에 붙지 않게: 스냅 기준에 여백을 준다 */
.shelf { scroll-padding: 0 16px; }

/* 썸네일 자리: 그림이 없으면 글자만 남는다 (img onerror 가 그림을 지운다) */
.thumb, .poster__art, .nextup__art, .hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #2b2f3b, #171920);
}
.thumb img, .poster__art img, .nextup__art img, .hero img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.thumb__text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, .45);
    font-weight: 800;
}
.thumb__bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: rgba(0, 0, 0, .5);
}
.thumb__bar span { display: block; height: 100%; background: var(--accent); }

.row--video { gap: 12px; padding: 10px 14px; }
.row--video .thumb {
    flex: 0 0 auto;
    width: 112px;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
}
.row--video .thumb__text { font-size: 12px; }
/* 본 회차는 그림을 반투명하게 하지 않고 위에 어두운 막을 씌운다 - 반투명이면 뒤의 형식 글자가 비친다 */
.thumb img { z-index: 1; }
.row--seen .thumb::after { content: ""; position: absolute; inset: 0; z-index: 2; background: rgba(11, 12, 16, .5); }
.thumb__bar { z-index: 3; }

/* 폴더 맨 위 "이어서 보기" */
.nextup {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 4px 0 20px;
    padding: 10px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid rgba(232, 163, 61, .35);
}
.nextup__art {
    flex: 0 0 auto;
    width: 140px;
    aspect-ratio: 16 / 9;
    border-radius: 10px;
}
.nextup__art .thumb__text { font-size: 22px; color: var(--accent); }
.nextup__main { display: flex; flex-direction: column; min-width: 0; }
.nextup__label { font-size: 13px; color: var(--accent); font-weight: 700; }
.nextup__title { font-weight: 700; font-size: 17px; line-height: 1.3; word-break: keep-all; }

/* 앱으로 볼 때 재생 화면 위쪽 */
.hero {
    margin: 0 -16px;
    aspect-ratio: 16 / 9;
}
.hero .thumb__text { font-size: 28px; }

.poster__art .thumb__text { font-size: 36px; color: rgba(255, 255, 255, .5); }

/* 접는 연결 양식 */
.fold > summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "+"; color: var(--muted); font-size: 22px; font-weight: 400; }
.fold[open] > summary::after { content: "−"; }

.row--link {
    margin-top: 20px;
    background: var(--surface);
    border-radius: var(--radius);
    color: var(--text);
}
.row--link > span[aria-hidden] { margin-left: auto; color: var(--muted); font-size: 20px; }

/* ---- v4: 계정 표시 · PC 화면 ---- */
.whoami { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.empty .whoami { margin-top: 20px; }

/* PC: 같은 화면을 넓게. 폰이 기준이고 넓으면 열을 늘린다. */
@media (min-width: 900px) {
    .app, .tabbar__inner { max-width: 1080px; }
    .content { padding: 16px 32px 0; }
    .topbar { padding-left: 32px; padding-right: 32px; }
    .tiles { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
    .shelf { margin: 0; padding: 0 0 4px; scroll-padding: 0; }
    .poster { flex: 0 0 280px; max-width: 280px; }
    .row--video .thumb { width: 176px; }
    .row--video .row__title { font-size: 17px; }
    .nextup__art { width: 240px; }
    .player, .hero { margin: 0; border-radius: var(--radius); overflow: hidden; }
    .player video { max-height: 72vh; }
    .players { grid-template-columns: repeat(4, 1fr); max-width: 760px; }
    .actions { max-width: 760px; }
    .form { max-width: 640px; }
    .fold { max-width: 640px; }
}

/* PC 재생 화면: 왼쪽 영상, 오른쪽 제목·버튼 */
@media (min-width: 900px) {
    .play { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 28px; align-items: start; }
    .play__side .section:first-child { margin-top: 0; }
    .play .players { grid-template-columns: 1fr 1fr; max-width: none; }
    .play .actions { max-width: none; }
}
