:root {
    --bg-color: #0d0d0d;
    --card-bg: rgba(255, 255, 255, 0.05);
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent-color: #ff0055;
    /* VHS Retro Red/Pink */
    --accent-glow: rgba(255, 0, 85, 0.4);
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Header */
header {
    padding: 2rem 1.5rem;
    text-align: center;
    background: radial-gradient(circle at top, rgba(20, 20, 30, 1) 0%, var(--bg-color) 100%);
}

h1 {
    font-weight: 800;
    font-size: 2rem;
    letter-spacing: -0.05em;
    background: linear-gradient(135deg, #fff 0%, #a0a0a0 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

h1 span {
    color: var(--accent-color);
    -webkit-text-fill-color: var(--accent-color);
}

p.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Grid Layout */
main {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.tape-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1.5rem;
    padding-bottom: 4rem;
}

/* Tape Card */
.tape-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: block;
}

@media (hover: hover) {

    .tape-card:hover,
    .tape-card:focus {
        transform: translateY(-5px);
        box-shadow: 0 10px 30px -10px var(--accent-glow);
        border-color: rgba(255, 255, 255, 0.2);
    }

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

    .tape-card:hover .play-icon {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.tape-card:active {
    transform: scale(0.98);
}

.thumbnail-container {
    aspect-ratio: 16/9;
    background: #222;
    position: relative;
    overflow: hidden;
}

.thumbnail-container .slideshow-inner {
    width: 100%;
    height: 100%;
    position: relative;
}

.thumbnail-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease, opacity 1s ease-in-out;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
}

.thumbnail-container img.active {
    opacity: 1;
}

/* Hover effects moved to media query above */

.play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    backdrop-filter: blur(4px);
}

.tape-info {
    padding: 1rem;
}

.tape-title {
    font-weight: 600;
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.tape-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Player View */
.player-container {
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #000;
}

.video-wrapper {
    width: 100%;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    position: sticky;
    top: 0;
    z-index: 10;
}

video {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    max-width: 100%;
    object-fit: contain;
    outline: none;
}

.playlist {
    padding: 1rem;
    background: var(--bg-color);
    overflow-y: auto;
    flex-shrink: 0;
    max-height: 40vh;
    /* Scrollable playlist on mobile */
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.playlist-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--bg-color);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 0.5rem;
    /* Add some top padding as we lost it from the container scroll */
    margin-bottom: 0.5rem;
}

.editable-title-group {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    /* margin-bottom: 1rem; Remove margin-bottom as it's handled by header */
    padding-left: 0.5rem;
    flex: 1;
    min-width: 0;
    margin-right: 2rem;
    /* Ensure gap to the close button */
}

.playlist h2 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.3;
}

.fav-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    font-size: 1.4rem;
    padding: 2px 8px;
    margin-left: 0.5rem;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
}

.fav-btn.active {
    color: #ff3b3b;
    transform: scale(1.1);
    filter: drop-shadow(0 0 5px rgba(255, 59, 59, 0.4));
}

.fav-btn.active .heart-icon {
    fill: #ff3b3b;
    stroke: none;
}

@media (hover: hover) {
    .fav-btn:hover {
        color: #ff3b3b;
        transform: scale(1.2);
    }
    .fav-btn:hover .heart-icon {
        fill: #ff3b3b;
        stroke: none;
    }
}

.fav-btn-small {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.15);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fav-btn-small.active {
    color: #ff3b3b;
    opacity: 1 !important;
}

.fav-btn-small.active .heart-icon {
    fill: #ff3b3b;
    stroke: none;
    transform: scale(1.1);
    filter: drop-shadow(0 0 5px rgba(255, 59, 59, 0.4));
}

@media (hover: hover) {
    .fav-btn-small:hover {
        color: #ff3b3b;
    }
    .fav-btn-small:hover .heart-icon {
        fill: rgba(255, 59, 59, 0.3);
        stroke: #ff3b3b;
    }
}

