/* ============================================
   🍊 ORANGETUBE - ESTILOS PRINCIPALES
   ============================================ */

/* === VARIABLES === */
:root {
    --primary: #FF6B00;
    --primary-light: #FF8C38;
    --primary-dark: #E55A00;
    --primary-glow: rgba(255, 107, 0, 0.3);

    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F5F5;
    --bg-card: #FFFFFF;
    --bg-hover: #F0F0F0;
    --bg-sidebar: #FFFFFF;

    --text-primary: #0F0F0F;
    --text-secondary: #606060;
    --text-muted: #909090;

    --border: #E5E5E5;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-strong: rgba(0, 0, 0, 0.15);

    --danger: #FF4444;
    --success: #00C853;
    --info: #2196F3;

    --sidebar-width: 240px;
    --navbar-height: 56px;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.3s ease;
}

/* === DARK MODE === */
[data-theme="dark"] {
    --bg-primary: #0F0F0F;
    --bg-secondary: #1A1A1A;
    --bg-card: #212121;
    --bg-hover: #2A2A2A;
    --bg-sidebar: #1A1A1A;

    --text-primary: #F1F1F1;
    --text-secondary: #AAAAAA;
    --text-muted: #717171;

    --border: #303030;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-strong: rgba(0, 0, 0, 0.5);
}

/* === RESET === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    transition: background-color var(--transition), color var(--transition);
}

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

button {
    cursor: pointer;
    border: none;
    outline: none;
    font-family: inherit;
}

input, textarea, select {
    font-family: inherit;
    outline: none;
}

/* === SCROLLBAR === */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    transition: background-color var(--transition);
}

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

.menu-btn,
.back-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-primary);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}

.menu-btn:hover,
.back-btn:hover {
    background: var(--bg-hover);
}

.logo {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.logo i {
    color: var(--primary);
    font-size: 28px;
}

.tube {
    color: var(--primary);
}

.nav-center {
    flex: 1;
    max-width: 600px;
    margin: 0 20px;
}

.search-box {
    display: flex;
    width: 100%;
    border: 2px solid var(--border);
    border-radius: 40px;
    overflow: hidden;
    transition: border-color var(--transition);
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-box input {
    flex: 1;
    padding: 8px 16px;
    border: none;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    transition: background var(--transition);
}

.search-btn {
    padding: 8px 20px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 16px;
    border-left: 1px solid var(--border);
    transition: all var(--transition);
}

.search-btn:hover {
    background: var(--primary);
    color: white;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.upload-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border-radius: 40px;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
}

.upload-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.theme-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-primary);
    font-size: 18px;
    transition: all var(--transition);
}

.theme-btn:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: all var(--transition);
}

.user-avatar:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px var(--primary-glow);
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--navbar-height));
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 12px 0;
    transition: all var(--transition);
    z-index: 999;
}

.sidebar.collapsed {
    width: 72px;
}

.sidebar.collapsed .sidebar-item span,
.sidebar.collapsed .sidebar-section h4,
.sidebar.collapsed .sidebar-footer {
    display: none;
}

.sidebar.collapsed .sidebar-item {
    justify-content: center;
    padding: 12px;
}

.sidebar-section {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-section h4 {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 12px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition);
    margin: 2px 0;
}

.sidebar-item:hover {
    background: var(--bg-hover);
}

.sidebar-item.active {
    background: var(--primary);
    color: white;
    font-weight: 500;
}

.sidebar-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    margin-top: var(--navbar-height);
    margin-left: var(--sidebar-width);
    padding: 20px;
    min-height: calc(100vh - var(--navbar-height));
    transition: margin-left var(--transition);
}

.main-content.expanded {
    margin-left: 72px;
}

/* === CATEGORY CHIPS === */
.category-chips {
    display: flex;
    gap: 8px;
    padding: 8px 0 20px;
    overflow-x: auto;
    scrollbar-width: none;
}

.category-chips::-webkit-scrollbar {
    display: none;
}

.chip {
    padding: 8px 16px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: all var(--transition);
    border: 1px solid var(--border);
}

.chip:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

.chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* === VIDEO GRID === */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* === VIDEO CARD === */
.video-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.video-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px var(--shadow-strong);
    border-color: var(--primary);
}

