* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0f172a;
    color: #f8fafc;
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

button {
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease-in-out;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 50px;
    border-bottom: 1px solid #1e293b;
    background: rgba(15, 23, 42, 0.95);
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: transparent;
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 8px;
    color: #cbd5e1;
}

.nav-toggle:hover {
    background: #1e293b;
    color: #f8fafc;
}

.nav-toggle-bar {
    width: 22px;
    height: 2px;
    background: currentColor;
    border-radius: 999px;
    display: block;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: #f8fafc;
    letter-spacing: 1px;
    cursor: pointer;
}

.navbar button {
    background: transparent;
    color: #cbd5e1;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    font-weight: 500;
}

.navbar button:hover {
    color: #f8fafc;
    background: #1e293b;
}

.navbar .primary {
    background: #3b82f6;
    color: white;
    margin-left: 10px;
}

.navbar .primary:hover {
    background: #2563eb;
}

.hero {
    text-align: center;
    margin-top: 100px;
    padding: 0 20px;
}

.hero h1 {
    font-size: 48px;
    margin-bottom: 10px;
}

.hero p {
    color: #94a3b8;
    font-size: 18px;
    margin-bottom: 30px;
}

.search-box {
    display: flex;
    justify-content: center;
    gap: 10px;
    max-width: 500px;
    margin: 0 auto;
}

.search-box input {
    flex: 1;
    padding: 14px 20px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #1e293b;
    color: white;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: #3b82f6;
}

.search-box button {
    padding: 14px 24px;
    background: #3b82f6;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 16px;
    font-weight: bold;
}

.search-box button:hover {
    background: #2563eb;
}

.quick-topics {
    max-width: 720px;
    margin: 20px auto 0;
    text-align: center;
}

.quick-topics-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #94a3b8;
    font-size: 14px;
    margin-bottom: 12px;
}

.quick-topics-toggle {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #cbd5e1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.quick-topics-toggle:hover {
    background: #1e293b;
    color: #f8fafc;
}

.quick-topics-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-height: 160px;
    opacity: 1;
    overflow: hidden;
    transform: translateX(0);
    transition: max-height 0.25s ease, opacity 0.2s ease, transform 0.25s ease;
}

.quick-topics-card {
    padding: 8px 18px;
    border-radius: 999px;
    border: 1px solid #334155;
    background: #121b2d;
    color: #e2e8f0;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.2px;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.quick-topics-card:hover {
    background: #1f2a3d;
    border-color: #3b82f6;
    transform: translateY(-1px);
}

.quick-topics.collapsed .quick-topics-list {
    max-height: 0;
    opacity: 0;
    transform: translateY(-14px);
}

.quick-topics.collapsed .quick-topics-toggle {
    transform: rotate(180deg);
}

.tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 60px;
    margin-bottom: 30px;
}

.tabs button {
    background: #1e293b;
    border: 1px solid #334155;
    padding: 10px 24px;
    border-radius: 20px;
    color: #94a3b8;
    font-weight: 500;
}

.tabs button:hover {
    background: #334155;
    color: white;
}

.tabs .active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.detail-tabs {
    margin-bottom: 20px;
}

#videos-container,
#repos-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px 50px;
}

.result-item {
    background: #1e293b;
    border: 1px solid #334155;
    padding: 20px;
    margin: 15px 0;
    border-radius: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.result-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: #1e293b;
    color: #f8fafc;
    width: 100%;
    max-width: 360px;
    padding: 30px;
    border-radius: 12px;
    border: 1px solid #334155;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    position: relative;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover {
    color: white;
}

#login-form,
#register-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-content h3 {
    margin-bottom: 5px;
    font-size: 22px;
}

.modal-content input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #334155;
    background: #0f172a;
    color: white;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s;
}

.modal-content input:focus {
    border-color: #3b82f6;
}

.modal-content select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #334155;
    background: #0f172a;
    color: white;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s;
    cursor: pointer;
}

.modal-content select:focus {
    border-color: #3b82f6;
}