/* Heart Icon general styles */
.heart-icon {
    width: 1.1em;
    height: 1.1em;
    vertical-align: middle;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

.title-heart {
    width: 1.4rem;
    height: 1.4rem;
    margin-left: 0.5rem;
    fill: #ff3b3b;
    stroke: none;
    filter: drop-shadow(0 0 8px rgba(255, 0, 85, 0.3));
}

.edit-btn {
    display: none;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.2s;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    margin-top: 2px;
}

body.edit-mode .edit-btn {
    display: inline-flex;
}

.edit-btn:hover {
    color: var(--accent-color);
    background: rgba(255, 255, 255, 0.1);
}

.edit-btn-small {
    display: none;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

body.edit-mode .edit-btn-small {
    display: inline-flex;
    opacity: 1;
}

.edit-btn-small:hover {
    color: var(--accent-color);
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

.tape-description-container {
    padding: 0.5rem 1rem 1rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1rem;
}

.tape-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: pre-wrap;
}

.tape-card-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.playlist-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 0.5rem;
    border: 1px solid transparent;
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
    .playlist-item:hover {
        background: rgba(255, 255, 255, 0.05);
    }

    .playlist-item:hover .item-thumbs img {
        opacity: 1;
    }
}

.playlist-item:active {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(0.98);
}

.playlist-item.active {
    background: rgba(255, 0, 85, 0.15);
    border-color: var(--accent-color);
}

.playlist-item.active .item-title {
    color: var(--accent-color);
    font-weight: 700;
}

.item-number {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-right: 1rem;
    width: 20px;
}

.item-duration {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

.item-title,
.item-title-display {
    font-size: 0.95rem;
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    margin-right: 0.5rem;
}

.tape-year {
    font-weight: 700;
    color: var(--text-primary);
}

.favorite-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 0, 85, 0.9);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    z-index: 5;
    pointer-events: none;
}

.favorite-badge .heart-icon {
    width: 14px;
    height: 14px;
    fill: white;
    stroke: none;
}

.item-header {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 0.5rem;
}

.item-thumbs {
    display: flex;
    gap: 4px;
    width: 100%;
    overflow: hidden;
}

.item-thumbs img {
    height: 80px;
    aspect-ratio: 16/9;
    object-fit: cover;
    border-radius: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.playlist-item.active .item-thumbs img {
    opacity: 1;
}

/* Back Button */
.back-nav {
    padding: 1rem;
    background: var(--bg-color);
}

.back-btn {
    color: var(--text-primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    opacity: 0.8;
    transition: var(--transition);
    flex-shrink: 0;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.back-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

/* Utilities */
.hidden {
    display: none;
}

@media (max-width: 767px) {
    .desktop-only {
        display: none !important;
    }
}

@media (min-width: 768px) {
    .mobile-only {
        display: none !important;
    }
}

/* Desktop Enhancements */
@media (min-width: 768px) {
    .tape-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 2rem;
    }

    .player-container {
        flex-direction: row;
        height: 100vh;
        overflow: hidden;
    }

    .video-wrapper {
        flex: 3;
        height: 100%;
    }

    .playlist {
        flex: 1;
        max-width: 400px;
        height: 100%;
        max-height: none;
        border-top: none;
        border-left: 1px solid rgba(255, 255, 255, 0.1);
    }
}

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

.modal-content {
    background-color: #1a1a1a;
    margin: 10% auto;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 90%;
    max-width: 500px;
    border-radius: var(--radius);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-header .close {
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
}

.modal-header .close:hover {
    color: white;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.form-group .edit-input {
    width: 100%;
    display: block;
}

/* Modal Inputs & Buttons */
.edit-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, background-color 0.2s;
}

.edit-input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.1);
}

.description-edit {
    min-height: 120px;
    resize: vertical;
}

.cancel-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.cancel-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.save-btn {
    background: var(--accent-color);
    color: white;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.save-btn:hover {
    opacity: 0.9;
}

/* Overview Footer */
.overview-footer {
    padding: 3rem 1.5rem;
    display: flex;
    justify-content: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 2rem;
}

.edit-mode-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.edit-mode-toggle:hover {
    color: var(--text-primary);
}

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

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

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

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

input:checked+.toggle-slider {
    background-color: var(--accent-color);
}

input:checked+.toggle-slider:before {
    transform: translateX(16px);
}
/* Highlights Section */
.highlights-section {
    margin-bottom: 3rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.section-title {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.highlights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
}

.highlight-card {
    display: flex;
    gap: 1rem;
    text-decoration: none;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px solid transparent;
    transition: var(--transition);
}

.highlight-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 0, 85, 0.2);
    transform: translateY(-2px);
}

.highlight-thumb {
    position: relative;
    width: 80px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
}

.highlight-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.highlight-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 0, 85, 0.8);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.highlight-card:hover .highlight-play {
    opacity: 1;
}

.highlight-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.highlight-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.highlight-tape {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