.video-card:hover .video-thumbnail img {
    transform: scale(1.05);
}

.video-thumbnail {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    overflow: hidden;
    background: var(--bg-secondary);
}

.video-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.video-card-info {
    padding: 12px;
    display: flex;
    gap: 12px;
}

.video-card-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.video-card-details {
    flex: 1;
    min-width: 0;
}

.video-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.video-card-channel {
    font-size: 13px;
    color: var(--text-secondary);
    transition: color var(--transition);
}

.video-card-channel:hover {
    color: var(--primary);
}

.video-card-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.video-card-meta span {
    margin-right: 4px;
}

/* === LOADING === */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* === NO RESULTS === */
.no-results {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.no-results i {
    font-size: 64px;
    margin-bottom: 16px;
    color: var(--primary);
    opacity: 0.5;
}

.no-results h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* ============================================
   WATCH PAGE
   ============================================ */
.watch-page {
    margin-top: var(--navbar-height);
    display: flex;
    gap: 24px;
    padding: 20px;
    max-width: 1800px;
    margin-left: auto;
    margin-right: auto;
}

.watch-main {
    flex: 1;
    min-width: 0;
}

.video-player-container {
    width: 100%;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    aspect-ratio: 16 / 9;
    position: relative;
}

.video-player {
    width: 100%;
    height: 100%;
    display: block;
}

.video-info-section {
    padding: 16px 0;
}

.video-title-watch {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 8px;
}

.video-meta-watch {
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.video-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 20px;
    font-size: 14px;
    transition: all var(--transition);
}

.action-btn:hover {
    background: var(--primary);
    color: white;
}

.action-btn.active {
    background: var(--primary);
    color: white;
}

/* === CHANNEL INFO === */
.channel-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.channel-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.channel-details {
    flex: 1;
}

.channel-details h3 {
    font-size: 16px;
    font-weight: 600;
}

.channel-details span {
    font-size: 13px;
    color: var(--text-muted);
}

.subscribe-btn {
    padding: 10px 24px;
    background: var(--primary);
    color: white;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition);
}

.subscribe-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.subscribe-btn.subscribed {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* === DESCRIPTION === */
.video-description {
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    margin: 16px 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* === COMMENTS === */
.comments-section {
    padding: 16px 0;
}

.comments-section h3 {
    font-size: 16px;
    margin-bottom: 20px;
}

.comment-form {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.comment-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.comment-input-wrapper {
    flex: 1;
}

.comment-input-wrapper input {
    width: 100%;
    padding: 8px 0;
    border: none;
    border-bottom: 2px solid var(--border);
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color var(--transition);
}

.comment-input-wrapper input:focus {
    border-bottom-color: var(--primary);
}

.comment-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
    display: none;
}

.comment-input-wrapper input:focus ~ .comment-buttons,
.comment-buttons.show {
    display: flex;
}

.btn-cancel {
    padding: 8px 16px;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 20px;
    font-size: 14px;
}

.btn-comment {
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.comment-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
}

.comment-content {
    flex: 1;
}

.comment-author {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.comment-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 8px;
    font-weight: 400;
}

.comment-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.comment-actions {
    display: flex;
    gap: 16px;
    margin-top: 8px;
}

.comment-action-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    color: var(--text-muted);
    font-size: 13px;
    transition: color var(--transition);
}

.comment-action-btn:hover {
    color: var(--primary);
}

/* === WATCH SIDEBAR === */
.watch-sidebar {
    width: 400px;
    flex-shrink: 0;
}

.watch-sidebar h3 {
    font-size: 16px;
    margin-bottom: 16px;
}

.related-video-card {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 4px;
    transition: background var(--transition);
}

.related-video-card:hover {
    background: var(--bg-hover);
}

.related-thumbnail {
    width: 168px;
    height: 94px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    background: var(--bg-secondary);
}

.related-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.related-info {
    flex: 1;
    min-width: 0;
}

.related-info h4 {
    font-size: 13px;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    margin-bottom: 4px;
}

.related-info p {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================
   UPLOAD PAGE
   ============================================ */
.upload-page {
    margin-top: var(--navbar-height);
    padding: 40px 20px;
    display: flex;
    justify-content: center;
}

.upload-container {
    max-width: 800px;
    width: 100%;
}

.upload-container h1 {
    font-size: 28px;
    margin-bottom: 24px;
    color: var(--primary);
}

.upload-zone {
    border: 3px dashed var(--border);
    border-radius: var(--radius);
    padding: 60px 20px;
    text-align: center;
    transition: all var(--transition);
    margin-bottom: 30px;
    background: var(--bg-secondary);
}

.upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(255, 107, 0, 0.05);
}

.upload-icon {
    font-size: 64px;
    color: var(--primary);
    margin-bottom: 16px;
    opacity: 0.7;
}

.upload-zone h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.upload-zone p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.btn-select {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition);
}