.modal-content button {
    padding: 12px;
    background: #3b82f6;
    margin-top: 10px;
    border: none;
    color: white;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
}

.modal-content button:hover {
    background: #2563eb;
}

.modal-content button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    background: #2563eb;
}

.result-item a {
    color: #60a5fa;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.2s;
}

.result-item a:hover {
    color: #93c5fd;
    text-decoration: underline;
}

.video-card {
    display: flex;
    gap: 20px;
    align-items: center;
}

.video-card img {
    width: 200px;
    height: 112px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #334155;
}

.video-card h4 {
    margin-bottom: 5px;
    font-size: 18px;
}

.video-card .channel {
    color: #94a3b8;
    font-size: 14px;
}

.repo-card h4 {
    font-size: 20px;
    margin-bottom: 8px;
}

.repo-card .repo-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
    font-size: 14px;
    color: #cbd5e1;
}

.repo-card .description {
    color: #94a3b8;
    font-size: 15px;
}

.video-meta {
    color: #94a3b8;
    font-size: 14px;
    margin-top: 5px;
    display: flex;
    gap: 10px;
}

.video-meta span {
    background: #0f172a;
    padding: 2px 8px;
    border-radius: 4px;
}

.controls-wrapper {
    display: flex;
    justify-content: flex-end;
    max-width: 800px;
    margin: 40px auto 20px;
    padding: 0 20px;
}

#sort-select {
    background: #1e293b;
    color: #f8fafc;
    padding: 8px 12px;
    border: 1px solid #334155;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    outline: none;
    margin-right: 300px;
}

#sort-select:hover,
#sort-select:focus {
    border-color: #3b82f6;
}

#prev-btn,
#next-btn {
    padding: 8px 16px;
    margin: 5px;
    background: #3b82f6;
    border: none;
    color: white;
    border-radius: 4px;
}

.close-video {
    position: absolute;
    top: 50px;
    right: 270px;
    color: white;
    font-size: 50px;
    font-weight: 200;
    cursor: pointer;
    z-index: 1001;
}

.video-container {
    width: 90%;
    max-width: 900px;
    aspect-ratio: 16 / 9;
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.modal.show .video-container {
    transform: scale(1);
}

#video-player {
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid #1e293b;
    border-bottom-color: #3b82f6;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
    margin: 20px auto;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.loading-container {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
}

#auth-error {
    color: #ef4444;
    margin-bottom: 10px;
    display: none;
}

.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: #1e293b;
    color: #f8fafc;
    padding: 12px 24px;
    border-radius: 8px;
    border-top: 4px solid #3b82f6;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(-20px);
    animation: slideInDown 0.4s forwards ease-out;
    font-weight: 500;
    min-width: 250px;
    text-align: center;
}

.toast.success {
    border-top-color: #10b981;
}

.toast.error {
    border-top-color: #ef4444;
}

@keyframes slideInDown {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOutUp {
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

#pagination-controls {
    text-align: center;
    margin-top: 20px;
    padding-bottom: 40px;
}

#page-info {
    margin: 0 15px;
    font-weight: bold;
}

.playlists-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    gap: 12px;
    flex-wrap: wrap;
}

.playlists-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 40px;
    align-items: center;
    flex-wrap: wrap;
}

.playlists-controls input {
    flex: 1;
    padding: 12px 15px;
    border-radius: 6px;
    border: 1px solid #334155;
    background: #1e293b;
    color: white;
    outline: none;
    transition: border-color 0.2s;
}

.playlists-controls input:focus {
    border-color: #3b82f6;
}

.playlists-controls select {
    padding: 12px 15px;
    border-radius: 6px;
    border: 1px solid #334155;
    background: #1e293b;
    color: #94a3b8;
    outline: none;
    min-width: 180px;
    cursor: pointer;
}

.playlists-controls button {
    padding: 12px 18px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #1e293b;
    color: #e2e8f0;
    font-weight: 600;
    transition: all 0.2s ease;
}

.playlists-controls button:hover {
    background: #334155;
}

.playlists-controls button:active {
    transform: translateY(1px);
}

