/* ---- Reset / base ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0e0f10;
    color: #e6e8eb;
    min-height: 100vh;
}
a { color: #7cb6ff; text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }

/* ---- Layout ---- */
.topnav {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    background: #16181b;
    border-bottom: 1px solid #23262b;
    position: sticky;
    top: 0;
    z-index: 50;
}
.brand {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.02em;
    color: #fff;
}
.brand:hover { text-decoration: none; }
.navlinks { display: flex; gap: 4px; flex: 1; }
.navlinks a {
    padding: 6px 12px;
    border-radius: 6px;
    color: #a8aeb6;
}
.navlinks a:hover { background: #23262b; color: #fff; text-decoration: none; }
.navlinks a.active { background: #2a2e34; color: #fff; }
.logout button { color: #a8aeb6; }

.main {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-head h1 { font-size: 22px; margin: 0 0 4px; }
.page-head-actions { display: flex; gap: 8px; }

.crumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.crumbs .sep { color: #555; }
.crumbs a { color: #a8aeb6; }
.crumbs a:hover { color: #fff; }

/* ---- Forms / buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: #2a2e34;
    color: #e6e8eb;
    border: 1px solid #3a3f47;
    border-radius: 6px;
    font-size: 13px;
    text-decoration: none;
    transition: background .15s;
}
.btn:hover { background: #353b43; text-decoration: none; }
.btn.primary { background: #4a7fff; border-color: #4a7fff; color: #fff; font-weight: 500; }
.btn.primary:hover { background: #5a8aff; }
.btn.small { padding: 4px 10px; font-size: 12px; }

.btn-link {
    background: none;
    border: none;
    color: #7cb6ff;
    padding: 0;
    font-size: inherit;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: #ff7878; }
.btn-link.small { font-size: 12px; }
.btn-link.tiny { font-size: 11px; opacity: 0.6; }
.btn-link.tiny:hover { opacity: 1; }

input[type=text], input[type=password], textarea, select {
    background: #1a1c1f;
    border: 1px solid #2f343a;
    color: #e6e8eb;
    padding: 7px 10px;
    border-radius: 6px;
    font: inherit;
    width: 100%;
}
input[type=text]:focus, input[type=password]:focus, textarea:focus {
    outline: none;
    border-color: #4a7fff;
}
textarea { resize: vertical; }

.inline-form {
    display: none;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}
.inline-form.open { display: flex; }
.inline-form input[type=text] { flex: 1; max-width: 360px; }

.muted { color: #8a8f97; }
.alert {
    background: #3a1f21;
    border: 1px solid #6a3232;
    color: #ffb8b8;
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 13px;
}

/* ---- Login ---- */
.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 360px;
    background: #16181b;
    border: 1px solid #23262b;
    border-radius: 10px;
    padding: 32px;
}
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card label { display: block; margin: 18px 0 8px; font-size: 13px; color: #a8aeb6; }
.login-card label input { margin-top: 6px; }
.login-card .btn { margin-top: 18px; width: 100%; justify-content: center; }

/* ---- Cards / grid ---- */
.section { margin-bottom: 32px; }
.section h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: #a8aeb6; margin: 0 0 12px; }

.grid {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.card {
    background: #16181b;
    border: 1px solid #23262b;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    transition: border-color .15s, transform .15s;
}
.card:hover { border-color: #353b43; }
.card-body {
    display: block;
    padding: 14px;
    color: inherit;
}
.card-body:hover { text-decoration: none; }
.card-title { font-weight: 500; color: #fff; margin-top: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { font-size: 12px; color: #8a8f97; margin-top: 2px; }
.folder-icon { font-size: 36px; line-height: 1; opacity: 0.7; }
.video-thumb {
    position: relative;
    background: #0a0b0c;
    aspect-ratio: 16/9;
    border-radius: 4px;
    margin-bottom: 4px;
    overflow: hidden;
}
.video-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.video-thumb-fallback {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    font-size: 28px;
    color: #4a7fff;
    background: #0a0b0c;
}
.video-duration {
    position: absolute;
    right: 6px;
    bottom: 6px;
    background: rgba(0,0,0,0.75);
    color: #fff;
    font-family: ui-monospace, monospace;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    pointer-events: none;
}

.card-menu {
    position: absolute;
    top: 8px;
    right: 8px;
}
.card-menu summary {
    list-style: none;
    cursor: pointer;
    background: rgba(0,0,0,0.4);
    color: #fff;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
}
.card-menu summary::-webkit-details-marker { display: none; }
.card-menu[open] summary { background: rgba(0,0,0,0.7); }
.menu-form {
    position: absolute;
    right: 0;
    top: 30px;
    background: #1a1c1f;
    border: 1px solid #2f343a;
    border-radius: 6px;
    overflow: hidden;
    z-index: 10;
    min-width: 120px;
}
.menu-form + .menu-form { top: 60px; }
.menu-item {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: #e6e8eb;
    text-align: left;
    padding: 8px 12px;
    font-size: 13px;
}
.menu-item:hover { background: #23262b; }
.menu-item.danger { color: #ff7878; }

/* ---- Upload zone ---- */
.upload-zone {
    border: 2px dashed #2f343a;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 24px;
    transition: border-color .15s, background .15s;
}
.upload-zone.dragover {
    border-color: #4a7fff;
    background: rgba(74,127,255,0.06);
}
.upload-empty {
    text-align: center;
    color: #8a8f97;
    font-size: 13px;
    padding: 8px;
}
.upload-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}
.upload-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    background: #1a1c1f;
    padding: 10px 14px;
    border-radius: 6px;
    align-items: center;
}
.upload-name { font-size: 13px; color: #e6e8eb; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-status { font-size: 12px; color: #8a8f97; }
.upload-status.error { color: #ff7878; }
.upload-status.done { color: #6dd49a; }
.upload-bar {
    grid-column: 1 / -1;
    height: 4px;
    background: #2a2e34;
    border-radius: 2px;
    overflow: hidden;
}
.upload-bar-fill {
    height: 100%;
    background: #4a7fff;
    width: 0;
    transition: width 0.2s linear;
}

/* ---- Review layout (video page) ---- */
.review-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    align-items: flex-start;
}
@media (max-width: 1000px) {
    .review-layout { grid-template-columns: 1fr; }
}
.player-pane { min-width: 0; }
.video-wrap {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}
.video-wrap video {
    width: 100%;
    display: block;
    max-height: 70vh;
}
.timeline-markers {
    position: relative;
    height: 14px;
    background: #1a1c1f;
    margin-top: -1px;
}
.marker {
    position: absolute;
    top: 2px;
    width: 8px;
    height: 8px;
    background: #ffaa44;
    border-radius: 50%;
    transform: translateX(-50%);
    cursor: pointer;
    transition: transform .15s;
}
.marker.admin { background: #4a7fff; }
.marker:hover { transform: translateX(-50%) scale(1.4); }

.comment-compose {
    margin-top: 14px;
    background: #16181b;
    border: 1px solid #23262b;
    border-radius: 8px;
    padding: 12px;
}
.compose-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: flex-start;
}
.compose-meta {
    font-size: 12px;
    color: #8a8f97;
    margin-top: 8px;
}
.ts-button {
    background: #2a2e34;
    color: #ffaa44;
    border: 1px solid #3a3f47;
    border-radius: 6px;
    font-family: ui-monospace, monospace;
    font-size: 13px;
    padding: 7px 12px;
    font-weight: 600;
    white-space: nowrap;
}

/* ---- Sidebar / comments ---- */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.panel {
    background: #16181b;
    border: 1px solid #23262b;
    border-radius: 8px;
    overflow: hidden;
}
.panel-head {
    padding: 12px 16px;
    border-bottom: 1px solid #23262b;
}
.panel-head h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: #a8aeb6; }

.comments {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 60vh;
    overflow-y: auto;
}
.comments .empty { padding: 20px 16px; text-align: center; }
.comment {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid #1f2226;
    transition: background .15s;
}
.comment:last-child { border-bottom: none; }
.comment:hover { background: #1a1c1f; }
.comment.active { background: rgba(74,127,255,0.08); }
.comment-ts {
    align-self: flex-start;
    background: #2a2e34;
    color: #ffaa44;
    border: 1px solid #3a3f47;
    border-radius: 4px;
    font-family: ui-monospace, monospace;
    font-size: 11px;
    padding: 3px 7px;
    font-weight: 600;
}
.comment-body { min-width: 0; }
.comment-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}
.comment-author { font-weight: 600; font-size: 12px; color: #c9ced5; }
.comment-author.is-admin { color: #7cb6ff; }
.comment-text { font-size: 13px; word-wrap: break-word; }

/* ---- Share section in video page ---- */
.share-create { display: flex !important; padding: 12px 16px; border-bottom: 1px solid #23262b; }
.shares { list-style: none; padding: 0; margin: 0; }
.share-item { padding: 12px 16px; border-bottom: 1px solid #1f2226; }
.share-item:last-child { border-bottom: none; }
.share-label { font-size: 12px; color: #c9ced5; margin-bottom: 6px; }
.share-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.share-url {
    font-family: ui-monospace, monospace;
    font-size: 11px !important;
    padding: 5px 8px !important;
    flex: 1;
    min-width: 120px;
}

.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; padding: 12px 16px; font-size: 13px; margin: 0; }
.details dt { color: #8a8f97; }
.details dd { margin: 0; }

/* ---- Shares index table ---- */
.shares-table {
    width: 100%;
    border-collapse: collapse;
    background: #16181b;
    border: 1px solid #23262b;
    border-radius: 8px;
    overflow: hidden;
    font-size: 13px;
}
.shares-table th, .shares-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid #1f2226;
}
.shares-table tbody tr:last-child td { border-bottom: none; }
.shares-table th {
    background: #1a1c1f;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8a8f97;
    font-weight: 600;
}
.share-link-cell { display: flex; gap: 6px; align-items: center; min-width: 280px; }
.link { color: #7cb6ff; }

.empty-state { padding: 40px 0; text-align: center; }

/* ---- Public share page ---- */
.public-shell { max-width: 1400px; margin: 0 auto; padding: 24px; }
.public-head {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-bottom: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid #23262b;
}
.public-brand {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: -0.02em;
    color: #4a7fff;
    padding: 4px 8px;
    border: 1px solid #4a7fff;
    border-radius: 4px;
}
.public-title h1 { margin: 0; font-size: 18px; }
.who-name { color: #ffaa44; font-weight: 600; }

.name-dialog::backdrop { background: rgba(0,0,0,0.6); }
.name-dialog {
    background: #16181b;
    border: 1px solid #23262b;
    color: #e6e8eb;
    border-radius: 10px;
    padding: 24px;
    max-width: 380px;
    width: 90%;
}
.name-dialog h3 { margin: 0 0 4px; }
.name-dialog input { margin-top: 12px; }
.dialog-actions { margin-top: 14px; display: flex; justify-content: flex-end; }

.centered { min-height: 60vh; display: grid; place-items: center; text-align: center; }

/* ---- Toast ---- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1a1c1f;
    border: 1px solid #2f343a;
    color: #e6e8eb;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 100;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.inline { display: inline; }

/* ---- Resolved comments ---- */
.comment.resolved { opacity: 0.5; }
.comment.resolved .comment-text { text-decoration: line-through; text-decoration-color: rgba(255,255,255,0.25); }
.resolved-tag {
    background: #1f3a2a;
    color: #6dd49a;
    border: 1px solid #2b5740;
    border-radius: 3px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 5px;
    margin-left: 6px;
}
.marker.resolved { background: #555; opacity: 0.55; }

.comment-actions { display: flex; gap: 8px; }
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.panel-toggle {
    font-size: 12px;
    color: #8a8f97;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.panel-toggle input { accent-color: #4a7fff; }

/* ---- Move-to-folder + delete-video form ---- */
.move-form {
    padding: 10px 16px 4px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    border-top: 1px solid #1f2226;
}
.move-label {
    flex: 1;
    font-size: 12px;
    color: #8a8f97;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.move-label select {
    background: #1a1c1f;
    border: 1px solid #2f343a;
    color: #e6e8eb;
    padding: 6px 8px;
    border-radius: 6px;
    font: inherit;
}
.panel-foot-action {
    padding: 10px 16px 14px;
    display: block !important;
}