.btn-select:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

/* Progress Bar */
.upload-progress {
    margin-top: 20px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

#progressText {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
}

/* Video Preview */
.video-preview {
    margin-bottom: 24px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
}

.video-preview video {
    width: 100%;
    max-height: 400px;
}

/* Upload Form */
.upload-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-group label i {
    color: var(--primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.char-count {
    position: absolute;
    right: 12px;
    bottom: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 12px;
}

.btn-cancel-upload {
    padding: 12px 24px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    transition: all var(--transition);
}

.btn-cancel-upload:hover {
    background: var(--bg-hover);
}

.btn-upload {
    padding: 12px 32px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition);
}

.btn-upload:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-upload:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 40px;
    max-width: 420px;
    width: 90%;
    position: relative;
    transform: scale(0.9);
    transition: transform var(--transition);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--danger);
    color: white;
}

.modal-header {
    text-align: center;
    margin-bottom: 24px;
}

.modal-logo {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 12px;
}

.modal-header h2 {
    font-size: 20px;
}

#loginForm {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.btn-primary {
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    padding: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 20px var(--shadow-strong);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    animation: slideInRight 0.3s ease;
    border-left: 4px solid var(--primary);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.info {
    border-left-color: var(--info);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .watch-sidebar {
        display: none;
    }

    .watch-page {
        padding: 12px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px var(--shadow-strong);
    }

    .main-content {
        margin-left: 0;
    }

    .main-content.expanded {
        margin-left: 0;
    }

    .nav-center {
        display: none;
    }

    .upload-btn span {
        display: none;
    }

    .video-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .video-actions {
        flex-wrap: wrap;
    }

    .channel-info {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .navbar {
        padding: 0 8px;
    }

    .logo span {
        display: none;
    }

    .upload-container h1 {
        font-size: 22px;
    }

    .upload-zone {
        padding: 40px 16px;
    }

    .modal {
        padding: 24px;
    }
}

/* ============================================
   YOUTUBE INTEGRATION
   ============================================ */
.yt-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: #FF0000;
    color: #fff;
    border-radius: 40px;
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition);
}

.yt-btn i {
    font-size: 18px;
}

.yt-btn:hover {
    background: #CC0000;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(255, 0, 0, 0.3);
}

.chip i.fa-youtube {
    color: #FF0000;
}

.chip.active i.fa-youtube {
    color: #fff;
}

/* Badge en las miniaturas */
.yt-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.yt-badge i,
.yt-source-label i {
    color: #FF0000;
}

.yt-source-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Reproductor embebido */
.video-embed {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: #000;
}

.yt-text {
    color: #FF0000;
}

/* Importar desde YouTube (página de subida) */
.yt-import-group {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    background: var(--bg-secondary);
}

.yt-import-group label i.fa-youtube {
    color: #FF0000;
}

.yt-import-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.yt-import-row input {
    flex: 1;
    min-width: 0;
    background: var(--bg-primary);
}

.yt-import-row .btn-select {
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

.form-hint.ok {
    color: var(--success);
}

.form-hint.error {
    color: var(--danger);
}

@media (max-width: 480px) {
    .yt-import-row {
        flex-direction: column;
    }
}

/* ============================================
   EXPLORAR YOUTUBE (sin API Key)
   ============================================ */
.explore-page {
    margin-top: var(--navbar-height);
    padding: 24px 20px 60px;
    max-width: 1700px;
    margin-left: auto;
    margin-right: auto;
    min-height: calc(100vh - var(--navbar-height));
}

.explore-header h1 {
    font-size: 26px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.explore-header h1 i {
    color: #FF0000;
}

.explore-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

.explore-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.ex-status {
    font-size: 13px;
    color: var(--text-muted);
}

.ex-status.ok {
    color: var(--success);
}

.ex-status.error {
    color: var(--danger);
}

.ex-ghost-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 40px;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
}

.ex-ghost-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Panel de instancias */
.ex-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}

