:root {
    --ink: #121216;
    --ink-soft: rgba(18, 18, 22, 0.7);
    --paper: #f2f8fb;
    --accent: #51a8d3;
    --accent-dark: #2f7ea6;
    --mist: #d7e6f0;
    --panel: rgba(255, 255, 255, 0.72);
    --shadow: 0 24px 60px rgba(10, 38, 60, 0.18);
    --radius: 18px;
    --mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --sans: "Space Grotesk", "Segoe UI", sans-serif;
    --footer-height: 28px;
}

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

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--sans);
    background: radial-gradient(circle at top, #f6fbff 0%, #e6f1f8 45%, #d4e6f2 100%);
    color: var(--ink);
    overflow: hidden;
    padding: 0;
}

.app-footer {
    padding: 0 16px;
    height: var(--footer-height);
    line-height: var(--footer-height);
    text-align: center;
    font-size: 0.85rem;
    color: var(--ink-soft);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
}

.app-footer a {
    color: var(--accent-dark);
    text-decoration: none;
    font-weight: 600;
}

.app-footer a:hover {
    text-decoration: underline;
}

body.admin-page .app-footer {
    position: static;
    background: transparent;
    backdrop-filter: none;
}

body:not(.admin-page) .app-shell {
    height: calc(100vh - var(--footer-height));
}

@media (max-width: 900px) {
    .volume {
        display: none;
    }
    .app-footer {
        position: static;
        height: auto;
        line-height: 1.4;
        padding: 10px 16px 16px;
        background: transparent;
        backdrop-filter: none;
    }

    body:not(.admin-page) .sidebar {
        height: auto;
    }

    body:not(.admin-page) .app-shell {
        height: auto;
    }

    body:not(.admin-page) .player-area {
        height: auto;
    }
}

body.admin-page {
    overflow: auto;
}

body.login-page {
    overflow: hidden;
}

@media (max-height: 500px) {
    body:not(.admin-page) {
        overflow: auto;
    }

    .app-shell {
        height: auto;
        min-height: 100vh;
    }

    body:not(.admin-page) .app-shell,
    body:not(.admin-page) .player-area,
    body:not(.admin-page) .sidebar {
        height: auto;
    }
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    overflow: hidden;
}

.login-card {
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--radius);
    padding: 24px;
    width: min(360px, 90vw);
    max-height: 90vh;
    overflow: auto;
    box-shadow: var(--shadow);
    display: grid;
    gap: 14px;
}

.login-card h1 {
    font-size: 1.4rem;
}

.login-card label {
    display: grid;
    gap: 6px;
    font-size: 0.9rem;
}

.login-card form {
    display: grid;
    gap: 12px;
}

.login-card input {
    border: 1px solid rgba(18, 18, 22, 0.15);
    border-radius: 10px;
    padding: 10px 12px;
    font-family: var(--sans);
}

