:root {
    color-scheme: dark;
    --bg: #090b10;
    --panel: rgba(20, 24, 33, 0.88);
    --panel-strong: #151924;
    --border: rgba(255, 255, 255, 0.1);
    --text: #f4f7fb;
    --muted: #98a2b3;
    --accent: #70e1b2;
    --accent-strong: #35c98d;
    --blue: #7aa7ff;
    --danger: #ff7a8a;
    --warning: #f5c76b;
    --radius: 18px;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: radial-gradient(circle at 15% 0%, #142421 0, transparent 35%),
                radial-gradient(circle at 90% 15%, #151d37 0, transparent 34%),
                var(--bg);
    overflow-x: hidden;
}

button,
input,
select {
    font: inherit;
}

a {
    color: inherit;
}

.ambient {
    position: fixed;
    z-index: -1;
    width: 28rem;
    height: 28rem;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.12;
    pointer-events: none;
}

.ambient-one {
    top: -15rem;
    left: -10rem;
    background: var(--accent);
}

.ambient-two {
    right: -16rem;
    bottom: -12rem;
    background: var(--blue);
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 26px 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    font-size: 0.93rem;
    font-weight: 750;
    letter-spacing: 0.02em;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 35px;
    height: 35px;
    place-items: center;
    border: 1px solid rgba(112, 225, 178, 0.48);
    border-radius: 10px;
    color: var(--accent);
    background: rgba(112, 225, 178, 0.08);
}

.text-button {
    border: 0;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}

.text-button:hover {
    color: var(--text);
}

.auth-layout {
    display: grid;
    min-height: calc(100vh - 105px);
    padding: 8vh 20px 14vh;
    place-items: start center;
}

.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.login-panel,
.setup-panel {
    width: min(100%, 480px);
    padding: clamp(28px, 6vw, 48px);
}

.setup-panel code {
    display: block;
    margin-top: 22px;
    padding: 14px;
    overflow-wrap: anywhere;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--accent);
    background: #0a0d12;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.17em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: -0.045em;
}

h1 {
    font-size: clamp(2.3rem, 7vw, 4.8rem);
    line-height: 0.98;
}

.login-panel h1,
.setup-panel h1 {
    font-size: clamp(2.25rem, 9vw, 3.5rem);
}

h2 {
    font-size: clamp(1.65rem, 4vw, 2.25rem);
}

.lede {
    max-width: 670px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: clamp(1rem, 2vw, 1.13rem);
    line-height: 1.65;
}

.stack {
    display: grid;
    gap: 18px;
    margin-top: 30px;
}

label > span:first-child,
legend {
    display: block;
    margin-bottom: 8px;
    color: #d4d9e2;
    font-size: 0.83rem;
    font-weight: 700;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="search"],
select {
    width: 100%;
    min-height: 50px;
    padding: 0 15px;
    border: 1px solid var(--border);
    border-radius: 11px;
    outline: none;
    color: var(--text);
    background: rgba(4, 6, 10, 0.62);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus {
    border-color: rgba(112, 225, 178, 0.7);
    box-shadow: 0 0 0 4px rgba(112, 225, 178, 0.1);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 11px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    color: #06110d;
    background: var(--accent);
}

.button-primary:hover {
    background: #8debc5;
}

.button-secondary {
    border-color: var(--border);
    color: var(--text);
    background: transparent;
}

.button-small {
    min-height: 34px;
    padding: 0 11px;
    border-radius: 8px;
    font-size: 0.78rem;
}

.dashboard {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 4vh 0 80px;
}

.dashboard h1 {
    font-size: clamp(2rem, 4vw, 3.1rem);
}

.dashboard h2 {
    font-size: 1.35rem;
}

.hero {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 42px;
}

.worker-indicator {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 9px;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.78rem;
    background: rgba(255, 255, 255, 0.03);
}

.pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 5px rgba(112, 225, 178, 0.1);
}

.notice {
    margin: 0 0 18px;
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: 11px;
    font-size: 0.9rem;
}

.notice-success {
    border-color: rgba(112, 225, 178, 0.3);
    color: #b9f4dc;
    background: rgba(112, 225, 178, 0.08);
}

.notice-error {
    border-color: rgba(255, 122, 138, 0.32);
    color: #ffc3ca;
    background: rgba(255, 122, 138, 0.08);
}

.create-panel {
    position: relative;
    z-index: 4;
    overflow: visible;
    padding: clamp(20px, 4vw, 30px);
}

.create-form {
    display: grid;
    grid-template-columns: minmax(250px, 1fr) auto auto;
    align-items: end;
    gap: 20px;
}

.upload-form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.2fr) auto;
    align-items: end;
    gap: 16px;
    margin-top: 22px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}

