:root {
    --paper: #fbfaf7;
    --surface: #ffffff;
    --surface-soft: #f2eee8;
    --ink: #1d252c;
    --muted: #68737d;
    --line: #ded7cd;
    --accent: #126c63;
    --accent-dark: #0c4f49;
    --gold: #b67918;
    --danger: #b42332;
    --shadow: 0 18px 48px rgba(29, 37, 44, .11);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
    min-height: 100vh;
}

body::before {
    background-image:
        linear-gradient(rgba(29, 37, 44, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(29, 37, 44, .035) 1px, transparent 1px);
    background-size: 36px 36px;
    content: "";
    inset: 0;
    pointer-events: none;
    position: fixed;
}

a {
    color: inherit;
    text-decoration: none;
}

.shell {
    margin: 0 auto;
    max-width: 1220px;
    padding: 26px;
    position: relative;
}

.topbar {
    align-items: center;
    background: rgba(251, 250, 247, .92);
    border: 1px solid rgba(222, 215, 205, .85);
    border-radius: 8px;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin-bottom: 30px;
    padding: 14px 16px;
    position: sticky;
    top: 14px;
    z-index: 20;
}

.topbar.is-compact {
    box-shadow: 0 12px 28px rgba(29, 37, 44, .08);
}

.brand {
    color: var(--accent-dark);
    display: grid;
    font-size: 21px;
    font-weight: 850;
    gap: 1px;
    letter-spacing: 0;
}

.brand small {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.nav {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.nav a,
.link-button {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-weight: 750;
    min-height: 36px;
    padding: 8px 12px;
    transition: border-color .2s ease, color .2s ease, transform .2s ease;
}

.nav a:hover,
.link-button:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
    transform: translateY(-1px);
}

.notice {
    border-radius: 8px;
    margin-bottom: 18px;
    padding: 14px 16px;
}

.notice.success {
    background: #e6f3ec;
    border: 1px solid #b8ddc8;
    color: #166534;
}

.notice.error {
    background: #fff0f1;
    border: 1px solid #f0c6cc;
    color: var(--danger);
}

.login-panel {
    align-items: stretch;
    display: grid;
    gap: 24px;
    grid-template-columns: minmax(0, 1fr) 390px;
    min-height: 70vh;
}

.login-copy {
    align-content: center;
    background: #12343b;
    border: 1px solid #0b2930;
    border-radius: 8px;
    color: #fff;
    display: grid;
    overflow: hidden;
    padding: 58px;
    position: relative;
}

.login-copy::after {
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 50%;
    content: "";
    height: 280px;
    position: absolute;
    right: -90px;
    top: -80px;
    width: 280px;
}

.login-copy h1,
.page-head h1,
.detail-content h1 {
    font-size: 44px;
    line-height: 1.03;
    margin: 0 0 14px;
}

.login-copy p {
    color: #d8e6e4;
    font-size: 18px;
    line-height: 1.65;
    max-width: 620px;
}

.eyebrow {
    color: var(--gold);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: 0;
    margin: 0 0 10px;
    text-transform: uppercase;
}

.helper-text {
    color: var(--muted);
    line-height: 1.65;
    margin: -6px 0 0;
    max-width: 640px;
}

.form-panel,
.filter-bar,
.detail-content,
.movie-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.form-panel {
    align-self: center;
    display: grid;
    gap: 18px;
    padding: 28px;
}

label {
    color: var(--muted);
    display: grid;
    font-size: 13px;
    font-weight: 750;
    gap: 8px;
}

input,
select {
    background: #fff;
    border: 1px solid #cfc7bc;
    border-radius: 6px;
    color: var(--ink);
    font: inherit;
    min-height: 44px;
    padding: 10px 12px;
    transition: border-color .2s ease, box-shadow .2s ease;
    width: 100%;
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(18, 108, 99, .12);
    outline: 0;
}

.primary-button,
.secondary-button,
.danger-button,
.favorite-button {
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 850;
    justify-content: center;
    min-height: 44px;
    padding: 11px 16px;
    transition: background .2s ease, border-color .2s ease, color .2s ease, transform .2s ease, box-shadow .2s ease;
}

.primary-button {
    background: var(--accent);
    color: #fff;
}

.primary-button:hover {
    background: var(--accent-dark);
    box-shadow: 0 10px 24px rgba(18, 108, 99, .2);
    transform: translateY(-1px);
}

.secondary-button {
    background: var(--surface-soft);
    border-color: var(--line);
    color: var(--ink);
}

.danger-button {
    background: #fff0f1;
    border-color: #f0c6cc;
    color: var(--danger);
}

.favorite-button {
    background: #fff8e8;
    border-color: #ead49d;
    color: #7a4f01;
    width: 100%;
}

.favorite-button:hover,
.secondary-button:hover,
.danger-button:hover {
    transform: translateY(-1px);
}

.favorite-button.is-active {
    background: #e8f5ef;
    border-color: #b8ddc8;
    color: #166534;
}

.page-head {
    align-items: end;
    display: flex;
    justify-content: space-between;
    margin-bottom: 18px;
}

.filter-bar {
    align-items: end;
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(240px, 1fr) 170px 140px auto auto;
    margin-bottom: 24px;
    padding: 18px;
}

.movie-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fill, minmax(218px, 1fr));
}

