:root {
  color-scheme: dark;
  --bg: #0c0d12;
  --panel: #14151c;
  --panel-2: #1a1b23;
  --text: #f5f2e9;
  --muted: #9b9ba7;
  --accent: #ff5c35;
  --accent-soft: rgba(255, 92, 53, 0.14);
  --line: rgba(255, 255, 255, 0.09);
  --green: #8cdb91;
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "DM Sans", sans-serif; min-height: 100vh; }
button, input { font: inherit; }
button { color: inherit; }
.app-shell { min-height: 100vh; overflow: hidden; }

.topbar { height: 78px; max-width: 1180px; margin: auto; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 10px; font: 800 21px "Manrope", sans-serif; }
.brand > span:last-child span { color: var(--accent); }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: #fff; background: var(--accent); font-size: 12px; padding-left: 2px; box-shadow: 0 7px 28px rgba(255,92,53,.3); }
.main-nav { display: flex; gap: 8px; }
.nav-link, .icon-button, .text-button { border: 0; background: transparent; cursor: pointer; }
.nav-link { color: var(--muted); padding: 10px 13px; border-radius: 10px; font-size: 14px; }
.nav-link:hover, .nav-link.active { color: var(--text); background: rgba(255,255,255,.05); }
.nav-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 3px; background: var(--accent); color: white; border-radius: 99px; font-size: 11px; }
.icon-button { width: 38px; height: 38px; color: var(--muted); border: 1px solid var(--line); border-radius: 12px; font-size: 19px; }
.icon-button:hover { color: var(--text); border-color: rgba(255,255,255,.2); }

main { max-width: 1180px; margin: auto; padding: 0 28px; }
.view { display: none; animation: fade .35s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } }

#discover-view.active { display: grid; grid-template-columns: 1.05fr .95fr; padding-top: 92px; }
.hero { position: relative; z-index: 2; padding: 22px 0 98px; }
.eyebrow, .section-label { color: var(--accent); text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 700; }
h1, h2, h3 { font-family: "Manrope", sans-serif; margin-top: 0; }
h1 { max-width: 670px; font-size: clamp(54px, 7vw, 86px); line-height: .98; letter-spacing: -.06em; margin: 20px 0 28px; }
h1 em { color: var(--accent); font-style: normal; }
.hero > p { max-width: 530px; color: var(--muted); font-size: 18px; line-height: 1.7; margin-bottom: 30px; }
.primary-button, .secondary-button { position: relative; overflow: hidden; min-height: 48px; border-radius: 13px; padding: 0 20px; cursor: pointer; font-weight: 700; border: 1px solid transparent; transition: transform .2s, background .2s, border-color .2s, box-shadow .2s; }
.primary-button { background: var(--accent); color: #fff; box-shadow: 0 9px 30px rgba(255,92,53,.2); }
.primary-button:hover { transform: translateY(-2px); background: #ff704d; }
.primary-button:disabled { cursor: wait; opacity: .72; transform: none; }
.primary-button:active, .secondary-button:active { transform: translateY(1px) scale(.98); }
.primary-button:focus-visible, .secondary-button:focus-visible, .text-button:focus-visible, .option-grid label:focus-within { outline: 2px solid #ffad99; outline-offset: 3px; }
.secondary-button { background: transparent; border-color: var(--line); color: var(--text); }
.secondary-button:hover { border-color: rgba(255,255,255,.25); background: rgba(255,255,255,.04); }
.trust-row { display: flex; gap: 25px; color: #777985; font-size: 12px; margin-top: 22px; }

.hero-art { position: relative; min-height: 520px; display: grid; place-items: center; }
.orb { position: absolute; border-radius: 50%; filter: blur(2px); opacity: .7; }
.orb-one { width: 320px; height: 320px; background: radial-gradient(circle at 35% 35%, #8f3f31, #221315 70%); }
.orb-two { width: 190px; height: 190px; border: 1px solid rgba(255,92,53,.2); transform: translate(170px, -130px); }
.feature-card { position: relative; z-index: 2; width: 340px; padding: 14px; border: 1px solid rgba(255,255,255,.13); border-radius: 22px; background: rgba(20,21,28,.83); backdrop-filter: blur(18px); box-shadow: 0 30px 80px rgba(0,0,0,.5); display: grid; grid-template-columns: 116px 1fr; gap: 18px; align-items: center; transform: rotate(-3deg); }
.mini-poster { height: 160px; border-radius: 14px; display: flex; align-items: end; padding: 15px; font: 800 20px/1 "Manrope"; letter-spacing: -.06em; }
.poster-dune { background: linear-gradient(155deg, transparent, rgba(0,0,0,.55)), radial-gradient(circle at 75% 28%, #f4b16d 0 5%, transparent 6%), linear-gradient(145deg, #6c2f2b, #dc713d 52%, #2a1718 53%); }
.feature-card small { color: var(--muted); }
.feature-card h3 { font-size: 22px; margin: 8px 0 3px; }
.feature-card p { margin: 0; color: var(--muted); font-size: 13px; }
.match { color: var(--green); font-size: 12px; font-weight: 700; margin-top: 17px; }
.match span { display: inline-block; width: 7px; height: 7px; background: var(--green); border-radius: 50%; margin-right: 5px; }

.how-it-works { grid-column: 1 / -1; border-top: 1px solid var(--line); padding: 70px 0 90px; display: grid; grid-template-columns: .8fr 2fr; gap: 60px; }
.how-it-works h2 { font-size: 32px; max-width: 300px; margin-top: 12px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 35px; }
.steps article > span { color: var(--accent); font: 700 12px "Manrope"; }
.steps h3 { margin: 25px 0 8px; font-size: 17px; }
.steps p { color: var(--muted); line-height: 1.6; font-size: 14px; }

.quiz-view { padding: 42px 0 90px; }
.text-button { color: var(--muted); padding: 8px 0; }
.text-button:hover { color: var(--text); }
.quiz-layout { display: grid; grid-template-columns: 290px 1fr; gap: 70px; padding-top: 45px; }
.quiz-sidebar h2, .results-heading h2, .library-heading h2 { font-size: clamp(36px, 5vw, 54px); letter-spacing: -.045em; margin: 13px 0; }
.quiz-sidebar p, .library-heading p { color: var(--muted); line-height: 1.6; }
.progress-track { height: 4px; background: var(--line); border-radius: 4px; margin: 42px 0 12px; overflow: hidden; }
.progress-track span { display: block; width: 20%; height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }
.quiz-sidebar small { color: var(--muted); }
.quiz-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(25px, 5vw, 50px); min-height: 470px; }
.question { display: none; border: 0; padding: 0; margin: 0; }
.question.active { display: block; animation: fade .25s ease; }
.question legend { font: 700 clamp(28px, 4vw, 38px) "Manrope"; letter-spacing: -.035em; }
.question > p { color: var(--muted); margin: 10px 0 28px; }
.option-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.option-grid label { cursor: pointer; }
.option-grid input { position: absolute; opacity: 0; pointer-events: none; }
.option-grid label > span { min-height: 76px; border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; justify-content: center; padding: 15px 18px; background: rgba(255,255,255,.02); transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease; }
.option-grid label:hover > span { border-color: rgba(255,255,255,.22); background: rgba(255,255,255,.04); }
.option-grid label:active > span { transform: scale(.975); }
.option-grid input:checked + span { transform: translateY(-2px); border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent), 0 8px 22px rgba(255,92,53,.12); }
.option-grid small { color: var(--muted); margin-top: 4px; }
.mood-options { grid-template-columns: repeat(3, 1fr); }
.mood-options label > span { gap: 7px; min-height: 90px; }
.genre-options { grid-template-columns: repeat(3, 1fr); }
.genre-options label > span { min-height: 60px; }
.vibe-controls { display: grid; gap: 20px; }
.vibe-controls label { display: grid; grid-template-columns: 1fr 90px; gap: 7px 18px; align-items: center; }
.vibe-controls label > span { grid-column: 1 / -1; display: flex; justify-content: space-between; color: var(--muted); font-size: 15px; transition: color .2s; }
.vibe-controls label > span b:last-child { color: var(--text); }
.vibe-controls label:focus-within > span { color: var(--text); }
.vibe-controls input { width: 100%; accent-color: var(--accent); cursor: grab; }
.vibe-controls input:active { cursor: grabbing; }
.vibe-controls input:focus-visible { outline: 2px solid rgba(255,92,53,.55); outline-offset: 5px; border-radius: 6px; }
.vibe-controls input::-webkit-slider-thumb { transition: box-shadow .18s ease, transform .18s ease; }
.vibe-controls input:active::-webkit-slider-thumb { transform: scale(1.2); box-shadow: 0 0 0 8px rgba(255,92,53,.16); }
.vibe-controls input::-moz-range-thumb { transition: box-shadow .18s ease, transform .18s ease; }
.vibe-controls input:active::-moz-range-thumb { transform: scale(1.2); box-shadow: 0 0 0 8px rgba(255,92,53,.16); }
.vibe-controls output { color: var(--accent); text-align: right; font-size: 14px; font-weight: 700; transition: transform .18s ease; }
.vibe-controls input:active + output { transform: scale(1.06); }
.provider-status { min-height: 20px; color: var(--muted); font-size: 12px; margin: -14px 0 14px; }
.provider-options { max-height: 255px; overflow-y: auto; padding-right: 5px; }
.provider-options label > span { min-height: 64px; }
.provider-logo { width: 28px; height: 28px; border-radius: 7px; object-fit: cover; margin-right: 9px; vertical-align: middle; }
.quiz-actions { display: flex; justify-content: space-between; margin-top: 40px; }
.quiz-actions .primary-button, .quiz-actions .secondary-button { min-width: 122px; }
.form-error { height: 18px; color: #ff8f76; font-size: 13px; margin-bottom: 0; }

.results-view, .library-view { padding: 75px 0 100px; }
.movie-detail-view { padding: 42px 0 100px; }
.results-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 22px; }
.results-heading h2 { margin-bottom: 0; }
.answer-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 40px; }
.answer-summary span { color: var(--muted); font-size: 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 99px; }
.pick-legend { display: flex; flex-wrap: wrap; gap: 10px 22px; margin: -18px 0 28px; color: var(--muted); font-size: 12px; }
.pick-legend b { color: var(--text); margin-right: 4px; }
.movie-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.movie-card { overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; transition: transform .2s, border-color .2s; }
.movie-card:hover { transform: translateY(-5px); border-color: rgba(255,255,255,.17); }
.movie-poster { position: relative; height: 270px; padding: 22px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
.detail-trigger { width: 100%; border: 0; color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.detail-trigger::after { pointer-events: none; }
.detail-trigger:hover .poster-hint, .detail-trigger:focus-visible .poster-hint { opacity: 1; transform: translateY(0); }
.detail-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
.poster-hint { position: relative; z-index: 2; align-self: end; margin-top: -38px; padding: 8px 10px; border-radius: 9px; background: rgba(12,13,18,.78); font-size: 11px; opacity: 0; transform: translateY(5px); transition: .2s; }
.movie-poster::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 35%, rgba(0,0,0,.72)); }
.poster-icon { position: relative; z-index: 1; align-self: end; font-size: 42px; opacity: .65; }
.poster-title { position: relative; z-index: 1; font: 800 30px/.95 "Manrope"; max-width: 210px; letter-spacing: -.06em; text-transform: uppercase; }
.score-badge { position: absolute; z-index: 3; top: 14px; left: 14px; background: rgba(12,13,18,.82); backdrop-filter: blur(8px); padding: 8px 10px; border-radius: 10px; color: var(--green); font-size: 12px; font-weight: 700; }
.pick-role { position: absolute; z-index: 3; top: 14px; right: 14px; background: var(--accent); padding: 8px 10px; border-radius: 10px; color: white; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.movie-info { padding: 18px; }
.movie-title-button { display: block; border: 0; padding: 0; background: none; color: var(--text); cursor: pointer; text-align: left; font: 700 20px "Manrope", sans-serif; margin: 0 0 6px; }
.movie-title-button:hover { color: #ff9a80; }
.movie-title-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
.meta { color: var(--muted); font-size: 13px; }
.reason { min-height: 44px; color: #c2c1c7; line-height: 1.5; font-size: 13px; margin: 15px 0; }
.card-actions { display: flex; gap: 8px; }
.card-actions button { flex: 1; min-height: 38px; border: 1px solid var(--line); border-radius: 10px; background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; }
.card-actions button:hover, .card-actions button.saved { background: var(--accent-soft); border-color: var(--accent); }
.empty-state { grid-column: 1 / -1; text-align: center; padding: 90px 20px; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty-state span { font-size: 45px; }
.empty-state h3 { margin: 18px 0 7px; }
.empty-state p { color: var(--muted); margin-bottom: 23px; }

.detail-loading { min-height: 65vh; display: grid; place-content: center; justify-items: center; gap: 15px; color: var(--muted); }
.loading-orbit { width: 34px; height: 34px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.detail-hero { position: relative; isolation: isolate; display: grid; grid-template-columns: minmax(190px, 290px) minmax(0, 1fr); gap: clamp(30px, 6vw, 75px); align-items: center; min-height: 490px; margin: 24px -28px 0; padding: 65px 55px; overflow: hidden; background: #171820; }
.detail-hero::before { content: ""; position: absolute; z-index: -2; inset: 0; background-image: linear-gradient(90deg, rgba(12,13,18,.94) 4%, rgba(12,13,18,.79) 45%, rgba(12,13,18,.56)), linear-gradient(0deg, var(--bg), transparent 65%), var(--detail-backdrop); background-position: center; background-size: cover; filter: blur(2px); transform: scale(1.02); }
.detail-hero::after { content: ""; position: absolute; z-index: -1; inset: 0; background: radial-gradient(ellipse at 76% 30%, rgba(255,92,53,.12), transparent 44%); }
.detail-poster { width: 100%; aspect-ratio: 2 / 3; max-height: 410px; display: grid; place-items: center; overflow: hidden; border: 1px solid rgba(255,255,255,.18); border-radius: 18px; background-position: center; background-size: cover; box-shadow: 0 28px 70px rgba(0,0,0,.48); }
.detail-poster span { font-size: 68px; }
.detail-copy { max-width: 720px; }
.detail-copy h1 { margin: 14px 0 10px; font-size: clamp(42px, 7vw, 78px); }
.detail-tagline { color: #d2c5bd; font-size: 18px; font-style: italic; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 10px 20px; color: #e0dce0; font-size: 14px; margin: 22px 0; }
.detail-genres { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-genres span { padding: 7px 11px; border: 1px solid rgba(255,255,255,.19); border-radius: 99px; background: rgba(10,11,16,.34); font-size: 12px; }
.detail-overview { max-width: 660px; color: #e0dde0; font-size: 16px; line-height: 1.75; margin: 23px 0 14px; }
.detail-why { max-width: 650px; padding-left: 13px; border-left: 2px solid var(--accent); color: #c2c1c7; line-height: 1.6; font-size: 13px; }
.detail-why b { display: inline-block; color: var(--text); margin-bottom: 4px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 25px; }
.detail-actions .saved { background: var(--accent-soft); border-color: var(--accent); }
.detail-homepage { display: inline-flex; align-items: center; text-decoration: none; }
.similar-section { padding-top: 70px; }
.similar-heading { margin-bottom: 28px; }
.similar-heading h2 { margin: 12px 0 8px; font: 700 clamp(30px, 4vw, 42px) "Manrope", sans-serif; letter-spacing: -.04em; }
.similar-heading p, .detail-note { max-width: 650px; color: var(--muted); line-height: 1.6; }
.detail-note { padding: 12px 15px; border: 1px solid var(--line); border-radius: 12px; }
.similar-grid .movie-poster { height: 235px; }

.history-stats { display: flex; gap: 12px; margin: 30px 0; }
.stat { min-width: 150px; padding: 16px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.stat b { display: block; font: 700 25px "Manrope"; }
.stat small { color: var(--muted); }
.history-list { display: grid; gap: 10px; }
.history-row { display: grid; grid-template-columns: 52px 1fr auto auto; gap: 18px; align-items: center; padding: 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.history-thumb { width: 52px; height: 64px; border-radius: 8px; display: grid; place-items: center; font-size: 20px; }
.history-row h3 { font-size: 15px; margin: 0 0 3px; }
.history-row p { margin: 0; color: var(--muted); font-size: 12px; }
.stars { display: flex; gap: 2px; }
.star { border: 0; background: transparent; cursor: pointer; color: #51525d; padding: 2px; font-size: 18px; }
.star.filled { color: #ffc857; }
.remove-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 8px; }
footer { max-width: 1180px; margin: auto; border-top: 1px solid var(--line); padding: 28px; display: flex; justify-content: space-between; gap: 35px; color: var(--muted); font-size: 12px; }
footer span { color: var(--text); font-weight: 700; }
footer p { margin: 4px 0 0; }
.tmdb-credit { max-width: 390px; text-align: right; }
.tmdb-credit img { display: inline-block; width: 112px; height: auto; }
.tmdb-credit p { line-height: 1.45; }
.tmdb-credit a { color: #86d4e8; }
.api-message { grid-column: 1 / -1; padding: 14px 16px; margin-bottom: 18px; border: 1px solid rgba(255,200,87,.25); border-radius: 12px; background: rgba(255,200,87,.07); color: #e5ca86; font-size: 13px; line-height: 1.5; }
.api-message.error { border-color: rgba(255,92,53,.3); background: var(--accent-soft); color: #ffad99; }
.movie-poster.has-image { background-position: center !important; background-size: cover !important; }

@media (prefers-reduced-motion: no-preference) {
  .quiz-actions button::after { content: ""; position: absolute; inset: 50%; width: 0; height: 0; border-radius: 50%; background: rgba(255,255,255,.25); transform: translate(-50%, -50%); opacity: 0; }
  .quiz-actions button:active::after { animation: button-ripple .42s ease-out; }
  @keyframes button-ripple { 0% { width: 0; height: 0; opacity: .8; } 100% { width: 240px; height: 240px; opacity: 0; } }
  .question.active .vibe-controls label { animation: slider-arrive .28s both; }
  .question.active .vibe-controls label:nth-child(2) { animation-delay: .035s; }
  .question.active .vibe-controls label:nth-child(3) { animation-delay: .07s; }
  .question.active .vibe-controls label:nth-child(4) { animation-delay: .105s; }
  .question.active .vibe-controls label:nth-child(5) { animation-delay: .14s; }
  @keyframes slider-arrive { from { opacity: .45; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
}

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

@media (max-width: 850px) {
  #discover-view.active { grid-template-columns: 1fr; padding-top: 50px; }
  .hero { padding-bottom: 20px; }
  .hero-art { min-height: 390px; }
  .how-it-works { grid-template-columns: 1fr; gap: 25px; }
  .quiz-layout { grid-template-columns: 1fr; gap: 30px; }
  .quiz-sidebar p { max-width: 500px; }
  .progress-track { margin-top: 22px; }
  .movie-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-hero { margin-inline: -28px; padding: 50px 28px; }
}

@media (max-width: 600px) {
  .topbar { height: auto; min-height: 72px; padding: 14px 18px; flex-wrap: wrap; gap: 12px; }
  .main-nav { order: 3; width: 100%; }
  .nav-link { flex: 1; padding-inline: 5px; }
  main { padding: 0 18px; }
  h1 { font-size: 50px; }
  .hero-art { min-height: 340px; }
  .feature-card { width: 300px; grid-template-columns: 100px 1fr; }
  .mini-poster { height: 140px; }
  .steps { grid-template-columns: 1fr; }
  .option-grid, .mood-options, .genre-options { grid-template-columns: 1fr 1fr; }
  .vibe-controls label { grid-template-columns: 1fr 75px; }
  .quiz-card { padding: 25px 18px; }
  .movie-grid { grid-template-columns: 1fr; }
  .detail-hero { grid-template-columns: 1fr; gap: 28px; margin-inline: -18px; padding: 38px 18px 45px; }
  .detail-poster { width: min(58vw, 230px); margin: auto; }
  .detail-copy h1 { font-size: 48px; }
  .detail-actions > * { flex: 1 1 100%; justify-content: center; }
  .similar-grid .movie-poster { height: 245px; }
  .results-heading { align-items: start; gap: 20px; flex-direction: column; }
  .movie-poster { height: 240px; }
  .history-stats { flex-wrap: wrap; }
  .stat { flex: 1; }
  .history-row { grid-template-columns: 45px 1fr auto; gap: 10px; }
  .history-thumb { width: 45px; }
  .stars { grid-column: 2 / 4; }
  footer { flex-direction: column; }
  .tmdb-credit { text-align: left; }
}