.upload-form input[type="file"] {
    width: 100%;
    min-height: 50px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 11px;
    color: var(--muted);
    background: rgba(4, 6, 10, 0.62);
}

.upload-form button {
    min-height: 50px;
}

.upload-note {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--muted);
    font-size: 0.78rem;
}

.format-picker {
    display: flex;
    gap: 8px;
    min-width: 225px;
    margin: 0;
    padding: 0;
    border: 0;
}

.format-picker legend {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.format-picker label {
    position: relative;
    flex: 1;
    cursor: pointer;
}

.format-picker input {
    position: absolute;
    opacity: 0;
}

.format-picker label > span {
    display: grid;
    min-height: 72px;
    margin: 0;
    padding: 13px;
    align-content: center;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(4, 6, 10, 0.55);
}

.format-picker input:checked + span {
    border-color: rgba(112, 225, 178, 0.65);
    background: rgba(112, 225, 178, 0.09);
    box-shadow: inset 0 0 0 1px rgba(112, 225, 178, 0.18);
}

.format-picker strong {
    font-size: 0.9rem;
}

.format-picker small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.7rem;
}

.url-field input,
.enqueue-button {
    min-height: 72px;
}

.url-search {
    position: relative;
    min-width: 0;
}

.search-menu {
    position: fixed;
    z-index: 80;
    max-height: min(360px, 60vh);
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #161b27;
    box-shadow: var(--shadow);
}

.search-result {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border-bottom: 1px solid var(--border);
}

.search-result:last-child {
    border-bottom: 0;
}

.search-result.active,
.search-result:hover {
    background: rgba(112, 225, 178, 0.1);
}

.search-result-main.no-thumb {
    grid-template-columns: minmax(0, 1fr);
}

.search-result-main {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    width: 100%;
    min-height: 62px;
    padding: 4px;
    border: 0;
    color: var(--text);
    text-align: left;
    background: transparent;
    cursor: pointer;
}

.search-result-main img {
    width: 96px;
    height: 54px;
    max-width: 96px;
    max-height: 54px;
    object-fit: cover;
    border-radius: 6px;
    background: #0e121a;
}

.search-result-title {
    min-width: 0;
    overflow: hidden;
    font-size: 0.88rem;
    line-height: 1.3;
}

.search-result-preview {
    margin-right: 4px;
}

.search-empty {
    padding: 14px 16px;
    color: var(--muted);
    font-size: 0.85rem;
}

.media-card.is-highlighted {
    border-color: rgba(112, 225, 178, 0.7);
    box-shadow: 0 0 0 3px rgba(112, 225, 178, 0.16);
}

.video-preview {
    position: fixed;
    z-index: 90;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
}

.video-preview[hidden] {
    display: none;
}

.video-preview-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(5, 7, 12, 0.76);
    cursor: pointer;
}

.video-preview-dialog {
    position: relative;
    z-index: 1;
    width: min(920px, 100%);
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #121722;
    box-shadow: var(--shadow);
}