.ex-help {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.ex-panel-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.ex-instance-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
    max-height: 260px;
    overflow-y: auto;
}

.ex-instance {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    padding: 6px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.ex-instance.ok .ex-instance-icon {
    color: var(--success);
}

.ex-instance.fail .ex-instance-icon {
    color: var(--danger);
}

.ex-instance.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.ex-instance-kind {
    text-transform: uppercase;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.ex-instance-base {
    font-weight: 600;
    color: var(--text-primary);
}

.ex-instance-info {
    margin-left: auto;
    color: var(--text-muted);
}

.ex-custom {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ex-custom input,
.ex-custom select {
    padding: 9px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
}

.ex-custom input {
    flex: 1;
    min-width: 220px;
}

/* Burbujas de canales */
.ex-section-title {
    font-size: 16px;
    margin: 8px 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ex-section-title i {
    color: var(--primary);
}

.ex-channels-section {
    margin-bottom: 24px;
}

.ex-channel-row {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 4px 2px 12px;
    scrollbar-width: thin;
}

.ex-channel {
    flex: 0 0 auto;
    width: 96px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 0;
    text-align: center;
}

.ex-channel-bubble {
    position: relative;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    border: 3px solid var(--border);
    transition: all var(--transition);
}

.ex-channel:hover .ex-channel-bubble {
    border-color: var(--primary);
    transform: scale(1.06);
    box-shadow: 0 6px 18px var(--primary-glow);
}

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

.ex-channel-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ex-channel-subs {
    font-size: 11px;
    color: var(--text-muted);
}

/* Cabecera del canal abierto */
.ex-channel-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.ex-channel-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ex-channel-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    flex-shrink: 0;
}

.ex-channel-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ex-channel-info h2 {
    font-size: 20px;
}

.ex-channel-info p {
    font-size: 13px;
    color: var(--text-muted);
}

/* Scroll infinito */
.ex-sentinel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 30px 0 10px;
    min-height: 60px;
}

.ex-end {
    color: var(--text-muted);
    font-size: 13px;
}

/* Avatares reales en tarjetas y en la página de ver */
.video-card-avatar {
    position: relative;
    overflow: hidden;
}

.video-card-avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

.channel-avatar {
    overflow: hidden;
    position: relative;
}

.channel-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

@media (max-width: 768px) {
    .explore-page {
        padding: 16px 12px 50px;
    }

    .explore-header h1 {
        font-size: 21px;
    }

    .ex-channel {
        width: 82px;
    }

    .ex-channel-bubble {
        width: 64px;
        height: 64px;
        font-size: 22px;
    }
}

/* ============================================
   ✨ ANIMACIONES Y MICROINTERACCIONES
   ============================================ */
@keyframes cardIn {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pageIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

@keyframes pop {
    0% { transform: scale(0.9); }
    60% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

@keyframes floaty {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes pulseRing {
    0% { box-shadow: 0 0 0 0 rgba(255, 107, 0, 0.45); }
    70% { box-shadow: 0 0 0 14px rgba(255, 107, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 107, 0, 0); }
}

body {
    animation: pageIn 0.35s ease both;
    -webkit-tap-highlight-color: transparent;
}

.video-card {
    animation: cardIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1) both;
    will-change: transform, opacity;
}

.video-card:active {
    transform: scale(0.985);
}

.video-card .video-thumbnail::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, 0.35));
    opacity: 0;
    transition: opacity var(--transition);
    pointer-events: none;
}

.video-card:hover .video-thumbnail::after {
    opacity: 1;
}

button, .chip, .action-btn, .btn-primary, .btn-secondary,
.upload-btn, .ex-ghost-btn, .ex-channel, .bottom-nav-item {
    transition: transform 0.16s ease, background-color var(--transition),
                color var(--transition), border-color var(--transition),
                box-shadow var(--transition), opacity var(--transition);
}

button:active, .chip:active, .action-btn:active,
.btn-primary:active, .btn-secondary:active, .upload-btn:active,
.ex-ghost-btn:active, .bottom-nav-item:active {
    transform: scale(0.96);
}

.chip.active {
    animation: pop 0.28s ease;
}

/* Ripple */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.45);
    transform: scale(0);
    animation: rippleOut 0.6s ease-out;
    pointer-events: none;
    z-index: 0;
}

