:root {
    color-scheme: dark;
    --bg: #090b10;
    --surface: #11151d;
    --surface-raised: #171c27;
    --line: rgba(255, 255, 255, 0.1);
    --text: #f4f5f7;
    --muted: #9ca5b5;
    --accent: #d7ff64;
    --accent-ink: #151a08;
    --danger: #ff8b8b;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 75% -10%, #242b3c 0, transparent 34rem), var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
img { max-width: 100%; }
[hidden] { display: none !important; }

main { width: min(100%, 1600px); margin: 0 auto; padding: 0 3vw 5rem; }
#loading, #authentication { max-width: 44rem; margin: 12vh auto; }
#authentication { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1rem; }
#authentication > h1 { grid-column: 1 / -1; font-size: clamp(2.6rem, 7vw, 5rem); margin: 0; letter-spacing: -.06em; }
#authentication > section, #home > section:not(.recommendation-home), #home > section:not(.recommendation-home) section {
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: rgba(17, 21, 29, .86);
    padding: 1.25rem;
    margin-top: 1rem;
}

.app-header { min-height: 5.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: .7rem; color: var(--text); text-decoration: none; font-weight: 750; letter-spacing: -.025em; }
.brand-mark { display: grid; place-items: center; width: 2rem; aspect-ratio: 1; border-radius: .6rem; background: var(--accent); color: var(--accent-ink); font-weight: 900; }
.account-cluster { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: .8rem 1rem; color: var(--muted); font-size: .82rem; }
.connection-state::before { content: ""; display: inline-block; width: .48rem; aspect-ratio: 1; margin-right: .4rem; border-radius: 50%; background: #69d49a; box-shadow: 0 0 0 .22rem rgba(105, 212, 154, .12); }

.quiet-button, .media-tabs button { border: 1px solid var(--line); background: rgba(255,255,255,.035); color: var(--text); border-radius: 999px; padding: .55rem .9rem; }
.quiet-button:hover, .media-tabs button:hover { border-color: rgba(255,255,255,.25); background: rgba(255,255,255,.075); }

.recommendation-home { padding: clamp(3rem, 8vw, 7rem) 0 2.25rem; overflow: hidden; }
.recommendation-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; margin-bottom: 2.6rem; }
.eyebrow { margin: 0 0 .65rem; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.recommendation-intro h1 { max-width: 13ch; margin: 0; font-size: clamp(3rem, 8vw, 7.5rem); line-height: .87; letter-spacing: -.07em; }
.intro-copy { max-width: 36rem; margin: 1.35rem 0 0; color: var(--muted); font-size: clamp(1rem, 1.7vw, 1.25rem); }
.media-tabs { display: flex; gap: .45rem; padding-bottom: .2rem; }
.media-tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 750; }
.recommendation-status { min-height: 1.5rem; color: var(--muted); }
.recommendation-status.is-error { color: #ffd3a0; }
.recommendation-shelves { display: grid; gap: 2.8rem; }
.recommendation-shelf { min-width: 0; }
.shelf-heading { display: flex; align-items: baseline; gap: .8rem; margin-bottom: .85rem; }
.shelf-heading h2 { margin: 0; font-size: clamp(1.2rem, 2vw, 1.65rem); letter-spacing: -.035em; }
.shelf-heading p { margin: 0; color: var(--muted); font-size: .82rem; }
.poster-row { display: grid; grid-auto-flow: column; grid-auto-columns: clamp(9rem, 13.5vw, 13rem); gap: .85rem; overflow-x: auto; overscroll-behavior-inline: contain; scroll-snap-type: inline proximity; scrollbar-width: thin; scrollbar-color: #333a49 transparent; padding: .25rem .2rem 1rem; }
.media-card { position: relative; min-width: 0; border: 0; padding: 0; overflow: hidden; border-radius: .8rem; background: var(--surface-raised); color: var(--text); text-align: left; scroll-snap-align: start; box-shadow: 0 .6rem 1.5rem rgba(0,0,0,.18); transition: transform .18s ease, box-shadow .18s ease; }
.media-card:hover, .media-card:focus-visible { transform: translateY(-.32rem); box-shadow: 0 1.2rem 2.3rem rgba(0,0,0,.4); outline: 2px solid var(--accent); outline-offset: 2px; }
.poster-frame { position: relative; aspect-ratio: 2 / 3; background: linear-gradient(145deg, #252c3a, #141823); overflow: hidden; }
.poster-frame img { width: 100%; height: 100%; display: block; object-fit: cover; }
.poster-fallback { width: 100%; height: 100%; display: grid; place-items: center; padding: 1rem; color: #bbc1cc; font-size: 2rem; font-weight: 800; text-align: center; }
.media-card-copy { position: absolute; inset: auto 0 0; padding: 3.6rem .8rem .75rem; background: linear-gradient(transparent, rgba(5,7,10,.94) 58%); }
.media-card-title { display: block; overflow: hidden; font-size: .9rem; font-weight: 720; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.media-card-meta { display: block; margin-top: .25rem; color: #b7beca; font-size: .72rem; }
.similar-content-section { overflow: hidden; }
.similar-content-section .shelf-heading h4 { margin: 0; font-size: clamp(1.15rem, 2vw, 1.55rem); }

.catalog-heading { margin: 3.5rem 0 1rem; padding-top: 2.5rem; border-top: 1px solid var(--line); }
.catalog-heading h2 { margin: 0; font-size: clamp(1.8rem, 4vw, 3.4rem); letter-spacing: -.05em; }
#error-output { position: sticky; top: .75rem; z-index: 20; padding: 1rem; border: 1px solid rgba(255,139,139,.35); border-radius: .75rem; background: #381d22; color: #ffd5d5; white-space: pre-wrap; }
h2, h3, h4, h5 { letter-spacing: -.025em; }
p, li, dd { line-height: 1.55; }
label { color: #d6dae1; font-size: .86rem; }
input, select, textarea { width: min(100%, 40rem); margin-top: .25rem; border: 1px solid var(--line); border-radius: .55rem; background: #0b0e14; color: var(--text); padding: .7rem .8rem; }
button:not(.media-card):not(.quiet-button):not([role="tab"]) { border: 1px solid var(--line); border-radius: .55rem; background: #252b38; color: var(--text); padding: .62rem .9rem; }
button:not(.media-card):not(.quiet-button):not([role="tab"]):hover { background: #303746; }
dl { display: grid; grid-template-columns: minmax(8rem, 12rem) 1fr; gap: .45rem 1rem; }
dt { color: var(--muted); }
dd { margin: 0; }
ul, ol { padding-left: 1.35rem; }

@media (max-width: 760px) {
    main { padding-inline: 1rem; }
    .app-header, .recommendation-intro { align-items: flex-start; flex-direction: column; }
    .app-header { padding: 1rem 0; }
    .account-cluster { justify-content: flex-start; }
    .recommendation-home { padding-top: 3.5rem; }
    .recommendation-intro h1 { font-size: clamp(3.3rem, 17vw, 5rem); }
    .media-tabs { width: 100%; overflow-x: auto; }
    .poster-row { grid-auto-columns: 9.5rem; }
    .shelf-heading { align-items: flex-start; flex-direction: column; gap: .2rem; }
    dl { grid-template-columns: 1fr; }
    dd { margin-bottom: .75rem; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .media-card { transition: none; }
}
