/* Movies Lampa — кабинет. Внутри Telegram цвета берутся из темы клиента. */

:root {
    --bg: var(--tg-theme-bg-color, #0e1016);
    --surface: var(--tg-theme-secondary-bg-color, #171a23);
    --surface-2: var(--tg-theme-section-bg-color, #1e222d);
    --text: var(--tg-theme-text-color, #f1f3f8);
    --hint: var(--tg-theme-hint-color, #8990a3);
    --line: rgba(128, 138, 160, 0.18);
    --accent: var(--tg-theme-button-color, #6d7cff);
    --accent-text: var(--tg-theme-button-text-color, #ffffff);
    --link: var(--tg-theme-link-color, #8ea2ff);
    --danger: var(--tg-theme-destructive-text-color, #ff6b6b);
    --ok: #3ecf8e;
    --gold: #ffc857;
    --radius: 16px;
    --tabs-height: 62px;
    --safe-top: calc(var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px));
    --safe-bottom: calc(var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)) + var(--tg-content-safe-area-inset-bottom, 0px));
    --safe-left: calc(var(--tg-safe-area-inset-left, env(safe-area-inset-left, 0px)) + var(--tg-content-safe-area-inset-left, 0px));
    --safe-right: calc(var(--tg-safe-area-inset-right, env(safe-area-inset-right, 0px)) + var(--tg-content-safe-area-inset-right, 0px));
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
    :root:not(.tg) {
        --bg: #f4f5f9;
        --surface: #ffffff;
        --surface-2: #eef0f6;
        --text: #14161d;
        --hint: #6c7385;
        --line: rgba(20, 22, 29, 0.1);
        --accent: #5464f0;
        --link: #4353e6;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body::before {
    content: "";
    position: fixed;
    inset: 0 0 auto 0;
    height: 320px;
    background: radial-gradient(120% 100% at 50% 0%, rgba(109, 124, 255, 0.22), transparent 70%);
    pointer-events: none;
    z-index: 0;
}

:root.tg body::before { display: none; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); text-decoration: none; }
h1, h2, h3, p { margin: 0; }

.app {
    position: relative;
    z-index: 1;
    max-width: 560px;
    margin: 0 auto;
    padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(var(--tabs-height) + var(--safe-bottom) + 24px) calc(16px + var(--safe-left));
    min-height: 100vh;
}

.app--plain { padding-bottom: 32px; }

.boot, .center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.spinner {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}

.spinner--small { width: 18px; height: 18px; border-width: 2px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- шапка ---------- */

.top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.top__logo { width: 40px; height: 40px; border-radius: 12px; flex: none; }
.top__title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.top__sub { font-size: 13px; color: var(--hint); }
.top__spacer { flex: 1; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--hint);
    white-space: nowrap;
}

.chip--premium {
    background: linear-gradient(135deg, #7c6cff, #3fa9ff);
    color: #fff;
}

.chip--online { color: var(--ok); }
.chip--online::before, .dot {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

/* ---------- карточки и типографика ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.card--hero {
    background: linear-gradient(140deg, rgba(124, 108, 255, 0.28), rgba(63, 169, 255, 0.12) 60%), var(--surface);
}

.card__title { font-size: 16px; font-weight: 650; margin-bottom: 4px; }
.card__text { font-size: 14px; color: var(--hint); }
.card__row { display: flex; align-items: center; gap: 12px; }
.card__grow { flex: 1; min-width: 0; }

.section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--hint);
    margin: 20px 4px 8px;
}

.hero__name { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.hero__meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.stat { display: flex; gap: 10px; margin-top: 14px; }
.stat__item { flex: 1; background: rgba(128, 138, 160, 0.1); border-radius: 12px; padding: 10px 12px; }
.stat__value { font-size: 18px; font-weight: 700; }
.stat__label { font-size: 12px; color: var(--hint); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; padding: 6px 0; font-size: 14px; }
.list li::before { content: "✓"; color: var(--ok); font-weight: 700; }

.muted { color: var(--hint); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt { margin-top: 12px; }
.hidden { display: none !important; }

/* ---------- элементы управления ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 16px;
    border: 0;
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text);
    font-weight: 600;
    font-size: 15px;
    text-align: center;
    transition: transform 0.08s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.55; pointer-events: none; }
.btn--primary { background: var(--accent); color: var(--accent-text); }
.btn--danger { color: var(--danger); }
.btn--ghost { background: transparent; border: 1px solid var(--line); }
.btn--block { display: flex; width: 100%; }
.btn--small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn svg { width: 18px; height: 18px; flex: none; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; }

.field {
    display: flex;
    gap: 8px;
}

.input {
    flex: 1;
    min-width: 0;
    min-height: 46px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--bg);
    outline: none;
}

.input:focus { border-color: var(--accent); }
.input--code { text-transform: uppercase; letter-spacing: 0.14em; font-weight: 700; text-align: center; font-size: 18px; }
.input::placeholder { color: var(--hint); letter-spacing: normal; font-weight: 400; text-transform: none; }

.switch-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}

.switch-row + .switch-row { border-top: 1px solid var(--line); }

.switch {
    position: relative;
    width: 46px;
    height: 28px;
    flex: none;
    border: 0;
    border-radius: 999px;
    background: var(--surface-2);
    transition: background 0.15s ease;
}

.switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
}

.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

.segments {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 12px;
    scrollbar-width: none;
}

.segments::-webkit-scrollbar { display: none; }

.segment {
    flex: none;
    border: 0;
    border-radius: 999px;
    padding: 8px 14px;
    background: var(--surface);
    color: var(--hint);
    font-size: 14px;
    font-weight: 600;
    border: 1px solid var(--line);
}

.segment[aria-selected="true"] { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.segment__count { opacity: 0.7; margin-left: 4px; font-weight: 500; }

/* ---------- устройства ---------- */

.device { display: flex; align-items: center; gap: 12px; }

.device__icon {
    width: 44px;
    height: 44px;
    flex: none;
    border-radius: 12px;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.device__icon svg { width: 24px; height: 24px; }
.device__name { font-weight: 650; }
.device__meta { font-size: 13px; color: var(--hint); }
.device__actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.device__actions .btn { flex: 1; }

/* ---------- медиатека ---------- */

.grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

@media (min-width: 480px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.poster {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
}

.poster__image {
    position: relative;
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(160deg, var(--surface-2), var(--surface));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    color: var(--hint);
}

.poster__image img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.poster__progress {
    position: absolute;
    left: 6px;
    right: 6px;
    bottom: 6px;
    height: 4px;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.poster__progress span { display: block; height: 100%; background: var(--gold); }
.poster__title { margin-top: 6px; font-size: 13px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.poster__year { font-size: 12px; color: var(--hint); }

.result { display: flex; gap: 12px; align-items: center; padding: 8px 0; }
.result + .result { border-top: 1px solid var(--line); }
.result .poster__image { width: 52px; flex: none; border-radius: 8px; font-size: 16px; }
.result__body { flex: 1; min-width: 0; }

.empty { text-align: center; padding: 36px 16px; color: var(--hint); }
.empty__icon { font-size: 40px; margin-bottom: 8px; }

/* ---------- подписка ---------- */

.plan {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 8px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--surface);
    text-align: left;
}

.plan:active { transform: scale(0.99); }
.plan__title { font-weight: 650; }
.plan__note { font-size: 13px; color: var(--hint); }
.plan__price { margin-left: auto; font-weight: 700; white-space: nowrap; }
.plan__badge { font-size: 11px; font-weight: 700; color: var(--ok); margin-left: 6px; }

.history { font-size: 14px; }
.history__row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; }
.history__row + .history__row { border-top: 1px solid var(--line); }

/* ---------- вход ---------- */

.login { text-align: center; padding-top: 6vh; }
.login__logo { width: 76px; height: 76px; border-radius: 22px; margin-bottom: 16px; box-shadow: 0 12px 40px rgba(109, 124, 255, 0.35); }
.login__title { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; }
.login__lead { color: var(--hint); margin: 10px auto 22px; max-width: 420px; }
.login__qr { width: 200px; height: 200px; border-radius: 16px; background: #fff; margin: 0 auto 14px; display: block; }
.login .card { text-align: left; }

.copy {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--bg);
    border: 1px dashed var(--line);
    font-size: 13px;
    word-break: break-all;
}

.copy__text { flex: 1; }

/* ---------- нижняя панель ---------- */

.tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    display: flex;
    justify-content: center;
    padding-bottom: var(--safe-bottom);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
}

.tabs__inner { display: flex; width: 100%; max-width: 560px; height: var(--tabs-height); }

.tab {
    flex: 1;
    border: 0;
    background: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 600;
    color: var(--hint);
}

.tab svg { width: 22px; height: 22px; }
.tab[aria-selected="true"] { color: var(--accent); }

/* ---------- всплывающая панель и уведомления ---------- */

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fade 0.15s ease;
}

.sheet {
    width: 100%;
    max-width: 560px;
    max-height: 88vh;
    overflow-y: auto;
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    padding: 20px 16px calc(20px + var(--safe-bottom));
    animation: rise 0.2s ease;
}

@media (min-width: 600px) {
    .sheet-backdrop { align-items: center; }
    .sheet { border-radius: 20px; }
}

.sheet__title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.sheet__text { color: var(--hint); font-size: 14px; margin-bottom: 16px; }
.sheet__media { display: flex; gap: 14px; margin-bottom: 16px; }
.sheet__media .poster__image { width: 96px; flex: none; }
.sheet__overview { font-size: 14px; color: var(--hint); display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 14px; }
.kv + .kv { border-top: 1px solid var(--line); }
.kv span:first-child { color: var(--hint); }
.kv span:last-child { text-align: right; font-weight: 600; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabs-height) + var(--safe-bottom) + 16px);
    z-index: 30;
    transform: translate(-50%, 20px);
    max-width: min(92vw, 480px);
    padding: 12px 16px;
    border-radius: 12px;
    background: #23283a;
    color: #fff;
    font-size: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast--visible { opacity: 1; transform: translate(-50%, 0); }
.toast--error { background: #b3261e; }

.noscript { text-align: center; padding: 40px 16px; }

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

/* Telegram mobile shell and cinematic home. */
:root.tg { overscroll-behavior-y: none; touch-action: pan-x pan-y; }
:root.tg body { overscroll-behavior-y: none; -webkit-overflow-scrolling: touch; }
:root.tg .app { min-height: 100dvh; }
.app--plain { padding-bottom: calc(32px + var(--safe-bottom)); }
.tabs { padding-left: var(--safe-left); padding-right: var(--safe-right); }
.sheet { max-height: calc(100dvh - var(--safe-top) - 16px); }
.sheet-backdrop { padding-top: var(--safe-top); padding-left: var(--safe-left); padding-right: var(--safe-right); }
main.is-rebounding { transition: transform 480ms cubic-bezier(.16,1.45,.35,1); }
button, a { -webkit-tap-highlight-color: transparent; }
.btn, .quick-action, .plan, .tab { transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease; }
.btn:active, .quick-action:active, .plan:active { transform: scale(.975); }
.eyebrow { font-size: 10px; letter-spacing: .13em; font-weight: 750; color: var(--hint); margin-bottom: 12px; }
.home-hero { position: relative; overflow: hidden; padding-top: 24px; }
.home-hero::after { content: ''; position: absolute; pointer-events: none; width: 190px; height: 190px; right: -90px; top: -65px; background: radial-gradient(circle, #6d7cff33, transparent 70%); }
.home-hero .eyebrow { padding-right: 58px; }
.hero-logo { width: 64px; height: 64px; border-radius: 20px; float: right; margin: 0 0 12px 12px; box-shadow: 0 8px 24px #14132b45; }
.hero__name { line-height: 1.18; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 22px; }
.quick-action { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); padding: 16px; text-align: left; display: flex; flex-direction: column; gap: 7px; }
.quick-action svg { width: 27px; height: 27px; color: var(--accent); margin-bottom: 2px; }
.quick-action strong { font-size: 14px; }
.quick-action small { color: var(--hint); font-size: 11px; line-height: 1.4; }
.home-shelf { margin: 0 0 22px; }
.shelf-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.shelf-heading h2 { font-size: 17px; letter-spacing: -.025em; }
.text-button { border: 0; background: none; color: var(--link); font-size: 12px; padding: 8px 0; }
.home-rail { display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; padding-bottom: 8px; }
.home-rail::-webkit-scrollbar { display: none; }
.home-rail .poster { width: 112px; flex: 0 0 112px; scroll-snap-align: start; }
.shelf-empty { display: flex; align-items: center; gap: 15px; border: 1px dashed var(--line); border-radius: 18px; padding: 22px 18px; width: 100%; }
.shelf-empty__icon { flex: 0 0 42px; color: var(--accent); }
.shelf-empty__icon svg { width: 38px; height: 38px; }
.shelf-empty strong { font-size: 14px; }
.shelf-empty p { color: var(--hint); font-size: 12px; line-height: 1.5; margin-top: 5px; }
.card--guide { padding: 24px 18px; }
.install-guide { scroll-margin-top: calc(var(--safe-top) + 16px); }
.install-picker { margin: 16px 0 12px; }
.install-picker .segment { font-size: 11px; white-space: nowrap; }
.install-step { display: flex; gap: 12px; padding: 17px 0; }
.install-step + .install-step { border-top: 1px solid var(--line); }
.step-number { font-size: 11px; font-weight: 800; color: var(--accent); border: 1px solid var(--line); border-radius: 50%; width: 30px; height: 30px; flex: 0 0 30px; display: grid; place-items: center; }
.install-step > div { min-width: 0; }
.install-step h3 { font-size: 14px; margin: 3px 0 7px; }
.install-step .card__text { font-size: 13px; }
.install-step .copy { flex-wrap: wrap; }
.install-step .copy__text { flex-basis: 160px; }
.premium-hero { position: relative; overflow: hidden; padding: 28px 22px; border-color: #9b8dff55; background: linear-gradient(145deg, #6d7cff18, var(--surface) 65%); }
.premium-hero .hero__name { font-size: 28px; max-width: 250px; }
.premium-hero .eyebrow { padding-right: 50px; }
.premium-orbit { float: right; width: 62px; height: 62px; padding: 14px; border: 1px solid #ffc85755; border-radius: 22px; background: #ffc85712; color: var(--gold); transform: rotate(10deg); margin: 0 0 15px 10px; }
.premium-orbit svg { width: 100%; height: 100%; }
.plan--subscription { border-radius: 18px; padding: 20px 16px; margin-bottom: 10px; }
.plan--featured { border-color: var(--accent); background: linear-gradient(110deg, #6d7cff15, var(--surface)); box-shadow: 0 4px 22px #6d7cff12; }
.plan--subscription .plan__note { font-size: 11px; margin-top: 6px; }
@media (max-width: 370px) { .top__title { font-size: 17px; } .top { gap: 8px; } .top .chip { font-size: 10px; } .shelf-heading h2 { font-size: 15px; } .quick-action { padding: 13px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }
