/* ===== KinoVit — Telegram Bot Style ===== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Semantic HTML5 elements styled as their div counterparts */
header.tg-header { display: flex; }
main.tg-chat { display: flex; }
nav.tg-inline-btns { display: flex; }

.tg-h1-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--tg-text);
}

:root {
    --tg-bg: #0e1621;
    --tg-chat-bg: #0e1621;
    --tg-header-bg: #17212b;
    --tg-bubble-bot: #182533;
    --tg-bubble-user: #2b5278;
    --tg-accent: #5eaaef;
    --tg-accent-hover: #4a9ae0;
    --tg-text: #f5f5f5;
    --tg-text-muted: #6c8eac;
    --tg-text-link: #6ab3f3;
    --tg-input-bg: #242f3d;
    --tg-border: #1c2733;
    --tg-green: #4caf50;
    --tg-red: #e53935;
    --tg-yellow: #ffc107;
    --tg-error: #ff5252;
    --tg-shadow: rgba(0,0,0,0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --tg-chat-wallpaper: url('../wallpaper.webp');
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--tg-bg);
    color: var(--tg-text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

input, textarea, button, select {
    font-size: 16px; /* prevents iOS zoom on focus */
}

a {
    color: var(--tg-text-link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===== App Container ===== */
.tg-app {
    max-width: 600px;
    margin: 0 auto;
    height: 100dvh; /* dvh handles mobile keyboard */
    display: flex;
    flex-direction: column;
    background: var(--tg-chat-bg);
    box-shadow: 0 0 40px var(--tg-shadow);
    position: relative;
}

/* ===== Header ===== */
.tg-header {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: var(--tg-header-bg);
    border-bottom: 1px solid var(--tg-border);
    min-height: 56px;
    gap: 12px;
    z-index: 100;
    flex-shrink: 0;
}

.tg-back {
    color: var(--tg-accent);
    font-size: 22px;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.tg-back:hover {
    background: rgba(94, 170, 239, 0.1);
    text-decoration: none;
}

.tg-header-info {
    flex: 1;
    min-width: 0;
}

.tg-header-title {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.tg-title-link {
    color: var(--tg-text);
    text-decoration: none;
    transition: color 0.2s;
}

.tg-title-link:hover {
    color: var(--tg-accent);
    text-decoration: none;
}

.tg-header-subtitle {
    font-size: 13px;
    color: var(--tg-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 8px;
}

.online-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 500;
    color: #4caf50;
    background: rgba(76, 175, 80, 0.1);
    padding: 2px 8px 2px 6px;
    border-radius: 10px;
    letter-spacing: 0.2px;
    flex-shrink: 0;
}

.online-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4caf50;
    display: inline-block;
    animation: onlinePulse 2s ease-in-out infinite;
    box-shadow: 0 0 4px rgba(76, 175, 80, 0.6);
}

@keyframes onlinePulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 4px rgba(76, 175, 80, 0.6); }
    50% { opacity: 0.4; box-shadow: 0 0 8px rgba(76, 175, 80, 0.3); }
}

.tg-header-actions {
    display: flex;
    gap: 4px;
}

.tg-header-btn {
    font-size: 20px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: background 0.2s;
}

.tg-header-btn:hover {
    background: rgba(94, 170, 239, 0.1);
    text-decoration: none;
}

/* ===== Chat Area ===== */
.tg-chat {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
    background: var(--tg-chat-wallpaper) center / auto repeat;
    background-color: var(--tg-chat-bg);
}

/* Custom scrollbar */
.tg-chat::-webkit-scrollbar {
    width: 6px;
}

.tg-chat::-webkit-scrollbar-track {
    background: transparent;
}

.tg-chat::-webkit-scrollbar-thumb {
    background: var(--tg-border);
    border-radius: 3px;
}

/* ===== Messages ===== */
.tg-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: msgIn 0.3s ease;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tg-message.bot {
    align-self: flex-start;
}

.tg-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.tg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--tg-header-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.tg-bubble {
    padding: 10px 14px;
    border-radius: var(--radius);
    max-width: 100%;
    word-wrap: break-word;
    position: relative;
}

.tg-message.bot .tg-bubble {
    background: var(--tg-bubble-bot);
    border-top-left-radius: 4px;
}

.tg-message.user .tg-bubble {
    background: var(--tg-bubble-user);
    border-top-right-radius: 4px;
}

.tg-bubble p {
    margin-bottom: 6px;
}

.tg-bubble p:last-child {
    margin-bottom: 0;
}

.error-bubble {
    background: rgba(229, 57, 53, 0.15) !important;
    border: 1px solid rgba(229, 57, 53, 0.3);
    color: #ff8a80;
}

/* ===== Inline Buttons ===== */
.tg-inline-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.tg-inline-btn {
    display: inline-block;
    padding: 7px 14px;
    background: rgba(94, 170, 239, 0.12);
    color: var(--tg-accent);
    border-radius: 20px;
    font-size: 13px;
    border: 1px solid rgba(94, 170, 239, 0.2);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.tg-inline-btn:hover {
    background: rgba(94, 170, 239, 0.25);
    text-decoration: none;
}

.tg-inline-btn.active {
    background: var(--tg-accent);
    color: #fff;
    border-color: var(--tg-accent);
}

.tg-inline-btn.danger {
    color: var(--tg-red);
    border-color: rgba(229, 57, 53, 0.3);
    background: rgba(229, 57, 53, 0.1);
}

.tg-inline-btn.danger:hover {
    background: rgba(229, 57, 53, 0.25);
}

/* ===== Genre Filter ===== */
.genre-filter {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--tg-border);
}

.genre-filter-label {
    font-size: 13px;
    color: var(--tg-text-muted);
    margin-bottom: 6px;
}

.genre-btns .genre-btn {
    font-size: 12px;
    padding: 5px 10px;
}

.filter-reset {
    color: var(--tg-red);
    font-size: 12px;
    text-decoration: none;
    margin-left: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.filter-reset:hover {
    opacity: 1;
    text-decoration: none;
}

.year-custom-form {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.year-custom-input {
    width: 65px;
    padding: 5px 8px;
    font-size: 12px;
    background: var(--tg-input-bg);
    color: var(--tg-text);
    border: 1px solid rgba(94, 170, 239, 0.2);
    border-radius: 20px;
    outline: none;
    text-align: center;
    -moz-appearance: textfield;
}

.year-custom-input::-webkit-inner-spin-button,
.year-custom-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.year-custom-input:focus {
    border-color: var(--tg-accent);
}

/* ===== Search Bar (bottom) ===== */
.tg-input-bar {
    padding: 10px 12px;
    background: var(--tg-header-bg);
    border-top: 1px solid var(--tg-border);
    flex-shrink: 0;
    z-index: 100;
    position: relative;
}

.tg-search-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tg-search-input {
    flex: 1;
    padding: 10px 16px;
    background: var(--tg-input-bg);
    border: none;
    border-radius: 22px;
    color: var(--tg-text);
    font-size: 15px;
    outline: none;
    transition: box-shadow 0.2s;
}

.tg-search-input::placeholder {
    color: var(--tg-text-muted);
}

.tg-search-input:focus {
    box-shadow: 0 0 0 2px rgba(94, 170, 239, 0.3);
}

.tg-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--tg-accent);
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.tg-send-btn:hover {
    background: var(--tg-accent-hover);
}

.tg-send-btn:active {
    transform: scale(0.95);
}

/* ===== Forms ===== */
.tg-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tg-input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tg-input-group label {
    font-size: 13px;
    color: var(--tg-text-muted);
}

.tg-input-group input,
.tg-input-group textarea {
    padding: 10px 14px;
    background: var(--tg-input-bg);
    border: 1px solid var(--tg-border);
    border-radius: var(--radius-sm);
    color: var(--tg-text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.tg-input-group input:focus,
.tg-input-group textarea:focus {
    border-color: var(--tg-accent);
}

.tg-btn {
    padding: 10px 20px;
    background: var(--tg-accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.tg-btn:hover {
    background: var(--tg-accent-hover);
}

.tg-link {
    color: var(--tg-text-link);
}

/* ===== CAPTCHA ===== */
.captcha-group .captcha-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
}

.captcha-img {
    border-radius: var(--radius-sm);
    height: 50px;
}

.captcha-refresh {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.3s;
}

.captcha-refresh:hover {
    transform: rotate(180deg);
}

/* ===== Movie Cards ===== */
.movie-link {
    text-decoration: none;
    color: var(--tg-text);
    display: block;
}

.movie-link:hover {
    text-decoration: none;
}

.movie-card {
    display: flex;
    gap: 12px;
}

.movie-poster {
    width: 80px;
    height: 120px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    background: var(--tg-input-bg);
}

/* Poster card wrapper with fav button */
.poster-card-wrapper {
    position: relative;
    flex-shrink: 0;
    width: 80px;
    height: 120px;
}

.poster-card-wrapper .movie-poster {
    width: 100%;
    height: 100%;
}

.poster-fav-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
    z-index: 2;
    opacity: 0;
}

.poster-card-wrapper:hover .poster-fav-btn,
.poster-fav-btn.active {
    opacity: 1;
}

.poster-fav-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.15);
}

.poster-fav-btn.active {
    color: #f5c518;
    background: rgba(0, 0, 0, 0.6);
}

.movie-poster-placeholder {
    width: 80px;
    height: 120px;
    background: var(--tg-input-bg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    flex-shrink: 0;
}

.movie-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.movie-title {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.3;
}

.movie-original {
    font-size: 12px;
    color: var(--tg-text-muted);
}

.movie-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: var(--tg-text-muted);
}

.movie-genres {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.genre-tag {
    padding: 2px 8px;
    background: rgba(94, 170, 239, 0.12);
    color: var(--tg-accent);
    border-radius: 10px;
    font-size: 11px;
}

.movie-action-text {
    font-size: 12px;
    color: var(--tg-text-muted);
    margin-top: 8px;
    text-align: right;
}

.movie-bubble {
    padding-bottom: 8px;
}

.movie-bubble:hover {
    background: rgba(94, 170, 239, 0.05);
}

/* ===== Movie Detail Page ===== */
.movie-detail-bubble {
    text-align: center;
}

.movie-detail-poster {
    width: 200px;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin-bottom: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

/* Poster wrapper with type badge */
.poster-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 12px;
}

.poster-wrapper .movie-detail-poster {
    margin-bottom: 0;
}

.poster-type-badge {
    position: absolute;
    top: 10px;
    left: -6px;
    padding: 4px 12px 4px 10px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    border-radius: 0 6px 6px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 2;
    line-height: 1.3;
}

/* Type-specific badge colors */
.poster-type-badge.type-films       { background: linear-gradient(135deg, #667eea, #764ba2); }
.poster-type-badge.type-serials     { background: linear-gradient(135deg, #f093fb, #f5576c); }
.poster-type-badge.type-anime-film  { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.poster-type-badge.type-anime-serials { background: linear-gradient(135deg, #43e97b, #38f9d7); color: #1a1a1a; }
.poster-type-badge.type-cartoon     { background: linear-gradient(135deg, #fa709a, #fee140); color: #1a1a1a; }
.poster-type-badge.type-cartoon-serials { background: linear-gradient(135deg, #f6d365, #fda085); color: #1a1a1a; }
.poster-type-badge.type-show        { background: linear-gradient(135deg, #a18cd1, #fbc2eb); color: #1a1a1a; }
.poster-type-badge.type-dorama      { background: linear-gradient(135deg, #ffecd2, #fcb69f); color: #1a1a1a; }

.movie-detail-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.3;
}

.movie-detail-original {
    font-size: 14px;
    color: var(--tg-text-muted);
    margin-bottom: 10px;
}

.movie-ratings {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
}

.rating-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    min-width: 70px;
}

.rating-badge.kp {
    background: rgba(255, 102, 0, 0.15);
    border: 1px solid rgba(255, 102, 0, 0.3);
}

.rating-badge.imdb {
    background: rgba(245, 197, 24, 0.15);
    border: 1px solid rgba(245, 197, 24, 0.3);
}

.rating-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--tg-text-muted);
    text-transform: uppercase;
}

.rating-value {
    font-size: 22px;
    font-weight: 700;
}

.rating-badge.kp .rating-value {
    color: #ff6600;
}

.rating-badge.imdb .rating-value {
    color: #f5c518;
}

/* Movie Info List */
.movie-info-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.info-row {
    display: flex;
    gap: 8px;
    font-size: 14px;
}

.info-label {
    color: var(--tg-text-muted);
    white-space: nowrap;
}

/* Collection tags */
.movie-collections {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.collection-tag {
    padding: 3px 10px;
    background: rgba(94, 170, 239, 0.12);
    color: var(--tg-accent);
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.4;
}

.movie-description {
    font-size: 14px;
    line-height: 1.6;
}

.movie-description strong {
    color: var(--tg-accent);
}

/* ===== Player (Full Width) ===== */
.player-fullwidth {
    width: 100%;
    max-width: 100%;
    padding: 8px 0;
}

.player-title {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 15px;
    padding: 0 8px;
    color: var(--tg-text);
}

/* Player Tabs */
.player-tabs {
    display: flex;
    gap: 4px;
    padding: 0 8px 0;
    flex-wrap: wrap;
}

.player-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    background: var(--tg-input-bg);
    color: var(--tg-text-muted);
    border: 1px solid var(--tg-border);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    justify-content: center;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.player-tab:hover {
    background: rgba(94, 170, 239, 0.12);
    color: var(--tg-text);
}

.player-tab.active {
    background: var(--tg-accent);
    color: #fff;
    border-color: var(--tg-accent);
    box-shadow: 0 -2px 8px rgba(94, 170, 239, 0.3);
    z-index: 2;
}

.player-tab-icon {
    font-size: 10px;
    opacity: 0.7;
}

.player-tab.active .player-tab-icon {
    opacity: 1;
}

.player-tab-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.movie-player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ===== Movie Actions (Like/Dislike/Fav) ===== */
.movie-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--tg-border);
    border-radius: 20px;
    background: transparent;
    color: var(--tg-text);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: rgba(94, 170, 239, 0.1);
}

.action-btn.like-btn.active {
    background: rgba(76, 175, 80, 0.2);
    border-color: var(--tg-green);
    color: var(--tg-green);
}

.action-btn.dislike-btn.active {
    background: rgba(229, 57, 53, 0.2);
    border-color: var(--tg-red);
    color: var(--tg-red);
}

.action-btn.fav-btn.active {
    background: rgba(255, 193, 7, 0.2);
    border-color: var(--tg-yellow);
    color: var(--tg-yellow);
}

.auth-hint {
    margin-top: 8px;
    font-size: 12px;
    color: var(--tg-text-muted);
}

.auth-hint a {
    color: var(--tg-accent);
}

/* ===== Comments ===== */
.comments-header {
    font-size: 15px;
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comment-form textarea {
    padding: 10px 14px;
    background: var(--tg-input-bg);
    border: 1px solid var(--tg-border);
    border-radius: var(--radius-sm);
    color: var(--tg-text);
    font-size: 14px;
    outline: none;
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.comment-form textarea:focus {
    border-color: var(--tg-accent);
}

.comment-bubble {
    width: 100%;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    gap: 10px;
}

.comment-header strong {
    color: var(--tg-accent);
    font-size: 14px;
}

.comment-time {
    font-size: 11px;
    color: var(--tg-text-muted);
}

.comment-text {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 6px;
}

.comment-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.comment-manage-group {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
    background: var(--tg-hover);
    border-radius: 12px;
    padding: 1px 2px;
}

.comment-vote-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: none;
    background: transparent;
    color: var(--tg-text-muted);
    font-size: 13px;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s;
}

.comment-vote-btn:hover {
    background: rgba(94, 170, 239, 0.1);
}

.comment-vote-btn.active {
    color: var(--tg-accent);
}

.comment-manage-btn {
    display: inline-flex;
    align-items: center;
    padding: 3px 6px;
    border: none;
    background: transparent;
    color: var(--tg-text-muted);
    font-size: 13px;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.2s;
}

.comment-manage-btn:hover {
    background: rgba(94, 170, 239, 0.15);
}

.comment-manage-btn.delete-btn:hover {
    background: rgba(239, 83, 80, 0.15);
    color: #ef5350;
}

.comment-edit-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

.comment-edit-form textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    border: 1px solid var(--tg-border);
    border-radius: 8px;
    background: var(--tg-input-bg);
    color: var(--tg-text);
    font-size: 14px;
    resize: vertical;
}

.comment-edit-actions {
    display: flex;
    gap: 8px;
}

.comment-edit-actions button {
    padding: 4px 12px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

.comment-edit-actions .save-btn {
    background: var(--tg-accent);
    color: #fff;
}

.comment-edit-actions .cancel-btn {
    background: var(--tg-secondary-bg);
    color: var(--tg-text-muted);
}

.comment-msg {
    max-width: 90%;
    margin-bottom: 8px;
}

/* ===== Voice Messages ===== */
.comment-form-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.comment-form-actions .tg-btn {
    flex: 1;
}

.voice-record-btn {
    width: 42px;
    height: 42px;
    border: none;
    background: var(--tg-input-bg);
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid var(--tg-border);
}

.voice-record-btn:hover {
    background: rgba(94, 170, 239, 0.15);
    border-color: var(--tg-accent);
}

.voice-record-btn.recording {
    background: #ef5350;
    border-color: #ef5350;
    animation: pulse-recording 1s infinite;
}

@keyframes pulse-recording {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 83, 80, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(239, 83, 80, 0); }
}

.voice-recorder {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(239, 83, 80, 0.08);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(239, 83, 80, 0.2);
    flex-wrap: nowrap;
}

.voice-recorder-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 24px;
}

.voice-wave-bar {
    width: 3px;
    height: 100%;
    background: #ef5350;
    border-radius: 2px;
    animation: voice-wave 0.8s ease-in-out infinite;
    animation-play-state: paused;
}

.voice-wave-bar:nth-child(1) { animation-delay: 0s; height: 40%; }
.voice-wave-bar:nth-child(2) { animation-delay: 0.15s; height: 70%; }
.voice-wave-bar:nth-child(3) { animation-delay: 0.3s; height: 50%; }
.voice-wave-bar:nth-child(4) { animation-delay: 0.45s; height: 80%; }
.voice-wave-bar:nth-child(5) { animation-delay: 0.6s; height: 60%; }

@keyframes voice-wave {
    0%, 100% { transform: scaleY(0.4); }
    50% { transform: scaleY(1); }
}

.voice-timer {
    font-size: 16px;
    font-weight: 600;
    color: #ef5350;
    min-width: 36px;
    font-variant-numeric: tabular-nums;
}

.voice-stop-btn {
    padding: 8px 12px;
    background: #ef5350;
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.voice-stop-btn:hover {
    background: #d32f2f;
}

.voice-stop-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.voice-cancel-btn {
    padding: 6px 10px;
    background: transparent;
    border: 1px solid var(--tg-border);
    border-radius: var(--radius-sm);
    color: var(--tg-text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.voice-stop-short {
    display: none;
}

@media (max-width: 640px) {
    .voice-stop-full {
        display: none;
    }
    .voice-stop-short {
        display: inline;
    }
    .voice-recorder {
        padding: 10px 10px;
        gap: 6px;
    }
    .voice-timer {
        font-size: 14px;
        min-width: 30px;
    }
    .voice-stop-btn {
        padding: 8px 10px;
        font-size: 12px;
    }
}

.voice-cancel-btn:hover {
    background: rgba(239, 83, 80, 0.1);
    color: #ef5350;
    border-color: #ef5350;
}

/* Voice message in comments */
.voice-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(94, 170, 239, 0.06);
    border-radius: 16px;
    min-width: 220px;
    max-width: 320px;
}

.voice-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--tg-accent);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.voice-play-btn:hover {
    background: var(--tg-accent-hover);
    transform: scale(1.05);
}

.voice-play-btn.playing {
    background: #ef5350;
}

.voice-progress-wrap {
    flex: 1;
    position: relative;
    height: 28px;
    overflow: hidden;
}

.voice-waveform {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 100%;
    position: relative;
    z-index: 1;
}

.voice-waveform-bar {
    flex: 1;
    background: var(--tg-accent);
    opacity: 0.3;
    border-radius: 2px;
    min-width: 2px;
    transition: opacity 0.2s;
}

.voice-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    overflow: hidden;
    z-index: 2;
    pointer-events: none;
}

.voice-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--tg-accent);
    opacity: 0.15;
    border-radius: 4px;
}

.voice-duration {
    font-size: 12px;
    color: var(--tg-text-muted);
    min-width: 32px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* ===== Pagination ===== */
.tg-pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.page-info {
    font-size: 13px;
    color: var(--tg-text-muted);
}

/* ===== Favorites page ===== */
.fav-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--tg-border);
}

/* ===== Loading spinner ===== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--tg-text-muted);
    border-top-color: var(--tg-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Toast notifications ===== */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--tg-header-bg);
    color: var(--tg-text);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    box-shadow: 0 4px 15px var(--tg-shadow);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== Responsive ===== */
/* ===== Mobile — tablets & small desktops ===== */
@media (max-width: 768px) {
    .tg-app {
        max-width: 100%;
        box-shadow: none;
    }
}

/* ===== Mobile — phones ===== */
@media (max-width: 640px) {
    .poster-fav-btn {
        opacity: 1;
    }
    .tg-app {
        max-width: 100%;
    }

    .tg-header {
        padding: 8px 10px;
        min-height: 50px;
        gap: 8px;
    }

    .tg-header-title {
        font-size: 15px;
    }

    .tg-header-subtitle {
        font-size: 12px;
    }

    .tg-header-btn {
        font-size: 18px;
        padding: 4px 6px;
    }

    .tg-chat {
        padding: 8px 4px 16px;
    }

    .tg-message {
        max-width: 94%;
    }

    .tg-message.bot,
    .tg-message.user {
        max-width: 94%;
    }

    .comment-msg {
        max-width: 96%;
        margin-bottom: 6px;
    }

    .tg-bubble {
        padding: 8px 12px;
        font-size: 14px;
    }

    .tg-avatar {
        width: 30px;
        height: 30px;
        font-size: 15px;
    }

    .movie-detail-poster {
        width: 140px;
    }

    .movie-detail-title {
        font-size: 18px;
    }

    .movie-actions {
        flex-direction: column;
    }

    .action-btn {
        justify-content: center;
        padding: 10px 16px;
        font-size: 14px;
    }

    .movie-card {
        gap: 10px;
    }

    .movie-poster {
        width: 70px;
        height: 105px;
    }

    .movie-title {
        font-size: 14px;
    }

    .movie-meta {
        font-size: 11px;
    }

    .genre-tag {
        font-size: 10px;
        padding: 2px 6px;
    }

    .tg-inline-btns {
        gap: 4px;
    }

    .tg-inline-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .tg-input-bar {
        padding: 8px 8px;
    }

    .tg-search-input {
        padding: 9px 14px;
        font-size: 14px;
    }

    .tg-send-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .player-fullwidth {
        padding: 4px 0;
    }

    .player-title {
        font-size: 14px;
        padding: 0 4px;
    }

    .tg-form {
        gap: 10px;
    }

    .tg-input-group input,
    .tg-input-group textarea {
        padding: 9px 12px;
        font-size: 14px;
    }

    .tg-btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    .rating-badge {
        padding: 6px 12px;
        min-width: 60px;
    }

    .rating-value {
        font-size: 18px;
    }

    .info-row {
        font-size: 13px;
    }

    .comment-text {
        font-size: 13px;
    }

    .comment-vote-btn {
        font-size: 12px;
    }

    .tg-pagination {
        gap: 6px;
    }
}

/* ===== Mobile — very small phones ===== */
@media (max-width: 400px) {
    .tg-header {
        padding: 6px 8px;
        gap: 6px;
    }

    .tg-header-title {
        font-size: 13px;
    }

    .tg-header-subtitle {
        font-size: 11px;
    }

    .tg-back {
        font-size: 18px;
        padding: 2px 4px;
    }

    .tg-avatar {
        width: 26px;
        height: 26px;
        font-size: 13px;
    }

    .movie-poster {
        width: 55px;
        height: 82px;
    }

    .movie-detail-poster {
        width: 120px;
    }

    .movie-detail-title {
        font-size: 16px;
    }

    .tg-bubble {
        padding: 7px 10px;
        font-size: 13px;
    }

    .movie-title {
        font-size: 13px;
    }

    .tg-inline-btn {
        padding: 5px 8px;
        font-size: 11px;
    }

    .captcha-img {
        height: 40px;
    }
}

/* ===== Typing animation ===== */
.typing-dots {
    display: inline-flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--tg-text-muted);
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* ===== Selection ===== */
::selection {
    background: rgba(94, 170, 239, 0.3);
}

/* ===== Views Rating Badge ===== */
.rating-badge.views {
    background: rgba(94, 170, 239, 0.15);
    border: 1px solid rgba(94, 170, 239, 0.3);
}

.rating-badge.views .rating-value {
    color: var(--tg-accent);
    font-size: 18px;
}

.rating-badge.views .rating-label {
    font-size: 16px;
}

/* ===== Horizontal Scroll (Popular) ===== */
.horizontal-scroll-wrapper {
    width: 100%;
    padding: 4px 0 8px;
}

.horizontal-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 4px 8px 8px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.horizontal-scroll::-webkit-scrollbar {
    height: 4px;
}

.horizontal-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.horizontal-scroll::-webkit-scrollbar-thumb {
    background: var(--tg-border);
    border-radius: 2px;
}

.scroll-card {
    flex: 0 0 120px;
    text-decoration: none;
    color: var(--tg-text);
    scroll-snap-align: start;
    transition: transform 0.2s;
}

.scroll-card:hover {
    transform: translateY(-4px);
    text-decoration: none;
}

.scroll-card-poster-wrap {
    position: relative;
    width: 120px;
    height: 170px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.scroll-card-poster {
    width: 120px;
    height: 170px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--tg-input-bg);
    display: block;
}

.scroll-card-poster-ph {
    width: 120px;
    height: 170px;
    background: var(--tg-input-bg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
}

.scroll-card-title {
    font-size: 12px;
    font-weight: 600;
    margin-top: 6px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.scroll-card-views {
    font-size: 11px;
    color: var(--tg-text-muted);
}

.scroll-card-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
}

/* ===== Calendar (Coming Soon) ===== */
.calendar-bubble {
    width: 100%;
}

.calendar-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.calendar-info {
    flex: 1;
    min-width: 0;
}

.calendar-title {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.3;
}

.calendar-origin {
    font-size: 12px;
    color: var(--tg-text-muted);
    margin-top: 2px;
}

.calendar-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
    font-size: 12px;
    color: var(--tg-text-muted);
}

.calendar-rating {
    color: var(--tg-yellow);
    font-weight: 600;
}

.calendar-badge {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 2px;
}

.calendar-badge.available {
    background: rgba(76, 175, 80, 0.2);
    color: var(--tg-green);
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.calendar-badge.upcoming {
    background: rgba(255, 193, 7, 0.15);
    color: var(--tg-yellow);
    border: 1px solid rgba(255, 193, 7, 0.3);
}

/* ===== Comment movie link ===== */
.comment-movie-link {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--tg-border);
    font-size: 12px;
}

/* ===== Mobile adjustments for new sections ===== */
@media (max-width: 640px) {
    .scroll-card {
        flex: 0 0 100px;
    }

    .scroll-card-poster-wrap {
        width: 100px;
        height: 140px;
    }

    .scroll-card-poster,
    .scroll-card-poster-ph {
        width: 100px;
        height: 140px;
    }

    .scroll-card-title {
        font-size: 11px;
    }

    .calendar-title {
        font-size: 13px;
    }

    .calendar-meta {
        font-size: 11px;
        gap: 6px;
    }

    .calendar-badge {
        font-size: 10px;
        padding: 3px 8px;
    }
}

@media (max-width: 400px) {
    .scroll-card {
        flex: 0 0 85px;
    }

    .scroll-card-poster-wrap {
        width: 85px;
        height: 120px;
    }

    .scroll-card-poster,
    .scroll-card-poster-ph {
        width: 85px;
        height: 120px;
    }
}

/* Comments page button */
.tg-comments-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 10px 20px;
    background: var(--tg-accent);
    color: #fff;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    transition: background 0.2s, transform 0.15s;
}
.tg-comments-btn:hover {
    background: var(--tg-accent-hover, #5ba0d0);
    transform: scale(1.03);
}
.comments-badge {
    background: rgba(255,255,255,0.25);
    color: #fff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}

/* Comments page elements */
.comment-footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    flex-wrap: wrap;
    gap: 6px;
}
.comment-stats {
    display: flex;
    gap: 10px;
    font-size: 13px;
    color: var(--tg-text-muted);
}
.comment-stat-likes {
    color: #4caf50;
}
.comment-stat-dislikes {
    color: #f44336;
}
.tg-back-link {
    display: block;
    text-align: center;
    padding: 14px;
    color: var(--tg-accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    width: 100%;
}

/* Admin badge */
.admin-name {
    color: #ffd700 !important;
}
.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    color: #1a1a2e;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Emoji reactions (legacy, kept for compatibility) */
.comment-reactions {
    display: none;
}
.reaction-btn {
    background: var(--tg-hover);
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: all 0.2s;
    color: var(--tg-text);
}
.reaction-btn:hover {
    background: rgba(90, 160, 220, 0.15);
    border-color: rgba(90, 160, 220, 0.3);
}
.reaction-btn.active {
    background: rgba(90, 160, 220, 0.25);
    border-color: var(--tg-accent);
}
.reaction-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--tg-accent);
}

/* Comment count on scroll cards */
.scroll-card-comments {
    font-size: 11px;
    color: var(--tg-accent);
}

/* ===== Mini Rating Badges (on cards) ===== */
.movie-ratings-mini {
    gap: 6px !important;
}

.rating-mini {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.rating-mini.kp {
    background: rgba(255, 193, 7, 0.12);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.25);
}

.rating-mini.imdb {
    background: rgba(255, 193, 7, 0.12);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.25);
}

/* Scroll card ratings — poster overlay */
.scroll-card-ratings {
    position: absolute;
    top: 4px;
    left: 4px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    z-index: 2;
}

.scroll-rating {
    display: block;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    color: #ffc107;
    letter-spacing: 0.3px;
    line-height: 1.3;
    white-space: nowrap;
}
