:root {
    /* Light mode (default) */
    --content-bg: #ffffff;
    --text-primary: #000000;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --card-bg: #f5f5f5;
    --input-bg: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.1);
    
    /* Viewport height (set by JavaScript for mobile) */
    --vh: 100vh;
}

body.dark-mode,
html.dark-mode {
    /* Dark mode */
    --content-bg: #0f0f1e;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #2a2a3e;
    --card-bg: #1a1a2e;
    --input-bg: #2a2a3e;
    --shadow-color: rgba(0, 0, 0, 0.5);
}

html.dark-mode body {
    /* Ensure body inherits dark mode from html */
    --content-bg: #0f0f1e;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #2a2a3e;
    --card-bg: #1a1a2e;
    --input-bg: #2a2a3e;
    --shadow-color: rgba(0, 0, 0, 0.5);
}

html {
    width: 100% !important;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: transparent;
    min-height: var(--vh);
    height: var(--vh);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    overscroll-behavior: none;
    padding: 0;
    transition: background 0.3s ease;
    position: relative;
}

/* Top Controls Container */
.top-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 10001;
}


/* QR Code Toggle Button */
.qr-toggle {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.qr-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.qr-toggle svg {
    width: 24px;
    height: 24px;
    color: #ffffff;
}

/* Theme Toggle Button */
.theme-toggle {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
    color: #ffffff;
    transition: all 0.3s ease;
}

body.dark-mode .theme-toggle {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.theme-toggle .sun-icon,
.theme-toggle .moon-icon {
    position: absolute;
}

.theme-toggle .hidden {
    opacity: 0;
    transform: rotate(180deg) scale(0);
}

body.dark-mode .theme-toggle .sun-icon {
    opacity: 0;
    transform: rotate(180deg) scale(0);
}

body.dark-mode .theme-toggle .moon-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* QR Code Modal */
.qr-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10002;
    transition: opacity 0.3s ease;
}

.qr-modal.hidden {
    display: none;
}

.qr-modal-content {
    background: var(--content-bg);
    border-radius: 20px;
    padding: 40px;
    max-width: 400px;
    text-align: center;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.qr-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 35px;
    height: 35px;
    background: rgba(255, 59, 48, 0.1);
    border: none;
    border-radius: 50%;
    font-size: 24px;
    color: #ff3b30;
    cursor: pointer;
    transition: all 0.3s ease;
}

.qr-close:hover {
    background: rgba(255, 59, 48, 0.2);
    transform: scale(1.1);
}

.qr-modal-content h2 {
    color: var(--text-primary);
    font-size: 24px;
    margin-bottom: 20px;
}

#qr-code {
    margin: 20px auto;
    padding: 20px;
    background: white;
    border-radius: 12px;
    display: inline-block;
}

.qr-url {
    color: var(--text-secondary);
    font-size: 14px;
    word-break: break-all;
    margin-top: 15px;
}

/* Webview Mode */
body.webview-mode {
    padding: 0;
    background: transparent;
}

body.webview-mode .top-controls {
    display: none;
}

/* Left Side Controls */
.left-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 12px;
    align-self: flex-start;
    margin-top: 100px;
    max-width: 200px;
}

.control-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Scroll Controls (Right Side) */
.scroll-controls-external {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 12px;
    align-self: flex-start;
    margin-top: 100px;
}

.scroll-controls-external h3 {
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.scroll-btn-external {
    width: 60px;
    height: 60px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.scroll-btn-external .icon {
    width: 28px;
    height: 28px;
    color: #ffffff;
}

.scroll-btn-external:hover {
    background: rgba(255, 255, 255, 0.3);
}

.scroll-btn-external.active {
    background: #ffffff;
    border-color: #ffffff;
}

.scroll-btn-external.active .icon {
    color: #667eea;
}

.height-controls h3 {
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.height-btn {
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid transparent;
    border-radius: 8px;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 110px;
    white-space: nowrap;
}

.height-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.height-btn.active,
.player-mode-btn.active {
    background: #ffffff;
    color: #667eea;
    border-color: #ffffff;
}

/* Main Content Wrapper */
.main-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}


/* View Containers */
.view-container {
    width: 100%;
    height: var(--vh);
    position: fixed;
    top: 0;
    left: 0;
    display: none;
}

.view-container.active {
    display: flex;
    flex-direction: column;
}

/* Full Screen Mode */
#fullscreen-view {
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    position: relative;
}

#fullscreen-view .content-area {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: var(--content-bg);
    transition: background 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* Slider Mode */
#slider-view.slider-mode {
    display: block;
}

.slider-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.slider-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--content-bg);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
    transition: height 0.3s ease, background 0.3s ease;
}

.slider-panel.height-50 {
    height: 50%;
}

.slider-panel.height-70 {
    height: 70%;
}

.slider-panel.height-90 {
    height: 90%;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.slider-handle {
    width: 40px;
    height: 5px;
    background: #d1d5db;
    border-radius: 3px;
    margin: 12px auto 8px;
    flex-shrink: 0;
}

.slider-panel .content-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 0 0 0;
    display: flex;
    flex-direction: column;
}

/* Content Area */
.page-content {
    display: none;
    width: 100%;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--content-bg);
    transition: background 0.3s ease;
    padding: 0 0px;
}

.page-content:not(.hidden) {
    display: flex;
}

.page-content h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    transition: color 0.3s ease;
}

.page-content p {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.6;
    transition: color 0.3s ease;
}

/* Home Page Controls */
.home-controls-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    min-height: min-content;
    flex-shrink: 0;
}