.login-card button {
    border: none;
    background: var(--accent);
    color: #fff;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

.login-error {
    color: #b42318;
    font-size: 0.9rem;
}

.admin-shell {
    min-height: 100vh;
    padding: 24px;
    display: grid;
    gap: 18px;
    align-content: start;
    align-items: start;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-back-form {
    margin: 0;
}

.admin-back {
    border: none;
    background: rgba(18, 18, 22, 0.08);
    color: var(--ink);
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

.admin-back:hover {
    background: rgba(81, 168, 211, 0.18);
    color: var(--accent-dark);
}

.admin-tabs {
    display: flex;
    gap: 8px;
}

.admin-splitter {
    height: 1px;
    background: rgba(18, 18, 22, 0.12);
    margin: 8px 0 10px;
}

.admin-tab {
    border: none;
    background: rgba(18, 18, 22, 0.08);
    color: var(--ink);
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

.admin-tab.active {
    background: var(--accent);
    color: #fff;
}

.admin-section {
    background: rgba(255, 255, 255, 0.85);
    border-radius: 14px;
    padding: 16px;
    box-shadow: var(--shadow);
    display: grid;
    gap: 8px;
    align-content: start;
}

.admin-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
    align-content: start;
}

.admin-form input,
.admin-form select {
    border: 1px solid rgba(18, 18, 22, 0.15);
    border-radius: 10px;
    padding: 8px 10px;
    font-family: var(--sans);
    height: 36px;
}

.admin-form textarea {
    border: 1px solid rgba(18, 18, 22, 0.15);
    border-radius: 10px;
    padding: 8px 10px;
    font-family: var(--sans);
    min-height: 96px;
    resize: vertical;
    width: 100%;
}

.admin-form label textarea {
    width: 100%;
}

.admin-form label {
    display: grid;
    gap: 6px;
}

.admin-form label.admin-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.admin-form input[type="file"] {
    padding: 6px 10px;
    height: auto;
}

.admin-form button {
    border: none;
    background: var(--accent);
    color: #fff;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    height: 36px;
}

.admin-userlist {
    display: grid;
    gap: 6px;
}

.admin-userline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid rgba(18, 18, 22, 0.08);
    padding: 8px 12px;
}

.admin-tree {
    list-style: none;
    margin: 6px 0 0 16px;
    display: grid;
    gap: 6px;
    border-left: 1px dashed rgba(18, 18, 22, 0.2);
    padding-left: 12px;
}

.admin-tree li {
    list-style: none;
}

.admin-tree li > .admin-user {
    position: relative;
}

.admin-tree li > .admin-user::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    width: 10px;
    height: 1px;
    background: rgba(18, 18, 22, 0.25);
}

.admin-tree-label {
    font-weight: 600;
    color: var(--ink);
    padding: 6px 8px;
}

.admin-tree-label.admin-category {
    display: flex;
    align-items: center;
    gap: 10px;
}

.videos-tree {
    margin-left: 20px;
    border-left: 1px dashed rgba(18, 18, 22, 0.15);
}

.videos-tree .admin-video {
    margin-left: 0;
}

.drag-over {
    background: rgba(81, 168, 211, 0.15);
    color: var(--accent-dark);
    outline: 2px solid rgba(81, 168, 211, 0.35);
    outline-offset: 2px;
}

.drag-video-over {
    background: rgba(81, 168, 211, 0.12);
    outline: 2px dashed rgba(81, 168, 211, 0.45);
    outline-offset: 2px;
}

.drag-before {
    box-shadow: inset 0 2px 0 rgba(81, 168, 211, 0.7);
}

.drag-after {
    box-shadow: inset 0 -2px 0 rgba(81, 168, 211, 0.7);
}

.drag-child {
    box-shadow: inset 0 0 0 2px rgba(81, 168, 211, 0.7);
}

.admin-search {
    margin-bottom: 6px;
    height: 36px;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.admin-sort {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.admin-inline-form {
    margin: 6px 0 10px;
}

.admin-message {
    background: rgba(81, 168, 211, 0.12);
    border: 1px solid rgba(81, 168, 211, 0.3);
    color: var(--accent-dark);
    padding: 8px 12px;
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.upload-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.upload-progress.hidden {
    display: none;
}

.upload-progress progress {
    flex: 1 1 auto;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
}

.upload-progress.processing progress {
    accent-color: rgba(81, 168, 211, 0.4);
}

.upload-progress-text {
    font-size: 0.85rem;
    color: var(--ink-soft);
    min-width: 48px;
    text-align: right;
}

.upload-modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 18, 28, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

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

.upload-modal-card {
    background: #fff;
    border-radius: 16px;
    padding: 24px 28px;
    min-width: 260px;
    max-width: 360px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
    display: grid;
    gap: 12px;
    justify-items: center;
}

.upload-modal-card h3 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--ink);
}

.upload-spinner {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 3px solid rgba(81, 168, 211, 0.2);
    border-top-color: var(--accent);
    animation: upload-spin 0.8s linear infinite;
}

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

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

@media (max-height: 900px) {
    body:not(.admin-page) {
        overflow: auto;
    }

    .video-frame {
        min-height: 0;
    }

    #video-player {
        min-height: 0;
        max-height: none;
    }
}

.admin-history-filter {
    grid-template-columns: auto auto auto;
    align-items: end;
    column-gap: 6px;
    justify-content: start;
}

.admin-history-filter input[type="date"] {
    padding: 6px 8px;
    font-size: 0.85rem;
    max-width: 160px;
}

.admin-history-note {
    font-size: 0.85rem;
    color: var(--ink-soft);
    margin-top: 4px;
}

.admin-history-table {
    display: grid;
    gap: 6px;
}

.admin-history-row {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 12px;
    align-items: center;
    background: #fff;
    border-radius: 12px;
    border: 1px solid rgba(18, 18, 22, 0.08);
    padding: 8px 12px;
    font-size: 0.9rem;
}

.admin-history-row span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-history-head {
    background: rgba(81, 168, 211, 0.15);
    font-weight: 600;
    color: var(--accent-dark);
}

.admin-history-controls {
    display: grid;
    grid-template-columns: 1fr 140px;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}

.admin-history-summary-controls {
    grid-template-columns: 1fr;
    max-width: 320px;
}

.admin-history-controls input,
.admin-history-controls select {
    border: 1px solid rgba(18, 18, 22, 0.15);
    border-radius: 10px;
    padding: 8px 10px;
    font-family: var(--sans);
    height: 36px;
}

.admin-history-all {
    gap: 8px;
}

.admin-history-all-head,
.admin-history-all-row {
    grid-template-columns: 160px 1fr 160px 120px;
}

.admin-history-pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
    padding: 4px 2px 0;
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.admin-history-pagination button[disabled] {
    opacity: 0.5;
    cursor: default;
}

.admin-history-item {
    border: 1px solid rgba(18, 18, 22, 0.08);
    background: #fff;
    cursor: pointer;
    text-align: left;
    width: 100%;
}

.admin-history-item:hover {
    background: rgba(81, 168, 211, 0.12);
    color: var(--accent-dark);
}

.admin-history-empty {
    font-size: 0.9rem;
    color: var(--ink-soft);
    padding: 6px 2px;
}

.admin-history-modal {
    display: grid;
    gap: 12px;
}

.admin-history-modal h3 {
    font-size: 1.1rem;
}

.admin-history-modal-list {
    display: grid;
    gap: 6px;
    max-height: 60vh;
    overflow: auto;
}

.admin-file-cleanup h3 {
    margin-top: 6px;
    font-size: 1.05rem;
}

.admin-filelist {
    display: grid;
    gap: 6px;
    margin-top: 8px;
}

.admin-file-row {
    display: grid;
    grid-template-columns: minmax(140px, 260px) 1fr auto;
    gap: 12px;
    align-items: center;
    background: #fff;
    border-radius: 12px;
    border: 1px solid rgba(18, 18, 22, 0.08);
    padding: 8px 12px;
    font-size: 0.9rem;
}

.admin-file-row span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-file-head {
    background: rgba(81, 168, 211, 0.15);
    font-weight: 600;
    color: var(--accent-dark);
}

.admin-file-delete {
    margin: 0;
}

.admin-history-detail {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 12px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid rgba(18, 18, 22, 0.08);
    padding: 8px 12px;
    font-size: 0.9rem;
}

.admin-danger {
    border: none;
    background: #d64040;
    color: #fff;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

.admin-danger:hover {
    background: #b93232;
}

.admin-sort select {
    border: none;
    border-radius: 10px;
    padding: 6px 12px;
    font-family: var(--sans);
    font-weight: 600;
    background: rgba(18, 18, 22, 0.08);
    color: var(--ink);
}

.admin-search input {
    width: 100%;
    border: 1px solid rgba(18, 18, 22, 0.15);
    border-radius: 10px;
    padding: 8px 10px;
    font-family: var(--sans);
    height: 36px;
    line-height: 20px;
    box-sizing: border-box;
    margin: 0;
    display: block;
}

.admin-user,
.admin-video {
    background: #fff;
    border-radius: 12px;
    border: 1px solid rgba(18, 18, 22, 0.08);
    padding: 8px 12px;
    text-align: left;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    min-height: 36px;
    height: auto;
    white-space: normal;
    overflow: visible;
    transition: background 0.2s ease, color 0.2s ease;
}

.admin-video {
    height: 36px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-video {
    cursor: pointer;
    font-weight: 600;
    width: 100%;
}

.admin-user:hover {
    background: rgba(81, 168, 211, 0.12);
    color: var(--accent-dark);
}

.admin-user-name {
    font-weight: 600;
}

.admin-user-meta {
    font-size: 0.8rem;
    color: var(--ink-soft);
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: nowrap;
}

.admin-user-meta span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-user-meta .meta-groups {
    flex: 1 1 auto;
}

.admin-user-meta .meta-valid {
    flex: 0 0 auto;
}

.admin-user-row {
    display: grid;
    grid-template-columns: 180px 1fr 120px 140px;
    align-items: center;
    gap: 12px;
}

.admin-user-row .admin-user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-user-row .admin-user-groups {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink-soft);
    font-weight: 500;
}

.admin-user-row .admin-user-valid {
    text-align: right;
    color: var(--ink-soft);
    font-weight: 500;
}

.admin-user-row .admin-user-client {
    text-align: right;
    color: var(--ink-soft);
    font-weight: 500;
}

.admin-category {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-category-title {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-category-groups {
    flex: 0 0 auto;
    font-size: 0.8rem;
    color: var(--ink-soft);
    white-space: nowrap;
}

.admin-user summary {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    font-weight: 600;
}

.admin-user summary::-webkit-details-marker {
    display: none;
}

.admin-user .meta {
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.admin-checkboxes {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
}

.admin-checkboxes label {
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1;
}

.admin-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.2;
    flex-direction: row;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.admin-checkbox input[type="checkbox"] {
    width: 14px;
    height: 14px;
}

.admin-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
}

.ghost {
    border: none;
    background: rgba(18, 18, 22, 0.1);
    color: var(--ink);
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

.ghost:hover {
    background: rgba(81, 168, 211, 0.18);
    color: var(--accent-dark);
}

.admin-actions .danger {
    background: #f04438;
}

.admin-actions .ghost {
    background: rgba(18, 18, 22, 0.1);
    color: var(--ink);
}

.admin-chapters {
    display: grid;
    gap: 8px;
    border: 1px solid rgba(18, 18, 22, 0.08);
    border-radius: 12px;
    padding: 10px;
    background: #fff;
    grid-column: 1 / -1;
}

.admin-chapters-footer {
    display: flex;
    justify-content: flex-end;
}

.admin-chapters input[type="file"] {
    grid-column: 1 / -1;
}

.admin-chapter-import {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
    grid-column: 1 / -1;
}

.admin-chapter-import label {
    display: grid;
    gap: 6px;
    font-size: 0.85rem;
    flex: 1 1 200px;
    min-width: 180px;
}

.admin-chapter-import .admin-chapter-fps {
    flex: 0 0 110px;
    min-width: 110px;
}

.admin-chapter-import select,
.admin-chapter-import input[type="number"] {
    border: 1px solid rgba(18, 18, 22, 0.15);
    border-radius: 10px;
    padding: 8px 10px;
    font-family: var(--sans);
    height: 36px;
    width: 100%;
    box-sizing: border-box;
}

.admin-chapter-import input[type="file"] {
    height: 36px;
    padding: 4px 6px;
    flex: 1 1 240px;
    min-width: 220px;
}

.admin-chapters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-weight: 600;
}

.admin-chapter-row {
    display: grid;
    grid-template-columns: 1fr 140px auto;
    gap: 8px;
    align-items: center;
}

.admin-chapter-row input {
    height: 32px;
}

#modal-video-description {
    grid-column: 1 / -1;
}

.admin-fileinfo {
    grid-column: 1 / -1;
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.admin-modal {
    border: none;
    border-radius: 16px;
    padding: 18px;
    width: min(620px, 92vw);
    box-shadow: var(--shadow);
    margin: auto;
}

.admin-modal::backdrop {
    background: rgba(12, 10, 6, 0.5);
}

.admin-modal-form {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.admin-modal-form label {
    grid-column: 1 / -1;
}

.admin-modal-form textarea {
    grid-column: 1 / -1;
    width: 100%;
}

.admin-modal-form h3 {
    grid-column: 1 / -1;
    font-size: 1.2rem;
}

.app-shell {
    display: grid;
    grid-template-columns: var(--nav-width, max-content) minmax(0, 1fr) var(--chapters-width, 260px);
    gap: 0;
    padding: 0;
    height: 100vh;
    margin: 0;
}

.no-access .player-area {
    display: none;
}

.app-shell.nav-collapsed {
    --nav-width: 48px;
}

.app-shell.chapters-collapsed {
    --chapters-width: 48px;
}

body:not(.admin-page) .app-shell.nav-collapsed {
    --nav-width: 48px;
}

body:not(.admin-page) .app-shell.chapters-collapsed {
    --chapters-width: 48px;
}

.app-shell.chapters-hidden {
    grid-template-columns: var(--nav-width, max-content) minmax(0, 1fr);
}

.sidebar {
    background: var(--panel);
    backdrop-filter: blur(12px);
    border-radius: 0;
    padding: 0 14px 14px;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

body:not(.admin-page) .sidebar {
    height: calc(100vh - var(--footer-height));
}

body:not(.admin-page) .player-area {
    height: calc(100vh - var(--footer-height));
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar.nav {
    width: max-content;
    max-width: 520px;
    padding: 0 12px 12px;
}

.sidebar.nav .panel-header {
    margin-top: 12px;
}

.sidebar.chapters {
    width: 260px;
    max-width: 320px;
}

.app-shell.chapters-hidden .sidebar.chapters {
    display: none;
}


.sidebar.chapters .panel-header {
    margin-top: 12px;
}

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

.panel-search {
    padding: 0 8px 12px;
}

.panel-search input {
    width: 100%;
    border: 1px solid rgba(18, 18, 22, 0.15);
    border-radius: 10px;
    padding: 8px 10px;
    font-family: var(--sans);
    font-size: 0.9rem;
}

.panel-title {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

#nav-top-videos {
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease;
}

#nav-top-videos:hover,
#nav-top-videos:focus-visible {
    background: rgba(81, 168, 211, 0.18);
    color: var(--accent-dark);
    outline: none;
}

.hidden {
    display: none !important;
}

.browser-view.hidden {
    display: none !important;
}

.player-area .hidden + .hidden {
    display: none;
}

.panel-toggle {
    border: none;
    background: rgba(18, 18, 22, 0.1);
    color: var(--ink);
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 0;
}

.sidebar.collapsed {
    width: 48px;
    min-width: 48px;
    max-width: 48px;
    padding: 10px 6px;
}

.sidebar.chapters.collapsed {
    display: flex;
    width: 48px;
    max-width: 48px;
    padding: 10px 6px;
    overflow: hidden;
}

.sidebar.collapsed .panel-body {
    display: none;
}

.sidebar.collapsed .panel-title {
    display: none;
}

.sidebar.collapsed .panel-search {
    display: none;
}

.sidebar.collapsed .panel-footer {
    display: none;
}

.sidebar.nav.collapsed .panel-footer {
    display: none !important;
}

.sidebar.collapsed .panel-header {
    justify-content: center;
}

.sidebar.collapsed .panel-toggle {
    transform: none;
}

.sidebar.chapters.collapsed {
    justify-self: end;
}

.panel-subtitle {
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.panel-body {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    padding-right: 14px;
    padding-left: 4px;
    flex: 1 1 auto;
}

.panel-footer {
    padding: 12px 8px 0;
}

.mobile-switcher {
    display: none;
}

@media (max-width: 900px) {
    body {
        overflow: auto;
    }

    .app-shell {
        display: flex;
        flex-direction: column;
        height: auto;
        gap: 0;
    }

    .app-shell.mobile-compact {
        height: 100vh;
    }


    .app-shell > .sidebar:first-child {
        margin-top: 0;
    }

    .sidebar {
        width: 100%;
        max-width: none;
        border-radius: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        height: auto;
        max-height: none;
        flex: 0 0 auto;
    }

    body:not(.admin-page) .sidebar {
        height: auto;
        max-height: none;
    }

    .sidebar.nav,
    .sidebar.chapters {
        display: block;
    }

    .sidebar.nav,
    .sidebar.chapters {
        padding: 0 12px 12px;
    }

    .sidebar.nav .panel-body,
    .sidebar.chapters .panel-body {
        max-height: none;
        flex: 1 1 auto;
    }

    .player-area {
        padding: 0 12px 16px;
        width: 100%;
        flex: 0 0 auto;
        min-height: 0;
    }

    body:not(.admin-page) .player-area {
        height: auto;
    }

    .app-shell.mobile-compact .player-area {
        flex: 1 1 auto;
    }

    .player-header {
        width: 100%;
    }

    .video-frame {
        padding: 12px;
        width: 100%;
    }

    #video-player {
        min-height: 220px;
        margin-top: 6px;
        width: 100%;
    }

    .controls,
    .control-group {
        gap: 8px;
    }

    .control-btn {
        padding: 10px 14px;
        font-size: 0.95rem;
    }

    .volume input {
        min-width: 120px;
    }

    .speed select {
        padding: 8px 10px;
    }

    .panel-toggle {
        min-width: 32px;
        min-height: 32px;
        margin-top: -8px;
    }

    .sidebar.mobile-collapsed {
        height: auto;
        max-height: none;
    }

    .sidebar.mobile-collapsed .panel-body,
    .sidebar.mobile-collapsed .panel-footer,
    .sidebar.mobile-collapsed .panel-search {
        display: none;
    }

    .sidebar.mobile-collapsed .panel-header {
        margin-bottom: 0;
    }
}

.panel-splitter {
    height: 1px;
    background: rgba(18, 18, 22, 0.12);
    margin: 8px 8px 0;
}

.sidebar.nav.collapsed .panel-footer,
.sidebar.nav.collapsed .logout-link {
    display: none !important;
    visibility: hidden;
    height: 0;
}

.category {
    border: none;
    border-radius: 0;
    margin-bottom: 6px;
    padding: 0;
    background: transparent;
}

.category summary {
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    outline: none;
    padding: 4px 2px 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.category summary.active {
    color: var(--accent-dark);
}

.category summary.active .tree-icon {
    background-color: var(--accent-dark);
}

.tree-toggle {
    width: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 2px;
    cursor: pointer;
    flex: 0 0 auto;
    color: rgba(18, 18, 22, 0.7);
    font-size: 0.8rem;
    line-height: 1;
}

.category summary::-webkit-details-marker {
    display: none;
}

.category-list {
    list-style: none;
    margin-left: 14px;
    margin-top: 6px;
    display: grid;
    gap: 4px;
    position: relative;
}

.category-list::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -8px;
    width: 1px;
    background-image: repeating-linear-gradient(
        to bottom,
        rgba(18, 18, 22, 0.35),
        rgba(18, 18, 22, 0.35) 2px,
        transparent 2px,
        transparent 6px
    );
}

.category-list.root {
    margin-left: 0;
    margin-top: 0;
}

.category-node {
    list-style: none;
}

.category-node:last-child > .category > .category-list::before {
    bottom: 14px;
}

.video-item {
    list-style: none;
}

.video-link,
.chapter-link,
.control-btn {
    font-family: var(--sans);
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.video-link {
    width: 100%;
    padding: 4px 6px 4px 16px;
    border-radius: 6px;
    font-size: 0.92rem;
    color: var(--ink);
    transition: background 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    position: relative;
    white-space: normal;
    word-break: break-word;
}

.video-link::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    width: 8px;
    height: 1px;
    background-image: repeating-linear-gradient(
        to right,
        rgba(18, 18, 22, 0.35),
        rgba(18, 18, 22, 0.35) 2px,
        transparent 2px,
        transparent 6px
    );
}

.video-link.active {
    background: rgba(81, 168, 211, 0.12);
    color: var(--accent-dark);
}

.video-link:hover,
.video-link.active {
    background: rgba(81, 168, 211, 0.15);
    color: var(--accent-dark);
}

.player-area {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
    padding: 0 12px 24px;
}

.app-shell.chapters-collapsed .sidebar.chapters {
    padding-left: 4px;
}


.player-area > .browser-view,
.player-area > .video-frame,
.player-area > .player-header {
    margin-top: 10px;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    background: rgba(255, 255, 255, 0.78);
    border-radius: var(--radius);
    padding: 8px 14px;
    box-shadow: var(--shadow);
}

.logout-link {
    color: var(--accent-dark);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(81, 168, 211, 0.12);
}

.logout-link:hover {
    background: rgba(81, 168, 211, 0.2);
}

.player-header h1 {
    font-size: 1.3rem;
    margin-bottom: 4px;
}

.player-header .eyebrow {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--accent-dark);
    margin-bottom: 6px;
}

.player-header p {
    color: var(--ink-soft);
    line-height: 1.3;
}

.browser-view {
    background: rgba(255, 255, 255, 0.78);
    border-radius: var(--radius);
    padding: 18px 22px;
    box-shadow: var(--shadow);
    display: grid;
    gap: 14px;
}


.browser-view h2 {
    font-size: 1.4rem;
}

.browser-view p {
    color: var(--ink-soft);
    line-height: 1.5;
}

.browser-view h2:empty,
.browser-view p:empty {
    display: none;
}

.browser-list {
    list-style: none;
    display: grid;
    gap: 8px;
}

.top-video-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.top-video-desc {
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.browser-item {
    list-style: none;
}

.browser-link {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    border: none;
    background: rgba(255, 255, 255, 0.75);
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
    text-align: left;
    font-family: var(--sans);
    color: var(--ink);
    transition: background 0.2s ease, color 0.2s ease;
}

.browser-link .tree-icon {
    margin-left: 4px;
}

.browser-link:hover {
    background: rgba(81, 168, 211, 0.15);
    color: var(--accent-dark);
}

.meta {
    display: grid;
    gap: 6px;
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.video-frame {
    background: #0f0d0c;
    border-radius: 22px;
    padding: 18px;
    box-shadow: var(--shadow);
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
}

.video-stage {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    margin-top: 8px;
    border-radius: 16px;
}

.video-frame:fullscreen {
    width: 100%;
    height: 100%;
    border-radius: 0;
    padding: 16px;
}

.video-frame:fullscreen .video-stage {
    margin-top: 0;
    border-radius: 0;
}

.video-frame:fullscreen .video-overlay {
    border-radius: 0;
}

.video-frame:fullscreen #video-player {
    min-height: 0;
}

.video-frame.fs-hide-controls .controls,
.video-frame.fs-hide-controls .timeline {
    opacity: 0;
    pointer-events: none;
    height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    flex: 0 0 0;
}

.video-frame.fs-hide-controls {
    cursor: none;
}

.video-frame:fullscreen.fs-hide-controls {
    padding: 0;
}

.video-frame:fullscreen.fs-hide-controls #video-player {
    margin-top: 0;
    border-radius: 0;
    height: 100%;
    max-height: 100%;
}

#video-player {
    width: 100%;
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    border-radius: 16px;
    background: #000;
    margin-top: 0;
    transition: min-height 0.25s ease, max-height 0.25s ease, height 0.25s ease;
}

.app-shell.nav-collapsed .video-frame,
.app-shell.chapters-collapsed .video-frame,
.app-shell.chapters-hidden .video-frame {
    padding: 12px;
}

.app-shell.nav-collapsed #video-player,
.app-shell.chapters-collapsed #video-player,
.app-shell.chapters-hidden #video-player {
    min-height: 0;
}

.app-shell.nav-collapsed.chapters-collapsed #video-player {
    min-height: 0;
}

.timeline {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    color: #fef7f0;
    font-family: var(--mono);
    position: relative;
}

.timeline input[type='range'] {
    width: 100%;
    accent-color: var(--accent);
}

.seekbar-wrap {
    position: relative;
    width: 100%;
    --thumb-size: 16px;
}

.seekbar-wrap input[type='range'] {
    width: 100%;
    display: block;
}

#seekbar {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: transparent;
    --thumb-size: inherit;
}

#seekbar::-webkit-slider-runnable-track {
    height: 6px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
}