.video-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.video-preview-bar h2 {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 1rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.video-preview-stage {
    overflow: hidden;
    border-radius: 10px;
    background: #000;
}

.video-preview-frame,
.video-preview-player {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    background: #000;
}

audio.video-preview-player {
    height: 64px;
    aspect-ratio: auto;
}

.library-tools {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.media-search {
    min-width: 0;
}

.media-search input {
    width: min(320px, 100%);
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 11px;
    color: var(--text);
    background: rgba(4, 6, 10, 0.72);
}

.jobs-section {
    margin-top: 62px;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.refresh-status {
    color: var(--muted);
    font-size: 0.76rem;
}

.table-wrap {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(12, 15, 22, 0.72);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 0.67rem;
    font-weight: 800;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

td {
    font-size: 0.87rem;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.mobile-label {
    display: none;
}

.format-badge,
.status {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: 0.69rem;
    font-weight: 800;
    letter-spacing: 0.05em;
}

.format-badge {
    padding: 5px 8px;
    color: #c7d7ff;
    background: rgba(122, 167, 255, 0.11);
}

.status::before {
    width: 6px;
    height: 6px;
    margin-right: 7px;
    border-radius: 50%;
    content: "";
    background: currentColor;
}

.status-queued {
    color: var(--warning);
}

.status-running {
    color: var(--blue);
}

.status-done {
    color: var(--accent);
}

.status-failed {
    color: var(--danger);
}

.progress {
    width: 150px;
    height: 3px;
    margin-top: 9px;
    overflow: hidden;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
}

.progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 300ms ease;
}

td small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
}

time {
    color: var(--muted);
    white-space: nowrap;
}

.job-action {
    display: flex;
    align-items: center;
    gap: 7px;
}

.error-detail {
    display: block;
    max-width: 250px;
    overflow: hidden;
    color: #f5abb4;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.muted,
.empty-row td {
    color: var(--muted);
}

.empty-row td {
    padding: 48px 20px;
    text-align: center;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 20;
    padding: 12px 16px;
    border: 1px solid rgba(112, 225, 178, 0.3);
    border-radius: 10px;
    color: #d7ffef;
    background: #17251f;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 860px) {
    .create-form,
    .upload-form {
        grid-template-columns: 1fr;
    }

    .enqueue-button {
        min-height: 54px;
    }

    .format-picker {
        width: 100%;
    }

    .hero {
        align-items: start;
        flex-direction: column;
    }

    .table-wrap {
        overflow: visible;
        border: 0;
        background: transparent;
    }

    thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    table,
    tbody,
    tr,
    td {
        display: block;
        width: 100%;
    }

    tbody {
        display: grid;
        gap: 12px;
    }

    tbody tr {
        padding: 18px;
        border: 1px solid var(--border);
        border-radius: 14px;
        background: rgba(12, 15, 22, 0.72);
    }

    td {
        padding: 7px 0;
        border: 0;
    }

    td:first-child {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .mobile-label {
        display: inline;
        color: var(--muted);
        font-size: 0.7rem;
        text-transform: uppercase;
    }

    .job-action {
        padding-top: 13px;
    }

    .empty-row {
        text-align: center;
    }
}

@media (max-width: 520px) {
    .site-header,
    .dashboard {
        width: min(100% - 26px, 1180px);
    }

    .dashboard {
        padding-top: 4vh;
    }

    .auth-layout {
        padding-right: 13px;
        padding-left: 13px;
    }

    .section-heading {
        align-items: start;
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.library-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 28px;
    margin-top: 62px;
    align-items: start;
}

.playlist-panel {
    position: sticky;
    top: 22px;
    padding: 22px;
}

.playlist-panel h2 {
    font-size: 1.55rem;
}

.playlist-create-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin: 22px 0;
}

.playlist-create-form input {
    min-width: 0;
    min-height: 40px;
}

.playlist-nav {
    display: grid;
    gap: 5px;
}

.playlist-nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    padding: 10px 11px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--muted);
    text-decoration: none;
}

.playlist-nav a:hover,
.playlist-nav a.active {
    border-color: var(--border);
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.playlist-nav a.active {
    border-color: rgba(112, 225, 178, 0.3);
    background: rgba(112, 225, 178, 0.08);
}

.playlist-nav span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.playlist-nav small {
    flex: 0 0 auto;
    margin-left: 10px;
    color: var(--muted);
}

.playlist-settings {
    display: grid;
    gap: 15px;
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.playlist-settings form:first-child {
    display: grid;
    gap: 9px;
}

.playlist-settings input {
    min-height: 42px;
}

.danger-text {
    color: var(--danger);
}

.media-library {
    min-width: 0;
}

.media-grid {
    display: grid;
    gap: 10px;
}

.media-card {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    align-items: start;
    gap: 14px;
    min-width: 0;
    padding: 10px;
    overflow: visible;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(12, 15, 22, 0.76);
}

.media-artwork {
    position: relative;
    display: grid;
    width: 112px;
    height: 63px;
    max-width: 112px;
    max-height: 63px;
    place-items: center;
    overflow: hidden;
    border-radius: 8px;
    background: #0e121a;
}

.media-artwork img {
    display: block;
    width: 112px;
    height: 63px;
    max-width: 112px;
    max-height: 63px;
    object-fit: cover;
    object-position: center;
}

.artwork-placeholder {
    color: var(--accent);
    font-size: 1.05rem;
    font-weight: 800;
}

.media-artwork .format-badge {
    position: absolute;
    right: 4px;
    bottom: 4px;
    padding: 2px 5px;
    color: #e8efff;
    background: rgba(8, 11, 17, 0.82);
}

.media-lists {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-width: 0;
}

.list-chip {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    max-width: 100%;
    min-width: min-content;
    min-height: 24px;
    padding: 1px 8px;
    border: 1px solid rgba(112, 225, 178, 0.28);
    border-radius: 999px;
    color: var(--accent);
    background: rgba(112, 225, 178, 0.08);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.3;
    text-decoration: none;
    white-space: nowrap;
}

.list-chip.is-current {
    border-color: rgba(112, 225, 178, 0.75);
}

.list-chip.is-empty {
    border-color: var(--border);
    color: var(--muted);
    background: transparent;
    font-weight: 600;
}

.media-card-body {
    display: grid;
    gap: 7px;
    min-width: 0;
    min-height: min-content;
    overflow: visible;
}

.media-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
}

.media-heading h3 {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 0.98rem;
    font-weight: 750;
    line-height: 1.3;
    letter-spacing: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-meta,
.media-phase {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
    margin: 0;
    color: var(--muted);
    font-size: 0.75rem;
}

.media-card .progress {
    width: min(100%, 220px);
    margin: 0;
}

.media-card .error-detail {
    max-width: none;
    margin: 0;
    white-space: normal;
}

.media-toolbar,
.inline-form,
.add-playlist-form {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
    margin: 0;
}

.add-playlist-form select {
    width: min(180px, 100%);
    min-height: 34px;
    padding: 0 8px;
}

.button-danger {
    border-color: rgba(255, 122, 138, 0.4);
    color: #ffd0d6;
    background: rgba(255, 122, 138, 0.08);
}

.icon-button {
    display: inline-grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: transparent;
    cursor: pointer;
}

.icon-button:hover:not(:disabled) {
    border-color: rgba(112, 225, 178, 0.42);
    color: var(--accent);
}

.icon-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.empty-library {
    grid-column: 1 / -1;
    padding: 56px 20px;
    border: 1px dashed var(--border);
    border-radius: 15px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 980px) {
    .library-layout {
        grid-template-columns: 1fr;
    }

    .playlist-panel {
        position: static;
    }

    .playlist-nav {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}

@media (max-width: 640px) {
    .media-card {
        grid-template-columns: 96px minmax(0, 1fr);
        align-items: start;
    }

    .media-artwork,
    .media-artwork img {
        width: 96px;
        height: 54px;
        max-width: 96px;
        max-height: 54px;
    }

    .library-tools {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
    }

    .media-search input {
        width: 100%;
    }
}
