:root {
    color-scheme: dark;
    --bg: #090b10;
    --panel: #121722;
    --panel-2: #181f2d;
    --line: #2a3446;
    --text: #edf3ff;
    --muted: #91a0b7;
    --blue: #46a6ff;
    --green: #3fd19b;
    --red: #ff667a;
    --amber: #f0b84f;
    --violet: #9a8cff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    border: 1px solid #3479bd;
    border-radius: 6px;
    background: #1c75bc;
    color: white;
    min-height: 38px;
    padding: 0 14px;
    cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
    opacity: .45;
    cursor: not-allowed;
}

input,
select {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #0c111a;
    color: var(--text);
    padding: 0 10px;
}

select {
    appearance: none;
}

.shell {
    display: grid;
    grid-template-columns: 310px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    border-right: 1px solid var(--line);
    background: #0d1119;
    padding: 18px;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--blue), var(--green));
    box-shadow: 0 0 24px rgba(70, 166, 255, .24);
}

.brand strong,
.brand small {
    display: block;
}

.brand small,
.empty-copy,
.eyebrow,
.media-meta span,
.media-meta p,
.empty-state p {
    color: var(--muted);
}

.side-section {
    margin-bottom: 28px;
}

.logout-form {
    margin-bottom: 28px;
}

.logout-form button,
.danger-form button,
.nav-row form button {
    width: 100%;
    border-color: rgba(255, 102, 122, .55);
    background: rgba(255, 102, 122, .14);
}

.section-title {
    margin-bottom: 10px;
    color: #c8d5ea;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.compact-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.nav-list {
    display: grid;
    gap: 6px;
}

.nav-list a,
.user-row {
    display: grid;
    gap: 3px;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text);
    padding: 10px 12px;
    text-decoration: none;
}

.user-row {
    color: var(--text);
}

.nav-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 82px;
    gap: 6px;
    align-items: stretch;
}

.nav-row form {
    display: grid;
}

.nav-row form button {
    min-height: 100%;
    padding: 0 8px;
    font-size: 12px;
}

.nav-list small {
    color: var(--muted);
}

.nav-list a:hover,
.nav-list a.active {
    border-color: var(--line);
    background: var(--panel-2);
}

.workspace {
    min-width: 0;
    padding: 22px;
    overflow-x: hidden;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.eyebrow {
    margin: 0 0 4px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: 34px;
    line-height: 1.05;
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: clamp(26px, 3vw, 42px);
    font-weight: 800;
    line-height: 1.05;
}

.breadcrumb a,
.breadcrumb span {
    color: var(--text);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--blue);
}

.breadcrumb a + a::before,
.breadcrumb a + span::before {
    content: "/";
    margin-right: 8px;
    color: var(--muted);
}

.breadcrumb span {
    color: var(--muted);
}

h2 {
    font-size: 16px;
}

.status-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.status-strip span {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    color: #c7d6ed;
    padding: 8px 12px;
}

.actions {
    display: grid;
    grid-template-columns: minmax(280px, 420px);
    gap: 14px;
    margin-bottom: 18px;
}

.topic-actions {
    max-width: 460px;
}

.action-panel,
.media-board,
.episode-strip {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.action-panel {
    padding: 14px;
}

.action-panel form,
.action-panel label {
    display: grid;
    gap: 8px;
}

.action-panel form {
    margin-top: 12px;
}

.drive-import-form {
    margin-top: 12px;
}

.drive-import-panel {
    border-color: #34597a;
    background: #101823;
}

.upload-status-panel {
    grid-column: 1 / -1;
}

.drop-zone {
    min-height: 112px;
    place-items: center;
    border: 1px dashed #3f5068;
    border-radius: 8px;
    background: #0d121b;
    color: #c9d7ea;
    padding: 16px;
    text-align: center;
}

.drop-zone.drag-over {
    border-color: var(--blue);
    background: #102035;
}

.drop-zone input {
    max-width: 100%;
}

.upload-status {
    display: grid;
    gap: 8px;
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #0d121b;
    padding: 9px;
}

.upload-status[hidden] {
    display: none;
}

.upload-status-line {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #c8d5ea;
    font-size: 13px;
}

.upload-status progress {
    width: 100%;
    height: 6px;
    accent-color: var(--blue);
}

.upload-status.done progress {
    accent-color: var(--green);
}

.upload-status.failed progress {
    accent-color: var(--amber);
}

.link-button {
    justify-self: start;
    min-height: 0;
    border: 0;
    background: transparent;
    color: var(--blue);
    padding: 0;
}

.upload-issues {
    display: grid;
    gap: 6px;
    max-height: 130px;
    overflow: auto;
    color: var(--muted);
    font-size: 13px;
}

.upload-issues[hidden] {
    display: none;
}

.upload-issues div {
    display: grid;
    gap: 2px;
}

.upload-issues strong {
    color: var(--text);
}

.search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin-top: 12px;
}

