/* --- БАЗОВЫЕ СТИЛИ --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #ffffff;
    color: #333;
    line-height: 1.6;
}
.header {
    background-color: #f8f9fa;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky; top: 0; z-index: 100;
    display: flex; justify-content: space-between; align-items: center;
}
.logo { display: flex; align-items: center; gap: 0.8rem; }
.logo-img { width: 50px; height: 50px; object-fit: contain; }
.logo-text { font-size: 1.8rem; font-weight: 700; color: #AC81ED; letter-spacing: -1px; }
.nav { display: flex; align-items: center; gap: 2rem; }
.nav-link { text-decoration: none; color: #333; font-weight: 500; transition: color 0.3s ease; }
.nav-link:hover { color: #AC81ED; }
.btn-login {
    background-color: #AC81ED; color: white; border: none;
    padding: 0.5rem 1.5rem; border-radius: 25px; font-weight: 600;
    cursor: pointer; transition: background-color 0.3s ease, transform 0.2s ease;
}
.btn-login:hover { background-color: #9568d6; transform: translateY(-2px); }
.hero { text-align: center; padding: 4rem 2rem 3rem; }
.hero-title { font-size: 4rem; font-weight: 700; color: #AC81ED; margin-bottom: 1rem; letter-spacing: -2px; }
.hero-subtitle { font-size: 1.3rem; color: #666; font-weight: 300; }
.cards-section { padding: 2rem; max-width: 1200px; margin: 0 auto; }
.cards-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2rem; padding: 2rem 0; }
.card {
    background-color: #ffffff; border: 2px solid #e9ecef; border-radius: 15px;
    padding: 2rem; text-decoration: none; color: #333; transition: all 0.3s ease;
    display: flex; flex-direction: column; min-height: 250px;
    position: relative; overflow: hidden; opacity: 0; transform: translateY(20px);
}
.card.card-visible { opacity: 1; transform: translateY(0); }
.card:hover { border-color: #AC81ED; box-shadow: 0 8px 20px rgba(172, 129, 237, 0.15); transform: translateY(-5px); }
.card.card-visible:hover { transform: translateY(-5px); }
.card-title { font-size: 1.8rem; font-weight: 600; margin-bottom: 1rem; color: #333; }
.card-text { color: #666; margin-bottom: 1.5rem; flex-grow: 1; line-height: 1.6; }
.card-action { display: flex; align-items: center; gap: 0.5rem; color: #AC81ED; font-weight: 600; transition: gap 0.3s ease; }
.card:hover .card-action { gap: 1rem; }
.card-action-text { font-size: 1.1rem; }
.card-arrow { font-size: 1.5rem; transition: transform 0.3s ease; }
.card:hover .card-arrow { transform: translateX(5px); }

/* --- ВНУТРЕННИЕ СТРАНИЦЫ --- */
.auth-wrapper { display: flex; justify-content: center; align-items: center; min-height: 80vh; }
.auth-box { background: #fff; border: 2px solid #AC81ED; border-radius: 20px; padding: 2rem; width: 100%; max-width: 400px; box-shadow: 0 10px 25px rgba(172, 129, 237, 0.15); }
.input-field { width: 100%; padding: 0.8rem; margin-bottom: 1rem; border: 1px solid #d1d5db; border-radius: 8px; font-family: inherit; outline: none; box-sizing: border-box; }
.input-field:focus { border-color: #AC81ED; }
.input-field.error { border-color: #ff6b6b; color: #ff6b6b; }
.btn-submit { width: 100%; padding: 0.8rem; background: #AC81ED; color: white; border: none; border-radius: 8px; font-size: 1rem; font-weight: 600; cursor: pointer; margin-top: 0.5rem; transition: 0.3s; }
.btn-submit:hover { background: #9568d6; }
.error-msg { color: #ff6b6b; text-align: center; font-size: 0.85rem; margin-top: 1rem; display: none; }

/* Профиль */
.profile-layout { display: flex; min-height: 100vh; }
.sidebar-purple { width: 280px; background: linear-gradient(180deg, #d1bdf2 0%, #AC81ED 100%); padding: 2rem; color: white; border-radius: 0 30px 30px 0; flex-shrink: 0; display: flex; flex-direction: column; }
.user-avatar { width: 80px; height: 80px; background: rgba(255,255,255,0.3); border-radius: 50%; margin-bottom: 1rem; }
.user-name { font-size: 1.5rem; font-weight: 800; margin-bottom: 1rem; }
.user-bio { background: rgba(255,255,255,0.2); border-radius: 10px; padding: 1rem; min-height: 80px; margin-bottom: 2rem; font-size: 0.9rem; }
.menu-link { display: block; color: white; text-decoration: none; padding: 0.8rem 1rem; margin-bottom: 0.5rem; border-radius: 10px; background: rgba(255,255,255,0.1); font-weight: 600; transition: 0.3s; }
.menu-link:hover, .menu-link.active { background: rgba(255,255,255,0.25); }
.profile-main { flex: 1; padding: 2rem 4rem; }

/* Списки */
.empty-state { color: #AC81ED; text-align: center; padding: 4rem 0; font-size: 1.1rem; }
.list-container { display: flex; flex-direction: column; gap: 1.2rem; }
.horizontal-card { display: flex; align-items: center; gap: 1.5rem; background: #fff; border: 2px solid #f3e8ff; border-radius: 15px; padding: 1rem; text-decoration: none; color: inherit; transition: all 0.3s ease; box-shadow: 0 4px 15px rgba(172, 129, 237, 0.05); }
.horizontal-card:hover { border-color: #AC81ED; transform: translateY(-2px); }
.h-card-img { width: 70px; height: 100px; background-color: #e2d5f8; border-radius: 10px; flex-shrink: 0; }
.h-card-info { display: flex; flex-direction: column; justify-content: center; }
.h-card-title { font-size: 1.1rem; color: #AC81ED; font-weight: 700; margin-bottom: 0.3rem; }
.h-card-subtitle { font-size: 0.85rem; color: #999; }

/* Рулетка */
.roulette-layout { display: flex; justify-content: center; align-items: flex-start; gap: 4rem; margin-top: 3rem; padding: 0 2rem; }
.collections-panel { width: 250px; flex-shrink: 0; }
.coll-btn { border: 1px solid #e5e7eb; border-radius: 10px; padding: 1rem; margin-bottom: 1rem; cursor: pointer; background: #fff; transition: 0.3s; }
.coll-btn.active { border-color: #AC81ED; background: #fbf9ff; box-shadow: 0 4px 10px rgba(172,129,237,0.1); }
.wheel-area { position: relative; text-align: center; display: flex; flex-direction: column; align-items: center; }
.wheel-pointer { width: 0; height: 0; border-left: 20px solid transparent; border-right: 20px solid transparent; border-top: 35px solid #AC81ED; position: absolute; top: 5px; z-index: 10; filter: drop-shadow(0 4px 4px rgba(0,0,0,0.15)); }
.canvas-wrapper { border-radius: 50%; box-shadow: 0 10px 30px rgba(172, 129, 237, 0.2); transition: transform 5s cubic-bezier(0.1, 0.7, 0.1, 1); display: flex; justify-content: center; align-items: center; position: relative; }
.canvas-wrapper::after { content: ''; position: absolute; width: 50px; height: 50px; background: #fff; border: 6px solid #AC81ED; border-radius: 50%; z-index: 5; }
#spinBtn { margin-top: 1.5rem !important; }
.result-box { margin-top: 1.5rem; background: #fbf9ff; border: 2px dashed #AC81ED; padding: 1rem 2rem; border-radius: 15px; text-align: center; animation: popIn 0.5s ease-out forwards; }
.result-box h2 { font-size: 1rem; color: #999; margin-bottom: 0.5rem; font-weight: 600; }
.result-box p { font-size: 1.8rem; color: #AC81ED; font-weight: 800; margin: 0; }
@keyframes popIn { 0% { transform: scale(0.8); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* Чат */
.chat-wrapper { max-width: 800px; margin: 2rem auto; height: 75vh; border: 2px solid #e9ecef; border-radius: 20px; background: #fff; display: flex; flex-direction: column; box-shadow: 0 10px 30px rgba(172, 129, 237, 0.05); }
.chat-messages { flex: 1; padding: 2rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; }
.msg { max-width: 75%; padding: 1rem 1.2rem; border-radius: 15px; font-size: 0.95rem; line-height: 1.5; }
.msg-ai { background-color: #AC81ED; color: #fff; align-self: flex-start; border-bottom-left-radius: 0; }
.msg-user { background-color: #f0e6ff; color: #333; align-self: flex-end; border-bottom-right-radius: 0; }
.chat-time { text-align: center; color: #d1d5db; font-size: 0.8rem; margin: 1rem 0; }
.chat-input-area { padding: 1rem; border-top: 1px solid #e9ecef; }
.chat-input-wrapper { display: flex; align-items: center; border: 1px solid #AC81ED; border-radius: 12px; padding: 0.5rem; }
.chat-input-wrapper input { flex: 1; border: none; outline: none; font-family: inherit; padding: 0.5rem; color: #333; }
.chat-send-btn { background: #AC81ED; color: white; border: none; width: 35px; height: 35px; border-radius: 50%; cursor: pointer; display: flex; justify-content: center; align-items: center; font-size: 1.2rem; }

/* Анкета / Mood */
.auth-wrapper { display: flex; justify-content: center; align-items: center; min-height: 80vh; }
.tags-wrapper { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; margin-bottom: 2rem; }
.mood-tag { background: #fff; border: 2px solid #e5e7eb; padding: 0.6rem 1.2rem; border-radius: 30px; font-family: inherit; font-size: 0.95rem; font-weight: 600; color: #666; cursor: pointer; transition: all 0.3s ease; }
.mood-tag:hover { border-color: #AC81ED; color: #AC81ED; }
.mood-tag.active { background: #AC81ED; border-color: #AC81ED; color: #fff; box-shadow: 0 4px 10px rgba(172, 129, 237, 0.3); }
.movies-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2rem; margin-top: 2rem; }
.movie-card { background: white; border-radius: 12px; overflow: hidden; border: 1px solid #e9ecef; }
.movie-poster { height: 280px; background: #f0e6ff; display: flex; align-items: center; justify-content: center; color: #AC81ED; font-weight: bold; }
.movie-info { padding: 1rem; }
.movie-title { font-size: 1.1rem; margin-bottom: 0.5rem; color: #333; }
.movie-year { color: #666; font-size: 0.9rem; }

/* Адаптивность */
@media (max-width: 768px) {
    .header { flex-direction: column; gap: 1rem; }
    .cards-grid { grid-template-columns: 1fr; }
    .roulette-layout { flex-direction: column; align-items: center; gap: 2rem; }
    .profile-layout { flex-direction: column; }
    .sidebar-purple { width: 100%; border-radius: 0; }
}

/* Moodvie — исправления и дополнительные компоненты */
[hidden] { display: none !important; }
.logo { text-decoration: none; }
.auth-box h1, .page-container > h1, .wheel-area > h1 { color: #AC81ED; text-align: center; margin-bottom: 1.5rem; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 1.5rem; border-bottom: 1px solid #eee; }
.auth-tab { flex: 1; padding: .8rem; border: 0; background: transparent; color: #888; font: inherit; font-weight: 700; cursor: pointer; border-bottom: 3px solid transparent; }
.auth-tab-active { color: #AC81ED; border-bottom-color: #AC81ED; }
.auth-box .error-msg { display: none; }
.page-container { max-width: 1200px; margin: 0 auto; padding: 2.5rem 1.5rem; }
.page-container > h1 { font-size: 2rem; }
.catalog-controls { max-width: 850px; margin: 0 auto 2rem; display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
.catalog-controls .input-field { margin-bottom: 0; }
.movies-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1.4rem; margin-top: 1.5rem; }
.movie-card { background: #fff; border: 1px solid #eee; border-radius: 14px; overflow: hidden; box-shadow: 0 5px 18px rgba(70,40,100,.06); min-width: 0; }
.movie-poster { display: block; width: 100%; height: 285px; object-fit: cover; background: #f0e6ff; }
.poster-placeholder { width: 100%; min-height: 285px; background: #f0e6ff; color: #8564ad; display: flex; align-items: center; justify-content: center; text-align: center; padding: 1rem; font-weight: 600; }
.movie-info { padding: 1rem; }
.movie-title { color: #4d3768; font-size: 1.05rem; line-height: 1.35; margin-bottom: .4rem; }
.movie-year, .movie-rating { color: #777; font-size: .9rem; margin: .2rem 0; }
.small-action { border: 1px solid #AC81ED; border-radius: 8px; background: #fff; color: #875dc0; padding: .5rem .8rem; margin: .5rem .4rem .1rem 0; cursor: pointer; font: inherit; font-size: .9rem; }
.small-action:hover { background: #f6f0ff; }
.collection-item { background: #fff; border: 1px solid #eee; border-radius: 14px; padding: 1.2rem; margin-bottom: 1rem; box-shadow: 0 4px 14px rgba(70,40,100,.05); }
.collection-item h3 { color: #7650a8; margin-bottom: .4rem; }
.collection-item p { color: #666; margin: .35rem 0; }
.collection-preview { font-size: .92rem; }
.result-section { max-width: 1200px; margin: 2rem auto; padding: 1.5rem; }
.result-section > h1 { text-align: center; color: #AC81ED; margin-bottom: 1.5rem; }
.result-actions { max-width: 420px; margin: 2rem auto; display: grid; gap: .6rem; }
.secondary-btn { background: #fff; color: #875dc0; border: 1px solid #AC81ED; }
.secondary-btn:hover { background: #f6f0ff; }
.quiz-box { max-width: 760px; }
.quiz-box .muted, .muted { color: #888; text-align: center; margin-bottom: 1.5rem; }
.tags-wrapper { align-items: center; }
.mood-tag { user-select: none; }
.mood-tag.active { background: #AC81ED; border-color: #AC81ED; color: #fff; }
.roulette-layout { max-width: 1400px; margin: 2.5rem auto; align-items: flex-start; }
.collections-panel { width: min(100%, 330px); }
.collections-panel h2 { color: #AC81ED; font-size: 1.2rem; margin: 1rem 0; }
.collections-panel hr { border: 0; border-top: 1px solid #eee; margin: 1.5rem 0; }
.collections-panel .input-field { margin-bottom: .7rem; }
.available-movies { max-height: 320px; overflow-y: auto; border: 1px solid #eee; border-radius: 10px; padding: .4rem; margin: .7rem 0; }
.movie-select-row { display: flex; gap: .6rem; align-items: center; padding: .55rem; border-bottom: 1px solid #f1edf6; cursor: pointer; }
.movie-select-row:last-child { border-bottom: 0; }
.movie-select-row small { color: #888; }
.wheel-area { flex: 1; min-width: 300px; }
.wheel-container { position: relative; width: min(500px, 85vw); aspect-ratio: 1; margin: 1rem auto; }
#wheelCanvas { display: block; width: 100%; height: 100%; border-radius: 50%; box-shadow: 0 10px 30px rgba(172,129,237,.2); }
.wheel-pointer { position: absolute; top: -3px; left: 50%; transform: translateX(-50%); z-index: 3; width: 0; height: 0; border-left: 18px solid transparent; border-right: 18px solid transparent; border-top: 34px solid #AC81ED; filter: drop-shadow(0 3px 3px rgba(0,0,0,.2)); }
.spin-button { max-width: 260px; margin: 1.5rem auto; }
.result-box[hidden] { display: none !important; }
.result-box { max-width: 520px; margin: 1rem auto; }
.profile-layout { min-height: 100vh; }
.profile-main > p { margin-bottom: 1rem; }
.profile-main > h1 { color: #AC81ED; text-align: center; margin: 1rem 0 2rem; }
.profile-nav { display: grid; gap: .35rem; }
.logout-btn { margin-top: auto; }
.user-avatar { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 2rem; font-weight: 800; }
.chat-wrapper { overflow: hidden; }
.chat-movie-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .8rem; padding: 1rem; }
.chat-movie-results .movie-poster, .chat-movie-results .poster-placeholder { height: 180px; min-height: 180px; }
.chat-actions { display: flex; gap: .5rem; padding: .5rem 1rem 1rem; flex-wrap: wrap; }
.chat-actions .btn-submit { width: auto; flex: 1; }
.chat-actions .secondary-btn { background: #fff; color: #875dc0; border: 1px solid #AC81ED; }
.group-page { padding: 2rem 1rem; }
.group-page .auth-box { width: min(100%, 620px); }
.group-page h2 { margin: 1.2rem 0 .7rem; color: #7650a8; }
.group-page #roomCodeDisplay { color: #AC81ED; letter-spacing: .1em; }
.group-lobby .tags-wrapper { margin: 1rem 0; }
.group-lobby #membersList { padding-left: 1.5rem; color: #666; }
.separator { margin: 1rem 0; }
.info-box { max-width: 650px; text-align: center; }
.info-box p { margin: .8rem 0; color: #666; }
.empty-state { color: #8b6ab7; text-align: center; padding: 2.5rem 1rem; }
@media (max-width: 850px) {
    .roulette-layout { flex-direction: column; align-items: center; }
    .collections-panel { width: min(100%, 600px); }
    .wheel-area { width: 100%; }
    .profile-main { padding: 1.5rem; }
}
@media (max-width: 600px) {
    .header { padding: 1rem; }
    .nav { gap: .7rem; flex-wrap: wrap; justify-content: center; }
    .logo-text { font-size: 1.4rem; }
    .hero { padding: 2.5rem 1rem 1.5rem; }
    .hero-title { font-size: 3rem; }
    .catalog-controls { grid-template-columns: 1fr; }
    .profile-layout { flex-direction: column; }
    .sidebar-purple { width: 100%; border-radius: 0; padding: 1.5rem; }
    .profile-main { padding: 1.2rem; }
    .movies-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
    .movie-poster, .poster-placeholder { height: 220px; min-height: 220px; }
    .chat-wrapper { margin: 1rem; height: 78vh; }
    .msg { max-width: 90%; }
}


.movie-open-link { display: block; color: inherit; text-decoration: none; }
.movie-open-link:hover .movie-title { text-decoration: underline; }
.movie-card > .favorite-toggle { margin: 0 1rem 1rem; }
.movie-detail { display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: 2rem; align-items: start; background: #fff; border: 1px solid #eee; border-radius: 16px; padding: 1.5rem; }
.movie-detail-poster .movie-poster, .movie-detail-poster .poster-placeholder { width: 100%; height: 450px; min-height: 450px; border-radius: 12px; }
.movie-detail-info h1 { color: #7650a8; margin: .3rem 0 1rem; }
.movie-detail-info p { margin: .7rem 0; color: #555; }
.movie-detail-actions { max-width: 500px; display: flex; gap: .8rem; margin: 1rem 0 2rem; }
.movie-detail-actions .btn-submit { flex: 1; }
.reviews-section { max-width: 850px; margin: 2rem auto; }
.reviews-section h2 { color: #7650a8; margin-bottom: 1rem; }
.review-form { background: #fff; border: 1px solid #eee; border-radius: 14px; padding: 1.2rem; margin-bottom: 1.5rem; }
.review-form label { display: block; color: #666; margin-bottom: .4rem; }
.review-form .input-field { margin-bottom: .8rem; }
@media (max-width: 650px) {
    .movie-detail { grid-template-columns: 1fr; }
    .movie-detail-poster { max-width: 300px; margin: 0 auto; width: 100%; }
    .movie-detail-poster .movie-poster, .movie-detail-poster .poster-placeholder { height: 400px; min-height: 400px; }
    .movie-detail-actions { flex-direction: column; }
}


/* Moodvie updates: shared questionnaire, centered layouts and profile actions */
.page-container #quizBox {
    display: block;
    width: min(100%, 760px);
    margin: 0 auto;
}
.group-page {
    justify-content: center;
    align-items: flex-start;
}
.group-page > .auth-box {
    margin: 1.5rem auto;
}
.question-list {
    display: grid;
    gap: 1rem;
    margin: 1.25rem 0;
}
.question-card {
    min-width: 0;
    margin: 0;
    padding: 1rem;
    border: 1px solid #e6d9f7;
    border-radius: 12px;
    background: #fff;
}
.question-card legend {
    padding: 0 .35rem;
    color: #7650a8;
    font-weight: 700;
}
.question-options {
    display: grid;
    gap: .55rem;
}
.question-option {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .65rem .75rem;
    border: 1px solid #eee6f8;
    border-radius: 9px;
    cursor: pointer;
}
.question-option:has(input:checked) {
    border-color: #AC81ED;
    background: #f7f1ff;
}
.question-option input {
    margin-top: .2rem;
    accent-color: #9568d6;
}
#roomQuizSection {
    margin-top: 1.5rem;
}
.group-page .group-lobby {
    max-width: 760px;
}
.profile-movies-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 1.2rem;
}
.profile-movie-item {
    min-width: 0;
}
.profile-movie-actions {
    display: grid;
    gap: .45rem;
    margin-top: .5rem;
}
.profile-movie-actions .small-action {
    width: 100%;
}
.result-box .movies-grid {
    margin-bottom: 1.2rem;
}
@media (max-width: 600px) {
    .page-container #quizBox {
        padding: 1.25rem;
    }
    .group-page > .auth-box {
        margin: .75rem auto;
    }
}