.home-controls-container h1 {
    text-align: center;
    font-size: 32px;
    margin-bottom: 10px;
}

.home-control-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px var(--shadow-color);
    transition: all 0.3s ease;
}

.home-control-section h3 {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    transition: color 0.3s ease;
}

.home-control-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.home-control-btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 20px;
    background: rgba(102, 126, 234, 0.1);
    color: var(--text-primary);
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.home-control-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.home-control-btn.active {
    background: #667eea;
    color: #ffffff;
    border-color: #667eea;
}

.home-sound-control {
    display: flex;
    align-items: center;
    gap: 15px;
}

.home-toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.home-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.home-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 34px;
}

.home-toggle-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

.home-toggle-switch input:checked + .home-toggle-slider {
    background-color: #667eea;
}

.home-toggle-switch input:checked + .home-toggle-slider:before {
    transform: translateX(26px);
}

.home-description {
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Display Mode Controls */
.display-mode-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}


.qr-button {
    width: 100%;
    padding: 12px 20px;
    background: rgba(102, 126, 234, 0.1);
    color: var(--text-primary);
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.qr-button:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.qr-button svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Clear Cache Button */
.clear-cache-btn {
    width: 100%;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.clear-cache-btn svg {
    width: 18px;
    height: 18px;
}

.clear-cache-btn:hover {
    background: linear-gradient(135deg, #e082ea 0%, #e4465b 100%);
    transform: translateY(-2px);
}

.clear-cache-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.cache-info {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

/* API Diagnostics Styles */
.diagnostics-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border: none;
}

.diagnostics-btn:hover {
    background: linear-gradient(135deg, #5568d3 0%, #653a8a 100%);
}

.diagnostics-results {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.diagnostics-results.hidden {
    display: none;
}

/* Platform Detection Section */
.platform-detection-section {
    background: rgba(124, 58, 237, 0.05);
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 12px;
    padding: 20px;
}

.platform-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.platform-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border-left: 3px solid var(--border-color);
    gap: 15px;
}

.platform-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 120px;
    flex-shrink: 0;
}

.platform-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    text-align: right;
    word-break: break-word;
}

.platform-value.platform-ua {
    font-size: 11px;
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
    line-height: 1.4;
}

.diagnostics-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 8px;
    border-left: 4px solid var(--border-color);
    transition: all 0.3s ease;
}

.diagnostics-item.success {
    border-left-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.diagnostics-item.error {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.diagnostics-item.testing {
    border-left-color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

.diag-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.diag-status {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.diagnostics-item.success .diag-status {
    color: #10b981;
}

.diagnostics-item.error .diag-status {
    color: #ef4444;
}

.diagnostics-item.testing .diag-status {
    color: #f59e0b;
}

/* Search Top Header */
.search-top-header {
    position: fixed;
    top: var(--safe-zone-top, 0px);
    left: 0;
    right: 0;
    height: 56px;
    background: var(--content-bg);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    z-index: 1000;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.search-top-header.hidden {
    display: none;
}

/* Mood Slider - inside search bar */
.search-mood-slider {
    display: flex;
    align-items: center;
    gap: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
    max-width: 60%;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 15%, black 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 15%, black 100%);
    transition: max-width 0.3s ease, opacity 0.3s ease;
}

.search-mood-slider.hidden {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.search-mood-slider::-webkit-scrollbar {
    display: none;
}

.search-mood-slider .mood-btn:first-child {
    margin-left: 20px;
}

.mood-btn {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease, transform 0.2s ease;
}

.mood-btn svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.mood-btn:active {
    transform: scale(0.9);
}

.mood-btn.active {
    background: var(--primary-color);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.4);
}

.mood-btn.active svg {
    color: white;
    stroke-width: 2;
}

.home-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.home-btn svg {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
}

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

.header-search-bar {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    background: var(--input-bg);
    border: 2px solid var(--text-secondary);
    border-radius: 12px;
    padding: 8px 12px;
    gap: 8px;
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.header-search-bar:focus-within {
    border-color: var(--primary-color);
}

.header-search-bar .search-icon {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    margin-right: 8px;
    flex-shrink: 0;
}

.header-search-bar input {
    flex: 1;
    min-width: 60px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
}

.header-search-bar input::placeholder {
    color: var(--text-secondary);
}

.header-search-bar .search-clear {
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    margin-left: 4px;
    flex-shrink: 0;
}

.header-search-bar .search-clear svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.header-search-bar .search-clear:active {
    background: var(--hover-bg);
}


/* Adjust content area when search header is visible */
.view-container:has(.search-top-header:not(.hidden)) .content-area {
    padding-top: 0px;
}

/* Bottom Toolbar */
.bottom-toolbar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--content-bg);
    border-top: 1px solid var(--border-color);
    padding: 4px 0 4px;
    flex-shrink: 0;
    transition: background 0.3s ease, border-color 0.3s ease;
}

/* Top Toolbar (Sticky) */
.top-toolbar {
    position: sticky;
    top: 0;
    z-index: 100;
    border-top: none;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Logo button in toolbar */
.toolbar-logo-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.toolbar-logo-btn:active {
    transform: scale(0.9);
}

/* Sidebar */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.sidebar-menu {
    position: fixed;
    top: var(--safe-zone-top, 0px);
    left: 0;
    width: 260px;
    height: calc(100% - var(--safe-zone-top, 0px) - var(--safe-zone-bottom, 0px));
    background: var(--content-bg);
    z-index: 9999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

.sidebar-menu.open {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 12px 0;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 24px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    transition: background 0.2s ease;
    text-align: left;
}

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

.sidebar-item svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    color: var(--text-secondary);
}

.sidebar-item.active {
    color: rgb(243, 24, 122);
}

.sidebar-item.active svg {
    color: rgb(243, 24, 122);
}

.toolbar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 16px;
    transition: all 0.2s ease;
    flex: 1;
}

.toolbar-btn:hover {
    color: rgb(243, 24, 122);
}

.toolbar-btn.active {
    color: rgb(243, 24, 122);
}

.toolbar-btn .icon {
    width: 22px;
    height: 22px;
    stroke-width: 2;
}

.toolbar-btn span {
    font-size: 11px;
    font-weight: 500;
}

/* View Toggle Controls */
.view-toggle {
    display: flex;
    gap: 12px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 8px;
    border-radius: 12px;
}

.toggle-btn {
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid transparent;
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.toggle-btn.active {
    background: #ffffff;
    color: #667eea;
    border-color: #ffffff;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    body {
        flex-direction: column;
        gap: 20px;
    }
    
    .height-controls {
        flex-direction: row;
        margin-top: 0;
        width: 100%;
        justify-content: center;
    }
    
    .height-controls h3 {
        display: none;
    }
}

@media (max-width: 480px) {
    .view-toggle {
        flex-direction: column;
        width: 100%;
    }
    
    .toggle-btn {
        width: 100%;
    }
    
    .height-controls {
        flex-wrap: wrap;
    }
    
    .height-btn {
        flex: 1;
        min-width: 60px;
    }
}

/* Scrollbar styling */
.content-area::-webkit-scrollbar {
    width: 6px;
}

.content-area::-webkit-scrollbar-track {
    background: transparent;
}

.content-area::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.content-area::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}


/* Video Grid Container */
.video-grid-container {
    width: 100%;
    height: auto;
    overflow: visible;
    background: var(--content-bg);
    position: relative;
    transition: background 0.3s ease;
}

.video-grid-container.horizontal-scroll {
    overflow-y: hidden;
    overflow-x: auto;
}

.video-grid-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.video-grid-container::-webkit-scrollbar-track {
    background: var(--card-bg);
}

.video-grid-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.video-grid-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Video Grid - Masonry Layout (Vertical) */
.video-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: 2px;
    /* Each column is ~1/3 viewport width; row height matches so squares are 1:1 */
    grid-auto-rows: calc((100vw - 8px) / 3);
    grid-auto-flow: dense;
}

.video-grid-container.horizontal-scroll .video-grid {
    display: grid;
    grid-template-rows: repeat(2, 1fr);
    grid-auto-flow: column;
    gap: 8px;
    padding: 16px;
    width: max-content;
    height: calc(100% - 32px);
}

/* Video Item */
.video-item {
    position: relative;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.video-item:hover {
    transform: scale(1.02);
}

/* Skeleton Loader for Video Items */
.video-item-skeleton {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        #e0e0e0 0%,
        #f0f0f0 50%,
        #e0e0e0 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    z-index: 1;
}

/* Dark mode skeleton */
@media (prefers-color-scheme: dark) {
    .video-item-skeleton {
        background: linear-gradient(
            90deg,
            #2a2a2a 0%,
            #3a3a3a 50%,
            #2a2a2a 100%
        );
    }
}

[data-theme="dark"] .video-item-skeleton {
    background: linear-gradient(
        90deg,
        #2a2a2a 0%,
        #3a3a3a 50%,
        #2a2a2a 100%
    );
}

@keyframes skeleton-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.video-item-skeleton.loaded {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Masonry 3-col pattern: Block A (1-5): LEFT tall, CENTER 2sq, RIGHT 2sq
   Block B (6-10): LEFT 2sq, CENTER 2sq, RIGHT tall — repeating every 10 */

/* Block A: item 1 — LEFT TALL */
.video-grid-container.vertical-scroll .video-item:nth-child(10n+1) {
    grid-column: 1;
    grid-row: span 2;
}
/* Block A: items 2,3 — CENTER top & bottom square */
.video-grid-container.vertical-scroll .video-item:nth-child(10n+2) {
    grid-column: 2;
    grid-row: span 1;
}
.video-grid-container.vertical-scroll .video-item:nth-child(10n+3) {
    grid-column: 2;
    grid-row: span 1;
}
/* Block A: items 4,5 — RIGHT top & bottom square */
.video-grid-container.vertical-scroll .video-item:nth-child(10n+4) {
    grid-column: 3;
    grid-row: span 1;
}
.video-grid-container.vertical-scroll .video-item:nth-child(10n+5) {
    grid-column: 3;
    grid-row: span 1;
}
/* Block B: items 6,7 — LEFT top & bottom square */
.video-grid-container.vertical-scroll .video-item:nth-child(10n+6) {
    grid-column: 1;
    grid-row: span 1;
}
.video-grid-container.vertical-scroll .video-item:nth-child(10n+7) {
    grid-column: 1;
    grid-row: span 1;
}
/* Block B: items 8,9 — CENTER top & bottom square */
.video-grid-container.vertical-scroll .video-item:nth-child(10n+8) {
    grid-column: 2;
    grid-row: span 1;
}
.video-grid-container.vertical-scroll .video-item:nth-child(10n+9) {
    grid-column: 2;
    grid-row: span 1;
}
/* Block B: item 10 — RIGHT TALL */
.video-grid-container.vertical-scroll .video-item:nth-child(10n+0) {
    grid-column: 3;
    grid-row: span 2;
}

/* Horizontal scroll items - 2 rows */
.video-grid-container.horizontal-scroll .video-item {
    width: 180px;
    height: 100%;
}

.video-grid-container.horizontal-scroll .video-item:nth-child(4n+1),
.video-grid-container.horizontal-scroll .video-item:nth-child(4n+2) {
    grid-column: span 1;
}

.video-grid-container.horizontal-scroll .video-item:nth-child(6n+3) {
    grid-column: span 2;
    grid-row: span 2;
}

/* Video Blur Background */
.video-blur-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(14px);
    transform: scale(1.1);
    opacity: 0;
    z-index: 1;
    transition: opacity 0.3s ease;
}

.video-blur-bg.loaded {
    opacity: 1;
}

/* Video Thumbnail — default: 80% cell height, proportional width, centered (landscape overflow clipped) */
.video-thumbnail {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: auto;
    transform: translate(-50%, -50%);
    display: block;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
}

.video-thumbnail.loaded {
    opacity: 1;
}

/* Tall cells (portrait): fill height, center vertically, clip overflow */
.video-grid-container.vertical-scroll .video-item:nth-child(10n+1) .video-thumbnail {
    inset: unset;
    width: auto;
    height: 80%;
    min-height: unset;
    max-height: unset;
    object-fit: unset;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.video-grid-container.vertical-scroll .video-item:nth-child(10n+0) .video-thumbnail {
    inset: unset;
    width: auto;
    height: 80%;
    min-height: unset;
    max-height: unset;
    object-fit: unset;
    top: 50%;
    left: -50%;
    transform: translateY(-50%);
}

/* Vertical/portrait thumbnails in tall cells: full height, no offset */
.video-grid-container.vertical-scroll .video-item.vertical-thumb:nth-child(10n+1) .video-thumbnail,
.video-grid-container.vertical-scroll .video-item.vertical-thumb:nth-child(10n+0) .video-thumbnail {
    height: 100%;
    left: 0%;
    transform: translateY(-50%);
}

/* Video Description Ribbon */
.video-description-ribbon {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 10px 10px 10px;
    background: rgba(0, 0, 0, 0.55); /* 55% opacity (15% more transparent) */
    color: #ffffff;
    font-size: 12px;
    line-height: 1.4;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    word-wrap: break-word;
    word-break: break-word;
    box-sizing: border-box;
    z-index: 3;
    
    /* Limit to 2 lines with ellipsis */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    
    /* Dynamic height - only as tall as needed, max 2 lines */
    max-height: calc((1.4em * 2) + 18px); /* Max 2 lines + padding */
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.loading-spinner.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Video Skeleton Loader */
.video-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Sound Toggle */
.sound-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    position: relative;
}

.sound-toggle input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    width: 50px;
    height: 26px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 13px;
    position: relative;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    top: 3px;
    left: 3px;
    transition: transform 0.3s;
}

.sound-toggle input:checked + .toggle-slider {
    background: #667eea;
}

.sound-toggle input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

.toggle-label {
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
}

/* Video Player Modal */
.video-modal {
    position: fixed;
    top: var(--safe-zone-top, 0px);
    left: 0;
    width: 100%;
    height: calc(var(--vh, 100vh) - var(--safe-zone-top, 0px) - var(--safe-zone-bottom, 0px)) !important;
    background: #000000;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    transform-origin: 0 0;
    will-change: transform, border-radius;
    overscroll-behavior: contain;
    touch-action: pan-y pinch-zoom;
    overflow: hidden !important;
}

.video-modal.modal-zoom-transitioning {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                border-radius 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.video-modal.modal-zoom-transitioning * {
    pointer-events: none !important;
}

.video-modal.hidden {
    display: none;
}


.modal-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 10001;
    pointer-events: none;
}

.modal-back-btn {
    position: fixed;
    top: 8px;
    left: 10px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999999;
    pointer-events: auto;
    backdrop-filter: blur(10px);
}

.modal-back-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.modal-back-btn svg {
    width: 24px;
    height: 24px;
    color: #ffffff;
}

.modal-sound-btn {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10002;
    pointer-events: auto;
    backdrop-filter: blur(10px);
}

/* Sound btn and action buttons inside video container */
.video-container-relevant .modal-sound-btn {
    position: absolute;
    top: 8px;
    right: 10px;
}

.video-container-relevant .modal-action-buttons {
    position: absolute;
    top: 56px;
    right: 10px;
}

.modal-sound-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.modal-sound-btn .sound-icon {
    width: 24px;
    height: 24px;
    color: #ffffff;
}

/* Modal Action Buttons (Heart, Edit, Info) */
.modal-action-buttons {
    position: absolute;
    top: 56px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 10002;
    pointer-events: auto;
}

/* When inside video container, buttons scroll with video */
.video-container-relevant {
    position: relative;
}

.modal-action-btn {
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.modal-action-btn:active {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(0.95);
}

.modal-action-btn svg {
    width: 22px;
    height: 22px;
    color: #ffffff;
}

/* More button - no background */
#modal-more-btn {
    background: transparent;
    backdrop-filter: none;
}

#modal-more-btn:active {
    background: rgba(0, 0, 0, 0.3);
}

/* Like button - Instagram style */
#modal-like-btn .like-icon {
    transition: all 0.3s ease;
}

#modal-like-btn.liked .like-icon {
    fill: #ff3b5c;
    stroke: #ff3b5c;
    animation: likeAnimation 0.4s ease;
}