.sidebar-search {
    grid-template-columns: minmax(0, 1fr);
}

.library-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    max-height: 280px;
    margin-top: 12px;
    overflow: auto;
}

.sidebar .library-results {
    grid-template-columns: 1fr;
    max-height: 360px;
}

.library-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0d121b;
    overflow: hidden;
}

.library-item img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
}

.library-item div {
    display: grid;
    gap: 8px;
    padding: 10px;
}

.library-item strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-item small {
    color: var(--muted);
}

.board-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding: 14px;
}

.board-heading span {
    color: var(--muted);
}

.browser-section {
    display: grid;
    gap: 14px;
}

.browser-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.episode-tools {
    display: grid;
    grid-template-columns: minmax(300px, 1fr);
    gap: 12px;
    width: min(100%, 600px);
}

.topic-create-form {
    grid-template-columns: minmax(180px, 1fr) minmax(160px, 220px);
    justify-self: end;
    width: 100%;
}

.episode-drive-import {
    justify-self: end;
    width: 100%;
}

.inline-create {
    display: grid;
    grid-template-columns: minmax(140px, 180px) minmax(160px, 220px) auto auto;
    gap: 8px;
    align-items: center;
}

.compact-check {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    color: #c8d5ea;
    white-space: nowrap;
}

.compact-check input {
    width: auto;
    min-height: 0;
}

.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.folder-card {
    display: grid;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0d121b;
    overflow: hidden;
}

.folder-card a {
    display: grid;
    gap: 7px;
    min-height: 150px;
    color: var(--text);
    padding: 16px;
    text-decoration: none;
}

.folder-card a:hover {
    background: var(--panel-2);
}

.folder-card strong {
    overflow-wrap: anywhere;
    font-size: 22px;
}

.folder-card small,
.folder-card p {
    margin: 0;
    color: var(--muted);
}

.folder-card form {
    border-top: 1px solid var(--line);
    padding: 10px;
}

.folder-card form button {
    width: 100%;
    border-color: rgba(255, 102, 122, .55);
    background: rgba(255, 102, 122, .14);
}

.folder-icon {
    width: 54px;
    height: 38px;
    border: 1px solid rgba(70, 166, 255, .5);
    border-radius: 7px;
    background:
        linear-gradient(180deg, rgba(70, 166, 255, .18), rgba(63, 209, 155, .10)),
        #101724;
    position: relative;
}

.folder-icon::before {
    content: "";
    position: absolute;
    top: -7px;
    left: 7px;
    width: 23px;
    height: 8px;
    border: 1px solid rgba(70, 166, 255, .5);
    border-bottom: 0;
    border-radius: 5px 5px 0 0;
    background: #101724;
}

.episode-strip {
    margin-bottom: 18px;
}

.episode-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 8px;
    max-height: 220px;
    overflow: auto;
    padding: 14px;
}

.episode-list a {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 6px 8px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0d121b;
    color: var(--text);
    padding: 9px;
    text-decoration: none;
}

.episode-list strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.episode-list small {
    grid-column: 2 / 4;
    color: var(--muted);
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 14px;
    min-height: 280px;
    padding: 14px;
}

.media-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0d121b;
    overflow: hidden;
}

.media-card.dragging {
    opacity: .42;
}

.media-card img,
.video-thumb {
    width: 100%;
    aspect-ratio: 16 / 10;
    display: block;
    object-fit: cover;
    background: #05070b;
}