#seekbar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: var(--thumb-size);
    height: var(--thumb-size);
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(81, 168, 211, 0.12);
    margin-top: calc((6px - var(--thumb-size)) / 2);
}

#seekbar::-moz-range-track {
    height: 6px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
}

#seekbar::-moz-range-progress {
    height: 6px;
    background: rgba(81, 168, 211, 0.5);
    border-radius: 999px;
}

#seekbar::-moz-range-thumb {
    width: var(--thumb-size);
    height: var(--thumb-size);
    border-radius: 50%;
    background: var(--accent);
    border: none;
    box-shadow: 0 0 0 4px rgba(81, 168, 211, 0.12);
}

.chapter-ticks {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 10px;
    transform: translateY(-50%);
    pointer-events: none;
    --thumb-size: inherit;
}

.chapter-tick {
    position: absolute;
    width: 2px;
    height: 8px;
    background: rgba(81, 168, 211, 0.7);
    border-radius: 2px;
    left: calc((100% - var(--thumb-size)) * var(--pos) + (var(--thumb-size) / 2));
    transform: translateX(-50%);
}

.timeline-hint {
    position: absolute;
    top: -28px;
    transform: translateX(-50%);
    background: rgba(18, 18, 22, 0.9);
    color: #fff;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.timeline-hint.visible {
    opacity: 1;
}