.btn-clear-search {
    background: #0f172a;
    color: #94a3b8;
}

.btn-clear-search:hover {
    background: #1e293b;
    color: #e2e8f0;
}

mark.highlight {
    background: rgba(59, 130, 246, 0.35);
    color: inherit;
    padding: 0 2px;
    border-radius: 3px;
}

.library-results {
    margin-bottom: 30px;
    padding-top: 10px;
    border-top: 1px solid #1e293b;
}

.library-section {
    margin-bottom: 40px;
}

.library-section h3 {
    font-size: 18px;
    margin-bottom: 16px;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-count {
    font-size: 13px;
    background: #1e293b;
    color: #94a3b8;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid #334155;
}

.library-list {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px 10px;
}

.library-list .result-item {
    margin: 12px 0;
    border-color: #1f2a3d;
}

.library-list .result-item:hover {
    transform: translateY(-1px);
}

.playlists-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 24px;
}

.playlist-card {
    background: #182233;
    padding: 16px;
    border-radius: 8px;
    transition: background-color 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
}

.playlist-card:hover {
    background: #283548;
}

.playlist-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.playlist-card h4 {
    font-size: 16px;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.playlist-card p {
    font-size: 14px;
    color: #94a3b8;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-delete-playlist-card {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-delete-playlist-card:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #fee2e2;
    transform: scale(1.05);
}

.create-playlist-button {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

#playlists-view {
    padding: 100px 20px;
    max-width: 1000px;
    margin: 0 auto;
}

#analytics-view {
    padding: 100px 20px;
    max-width: 1000px;
    margin: 0 auto;
}

#playlist-detail-view {
    padding: 100px 20px 60px;
    max-width: 1000px;
    margin: 0 auto;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 320px));
    gap: 18px;
    justify-content: center;
}

.results-grid .result-item {
    margin: 0;
    height: 100%;
}

.results-grid .video-card {
    flex-direction: column;
    align-items: flex-start;
}

.results-grid .video-card img {
    width: 100%;
    height: 160px;
}

.results-grid .repo-meta {
    flex-wrap: wrap;
    row-gap: 6px;
}

.btn-create-playlist {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 500px;
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
    letter-spacing: 0.5px;
}

.btn-create-playlist .plus-icon {
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
}

.btn-create-playlist:hover {
    transform: scale(1.06);
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.btn-create-playlist:active {
    transform: scale(0.96);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-create-playlist:hover .plus-icon {
    transform: rotate(90deg);
    transition: transform 0.3s ease;
}

.btn-add-to-playlist {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 5;
}

.btn-add-to-playlist:hover {
    background: #3b82f6;
    color: white;
    transform: scale(1.1);
}

#add-to-playlist-modal .modal-content {
    max-width: 400px;
    padding: 24px;
    background: #1e293b;
    border: 1px solid #334155;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

#add-to-playlist-modal h3 {
    margin-bottom: 20px;
    font-size: 1.25rem;
    color: #f8fafc;
    text-align: center;
}

.playlists-list-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
    max-height: 350px;
    overflow-y: auto;
    padding-right: 8px;
}

.playlists-list-container::-webkit-scrollbar {
    width: 6px;
}

.playlists-list-container::-webkit-scrollbar-track {
    background: #0f172a;
    border-radius: 10px;
}

.playlists-list-container::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 10px;
}

.playlists-list-container::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