@keyframes rippleOut {
    to { transform: scale(2.6); opacity: 0; }
}

/* Skeleton de carga */
.skeleton {
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-hover) 50%, var(--bg-secondary) 75%);
    background-size: 600px 100%;
    animation: shimmer 1.2s infinite linear;
    border-radius: 6px;
}

.skeleton-card { pointer-events: none; }

.skeleton-thumb {
    width: 100%;
    padding-top: 56.25%;
    border-radius: 0;
}

.skeleton-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-line {
    height: 12px;
    margin-bottom: 8px;
}

.skeleton-line.short { width: 70%; }
.skeleton-line.tiny { width: 45%; height: 10px; }

/* ============================================
   📱 INTERFAZ MÓVIL
   ============================================ */
.mobile-search {
    display: none;
    position: sticky;
    top: calc(var(--navbar-height) + env(safe-area-inset-top, 0px));
    z-index: 900;
    margin: 0 0 12px;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 40px;
    box-shadow: 0 4px 16px var(--shadow);
}

.mobile-search input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 16px; /* evita el zoom automático de iOS */
    font-family: inherit;
    outline: none;
}

.mobile-search i.fa-search {
    color: var(--primary);
}

.mobile-search button {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Barra inferior */
.bottom-nav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1500;
    background: var(--bg-card);
    background: color-mix(in srgb, var(--bg-card) 92%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    justify-content: space-around;
    align-items: stretch;
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.08);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    border-radius: 14px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    position: relative;
}

.bottom-nav-item i {
    font-size: 20px;
    transition: transform 0.2s ease;
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item.active i {
    transform: translateY(-2px) scale(1.06);
}

.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    width: 22px;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: var(--primary);
}

.bottom-nav-item.accent .bottom-nav-icon {
    width: 44px;
    height: 44px;
    margin-top: -14px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px var(--primary-glow);
    animation: pulseRing 3s infinite;
}

.bottom-nav-item.accent i {
    font-size: 22px;
}

/* Aviso de instalación */
.install-banner {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    z-index: 1800;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 12px 30px var(--shadow-strong);
    transform: translateY(140%);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.3s ease;
}

.install-banner.show {
    transform: translateY(0);
    opacity: 1;
}

.install-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    flex-shrink: 0;
}

.install-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
    color: var(--text-secondary);
}

.install-text strong {
    font-size: 14px;
    color: var(--text-primary);
}

.install-btn {
    padding: 9px 16px;
    border-radius: 30px;
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.install-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Aviso sin conexión */
.offline-banner {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    left: 50%;
    transform: translate(-50%, -160%);
    z-index: 2500;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 30px;
    background: var(--danger);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(255, 68, 68, 0.4);
    transition: transform 0.3s ease;
    max-width: 92vw;
}

.offline-banner.show {
    transform: translate(-50%, 0);
}

/* Botón volver arriba */
.scroll-top {
    position: fixed;
    right: 16px;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    z-index: 1400;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 22px var(--primary-glow);
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    pointer-events: none;
    transition: all 0.25s ease;
}

.scroll-top.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Acción dentro del toast */
.toast-action {
    margin-left: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

/* Fondo oscuro del menú lateral */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

body.no-scroll {
    overflow: hidden;
}

.navbar.nav-scrolled {
    box-shadow: 0 4px 18px var(--shadow);
}

/* ============================================
   🎛️ CONTROLES EXTRA DEL REPRODUCTOR
   ============================================ */
.player-extras {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 0 4px;
    border-bottom: 1px solid var(--border);
}

.pe-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 30px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
}

.pe-btn i {
    font-size: 14px;
}

.pe-btn.active {
    background: rgba(255, 107, 0, 0.14);
    color: var(--primary);
    box-shadow: inset 0 0 0 1px var(--primary-glow);
}

.pe-speed {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 30px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
}

.pe-speed select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    outline: none;
}