.time {
    font-size: 0.85rem;
    color: #f5e9df;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    flex-wrap: wrap;
    color: #fff;
    font-size: clamp(0.72rem, 2.1vw, 0.95rem);
}

.control-group {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
    justify-content: center;
}

.video-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 4.5rem;
    color: rgba(255, 255, 255, 0.7);
    pointer-events: none;
    background: radial-gradient(circle, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0) 60%);
    border-radius: 16px;
    z-index: 1;
}

.control-btn {
    background: #1f1a17;
    color: #fef7f0;
    padding: 0.55em 0.85em;
    border-radius: 12px;
    font-size: 1em;
    transition: background 0.2s ease, transform 0.2s ease;
    letter-spacing: 0.02em;
}

.control-btn:hover {
    background: #2f2824;
    transform: translateY(-1px);
}

.volume {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: #f5e9df;
}

.volume-toggle {
    background: #1f1a17;
    color: #fef7f0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 0.35em 0.6em;
    font-size: 1em;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.volume-toggle:hover {
    background: #2f2824;
    transform: translateY(-1px);
}

.speed {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #f5e9df;
}

.speed select {
    background: #1f1a17;
    color: #fef7f0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 0.35em 0.55em;
    font-family: var(--sans);
    font-size: 1em;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.volume input {
    accent-color: var(--accent);
}

.tree-icon {
    width: 16px;
    height: 16px;
    display: inline-block;
    background-color: var(--accent-dark);
    flex: 0 0 auto;
}

.tree-folder {
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0%200%2024%2024'><path fill='black' d='M3%206a2%202%200%200%201%202-2h5l2%202h7a2%202%200%200%201%202%202v9a2%202%200%200%201-2%202H5a2%202%200%200%201-2-2V6z'/></svg>") no-repeat center / contain;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0%200%2024%2024'><path fill='black' d='M3%206a2%202%200%200%201%202-2h5l2%202h7a2%202%200%200%201%202%202v9a2%202%200%200%201-2%202H5a2%202%200%200%201-2-2V6z'/></svg>") no-repeat center / contain;
}

.tree-video {
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0%200%2024%2024'><path fill='black' d='M4%205h16a2%202%200%200%201%202%202v10a2%202%200%200%201-2%202H4a2%202%200%200%201-2-2V7a2%202%200%200%201%202-2zm6%203v8l6-4-6-4z'/></svg>") no-repeat center / contain;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0%200%2024%2024'><path fill='black' d='M4%205h16a2%202%200%200%201%202%202v10a2%202%200%200%201-2%202H4a2%202%200%200%201-2-2V7a2%202%200%200%201%202-2zm6%203v8l6-4-6-4z'/></svg>") no-repeat center / contain;
}

.chapter-list {
    list-style: none;
    display: grid;
    gap: 10px;
    margin-left: 8px;
}

.chapter-link {
    width: 100%;
    background: rgba(255, 255, 255, 0.75);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--ink);
    transition: background 0.2s ease;
    align-items: center;
    flex-wrap: wrap;
}

.chapter-link.active {
    background: rgba(81, 168, 211, 0.25);
    box-shadow: inset 0 0 0 1px rgba(81, 168, 211, 0.45);
}

.chapter-link:hover {
    background: rgba(81, 168, 211, 0.15);
}

.chapter-time {
    font-family: var(--mono);
    color: var(--ink-soft);
    white-space: nowrap;
    margin-left: auto;
}

.chapter-title {
    flex: 1 1 auto;
    min-width: 0;
    word-break: break-word;
}

.empty-state {
    font-size: 0.9rem;
    color: var(--ink-soft);
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 240px 1fr;
    }

    .chapters {
        grid-column: 1 / -1;
    }
}

