/* 트렌드(실시간 인기 영상). 공통 레이아웃 안에 들어가므로 모든 규칙을 .ytr 범위로 묶는다. 색은 흰 배경 + 브랜드 보라·오렌지. */
.ytr {
    --line: var(--upc-line);
    --text: var(--upc-ink);
    --muted: #6B7280;
    --accent: var(--upc-accent);
    --hype: #B45309;
    color: var(--text);
    font-size: 14px;
    line-height: 1.4;
}

.ytr *, .ytr *::before, .ytr *::after { box-sizing: border-box; }
.ytr a { color: inherit; text-decoration: none; }
.ytr button, .ytr select, .ytr input { font: inherit; color: inherit; }
.ytr :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ytr .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

/* 상단 */
.ytr .top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.ytr .top h1 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.ytr .top h1 svg { width: 28px; height: 28px; fill: none; stroke: var(--upc-point); stroke-width: 2; stroke-linejoin: round; }
.ytr .clock { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-size: 12px; }
.ytr .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.ytr .dot-stale { background: var(--upc-point); }

/* 검색 */
.ytr .search {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 6px 6px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}
.ytr .search:focus-within { border-color: var(--accent); }
.ytr .search svg { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.ytr .search input { flex: 1; min-width: 0; height: auto; padding: 8px 0; border: 0; outline: 0; background: transparent; font-size: 16px; }
.ytr .search input::placeholder { color: var(--muted); }
.ytr .search button {
    flex: none;
    padding: 10px 16px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: var(--upc-on-accent);
    font-weight: 800;
    cursor: pointer;
}
.ytr .search button:hover { filter: brightness(.92); }

/* 필터 */
.ytr .filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 14px 0 20px; }
.ytr .spacer { flex: 1; }

.ytr .tabs { display: flex; gap: 24px; margin-right: 8px; }
.ytr .tabs a { padding: 8px 0 10px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 16px; font-weight: 700; }
.ytr .tabs a:hover { color: var(--text); }
.ytr .tabs a.on { border-color: var(--accent); color: var(--accent); }

.ytr .field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    font-size: 14px;
    font-weight: 700;
}
.ytr .field > span:not(.sr-only) { color: var(--muted); font-weight: 500; }
.ytr .field > span:not(.sr-only)::after { content: " ·"; }
.ytr .field select { height: auto; padding: 8px 2px; border: 0; outline: 0; background: transparent; font-weight: 700; cursor: pointer; }
.ytr .field select option { background: #fff; color: var(--text); }
.ytr .field:focus-within { border-color: var(--accent); }

.ytr .saved-toggle {
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
.ytr .saved-toggle b { color: var(--accent); }
.ytr .saved-toggle[aria-pressed="true"] { border-color: var(--accent); }

/* 안내 */
.ytr .notice {
    margin: 0 0 20px;
    padding: 14px 16px;
    border: 1px solid #fde4a7;
    border-radius: 10px;
    background: var(--upc-point-soft);
    color: #6b4300;
    font-size: 14px;
}
.ytr .notice code { color: var(--accent); }
.ytr .empty { padding: 64px 0; color: var(--muted); text-align: center; }

/* 카드 */
.ytr .grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.ytr .grid[hidden] { display: none; }

.ytr .card {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    transition: border-color .15s, transform .15s;
}
.ytr .card:hover { border-color: var(--accent); transform: translateY(-2px); }

.ytr .thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: #000; }
.ytr .thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

.ytr .rank {
    position: absolute;
    top: 10px;
    left: 10px;
    min-width: 34px;
    padding: 5px 9px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--upc-on-accent);
    font-size: 14px;
    font-weight: 800;
    text-align: center;
}
.ytr #saved .rank { display: none; }

.ytr .length {
    position: absolute;
    right: 8px;
    bottom: 8px;
    padding: 2px 7px;
    border-radius: 6px;
    background: rgba(0, 0, 0, .78);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.ytr .bookmark {
    position: absolute;
    top: 10px;
    right: 10px;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 50%;
    background: rgba(0, 0, 0, .68);
    cursor: pointer;
}
.ytr .bookmark svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2; stroke-linejoin: round; }
.ytr .bookmark[aria-pressed="true"] svg { fill: var(--upc-point); stroke: var(--upc-point); }

.ytr .body { display: flex; flex: 1; flex-direction: column; padding: 14px 16px 16px; }
.ytr .tags { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.ytr .tags .hype { color: var(--hype); }
.ytr .tags .reuse { color: var(--accent); }

.ytr .card h2 {
    display: -webkit-box;
    min-height: 2.8em;
    margin: 0 0 12px;
    overflow: hidden;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: -.01em;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}
.ytr .card h2 a:hover { text-decoration: underline; }

.ytr .channel { margin: auto 0 8px; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.ytr .meta { margin: 0; color: #4B5565; font-size: 13px; font-weight: 600; }

@media (max-width: 960px) {
    .ytr .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .ytr .spacer { flex-basis: 100%; height: 0; }
}

@media (max-width: 720px) {
    .ytr .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .ytr .top h1 { font-size: 22px; }
}

@media (max-width: 460px) {
    .ytr .grid { grid-template-columns: minmax(0, 1fr); }
    .ytr .tabs { flex-basis: 100%; }
    .ytr .field, .ytr .saved-toggle { flex: 1 1 auto; }
    .ytr .field select { flex: 1; min-width: 0; }
}

/* 순차 로딩: 다음 묶음 안내 */
.ytr .more { min-height: 1px; margin: 20px 0 0; color: var(--muted); font-size: 13px; text-align: center; }

/* 수집 관리(collect_admin.php) */
.ytr-admin .stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 20px; }
.ytr-admin .stats div { padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; }
.ytr-admin .stats dt { color: var(--muted); font-size: 12px; }
.ytr-admin .stats dd { margin: 4px 0 0; font-size: 18px; font-weight: 800; }
.ytr-admin .actions { display: flex; flex-wrap: wrap; gap: 10px; }
.ytr-admin .actions button { min-height: 44px; padding: 0 20px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent); color: var(--upc-on-accent); font-weight: 800; cursor: pointer; }
.ytr-admin .actions .sub { background: #fff; color: var(--accent); }
.ytr-admin .actions button:disabled { opacity: .5; cursor: default; }
.ytr-admin .help { margin: 10px 0 20px; color: var(--muted); font-size: 13px; }
.ytr-admin .notice { white-space: pre-line; }
.ytr-admin .table-wrap { overflow-x: auto; }
.ytr-admin table { width: 100%; border-collapse: collapse; }
.ytr-admin th, .ytr-admin td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.ytr-admin th { color: var(--muted); font-size: 12px; font-weight: 600; }
.ytr-admin th:last-child, .ytr-admin .memo { text-align: left; }
.ytr-admin .memo { white-space: normal; min-width: 200px; color: var(--muted); font-size: 12px; }
.ytr-admin .status-failed { color: var(--upc-up); font-weight: 700; }
@media (max-width: 720px) { .ytr-admin .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
