:root {
    color-scheme: dark;
    --ink: #edf3f7;
    --muted: #8d9cab;
    --subtle: #647586;
    --line: #273543;
    --paper: #0b1016;
    --panel: #121b25;
    --panel-hover: #172536;
    --navy: #101d2b;
    --cyan: #79d5d0;
    --blue: #6da5ff;
    font-family: "Trebuchet MS", "Gill Sans", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--paper);
}

.home-shell {
    width: min(100% - 48px, 1180px);
    min-height: 100vh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 28px 0;
    border-bottom: 1px solid var(--line);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -.04em;
}

.brand-mark {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 9px 9px 9px 2px;
    background: var(--blue);
    color: #08111d;
    font-family: Georgia, serif;
    font-size: 1.25rem;
    font-style: italic;
}

.topnav { display: flex; align-items: center; gap: 24px; }
.account-name { color: var(--ink); font-size: .82rem; font-weight: 700; }
.signout-form { margin: 0; }
.signout-button { font: inherit; cursor: pointer; }
.topnav a { color: var(--muted); font-size: .82rem; font-weight: 700; text-decoration: none; }
.topnav a:hover { color: var(--cyan); }
.topnav .nav-button { padding: 10px 15px; border: 1px solid #3f75bd; border-radius: 6px; color: var(--blue); }
.topnav .nav-button:hover { background: #172944; }

.hero { position: relative; padding: clamp(48px, 6vw, 76px) 0 48px; }
.hero::after { content: ""; position: absolute; top: 50%; right: 12%; width: 10px; height: 10px; background: var(--cyan); transform: rotate(45deg); box-shadow: 42px 37px 0 -2px var(--blue), -28px 68px 0 -3px #ffffff40; }
.eyebrow { margin: 0 0 17px; color: var(--cyan); font-size: .68rem; font-weight: 700; letter-spacing: .17em; }
h1, h2, h3 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-weight: 400; letter-spacing: -.045em; }
h1 { max-width: 700px; font-size: clamp(3.3rem, 8vw, 7rem); line-height: .9; }
h1 em { color: var(--blue); font-style: normal; }
.hero-copy { max-width: 400px; margin: 29px 0 0; color: var(--muted); font-size: 1rem; line-height: 1.65; }

.site-section { padding: 36px 0 80px; border-top: 1px solid var(--line); }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 25px; }
.section-heading .eyebrow { margin-bottom: 9px; }
h2 { font-size: 2rem; }
.site-count { color: var(--subtle); font-size: .75rem; }
.site-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 13px; }
.site-card { display: flex; align-items: center; gap: 15px; min-height: 100px; padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); text-decoration: none; transition: border-color .2s, background .2s, transform .2s; }
.site-card:hover { border-color: #4772a5; background: var(--panel-hover); transform: translateY(-2px); }
.site-icon { display: grid; flex: 0 0 auto; width: 42px; height: 42px; place-items: center; overflow: hidden; border-radius: 6px; background: #1c334e; color: var(--blue); font-family: Georgia, serif; font-size: 1.2rem; }
.site-icon img { width: 100%; height: 100%; object-fit: contain; }
.site-card-content { display: grid; min-width: 0; gap: 5px; }
.site-card-content strong { font-size: .95rem; }
.site-card-content span { overflow: hidden; color: var(--muted); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.card-arrow { margin-left: auto; color: var(--cyan); font-size: 1.35rem; }

.empty-state { padding: 52px 20px; border: 1px dashed #344555; border-radius: 8px; text-align: center; }
.empty-icon { display: grid; width: 36px; height: 36px; margin: 0 auto 16px; place-items: center; border: 1px solid #41617f; border-radius: 50%; color: var(--blue); font-size: 1.3rem; }
.empty-state h3 { font-size: 1.5rem; }
.empty-state p { margin: 10px auto 0; max-width: 340px; color: var(--muted); font-size: .85rem; line-height: 1.5; }
.back-link { display: inline-block; margin-bottom: 24px; color: var(--muted); font-size: .82rem; text-decoration: none; }
.back-link:hover { color: var(--cyan); }
.detail-hero { padding: 70px 0 58px; }
.detail-title { display: flex; align-items: center; gap: 18px; }
.detail-title .site-icon { width: 56px; height: 56px; }
.detail-copy { max-width: 600px; margin: 18px 0 0; color: var(--muted); line-height: 1.6; }
.channel-detail-actions { display: flex; align-items: center; justify-content: space-between; gap: 18px; max-width: 760px; }
.channel-detail-actions .detail-copy { margin-bottom: 0; }
.channel-grid, .video-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.channel-card, .video-card { display: flex; gap: 15px; padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); text-decoration: none; transition: border-color .2s, background .2s, transform .2s; }
.channel-card:hover, .video-card:hover { border-color: #4772a5; background: var(--panel-hover); transform: translateY(-2px); }
.channel-avatar { display: grid; flex: 0 0 auto; width: 44px; height: 44px; place-items: center; overflow: hidden; border-radius: 50%; background: #1c334e; color: var(--blue); font-family: Georgia, serif; font-size: 1.15rem; }
.channel-avatar img { width: 100%; height: 100%; object-fit: cover; }
.channel-card-content, .video-card-content { display: grid; min-width: 0; gap: 6px; }
.channel-card-content strong, .video-card-content strong { font-size: .95rem; }
.channel-card-content span, .video-card-content span { color: var(--muted); font-size: .78rem; line-height: 1.4; }
.video-card { display: grid; gap: 7px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.video-card-link { display: grid; gap: 7px; min-width: 0; color: var(--ink); text-decoration: none; }
.video-card-link:hover .video-card-content strong { color: var(--cyan); }
.video-thumbnail { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; background: #1c334e; }
.video-thumbnail-placeholder { display: grid; place-items: center; color: var(--blue); font: italic 2rem Georgia, serif; }
.video-card-content p { margin: 0; overflow: hidden; color: var(--muted); font-size: .82rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.video-card form { margin: 0; }
.remove-video-button { padding: 5px 8px; border: 1px solid #82434a; border-radius: 4px; background: transparent; color: #df8991; font: inherit; font-size: .72rem; cursor: pointer; }
.remove-video-button:hover { background: #3a2026; }
.video-meta { color: var(--subtle) !important; }
.video-page { padding: 54px 0 80px; }
.video-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
.playlist-sidebar { overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.playlist-sidebar-heading { display: flex; justify-content: space-between; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); }
.playlist-sidebar-heading span { color: var(--muted); font-size: .75rem; }
.playlist-queue { display: grid; max-height: 570px; overflow-y: auto; }
.playlist-queue-item { display: flex; align-items: center; gap: 9px; padding: 8px; color: var(--ink); font-size: .78rem; text-decoration: none; }
.playlist-queue-item:hover, .playlist-queue-item.is-current { background: var(--panel-hover); }
.playlist-queue-item.is-current { border-left: 3px solid var(--cyan); padding-left: 5px; }
.playlist-queue-item img, .queue-thumbnail { display: grid; flex: 0 0 82px; width: 82px; height: 46px; place-items: center; object-fit: cover; border-radius: 3px; background: #1c334e; color: var(--blue); font-family: Georgia, serif; }
.playlist-queue-item span:last-child { overflow: hidden; text-overflow: ellipsis; }
.player-frame { overflow: hidden; aspect-ratio: 16 / 9; margin: 24px 0 28px; background: #05080c; }
.player-frame video { width: 100%; height: 100%; object-fit: contain; }
.video-heading h1 { max-width: 900px; font-size: clamp(2rem, 5vw, 4.5rem); line-height: 1; }
.video-heading .video-meta { display: block; margin-top: 14px; }
.video-description { max-width: 760px; margin-top: 34px; padding-top: 24px; border-top: 1px solid var(--line); }
.video-description h2 { font-size: 1.25rem; }
.video-description p { color: var(--muted); line-height: 1.7; white-space: pre-wrap; }
.source-link { display: inline-block; margin-top: 24px; color: var(--cyan); font-size: .85rem; text-decoration: none; }
.playlist-actions { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); }
.playlist-actions h2 { font-size: 1.25rem; }
.playlist-add-row, .playlist-create { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.playlist-create input { min-width: 190px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); color: var(--ink); font: inherit; }
.playlist-button { padding: 8px 11px; border: 1px solid #4772a5; border-radius: 5px; background: transparent; color: var(--cyan); font: inherit; font-size: .8rem; cursor: pointer; }
.playlist-button:hover { background: var(--panel-hover); }
.playlist-login { margin-top: 24px; color: var(--muted); font-size: .85rem; }
.playlist-login a, .topnav-link { color: var(--cyan); text-decoration: none; }
.playlist-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.playlist-section { margin-top: 44px; }
.playlist-card { display: flex; align-items: center; justify-content: space-between; padding: 17px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); text-decoration: none; }
.playlist-card:hover { border-color: #4772a5; background: var(--panel-hover); }
.playlist-thumbnail { display: block; flex: 0 0 82px; width: 82px; height: 46px; object-fit: cover; border-radius: 4px; background: #1c334e; }
.playlist-thumbnail-placeholder { display: grid; place-items: center; color: var(--blue); font: italic 1.5rem Georgia, serif; }
.playlist-card-name { flex: 1; min-width: 0; margin: 0 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.footer { display: flex; justify-content: space-between; margin-top: auto; padding: 22px 0; border-top: 1px solid var(--line); color: var(--subtle); font-size: .7rem; }

@media (max-width: 620px) {
    .home-shell { width: min(100% - 34px, 500px); }
    .topbar { padding: 21px 0; }
    .topnav { gap: 14px; }
    .topnav .nav-button { padding: 9px 10px; }
    .hero { padding: 48px 0; }
    h1 { font-size: clamp(3.2rem, 15vw, 5rem); }
    .hero::after { right: 10%; top: 24%; }
    .section-heading { align-items: start; }
    h2 { font-size: 1.7rem; }
    .site-grid { grid-template-columns: 1fr; }
    .footer { gap: 18px; }
    .video-layout { grid-template-columns: 1fr; }
    .playlist-sidebar { order: 2; }
}