.pe-resume {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--primary);
    opacity: 0;
    transform: translateX(-6px);
    transition: all 0.3s ease;
}

.pe-resume.show {
    opacity: 1;
    transform: translateX(0);
}

/* ============================================
   📴 PÁGINA SIN CONEXIÓN
   ============================================ */
.offline-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at 50% 0%, rgba(255, 107, 0, 0.15), transparent 60%), var(--bg-primary);
}

.offline-card {
    text-align: center;
    max-width: 420px;
    padding: 32px 24px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: 0 20px 50px var(--shadow);
    animation: cardIn 0.5s ease both;
}

.offline-logo {
    width: 84px;
    height: 84px;
    border-radius: 20px;
    margin-bottom: 16px;
    animation: floaty 4s ease-in-out infinite;
}

.offline-card h1 {
    font-size: 22px;
    margin-bottom: 8px;
}

.offline-card p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.offline-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0 12px;
}

.offline-actions .btn-primary,
.offline-actions .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.offline-hint {
    font-size: 12px;
    color: var(--text-muted);
}

@media (min-width: 769px) {
    .install-banner {
        left: auto;
        right: 20px;
        bottom: 20px;
        max-width: 400px;
    }
}

/* ============================================
   📐 RESPONSIVE MÓVIL (mejorado)
   ============================================ */
@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
    }

    .mobile-search {
        display: flex;
    }

    body.has-bottom-nav {
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }

    .main-content,
    .explore-page {
        padding-left: 12px;
        padding-right: 12px;
    }

    .main-content {
        padding-bottom: 24px;
    }

    .video-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .category-chips {
        padding: 4px 0 14px;
        scroll-snap-type: x proximity;
    }

    .chip {
        scroll-snap-align: start;
        padding: 9px 16px;
        font-size: 13px;
    }

    .scroll-top {
        bottom: calc(84px + env(safe-area-inset-bottom, 0px));
        right: 12px;
        width: 44px;
        height: 44px;
    }

    .toast-container {
        left: 12px;
        right: 12px;
        bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    }

    .toast {
        width: 100%;
    }

    /* Watch en móvil: player a todo el ancho */
    .watch-page {
        padding: 0 0 20px;
        gap: 16px;
    }

    .video-player-container {
        border-radius: 0;
    }

    .video-info-section,
    .comments-section,
    .video-description,
    .watch-sidebar {
        padding-left: 14px;
        padding-right: 14px;
    }

    .video-title-watch {
        font-size: 17px;
    }

    .video-actions {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 12px;
        scrollbar-width: none;
    }

    .video-actions::-webkit-scrollbar {
        display: none;
    }

    .action-btn {
        flex: 0 0 auto;
    }

    .player-extras {
        padding: 10px 14px 10px;
    }

    .pe-btn span {
        font-size: 12px;
    }

    /* Modales como hoja inferior */
    .modal-overlay {
        align-items: flex-end;
    }

    .modal {
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
        transform: translateY(100%);
        transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.3, 1);
        max-height: 92vh;
        overflow-y: auto;
    }

    .modal-overlay.active .modal {
        transform: translateY(0);
    }

    .modal-close {
        top: 12px;
        right: 12px;
    }

    /* Subida */
    .upload-page {
        padding: 20px 12px 30px;
    }

    .upload-zone {
        padding: 34px 16px;
    }

    /* Explorar */
    .explore-header h1 {
        font-size: 20px;
    }

    .ex-channel-row {
        gap: 12px;
    }

    /* Navbar un poco más compacta */
    .navbar {
        padding: 0 10px;
    }

    .user-avatar,
    .theme-btn,
    .menu-btn,
    .back-btn {
        width: 38px;
        height: 38px;
    }
}

@media (max-width: 480px) {
    .logo span {
        display: none;
    }

    .video-card-title {
        font-size: 14px;
    }

    .video-card-info {
        padding: 10px;
    }

    .pe-btn {
        padding: 7px 12px;
        font-size: 12px;
    }
}