.playlist-list-item {
    display: flex;
    flex-direction: column;
    padding: 14px 18px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.playlist-list-item:hover {
    background: #1e293b;
    border-color: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.playlist-list-item strong {
    color: #f1f5f9;
    font-size: 15px;
    margin-bottom: 2px;
}

.playlist-list-item span {
    color: #64748b;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.create-new-option {
    background: rgba(59, 130, 246, 0.1) !important;
    border: 1px dashed #3b82f6 !important;
    color: #3b82f6;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    padding: 16px !important;
    margin-bottom: 12px;
}

.create-new-option:hover {
    background: #3b82f6 !important;
    color: white !important;
    border-style: solid !important;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #334155;
}

.btn-delete-playlist {
    margin-left: auto;
    background: rgba(239, 68, 68, 0.15);
    color: #fecaca;
    border: 1px solid rgba(239, 68, 68, 0.5);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-delete-playlist:hover {
    background: rgba(239, 68, 68, 0.35);
    color: #fff1f2;
}

.btn-remove-item {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 2;
}

.btn-remove-item:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #fee2e2;
    transform: scale(1.05);
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #1e293b;
    color: #cbd5e1;
    border: 1px solid #334155;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-back:hover {
    background: #334155;
    color: white;
}

.title-area h2 {
    margin: 0 0 5px 0;
    font-size: 28px;
    color: #f8fafc;
}

.badge {
    display: inline-block;
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid rgba(59, 130, 246, 0.5);
}

.card-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: bold;
    color: #64748b;
    margin-bottom: 5px;
}

.parent-link {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-top: 10px;
}

.parent-link span {
    color: #3b82f6;
    text-decoration: underline;
    cursor: pointer;
}

.parent-link span:hover {
    color: #60a5fa;
}

.analytics-link {
    margin-left: auto;
    color: #60a5fa;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}

.analytics-link:hover {
    color: #93c5fd;
}

.analytics-section {
    margin-top: 50px;
    padding: 24px;
    border: 1px solid #1e293b;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(15, 23, 42, 0.85));
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.analytics-header h3 {
    margin: 4px 0 0;
}

.analytics-total {
    color: #cbd5e1;
    font-weight: 600;
    background: rgba(15, 23, 42, 0.6);
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid #1e293b;
}

.analytics-chart-wrapper {
    display: flex;
    gap: 24px;
    align-items: center;
    flex-wrap: wrap;
}

.analytics-legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    flex: 1;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid #1e293b;
    padding: 10px 12px;
    border-radius: 10px;
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.analytics-empty,
.analytics-loading {
    color: #94a3b8;
    margin-top: 10px;
}

.eyebrow {
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #93c5fd;
    font-size: 12px;
    margin: 0;
}

@media (max-width: 1024px) {
    .navbar {
        padding: 16px 24px;
    }

    .hero {
        margin-top: 70px;
    }

    .video-card img {
        width: 160px;
        height: 90px;
    }

    .close-video {
        right: 40px;
        top: 30px;
    }
}

@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .nav-toggle {
        display: inline-flex;
        align-self: flex-end;
    }

    #nav-actions {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        pointer-events: none;
        transition: max-height 0.25s ease, opacity 0.2s ease;
    }

    #nav-actions.open {
        max-height: 320px;
        opacity: 1;
        pointer-events: auto;
    }

    #nav-actions button {
        width: 100%;
        text-align: left;
        margin-left: 0 !important;
    }

    .nav-toggle.is-open .nav-toggle-bar:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .nav-toggle.is-open .nav-toggle-bar:nth-child(2) {
        opacity: 0;
        transform: scaleX(0.3);
    }

    .nav-toggle.is-open .nav-toggle-bar:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    .hero h1 {
        font-size: 36px;
    }

    .search-box {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box button {
        width: 100%;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .video-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .video-card img {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
    }

    .controls-wrapper {
        justify-content: space-between;
    }

    #sort-select {
        margin-right: 0;
        width: 100%;
        max-width: 260px;
    }

    #pagination-controls {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
    }
}

@media (max-width: 560px) {
    .navbar {
        padding: 14px 16px;
    }

    .hero h1 {
        font-size: 30px;
    }

    .hero p {
        font-size: 16px;
    }

    .navbar button {
        padding: 8px 14px;
    }

    .playlists-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .playlists-controls input,
    .playlists-controls select,
    .playlists-controls button {
        width: 100%;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .detail-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .analytics-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .analytics-chart-wrapper {
        justify-content: center;
    }

    .playlist-card h4,
    .playlist-card p {
        white-space: normal;
    }

    .modal-content {
        max-width: 320px;
    }

    .close-video {
        right: 16px;
        top: 20px;
        font-size: 36px;
    }

    .video-container {
        width: 95%;
    }
}