@keyframes likeAnimation {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
    }
}

/* Player Views - Base Styles */
.player-view-static,
.player-view-static-relevant,
.player-view-reel {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background: #000000;
}

.player-view-static.hidden,
.player-view-static-relevant.hidden,
.player-view-reel.hidden {
    display: none;
}

/* Static View */
.player-view-static {
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Blurred background video */
.video-background {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: 1;
    filter: blur(40px) brightness(0.4);
    object-fit: cover;
}

/* Content wrapper - centered */
.static-content-wrapper {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 8px 20px 20px 20px;
    gap: 20px;
}

.video-container {
    width: 100%;
    max-width: 500px;
    background: #000;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

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

/* Sound icon overlay on video */
.video-sound-overlay {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10000;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.video-sound-overlay:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.sound-icon {
    width: 28px;
    height: 28px;
    color: #ffffff;
    transition: opacity 0.3s ease;
}

.sound-icon.hidden {
    display: none;
}

/* Center send button and ad banner */
.static-content-wrapper .send-btn {
    width: 100%;
    max-width: 500px;
    padding: 16px;
    background: #667eea;
    color: #ffffff;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.static-content-wrapper .send-btn:hover {
    background: #5568d3;
}

.static-content-wrapper .ad-banner {
    width: 100%;
    max-width: 500px;
    padding: 40px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Static + Relevant View */
.player-view-static-relevant {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.static-relevant-scroll-container {
    width: 100%;
    height: 100vh !important;
    height: var(--vh) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    position: relative;
    z-index: 2;
}

.static-relevant-content {
    display: flex !important;
    flex-direction: column !important;
    width: 100%;
    grid-template-columns: none !important;
    align-items: center;
    padding-top: 8px;
    padding-left: 5px;
    padding-right: 5px;
}

.static-relevant-content > * {
    width: 100% !important;
    grid-column: auto !important;
}

.video-send-sticky-wrapper {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.video-container-relevant {
    width: 100%;
    flex-shrink: 0;
    background: #000;
    position: relative;
    min-height: 200px;
    display: block !important;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    margin-bottom: 0;
}

.video-container-relevant video {
    width: 100%;
    height: auto;
    display: block;
    position: relative;
    z-index: 2;
    border-radius: 8px;
}

/* Ad overlay for vertical videos */
.ad-banner-overlay {
    display: none;
}

.video-container-relevant.has-vertical-video .ad-banner-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    height: 60px;
    padding: 0 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 10;
    backdrop-filter: blur(10px);
}

.ad-banner-overlay span {
    flex: 1;
}

.ad-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
}

.ad-close-btn:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: scale(1.1);
}

.ad-close-btn svg {
    width: 16px;
    height: 16px;
    color: #ffffff;
}

/* Horizontal video - center vertically with auto margins */
.video-container-relevant video.horizontal {
    margin: auto;
}

/* Vertical video - position at top */
.video-container-relevant video.vertical {
    margin: 0;
}

/* Video action buttons container */
.video-action-buttons {
    display: flex;
    gap: 8px;
    width: 100%;
    flex-shrink: 0;
    margin: 0;
}

.copy-btn,
.share-btn,
.send-btn {
    flex: 1;
    padding: 14px 12px;
    color: #ffffff;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 8px;
}

.copy-btn {
    background: #3b82f6;
}

.copy-btn:hover {
    background: #2563eb;
}

.copy-btn:disabled {
    background: #93c5fd;
    cursor: not-allowed;
}

.share-btn {
    background: #10b981;
}

.share-btn:hover {
    background: #059669;
}

.share-btn:disabled {
    background: #6ee7b7;
    cursor: not-allowed;
}

.send-btn {
    background: #28a745;
}

.send-btn:hover {
    background: #218838;
}

.send-btn:disabled {
    background: #a5b4fc;
    cursor: not-allowed;
}

.copy-btn svg,
.share-btn svg,
.send-btn svg {
    flex-shrink: 0;
}

.ad-banner {
    width: 100%;
    padding: 40px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
    display: block !important;
}

/* Dark overlay for edit mode */
.edit-mode-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000000;
    z-index: 50000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 150px;
    pointer-events: all;
}

.edit-mode-overlay.active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: all !important;
}

/* Hide ALL modal content when in edit mode - only show the edit overlay */
.video-modal.editing-mode .modal-header,
.video-modal.editing-mode .modal-action-buttons,
.video-modal.editing-mode .player-view-static-relevant .static-relevant-scroll-container {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.2s ease;
}

/* Edit overlay main container */
.edit-overlay-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: calc(100% - 20px);
    max-width: 500px;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 50001;
}