/* iOS con notch (modo app instalada) */
@media (display-mode: standalone) {
    .navbar {
        padding-top: env(safe-area-inset-top, 0px);
        height: calc(var(--navbar-height) + env(safe-area-inset-top, 0px));
    }

    .sidebar {
        top: calc(var(--navbar-height) + env(safe-area-inset-top, 0px));
        height: calc(100vh - var(--navbar-height) - env(safe-area-inset-top, 0px));
    }

    .main-content {
        margin-top: calc(var(--navbar-height) + env(safe-area-inset-top, 0px));
    }

    .watch-page,
    .explore-page,
    .upload-page {
        margin-top: calc(var(--navbar-height) + env(safe-area-inset-top, 0px));
    }

    .mobile-search {
        top: calc(var(--navbar-height) + env(safe-area-inset-top, 0px));
    }
}

/* Respeto por quien prefiere menos movimiento */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* Botón de instalar en el menú lateral */
.sidebar-install {
    width: calc(100% - 24px);
    margin: 6px 12px 10px;
    background: rgba(255, 107, 0, 0.12);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-install:hover {
    background: rgba(255, 107, 0, 0.2);
}

/* ============================================================
   🎛️ REPRODUCTOR PROPIO (controles de OrangeTube)
   ============================================================ */
.otp {
    position: absolute;
    inset: 0;
    z-index: 6;
    pointer-events: none;
    --otp-bar: linear-gradient(transparent, rgba(0, 0, 0, .82));
}

.otp-big,
.otp-panel,
.otp-help {
    pointer-events: auto;
}

/* La barra solo captura clics en sus controles: el resto del video sigue
   siendo clicable (saltar anuncio, tarjetas finales de YouTube, etc.) */
.otp-bar {
    pointer-events: none;
}

.otp-bar .otp-btn,
.otp-bar .otp-progress,
.otp-bar .otp-volbox {
    pointer-events: auto;
}

.otp-surface {
    position: absolute;
    inset: 0;
    pointer-events: auto;
    cursor: pointer;
    background: transparent;
}

/* Escotilla: durante 10 s los clics vuelven a YouTube (anuncios, etc.) */
.otp-passthrough .otp-surface,
.otp-passthrough .otp-cover {
    pointer-events: none !important;
}

.otp-big {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    font-size: 24px;
    background: rgba(0, 0, 0, .48);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
    transition: opacity .25s ease, transform .25s ease, background .2s ease;
}

.otp-big:hover {
    background: var(--primary);
    transform: translate(-50%, -50%) scale(1.06);
}

.otp-playing .otp-big {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(.8);
}

.otp-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 26px 12px 10px;
    background: linear-gradient(rgba(0, 0, 0, .30), rgba(8, 8, 10, .96) 42%);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #fff;
    transition: opacity .25s ease, transform .25s ease;
}

.otp-hidden .otp-bar {
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
}

.otp-hidden .otp-big {
    opacity: 0;
    pointer-events: none;
}

.otp-btn {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: background .18s ease, transform .18s ease;
}

.otp-btn:hover,
.otp-btn:focus-visible {
    background: rgba(255, 255, 255, .16);
}

.otp-btn:active {
    transform: scale(.92);
}

.otp-btn-speed span {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .02em;
}

.otp-time {
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
    opacity: .92;
    min-width: 34px;
    text-align: center;
}

.otp-progress {
    position: relative;
    flex: 1 1 auto;
    height: 22px;
    display: flex;
    align-items: center;
    cursor: pointer;
    touch-action: none;
}

.otp-progress::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .28);
}

.otp-buffer {
    position: absolute;
    left: 0;
    height: 4px;
    width: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .42);
}

.otp-played {
    position: absolute;
    left: 0;
    height: 4px;
    width: 0;
    border-radius: 999px;
    background: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow, rgba(255, 107, 0, .45));
}

.otp-knob {
    position: absolute;
    right: -5px;
    top: 50%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    transform: translateY(-50%) scale(0);
    transition: transform .18s ease;
}

.otp-progress:hover .otp-knob,
.otp-progress:focus-visible .otp-knob {
    transform: translateY(-50%) scale(1);
}

.otp-volbox {
    width: 70px;
    display: flex;
    align-items: center;
}

.otp-volume {
    width: 100%;
    height: 4px;
    accent-color: var(--primary);
    cursor: pointer;
}

