:root {
    --bg-color: #0d0d0d;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --text-color: #e0e0e0;
    --text-muted: #888888;
    --primary-color: #bb86fc;
    --primary-hover: #a370f7;
    --secondary-color: #03dac6;
    --error-color: #cf6679;
    --border-color: #333333;
    --grid-gap: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    min-height: 100vh;
}

header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

#title-search {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

#title-container {
    flex-shrink: 0;
}

#logo {
    height: 32px;
    width: auto;
    border-radius: 4px;
}

#search-container {
    display: flex;
    flex: 1;
    max-width: 500px;
    gap: 0;
}

#search-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: 6px 0 0 6px;
    background-color: var(--bg-tertiary);
    color: var(--text-color);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#search-input:focus {
    border-color: var(--primary-color);
}

#search-input::placeholder {
    color: var(--text-muted);
}

#search-button {
    padding: 10px 16px;
    background-color: var(--primary-color);
    color: #000;
    border: none;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#search-button:hover {
    background-color: var(--primary-hover);
}

#controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

#platform-selection {
    display: flex;
    gap: 16px;
}

.platform-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    transition: color 0.2s;
}

.platform-toggle:hover {
    color: var(--text-color);
}

.platform-toggle input {
    accent-color: var(--primary-color);
}

.platform-toggle input:checked + .toggle-label {
    color: var(--primary-color);
}

#global-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

#global-controls button {
    width: 32px;
    height: 32px;
    background-color: var(--bg-tertiary);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#global-controls button:hover {
    background-color: var(--primary-color);
    color: #000;
    border-color: var(--primary-color);
}

#volume-all {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
}

#volume-all input[type="range"] {
    width: 80px;
    height: 4px;
    accent-color: var(--primary-color);
}

#volume-value {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 32px;
}

#action-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

#action-controls button {
    width: 32px;
    height: 32px;
    background-color: var(--bg-tertiary);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

#action-controls button:hover {
    background-color: var(--primary-color);
    color: #000;
    border-color: var(--primary-color);
}

#view-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
}

#view-controls input {
    accent-color: var(--primary-color);
}

#view-controls span {
    transition: color 0.2s;
}

#view-controls input:checked ~ span {
    color: var(--primary-color);
}

#status-bar {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

#video-count {
    font-weight: 500;
}

/* Loading */
#loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    color: var(--text-muted);
    font-size: 14px;
}

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

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

#error-message {
    display: none;
    text-align: center;
    padding: 20px;
    color: var(--error-color);
    background: rgba(207, 102, 121, 0.1);
    border-radius: 8px;
    margin: 20px;
    font-size: 14px;
}

/* Results Grid */
#results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--grid-gap);
    padding: 20px 24px;
}

.video-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.video-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border-color: var(--primary-color);
}

.video-thumbnail {
    position: relative;
    aspect-ratio: 16/9;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.video-thumbnail iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.video-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--error-color);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s;
    z-index: 10;
}

.video-item:hover .close-btn {
    opacity: 1;
}

.close-btn:hover {
    background: var(--error-color);
}

.video-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.video-controls button {
    padding: 4px 10px;
    font-size: 11px;
    background: var(--bg-secondary);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.video-controls button:hover {
    background: var(--primary-color);
    color: #000;
    border-color: var(--primary-color);
}

.video-controls input[type="range"] {
    width: 70px;
    height: 4px;
    accent-color: var(--primary-color);
}

.video-info {
    padding: 12px;
}

.video-title {
    font-weight: 500;
    font-size: 13px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.platform-badge {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.platform-badge.youtube {
    background: #ff0000;
    color: #fff;
}

.platform-badge.x {
    background: #000;
    color: #fff;
}

/* X.com items - unified design */
.x-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.x-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border-color: var(--secondary-color);
}

.x-item .close-btn {
    opacity: 1;
}

.x-thumbnail {
    padding: 16px;
    background: var(--bg-tertiary);
}

.x-title {
    font-size: 13px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.x-link {
    display: inline-block;
    margin-top: 12px;
    color: var(--secondary-color);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
}

.x-link:hover {
    text-decoration: underline;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content, .history-modal-content {
    background-color: var(--bg-secondary);
    margin: 10% auto;
    padding: 24px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    color: var(--text-color);
    position: relative;
}

.modal-content h2 {
    color: var(--primary-color);
    margin-bottom: 16px;
    font-size: 18px;
}

.modal .close {
    position: absolute;
    top: 16px;
    right: 16px;
    color: var(--text-muted);
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.modal .close:hover {
    color: var(--error-color);
}

#share-link {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: 6px;
    word-break: break-all;
    font-size: 12px;
    margin-bottom: 12px;
}

#copy-link {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: #000;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s;
}

#copy-link:hover {
    background: var(--primary-hover);
}

#qr-code {
    margin-top: 16px;
    text-align: center;
}

#qr-code img {
    border-radius: 8px;
}

/* History Panel */
#favorites-list, #history-list {
    margin-bottom: 20px;
}

#favorites-list h3, #history-list h3 {
    font-size: 14px;
    margin-bottom: 10px;
    color: var(--text-color);
}

#favorites-items, #history-items {
    max-height: 120px;
    overflow-y: auto;
    background: var(--bg-tertiary);
    border-radius: 6px;
    padding: 4px;
}

.history-item, .favorite-item {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.history-item:hover, .favorite-item:hover {
    background: var(--bg-secondary);
}

.history-item:last-child, .favorite-item:last-child {
    border-bottom: none;
}

.remove-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.remove-btn:hover {
    background: var(--error-color);
    color: #fff;
}

/* Footer */
footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--border-color);
}

/* Simple View */
body.simple-view .video-controls,
body.simple-view .x-thumbnail {
    display: none;
}

body.simple-view .video-item,
body.simple-view .x-item {
    background: transparent;
    border: none;
    box-shadow: none;
}

body.simple-view .video-item:hover,
body.simple-view .x-item:hover {
    transform: none;
    box-shadow: none;
}

body.simple-view .video-info {
    padding: 8px 0;
}

body.simple-view .video-title {
    -webkit-line-clamp: 1;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        padding: 12px 16px;
    }

    #title-search {
        flex-wrap: wrap;
    }

    #search-container {
        order: 3;
        max-width: 100%;
        width: 100%;
    }

    #controls-row {
        flex-direction: column;
        align-items: flex-start;
    }

    #results-grid {
        grid-template-columns: 1fr;
        padding: 16px;
    }
}

@media (max-width: 480px) {
    #global-controls button {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    #action-controls button {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    #volume-all input[type="range"] {
        width: 60px;
    }
}