/* Edit overlay header */
.edit-overlay-header {
    font-size: 20px;
    font-weight: 600;
    color: #ffffff;
    text-align: center;
    margin: 0;
    padding: 0;
}

/* Edit overlay content container */
.edit-overlay-content {
    display: flex !important;
    align-items: stretch;
    gap: 8px;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative;
}

/* Edit overlay text box */
.edit-overlay-textbox {
    flex: 1;
    padding: 16px 20px;
    background: #ffffff;
    color: #1a1a1a;
    font-size: 18px;
    line-height: 1.5;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    text-align: center;
    min-height: 50px;
    outline: none;
    border: 2px solid #e0e0e0;
    cursor: text;
    visibility: visible !important;
    opacity: 1 !important;
}

.edit-overlay-textbox:focus {
    outline: none;
    border-color: #c0c0c0;
}

/* Dark mode text box */
.dark-mode .edit-overlay-textbox {
    background: #2a2a2a;
    color: #ffffff;
}

/* Edit overlay save button */
.edit-overlay-save-btn {
    width: 56px;
    height: 56px;
    background: #3a3a3a;
    border: none;
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    align-self: center;
    visibility: visible !important;
    opacity: 1 !important;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.edit-overlay-save-btn svg {
    width: 28px;
    height: 28px;
    stroke: #ffffff;
    fill: none;
    stroke-width: 2;
}

.edit-overlay-save-btn:hover {
    background: #4a4a4a;
    transform: scale(1.05);
}

.edit-overlay-save-btn:active {
    transform: scale(0.95);
}

/* Edit overlay checkbox */
.edit-overlay-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    padding: 0 4px;
}