.movie-card {
    overflow: hidden;
    transform-origin: center bottom;
    transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.movie-card:hover {
    border-color: #c1b7aa;
    box-shadow: 0 24px 54px rgba(29, 37, 44, .14);
    transform: translateY(-5px);
}

.poster-link {
    background: var(--surface-soft);
    display: block;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    position: relative;
}

.poster-link::after {
    background: rgba(29, 37, 44, .04);
    content: "";
    inset: 0;
    opacity: 0;
    position: absolute;
    transition: opacity .2s ease;
}

.movie-card:hover .poster-link::after {
    opacity: 1;
}

.poster-link img,
.detail-poster img {
    display: block;
    height: 100%;
    object-fit: cover;
    transition: transform .45s ease, opacity .25s ease;
    width: 100%;
}

.movie-card:hover .poster-link img {
    transform: scale(1.035);
}

img.is-loading {
    opacity: .2;
}

.poster-empty {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-weight: 850;
    height: 100%;
    justify-content: center;
    min-height: 240px;
}

.movie-card-body {
    display: grid;
    gap: 14px;
    padding: 15px;
}

.movie-card h2 {
    font-size: 17px;
    line-height: 1.32;
    margin: 0 0 7px;
}

.movie-card h2 a:hover {
    color: var(--accent-dark);
}

.movie-card p {
    color: var(--muted);
    margin: 0;
}

.empty-state,
.scroll-status {
    background: var(--surface);
    border: 1px dashed #c8bfb4;
    border-radius: 8px;
    color: var(--muted);
    padding: 30px;
    text-align: center;
}

.scroll-status {
    display: none;
    margin-top: 18px;
}

.back-link {
    color: var(--accent-dark);
    display: inline-block;
    font-weight: 850;
    margin-bottom: 18px;
    transition: transform .2s ease;
}

.back-link:hover {
    transform: translateX(-3px);
}

.detail-layout {
    display: grid;
    gap: 28px;
    grid-template-columns: 330px minmax(0, 1fr);
}

.detail-poster {
    aspect-ratio: 2 / 3;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.detail-content {
    padding: 28px;
}

.plot {
    color: var(--muted);
    font-size: 17px;
    line-height: 1.75;
}

.movie-meta {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 24px 0;
}

.movie-meta div {
    border-top: 1px solid #ece5dc;
    padding-top: 12px;
}

.movie-meta dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.movie-meta dd {
    margin: 0;
}

.reveal {
    opacity: 0;
    transform: translateY(14px);
}

.reveal.is-visible {
    animation: rise-in .58s cubic-bezier(.2, .8, .2, 1) forwards;
}

.favorite-pop {
    animation: button-pop .32s ease;
}

@keyframes rise-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes button-pop {
    50% {
        transform: scale(.97);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }

    .reveal {
        opacity: 1;
        transform: none;
    }
}

@media (max-width: 900px) {
    .filter-bar {
        grid-template-columns: 1fr 1fr;
    }

    .filter-bar .primary-button,
    .filter-bar .secondary-button {
        width: 100%;
    }
}

@media (max-width: 780px) {
    .shell {
        padding: 16px;
    }

    .topbar,
    .page-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .nav {
        justify-content: flex-start;
    }

    .login-panel,
    .detail-layout,
    .filter-bar {
        grid-template-columns: 1fr;
    }

    .login-copy {
        padding: 30px;
    }

    .login-copy h1,
    .page-head h1,
    .detail-content h1 {
        font-size: 32px;
    }

    .movie-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .movie-meta {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .topbar {
        padding: 12px;
        top: 8px;
    }

    .nav a,
    .link-button {
        min-height: 34px;
        padding: 7px 10px;
    }

    .movie-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .movie-card-body {
        padding: 12px;
    }

    .movie-card h2 {
        font-size: 15px;
    }
}