.otp-panel {
    position: absolute;
    right: 12px;
    bottom: 62px;
    width: min(300px, calc(100% - 24px));
    padding: 12px;
    border-radius: 16px;
    background: rgba(18, 18, 20, .94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, .1);
    box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
    color: #fff;
    max-height: 60%;
    overflow-y: auto;
}

.otp-panel-group + .otp-panel-group {
    margin-top: 10px;
}

.otp-panel-title {
    display: block;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255, 255, 255, .55);
    margin-bottom: 6px;
}

.otp-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.otp-chip {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .07);
    color: #fff;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.otp-chip:hover {
    background: rgba(255, 255, 255, .16);
}

.otp-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.otp-chip:active {
    transform: scale(.95);
}

.otp-help {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    padding: 16px 18px;
    border-radius: 16px;
    background: rgba(18, 18, 20, .96);
    border: 1px solid rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 12px;
    min-width: 240px;
}

.otp-help-title {
    display: block;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--primary);
}

.otp-help-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 14px;
    color: rgba(255, 255, 255, .82);
}

.otp-help-grid span:nth-child(odd) {
    font-weight: 700;
    color: #fff;
}

.otp-flash {
    position: absolute;
    top: 50%;
    width: 88px;
    height: 88px;
    margin-top: -44px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 20px;
    opacity: 0;
    pointer-events: none;
}

.otp-flash-left { left: 8%; }
.otp-flash-right { right: 8%; }

.otp-flash-run {
    animation: otpFlash .55s ease forwards;
}

@keyframes otpFlash {
    0% { opacity: .9; transform: scale(.85); }
    100% { opacity: 0; transform: scale(1.15); }
}

.otp-visible .otp-bar {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 640px) {
    .otp-volbox,
    .otp-btn-speed {
        display: none;
    }

    .otp-bar {
        gap: 2px;
        padding: 22px 8px 8px;
    }

    .otp-btn {
        width: 32px;
        height: 32px;
    }

    .otp-big {
        width: 58px;
        height: 58px;
        font-size: 20px;
    }

    .otp-time {
        min-width: 28px;
        font-size: 10.5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .otp-bar,
    .otp-big,
    .otp-chip,
    .otp-btn {
        transition: none;
    }

    .otp-flash-run {
        animation-duration: .01s;
    }
}

/* --- Portada propia: tapa los controles flotantes de YouTube --- */
.otp-cover {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 14px;
    background: radial-gradient(circle at 50% 45%, rgba(0, 0, 0, .45), rgba(0, 0, 0, .78));
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
}

/* Con miniatura: tapa por completo el fotograma y los avisos de YouTube */
.otp-cover-photo {
    background-size: cover;
    background-position: center;
    background-color: #000;
}

.otp-cover-photo::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(0, 0, 0, .55), rgba(0, 0, 0, .72));
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.otp-cover-on .otp-cover {
    opacity: 1;
    pointer-events: auto;
}

.otp-cover .otp-big {
    position: static;
    transform: none;
    margin: 0 auto;
}

.otp-cover .otp-big:hover {
    transform: scale(1.06);
}

.otp-ended .otp-big {
    background: rgba(255, 255, 255, .16);
}

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

.otp-end-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .2);
    background: rgba(0, 0, 0, .55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .18s ease, transform .18s ease;
}

.otp-end-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.otp-end-btn:active {
    transform: scale(.95);
}

/* Barra superior propia (tapa el título y los enlaces de YouTube) */
.otp-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 30px;
    background: linear-gradient(rgba(0, 0, 0, .92), rgba(0, 0, 0, .72) 55%, transparent);
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}

.otp-visible .otp-top {
    opacity: 1;
    pointer-events: auto;
}

.otp-brand {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--primary);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .02em;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
}

.otp-title {
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: .95;
}

@media (max-width: 640px) {
    .otp-brand span {
        display: none;
    }

    .otp-title {
        font-size: 11.5px;
    }
}

/* Progreso fluido mientras el video avanza */
.otp-played,
.otp-buffer {
    transition: width .22s linear;
}

.otp-scrubbing .otp-played,
.otp-scrubbing .otp-buffer {
    transition: none;
}

.otp-playing .otp-progress::before {
    background: rgba(255, 255, 255, .34);
}

/* Calidad actual en el panel del reproductor */
.otp-quality-now {
    font-style: normal;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 0;
    text-transform: none;
}