.edit-overlay-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #7C3AED;
    flex-shrink: 0;
}

.edit-overlay-checkbox input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.edit-overlay-checkbox span {
    opacity: 0.8;
}

/* Video Description Container with Edit Button */
.video-description-container {
    position: relative;
    width: 100%;
    display: flex;
    align-items: stretch;
    gap: 8px;
    padding-right: 5px;
    min-height: 40px; /* Reserve space to prevent layout shift */
}

.video-description-container.active {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

/* Description loader animation */
.description-loader {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
}

.loader-dot {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    animation: dotPulse 1.2s ease-in-out infinite;
}

.loader-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loader-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Edit mode - elevated container */
.video-description-container.editing {
    position: fixed;
    top: 150px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 20px);
    max-width: 500px;
    z-index: 30000;
    padding-right: 5px;
}

/* Video Description Display in Modal */
.video-description-display {
    flex: 1;
    padding: 16px 20px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 18px;
    line-height: 1.5;
    border-radius: 12px;
    margin-top: 0px;
    margin-bottom: 0px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
    display: block;
    min-height: 50px;
}

.video-description-display[contenteditable="true"] {
    outline: 2px solid #667eea;
    background: var(--card-bg);
    cursor: text;
    position: relative;
    z-index: 30001;
}

/* Description Edit/Save Button */
.description-edit-btn {
    align-self: center;
    position: relative;
    z-index: 30002;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.description-edit-btn .save-icon {
    stroke: #10b981;
}

.description-edit-btn:hover .save-icon {
    stroke: #ffffff;
}

.description-edit-btn .hidden {
    display: none !important;
}

/* Spacing for Static + Relevant view */
.static-relevant-content .video-send-sticky-wrapper {
    margin-bottom: 20px;
}

.video-send-sticky-wrapper .send-btn {
    width: 100%;
    padding: 16px;
    background: #667eea;
    color: #ffffff;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.video-send-sticky-wrapper .send-btn:hover {
    background: #5568d3;
}

.mid-banner {
    width: 100%;
    height: 600px;
    min-height: 600px !important;
    max-height: 600px !important;
    flex: 0 0 600px !important;
    margin: 12px auto;
    position: relative;
    overflow: visible;
}

.sticky-banner {
    position: sticky;
    top: 0;
    width: 300px !important;
    min-width: 300px !important;
    height: 250px;
    margin: 0 auto;
    z-index: 10;
    text-align: center;
    display: block !important;
}

.ad-scroll-container {
    width: 300px !important;
    min-width: 300px !important;
    height: 250px;
    margin: 0 auto;
    text-align: center;
    display: block !important;
}

.ad-scroll-container .adsbygoogle {
    display: inline-block !important;
    width: 300px !important;
    min-width: 300px !important;
    height: 250px !important;
}

/* Video Content Context for AdSense targeting */
.video-content-context {
    padding: 8px 16px;
    color: #999;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
}

.video-content-context .video-title-seo {
    font-size: 13px;
    font-weight: 600;
    color: #ccc;
    margin-bottom: 4px;
}

.video-content-context .video-description-seo {
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
}

.video-content-context .video-mood-label {
    font-size: 11px;
    color: #7c3aed;
    font-weight: 500;
}

/* Modal top ad - shorter height */
.modal-top-ad-break {
    height: 350px !important;
    min-height: 350px !important;
    max-height: 350px !important;
    flex: 0 0 350px !important;
}

/* Related Ad Break - banner between grid segments */
.related-ad-break {
    height: 450px !important;
    min-height: 450px !important;
    max-height: 450px !important;
    flex: 0 0 450px !important;
}

.related-ad-break .ad-context-label {
    font-size: 11px;
    color: #666;
    text-align: center;
    padding: 8px 12px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Relevant Videos Section */
.relevant-videos-section {
    padding: 0;
    background: #000000;
    width: 100%;
}

.relevant-videos-section h3 {
    color: #ffffff;
    font-size: 18px;
    padding: 20px;
    margin: 0;
    font-weight: 600;
    background: #1a1a1a;
}

.relevant-videos-grid {
    width: 100%;
}

.relevant-videos-container,
.search-results .video-grid-container {
    height: auto;
    overflow: visible;
}

/* Reel View */
.player-view-reel {
    padding: 0;
    max-width: 100%;
    overflow: hidden;
}

.reel-container {
    width: 100%;
    height: 100%;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
}

.reel-item {
    width: 100%;
    height: 100%;
    position: relative;
    scroll-snap-align: start;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: hidden;
}

.reel-video {
    width: auto;
    height: 100%;
    max-width: none;
    object-fit: cover;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.reel-video.vertical {
    object-fit: cover;
    width: 100%;
    height: 100%;
}

.reel-video.horizontal {
    object-fit: cover;
    width: auto;
    height: 100%;
}

.reel-send-btn {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: rgba(102, 126, 234, 0.9);
    border: none;
    border-radius: 50%;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    z-index: 10;
}

.reel-send-btn:hover {
    background: rgba(102, 126, 234, 1);
    transform: translateY(-50%) scale(1.1);
}

.reel-ad-banner {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 500px;
    padding: 25px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reel-ad-banner.hidden {
    display: none;
}

.reel-ad-close {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
}

.reel-ad-close:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.reel-ad-close svg {
    width: 14px;
    height: 14px;
    color: #ffffff;
}

/* ==================================================================
   Send Instruction Modal
   Shown after the user taps Send and the pending video is staged
   on the bot. Points the user to Viber's header ↑ arrow which
   actually delivers the video into the chat.
   ================================================================== */
.send-instruction-modal {
    position: fixed;
    inset: 0;
    background: rgba(8, 8, 16, 0.88);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    z-index: 99999;
    color: #FFFFFF;
    animation: send-instruction-fade 0.25s ease-out;
}

.send-instruction-modal.hidden {
    display: none;
}

/* Finger anchored at the very top-right edge, pointing up at Viber's header arrow
   which lives directly above this point (in Viber's chrome, outside the webview).
   The emoji is mirrored horizontally (scaleX(-1)) so it reads as a LEFT hand —
   Unicode 👆 has no separate left-hand variant; rendering varies, so we flip it
   ourselves. The mirror is baked into every keyframe so the animation preserves it. */
.send-instruction-finger {
    position: absolute;
    top: 22px;
    right: 2px;
    font-size: 96px;
    line-height: 1;
    user-select: none;
    text-shadow:
        0 0 24px rgba(167, 139, 250, 0.45),
        0 6px 14px rgba(0, 0, 0, 0.55);
    transform-origin: center;
    animation: send-instruction-tap 1.4s ease-in-out infinite;
}

/* Centered instruction block — sits in the middle of the viewport, well below
   the finger so the eye sweeps from the finger (top-right) down to the text. */
.send-instruction-body {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    padding: 0 28px;
    text-align: center;
}

.send-instruction-text {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.45;
    max-width: 360px;
    margin: 0 auto 22px auto;
    letter-spacing: -0.3px;
}

/* Inline SVG of Viber's purple circle-arrow icon, sized to match the surrounding
   text so it reads naturally as a word. */
.send-instruction-inline-icon {
    display: inline-block;
    width: 1.4em;
    height: 1.4em;
    vertical-align: -0.35em;
    margin: 0 2px;
}

.send-instruction-inline-icon svg,
.send-instruction-inline-icon img {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 0 6px rgba(167, 139, 250, 0.5));
}

.send-instruction-subtext {
    font-size: 17px;
    font-weight: 400;
    line-height: 1.5;
    opacity: 0.85;
    margin: 0 auto 32px auto;
    max-width: 340px;
}

.send-instruction-subtext strong {
    font-weight: 700;
    color: #FFFFFF;
}

.send-instruction-cancel {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: rgba(255, 255, 255, 0.85);
    padding: 12px 22px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.send-instruction-cancel:hover,
.send-instruction-cancel:active {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.6);
}

/* Finger taps upward toward Viber's arrow above. Small overshoot at the top
   to suggest impact. scaleX(-1) is baked in so the emoji stays mirrored
   (left-hand) throughout the animation. */
@keyframes send-instruction-tap {
    0%, 100% { transform: scaleX(-1) translateY(6px); }
    40%      { transform: scaleX(-1) translateY(-14px); }
    50%      { transform: scaleX(-1) translateY(-18px); }
    60%      { transform: scaleX(-1) translateY(-14px); }
}

@keyframes send-instruction-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ========== SEARCH INTERFACE ========== */
.search-container {
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: visible;
}

.search-header {
    flex-shrink: 0;
    margin-bottom: 20px;
}

.search-header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.search-bar {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    transition: border-color 0.2s ease;
}

.search-bar:focus-within {
    border-color: #8B5CF6;
}

.search-icon {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    margin-right: 12px;
    flex-shrink: 0;
}

.search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    color: var(--text-primary);
    outline: none;
}

.search-bar input::placeholder {
    color: var(--text-secondary);
}

.search-clear {
    width: 24px;
    height: 24px;
    padding: 4px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.search-clear svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.search-clear:hover {
    background: var(--card-bg);
}

.search-results-container {
    flex: 1;
    overflow: visible;
}

.search-empty-state,
.search-loading,
.search-no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    min-height: 300px;
}

.search-empty-state.hidden,
.search-loading.hidden,
.search-no-results.hidden,
.search-results.hidden {
    display: none !important;
}

.search-empty-state svg,
.search-no-results svg {
    width: 80px;
    height: 80px;
    color: var(--text-secondary);
    opacity: 0.5;
    margin-bottom: 20px;
}

.search-loading svg {
    width: 40px;
    height: 40px;
    margin-bottom: 16px;
}

.search-empty-state p,
.search-no-results p {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.search-no-results span {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Search Loading Overlay (over content area, below search header) */
.search-loading-overlay {
    position: fixed;
    top: calc(56px + var(--safe-zone-top, 0px));
    left: 0;
    right: 0;
    bottom: var(--safe-zone-bottom, 0px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10, 25, 80, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999;
    padding: 40px 20px;
    gap: 12px;
    opacity: 1;
    transition: opacity 0.2s ease;
    pointer-events: auto;
}

.search-loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.search-loading-overlay .spinner {
    width: 32px;
    height: 32px;
}

.search-loading-overlay p {
    font-size: 20px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
}

[data-theme="dark"] .search-loading-overlay {
    background: rgba(10, 25, 80, 0.8);
}

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

.search-results {
    padding-bottom: 20px;
    overflow: visible;
}


/* Mobile optimization */
@media (max-width: 768px) {
    .search-container {
        padding: 0px;
    }
    
    .search-header h1 {
        font-size: 28px;
        margin-bottom: 12px;
    }
}

/* ========== UI DEBUG PAGE ========== */
.ui-debug-page {
    padding: 16px;
    color: var(--text-primary);
}

.ui-debug-page h1 {
    font-size: 18px;
    margin: 0 0 16px;
    font-weight: 700;
}

.ui-debug-page h3 {
    font-size: 14px;
    margin: 20px 0 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.ui-debug-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0 0 10px;
}

/* Metrics table */
.ui-debug-metrics {
    background: var(--card-bg, #1a1a2e);
    border-radius: 10px;
    padding: 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.metric-row:last-child {
    border-bottom: none;
}

.metric-label {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.metric-value {
    color: #4fc3f7;
    font-weight: 600;
    text-align: right;
}

/* Ruler */
.ui-debug-ruler-section {
    margin-top: 20px;
}

.ui-debug-ruler-container {
    position: relative;
    width: 60px;
    background: linear-gradient(to bottom, #1a237e, #311b92);
    border-radius: 6px;
    overflow: hidden;
    margin: 0 auto;
}

.ui-debug-ruler {
    position: relative;
    width: 100%;
}

.ui-debug-ruler-tick {
    position: absolute;
    left: 0;
    width: 100%;
    height: 1px;
    display: flex;
    align-items: center;
}

.ui-debug-ruler-tick::before {
    content: '';
    display: block;
    height: 1px;
    background: rgba(255,255,255,0.4);
}

.ui-debug-ruler-tick.major::before {
    width: 100%;
    background: rgba(255,255,255,0.8);
}

.ui-debug-ruler-tick.minor::before {
    width: 50%;
    background: rgba(255,255,255,0.3);
}

.ui-debug-ruler-tick-label {
    position: absolute;
    right: -40px;
    font-size: 9px;
    color: rgba(255,255,255,0.7);
    white-space: nowrap;
}

.ui-debug-ruler-marker {
    position: absolute;
    left: 0;
    width: 100%;
    height: 3px;
    background: #ff5252;
    cursor: grab;
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    z-index: 2;
}

.ui-debug-ruler-marker span {
    position: absolute;
    right: -70px;
    font-size: 11px;
    color: #ff5252;
    font-weight: 700;
    white-space: nowrap;
}

/* Touch measurement */
.ui-debug-touch-section {
    margin-top: 24px;
}

.ui-debug-btn {
    display: inline-block;
    padding: 10px 20px;
    background: #7C3AED;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.ui-debug-btn.active {
    background: #ff5252;
}

.ui-debug-measure-result {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    min-height: 20px;
}

.ui-debug-measure-dot {
    position: fixed;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ff5252;
    border: 2px solid #fff;
    transform: translate(-50%, -50%);
    z-index: 9999;
    pointer-events: none;
}

.ui-debug-measure-line {
    position: fixed;
    z-index: 9998;
    pointer-events: none;
    border-top: 2px dashed #ff5252;
    transform-origin: left center;
}

/* ===== Profile Page ===== */
.profile-page {
    padding: 24px 16px;
}

.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 32px;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--border-color, #e0e0e0);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.profile-avatar svg {
    color: var(--text-secondary, #666);
}

.profile-username {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #000);
    margin: 0;
}

.profile-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border: none;
    background: var(--content-bg, #fff);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
    text-align: left;
    font-size: 16px;
    color: var(--text-primary, #000);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.profile-menu-item:hover {
    background: var(--hover-bg, #f5f5f5);
}

.profile-menu-item:active {
    background: var(--active-bg, #ebebeb);
}

.profile-menu-item span {
    flex: 1;
    font-weight: 500;
}

.profile-menu-arrow {
    color: var(--text-secondary, #999);
}

/* ===== History / Favorites 2-Column Masonry Grid ===== */
.user-video-grid {
    column-count: 2;
    column-gap: 2px;
    padding: 2px;
}

.user-video-grid .user-video-card {
    break-inside: avoid;
    margin-bottom: 2px;
    margin-top: 0;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    background: #000;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.user-video-grid .user-video-card:hover {
    transform: scale(1.02);
}

.user-video-grid .user-video-card img {
    display: block;
    width: 100%;
    height: auto;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.user-video-grid .user-video-card img.loaded {
    opacity: 1;
}

.user-video-grid .user-video-card .card-skeleton {
    width: 100%;
    padding-bottom: 100%;
    background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

[data-theme="dark"] .user-video-grid .user-video-card .card-skeleton {
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
}

@media (prefers-color-scheme: dark) {
    .user-video-grid .user-video-card .card-skeleton {
        background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
        background-size: 200% 100%;
    }
}

.user-video-grid .user-video-card .card-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px 6px 6px;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 3;
}

/* ===== Subpage Header (History / Favorites) ===== */
.subpage-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    position: sticky;
    top: 0;
    background: var(--content-bg, #fff);
    z-index: 10;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.subpage-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #000);
}

.subpage-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-primary, #000);
    transition: background 0.2s;
}

.subpage-back-btn:hover {
    background: var(--hover-bg, #f0f0f0);
}

/* ===== Pull-to-Refresh Indicator ===== */
.pull-to-refresh-indicator {
    height: 0;
    opacity: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--text-secondary, #999);
    transition: height 0.2s ease, opacity 0.2s ease;
}

/* ===== Empty State ===== */
.empty-state.hidden {
    display: none;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-secondary, #666);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary, #000);
}

.empty-state span {
    font-size: 14px;
    color: var(--text-secondary, #999);
}
