html,
body {
    margin: 0;
    min-height: 100%;
    background: #0d1117;
    color: #f2f6fb;
    font-family: "Segoe UI", Arial, sans-serif;
}

a {
    color: inherit;
}

button,
.primary-action {
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    background: #1db954;
    color: #051b0e;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.shell {
    width: min(1180px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 24px 0 40px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding-bottom: 20px;
}

.topbar h1,
.topbar p {
    margin: 0;
}

.topbar p,
.muted,
.artist,
.album,
.track-row span,
.track-row small {
    color: #a7b1c2;
}

.actions {
    display: flex;
    gap: 10px;
}

.error {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-left: 4px solid #ff5d5d;
    background: #35151b;
    color: #ffdede;
}

.connect-panel,
.loading-panel {
    margin-top: 10vh;
    padding: 28px;
    background: #151b23;
    border: 1px solid #303846;
    border-radius: 8px;
}

.connect-panel h2,
.loading-panel h2 {
    margin-top: 0;
}

.connect-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.password-input {
    min-width: min(100%, 260px);
    border: 1px solid #303846;
    border-radius: 8px;
    padding: 10px 12px;
    background: #0d1117;
    color: #f2f6fb;
    font: inherit;
}

.password-input:focus {
    border-color: #1db954;
    outline: 2px solid rgba(29, 185, 84, 0.22);
}

.connect-error {
    margin: 12px 0 0;
    color: #ffb0b0;
}

.now-grid {
    display: grid;
    grid-template-columns: minmax(280px, 420px) 1fr;
    gap: 28px;
    align-items: center;
    padding: 24px;
    background: #151b23;
    border: 1px solid #303846;
    border-radius: 8px;
}

.art-frame {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: #222a35;
}

.art-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.empty-art,
.mini-empty {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    color: #758195;
    background: #222a35;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 10px;
    color: #1db954;
    font-weight: 800;
    text-transform: uppercase;
}

.now-copy h2 {
    margin: 0;
    font-size: clamp(2rem, 6vw, 5rem);
    line-height: 1;
}

.artist {
    margin: 18px 0 6px;
    font-size: 1.35rem;
}

.album {
    margin: 0 0 6px;
}

.progress {
    height: 8px;
    margin-top: 20px;
    overflow: hidden;
    border-radius: 999px;
    background: #303846;
}

.progress div {
    height: 100%;
    background: #1db954;
}

.lists {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 24px;
}

.lists > div {
    padding: 18px;
    background: #151b23;
    border: 1px solid #303846;
    border-radius: 8px;
}

.lists h2 {
    margin: 0 0 14px;
}

.list-context {
    margin: -8px 0 12px;
    color: #a7b1c2;
    font-size: 0.9rem;
}

.track-row {
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-top: 1px solid #27303d;
}

.track-row:first-of-type {
    border-top: 0;
}

.track-row img,
.mini-empty {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    object-fit: cover;
}

.track-row strong,
.track-row span,
.track-row small {
    display: block;
}

@media (max-width: 780px) {
    .topbar,
    .actions {
        align-items: stretch;
        flex-direction: column;
    }

    .now-grid,
    .lists {
        grid-template-columns: 1fr;
    }

    .now-copy h2 {
        font-size: 2.4rem;
    }
}

.tv-shell {
    box-sizing: border-box;
    height: 100vh;
    height: 100svh;
    min-height: 0;
    overflow: hidden;
    padding: 16px;
}

.tv-layout {
    display: grid;
    grid-template-rows: minmax(0, 1.35fr) minmax(0, 0.85fr);
    gap: 16px;
    height: calc(100vh - 32px);
    height: calc(100svh - 32px);
    min-height: 0;
}

.tv-panel {
    min-height: 0;
    overflow: hidden;
    border: 1px solid #303846;
    border-radius: 8px;
    background: #151b23;
}

.tv-center {
    display: grid;
    place-items: center;
    height: calc(100vh - 32px);
    height: calc(100svh - 32px);
    padding: 24px;
    text-align: center;
}

.tv-center h1 {
    margin: 0;
    font-size: 3rem;
}

.tv-error {
    position: fixed;
    z-index: 2;
    top: 12px;
    right: 12px;
    max-width: min(680px, calc(100vw - 24px));
    padding: 10px 12px;
    border-left: 4px solid #ff5d5d;
    border-radius: 6px;
    background: #35151b;
    color: #ffdede;
    font-size: 0.9rem;
}

.tv-now {
    display: grid;
    grid-template-columns: minmax(0, 46vh) minmax(0, 1fr);
    gap: 22px;
    align-items: center;
    padding: 18px;
}

.tv-art {
    aspect-ratio: 1;
    width: min(100%, 46vh);
    max-height: 100%;
    justify-self: center;
    overflow: hidden;
    border-radius: 8px;
    background: #222a35;
}

.tv-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tv-empty-art,
.tv-mini-empty {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    color: #758195;
    background: #222a35;
}

.tv-now-copy {
    min-width: 0;
}

.tv-eyebrow {
    display: block;
    margin-bottom: 8px;
    color: #1db954;
    font-weight: 800;
    text-transform: uppercase;
}

.tv-now-copy h1 {
    display: -webkit-box;
    overflow: hidden;
    margin: 0;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: 4rem;
    line-height: 1;
    overflow-wrap: anywhere;
}

.tv-artist {
    display: -webkit-box;
    overflow: hidden;
    margin: 14px 0 4px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    color: #a7b1c2;
    font-size: 1.45rem;
}

.tv-album {
    overflow: hidden;
    margin: 0;
    color: #a7b1c2;
    font-size: 1.1rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tv-progress {
    height: 8px;
    margin-top: 18px;
    overflow: hidden;
    border-radius: 999px;
    background: #303846;
}

.tv-progress div {
    height: 100%;
    background: #1db954;
}

.tv-lists {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
    min-height: 0;
}

.tv-list {
    padding: 14px 16px;
}

.tv-list h2 {
    margin: 0 0 8px;
    font-size: 1.45rem;
}

.tv-muted {
    margin: 0;
    color: #a7b1c2;
}

.tv-track {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-height: 60px;
    padding: 7px 0;
    border-top: 1px solid #27303d;
}

.tv-track:first-of-type {
    border-top: 0;
}

.tv-track img,
.tv-mini-empty {
    width: 54px;
    height: 54px;
    border-radius: 6px;
    object-fit: cover;
}

.tv-track strong,
.tv-track span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tv-track strong {
    font-size: 1.05rem;
}

.tv-track span {
    color: #a7b1c2;
    font-size: 0.95rem;
}

@media (max-height: 720px) {
    .tv-shell {
        padding: 10px;
    }

    .tv-layout {
        grid-template-rows: minmax(0, 1.2fr) minmax(0, 0.8fr);
        gap: 10px;
        height: calc(100vh - 20px);
        height: calc(100svh - 20px);
    }

    .tv-now {
        grid-template-columns: minmax(0, 42vh) minmax(0, 1fr);
        gap: 14px;
        padding: 12px;
    }

    .tv-art {
        width: min(100%, 42vh);
    }

    .tv-now-copy h1 {
        font-size: 3rem;
    }

    .tv-artist {
        margin-top: 10px;
        font-size: 1.15rem;
    }

    .tv-list {
        padding: 10px 12px;
    }

    .tv-list h2 {
        font-size: 1.2rem;
    }

    .tv-track {
        grid-template-columns: 44px minmax(0, 1fr);
        min-height: 49px;
        padding: 4px 0;
    }

    .tv-track img,
    .tv-mini-empty {
        width: 44px;
        height: 44px;
    }
}

.tv-scale-viewport {
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100vw;
    height: 100vh;
    height: 100svh;
    overflow: hidden;
}

.tv-scale-content {
    flex: 0 0 auto;
    transform-origin: top center;
}

.tv-fit-page {
    box-sizing: border-box;
    display: grid;
    grid-template-rows: auto minmax(0, 1.2fr) minmax(0, 0.8fr);
    gap: 12px;
    height: 100vh;
    height: 100svh;
    overflow: hidden;
    padding: 12px 0;
}

.tv-fit-page .topbar {
    min-height: 0;
    padding-bottom: 0;
}

.tv-fit-page .topbar h1 {
    font-size: 1.7rem;
    line-height: 1;
}

.tv-fit-page .tv-fit-error {
    position: fixed;
    z-index: 2;
    top: 10px;
    right: 10px;
    max-width: min(680px, calc(100vw - 20px));
    margin: 0;
}

.tv-fit-page .now-grid {
    grid-template-columns: minmax(0, 34vh) minmax(0, 1fr);
    gap: 18px;
    align-items: center;
    min-height: 0;
    padding: 14px;
}

.tv-fit-page .art-frame {
    width: min(100%, 34vh);
    max-height: 100%;
    justify-self: center;
}

.tv-fit-page .now-copy {
    min-width: 0;
}

.tv-fit-page .eyebrow {
    margin-bottom: 6px;
    font-size: 0.82rem;
}

.tv-fit-page .now-copy h2 {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: clamp(1.6rem, 4.4vh, 3.4rem);
    line-height: 1;
    overflow-wrap: anywhere;
}

.tv-fit-page .artist {
    display: -webkit-box;
    overflow: hidden;
    margin: 10px 0 4px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    font-size: clamp(1rem, 2.3vh, 1.3rem);
}

.tv-fit-page .album {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tv-fit-page .progress {
    height: 7px;
    margin-top: 14px;
}

.tv-fit-page .lists {
    gap: 12px;
    min-height: 0;
    margin-top: 0;
}

.tv-fit-page .lists > div {
    min-height: 0;
    overflow: hidden;
    padding: 12px;
}

.tv-fit-page .lists h2 {
    margin-bottom: 8px;
    font-size: 1.2rem;
}

.tv-fit-page .list-context {
    margin: -5px 0 6px;
    font-size: 0.78rem;
}

.tv-fit-page .track-row {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 9px;
    min-height: 48px;
    padding: 5px 0;
}

.tv-fit-page .track-row img,
.tv-fit-page .mini-empty {
    width: 42px;
    height: 42px;
}

.tv-fit-page .track-row strong,
.tv-fit-page .track-row span,
.tv-fit-page .track-row small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tv-fit-page .track-row strong {
    font-size: 0.95rem;
}

.tv-fit-page .track-row span,
.tv-fit-page .track-row small,
.tv-fit-page .muted {
    font-size: 0.85rem;
}

.tv-fit-page .connect-panel,
.tv-fit-page .loading-panel {
    align-self: stretch;
    min-height: 0;
    margin-top: 0;
    padding: 18px;
}

@media (max-height: 720px) {
    .tv-fit-page {
        grid-template-rows: auto minmax(0, 1.05fr) minmax(0, 0.8fr);
        gap: 8px;
        padding: 8px 0;
    }

    .tv-fit-page .topbar h1 {
        font-size: 1.35rem;
    }

    .tv-fit-page .now-grid {
        grid-template-columns: minmax(0, 30vh) minmax(0, 1fr);
        gap: 12px;
        padding: 10px;
    }

    .tv-fit-page .art-frame {
        width: min(100%, 30vh);
    }

    .tv-fit-page .now-copy h2 {
        font-size: clamp(1.35rem, 4vh, 2.6rem);
    }

    .tv-fit-page .artist {
        margin-top: 7px;
        font-size: 0.95rem;
    }

    .tv-fit-page .album {
        font-size: 0.85rem;
    }

    .tv-fit-page .progress {
        margin-top: 9px;
    }

    .tv-fit-page .lists > div {
        padding: 9px;
    }

    .tv-fit-page .track-row {
        grid-template-columns: 36px minmax(0, 1fr);
        min-height: 40px;
        padding: 3px 0;
    }

    .tv-fit-page .track-row img,
    .tv-fit-page .mini-empty {
        width: 36px;
        height: 36px;
    }
}