@media (max-width: 860px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;
    }

    #video-player {
        max-height: 55vh;
    }
}

@media (max-width: 900px) {
    .sidebar.mobile-collapsed .panel-body,
    .sidebar.mobile-collapsed .panel-footer,
    .sidebar.mobile-collapsed .panel-search {
        display: none;
    }

    .sidebar.mobile-collapsed .panel-header {
        border-bottom: 1px solid rgba(18, 18, 22, 0.08);
        margin-bottom: 0;
    }

    .sidebar.mobile-collapsed {
        padding-bottom: 0;
        max-height: 52px;
        overflow: hidden;
    }

    .sidebar:not(.mobile-collapsed) {
        max-height: none;
        overflow: visible;
    }

    .sidebar.nav {
        padding-left: 0;
        padding-right: 0;
    }

    .sidebar.nav .panel-header,
    .sidebar.nav .panel-search,
    .sidebar.nav .panel-body,
    .sidebar.nav .panel-footer {
        padding-left: 12px;
        padding-right: 12px;
    }

    .sidebar.chapters {
        padding-left: 0;
        padding-right: 0;
    }

    .sidebar.chapters .panel-header,
    .sidebar.chapters .panel-body {
        padding-left: 12px;
        padding-right: 12px;
    }

    .sidebar.nav,
    .sidebar.chapters {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
}

@media (max-width: 900px) {
    .controls .volume {
        display: none;
    }
}