.video-thumb {
    display: grid;
    place-items: center;
    color: #d8e2f1;
    font-weight: 800;
    letter-spacing: .08em;
    background:
        linear-gradient(135deg, rgba(70, 166, 255, .22), transparent),
        #101724;
}

.media-meta {
    display: grid;
    gap: 4px;
    padding: 10px;
}

.media-meta strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-meta p {
    margin: 0;
}

.badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.type-badge,
.status-badge {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px 7px;
    color: #dce8f7;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.1;
    text-transform: uppercase;
}

.type-badge.image {
    border-color: rgba(63, 209, 155, .45);
    background: rgba(63, 209, 155, .12);
}

.type-badge.video {
    border-color: rgba(154, 140, 255, .5);
    background: rgba(154, 140, 255, .14);
}

.status-badge.ready,
.status-badge.uploaded {
    border-color: rgba(63, 209, 155, .45);
    background: rgba(63, 209, 155, .12);
}

.status-badge.processing,
.status-badge.uploading,
.status-badge.queued {
    border-color: rgba(70, 166, 255, .45);
    background: rgba(70, 166, 255, .13);
}

.status-badge.failed {
    border-color: rgba(255, 102, 122, .55);
    background: rgba(255, 102, 122, .13);
}

.status-message {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #ffb7c1;
}

.media-card form {
    padding: 0 10px 10px;
}

.media-card button,
.library-item button {
    width: 100%;
    border-color: #3a465a;
    background: #182233;
}

.empty-state {
    display: grid;
    place-items: center;
    align-content: center;
    min-height: 250px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    grid-column: 1 / -1;
    text-align: center;
}

.flash-stack {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 10;
    display: grid;
    gap: 8px;
}

.flash {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #131b28;
    padding: 10px 12px;
    box-shadow: 0 14px 36px rgba(0, 0, 0, .24);
}

.flash.success {
    border-color: rgba(63, 209, 155, .5);
}

.flash.error {
    border-color: rgba(255, 102, 122, .6);
}

.toast-stack {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 20;
    display: grid;
    gap: 8px;
}

.toast {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #131b28;
    color: var(--text);
    padding: 10px 12px;
    box-shadow: 0 14px 36px rgba(0, 0, 0, .24);
}

.toast.success {
    border-color: rgba(63, 209, 155, .5);
}

.toast.warning {
    border-color: rgba(240, 184, 79, .55);
}

.login-screen {
    grid-column: 1 / -1;
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 22px;
}

.login-panel {
    display: grid;
    gap: 14px;
    width: min(100%, 380px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 22px;
}

.login-panel label {
    display: grid;
    gap: 8px;
    color: #c8d5ea;
}

.settings-nav {
    margin-bottom: 28px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.settings-card,
.settings-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.settings-card {
    display: grid;
    gap: 6px;
    padding: 18px;
}

.settings-card strong {
    font-size: 34px;
}

.settings-card span,
.settings-list span,
.settings-list small {
    color: var(--muted);
}

.settings-panel {
    margin-bottom: 18px;
}

.settings-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 14px;
}

.settings-list {
    display: grid;
    gap: 10px;
    padding: 14px;
}

.settings-list article {
    display: grid;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0d121b;
    padding: 12px;
}

.settings-toggle-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

.settings-toggle-row form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.toggle-control {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #c8d5ea;
}

.settings-list.compact article {
    grid-template-columns: minmax(0, 1fr) 160px;
    align-items: center;
}

.settings-row-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

@media (max-width: 880px) {
    .settings-form,
    .settings-list.compact article,
    .settings-row-form {
        grid-template-columns: 1fr;
    }
}

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

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .topbar,
    .actions,
    .inline-create {
        grid-template-columns: 1fr;
        display: grid;
    }

    .settings-toggle-row {
        grid-template-columns: 1fr;
    }

    .settings-toggle-row form {
        justify-content: flex-start;
    }

    .status-strip {
        justify-content: flex-start;
    }

    .browser-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .episode-tools,
    .topic-create-form,
    .episode-drive-import {
        width: 100%;
    }
}
