:root {
    color-scheme: light;
    --bg: #f4f4f2;
    --panel: #ffffff;
    --panel-2: #ecece8;
    --text: #101113;
    --muted: #74777d;
    --line: rgba(16, 17, 19, 0.11);
    --line-strong: rgba(16, 17, 19, 0.2);
    --shadow: 0 20px 60px rgba(16, 17, 19, 0.12);
    --button: #111214;
    --button-text: #ffffff;
    --danger: #c82d42;
    --accent: linear-gradient(135deg, #1b6fff 0%, #88f6d2 24%, #fff7a8 43%, #ff7a4e 62%, #171719 84%, #ecedf4 100%);
    --accent-soft: linear-gradient(135deg, rgba(27, 111, 255, 0.22), rgba(136, 246, 210, 0.18), rgba(255, 122, 78, 0.22));
    --radius: 8px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #08090a;
    --panel: #141416;
    --panel-2: #1d1e21;
    --text: #f5f6f7;
    --muted: #a7aab2;
    --line: rgba(245, 246, 247, 0.12);
    --line-strong: rgba(245, 246, 247, 0.22);
    --shadow: 0 20px 70px rgba(0, 0, 0, 0.42);
    --button: #f5f6f7;
    --button-text: #101113;
    --danger: #ff5f74;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background:
        linear-gradient(125deg, transparent 0 44%, rgba(255, 122, 78, 0.09) 44% 54%, transparent 54%),
        linear-gradient(35deg, transparent 0 56%, rgba(27, 111, 255, 0.07) 56% 66%, transparent 66%),
        var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 38px 38px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent 70%);
}

button,
input,
textarea,
select {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    cursor: pointer;
}

input,
textarea,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--text);
    outline: none;
    padding: 0 13px;
}

textarea {
    resize: vertical;
    padding-block: 12px;
}

input:focus,
textarea:focus,
select:focus {
    border-color: transparent;
    box-shadow: 0 0 0 2px rgba(80, 150, 255, 0.6);
}

label span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.83rem;
    font-weight: 700;
}

.is-hidden {
    display: none !important;
}

.toast {
    position: fixed;
    z-index: 90;
    top: 18px;
    left: 50%;
    max-width: min(460px, calc(100vw - 32px));
    transform: translate(-50%, -120%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    color: var(--text);
    padding: 12px 14px;
    opacity: 0;
    transition: transform 180ms ease, opacity 180ms ease;
}

.toast.is-visible {
    transform: translate(-50%, 0);
    opacity: 1;
}

.login-view {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(440px, 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(var(--panel), var(--panel)) padding-box, var(--accent) border-box;
    box-shadow: var(--shadow);
    padding: 24px;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border-radius: var(--radius);
    background: var(--accent);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.38);
}

.brand-name {
    font-weight: 850;
}

.login-copy {
    margin: 46px 0 24px;
}

.eyebrow,
.panel-label {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    line-height: 1.04;
    letter-spacing: 0;
}

h1 {
    max-width: 8ch;
    font-size: 2.7rem;
}

h2 {
    font-size: 1.35rem;
}

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

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.check-row input {
    width: 18px;
    min-height: 18px;
}

.check-row span {
    margin: 0;
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 650;
}

.form-error {
    min-height: 20px;
    margin: 0;
    color: var(--danger);
    font-weight: 700;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
    min-height: 42px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    font-weight: 800;
    padding: 0 15px;
}

.primary-button {
    background: var(--button);
    color: var(--button-text);
}

.ghost-button {
    border-color: var(--line);
    background: var(--panel);
    color: var(--text);
}

.danger-button {
    background: var(--danger);
    color: #ffffff;
}

.icon-button {
    width: 42px;
    padding: 0;
    border-color: var(--line);
    background: var(--panel);
    color: var(--text);
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.icon-button:hover {
    transform: translateY(-1px);
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    border-right: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel) 92%, transparent);
    backdrop-filter: blur(18px);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-brand {
    min-height: 44px;
}

.nav-stack {
    display: grid;
    gap: 8px;
}

.nav-item,
.mobile-nav-item {
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    font-weight: 800;
}

.nav-item {
    min-height: 48px;
    display: grid;
    grid-template-columns: 32px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    text-align: left;
}

.nav-item strong {
    color: var(--muted);
    font-size: 0.78rem;
}

.nav-item.is-active,
.mobile-nav-item.is-active {
    border-color: var(--line);
    background: var(--panel-2);
    color: var(--text);
}

.nav-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--text);
    font-size: 0.72rem;
}

.side-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    padding: 14px;
}

.side-panel strong {
    display: block;
    font-size: 1.35rem;
}

.side-panel span {
    color: var(--muted);
    font-size: 0.88rem;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.collection-list {
    display: grid;
    gap: 6px;
    max-height: 220px;
    overflow: auto;
}

.collection-button {
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    min-height: 34px;
    padding: 0 8px;
    text-align: left;
    font-weight: 750;
}

.collection-button.is-active {
    background: var(--panel-2);
    color: var(--text);
}

.workspace {
    min-width: 0;
    padding: 20px 24px 36px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 0 0 16px;
    background: linear-gradient(to bottom, var(--bg) 0 72%, transparent);
}

.search-wrap {
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    display: grid;
    grid-template-columns: 42px 1fr;
    align-items: center;
    overflow: hidden;
}

.search-wrap span {
    display: grid;
    place-items: center;
    color: var(--muted);
    font-weight: 900;
}

.search-wrap input {
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.top-actions,
.toolbar-controls,
.modal-actions,
.drawer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.drawer-actions {
    flex-wrap: wrap;
}

.drawer-actions > * {
    flex: 1 1 auto;
}

.quick-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.quick-stats article {
    min-height: 92px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    padding: 14px;
    position: relative;
    overflow: hidden;
}

.quick-stats article::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 4px;
    background: var(--accent);
}

.quick-stats span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.quick-stats strong {
    display: block;
    margin-top: 12px;
    font-size: 2rem;
    line-height: 1;
}

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

.chip-row {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}

.chip {
    min-height: 36px;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--muted);
    font-weight: 800;
    padding: 0 12px;
}

.chip.is-active {
    background: var(--button);
    color: var(--button-text);
}

.bulk-bar {
    position: sticky;
    top: 64px;
    z-index: 18;
    min-height: 54px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: auto minmax(120px, 1fr) auto auto auto auto;
    align-items: center;
    gap: 8px;
    padding: 8px;
    margin-bottom: 14px;
}

.asset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
}

.asset-card {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    overflow: hidden;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.05);
}

.asset-card.is-selected {
    outline: 2px solid #3d8cff;
    outline-offset: 2px;
}

.asset-preview {
    position: relative;
    aspect-ratio: 4 / 5;
    background:
        linear-gradient(var(--panel-2), var(--panel-2)) padding-box,
        var(--accent) border-box;
    display: grid;
    place-items: center;
    overflow: hidden;
}

.asset-preview img,
.asset-preview video,
.detail-preview img,
.detail-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.asset-preview video {
    pointer-events: none;
}

.file-glyph {
    width: 70px;
    height: 92px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    background: var(--panel);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.asset-select,
.asset-favorite {
    position: absolute;
    top: 8px;
    z-index: 2;
}

.asset-select {
    left: 8px;
    width: 20px;
    min-height: 20px;
}

.asset-favorite {
    right: 8px;
    width: 32px;
    min-height: 32px;
    border: 1px solid rgba(255, 255, 255, 0.44);
    border-radius: var(--radius);
    background: rgba(0, 0, 0, 0.45);
    color: #ffffff;
}

.kind-badge {
    position: absolute;
    left: 8px;
    bottom: 8px;
    border-radius: var(--radius);
    background: rgba(0, 0, 0, 0.62);
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 900;
    padding: 5px 7px;
    text-transform: uppercase;
}

.asset-body {
    padding: 12px;
}

.asset-title {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    font-weight: 850;
    padding: 0;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.asset-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.asset-card-actions {
    margin-top: 10px;
    display: grid;
}

.asset-download {
    min-height: 36px;
    width: 100%;
    padding: 0 10px;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
}

.tag-pill {
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 800;
    padding: 4px 6px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asset-grid.is-list {
    grid-template-columns: 1fr;
}

.asset-grid.is-list .asset-card {
    display: grid;
    grid-template-columns: 108px minmax(0, 1fr);
}

.asset-grid.is-list .asset-preview {
    aspect-ratio: 1 / 1;
}

.asset-grid.is-list .asset-card-actions {
    max-width: 180px;
}

.empty-state {
    min-height: 48vh;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--panel) 78%, transparent);
    display: grid;
    place-items: center;
    align-content: center;
    gap: 16px;
    text-align: center;
    padding: 24px;
}

.empty-mark {
    width: 78px;
    height: 78px;
    border-radius: var(--radius);
    background: var(--accent);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.42);
    padding: 18px;
}

.modal-card {
    width: min(720px, 100%);
    max-height: calc(100dvh - 36px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 18px;
}

.modal-head,
.drawer-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.drop-zone {
    min-height: 220px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background: var(--accent-soft);
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    text-align: center;
    padding: 20px;
}

.drop-zone.is-over {
    border-color: #3d8cff;
    background: var(--panel-2);
}

.drop-zone input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.drop-zone span,
.drop-zone small {
    margin: 0;
}

.drop-mark {
    width: 54px;
    height: 54px;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    background: var(--button);
    color: var(--button-text);
    font-size: 1.4rem;
    font-weight: 900;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.file-queue {
    display: grid;
    gap: 8px;
    max-height: 160px;
    overflow: auto;
    margin: 14px 0;
}

.queue-item {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
}

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

.queue-item span {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 750;
}

.progress-track {
    height: 8px;
    border-radius: var(--radius);
    background: var(--panel-2);
    overflow: hidden;
    margin-bottom: 14px;
}

.progress-track span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--accent);
    transition: width 120ms ease;
}

.detail-drawer {
    position: fixed;
    z-index: 50;
    top: 0;
    right: 0;
    width: min(440px, 100%);
    height: 100dvh;
    overflow: auto;
    border-left: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 16px;
}

.detail-preview {
    aspect-ratio: 4 / 5;
    border-radius: var(--radius);
    background: var(--panel-2);
    overflow: hidden;
    display: grid;
    place-items: center;
    margin-bottom: 16px;
}

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

.metadata-list {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 7px 12px;
    margin: 4px 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.metadata-list dt {
    font-weight: 850;
}

.metadata-list dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.mobile-nav {
    display: none;
}

@media (max-width: 980px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        display: none;
    }

    .workspace {
        padding: 14px 14px calc(82px + var(--safe-bottom));
    }

    .topbar {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .top-actions {
        justify-content: stretch;
    }

    .top-actions .primary-button,
    .top-actions .ghost-button {
        flex: 1;
    }

    .quick-stats {
        grid-template-columns: repeat(4, minmax(78px, 1fr));
        overflow-x: auto;
    }

    .quick-stats article {
        min-width: 78px;
    }

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

    .toolbar-controls {
        display: grid;
        grid-template-columns: 1fr 42px;
    }

    .bulk-bar {
        top: 118px;
        grid-template-columns: 1fr auto auto auto;
    }

    .bulk-bar input {
        grid-column: 1 / -1;
    }

    .asset-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .asset-grid.is-list .asset-card {
        grid-template-columns: 92px minmax(0, 1fr);
    }

    .mobile-nav {
        position: fixed;
        z-index: 30;
        left: 10px;
        right: 10px;
        bottom: calc(10px + var(--safe-bottom));
        min-height: 62px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: color-mix(in srgb, var(--panel) 92%, transparent);
        backdrop-filter: blur(18px);
        box-shadow: var(--shadow);
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
        padding: 6px;
    }

    .mobile-nav-item {
        display: grid;
        gap: 2px;
        place-items: center;
        min-height: 48px;
        font-size: 0.72rem;
    }

    .mobile-nav-item span {
        font-size: 0.8rem;
    }
}

@media (max-width: 560px) {
    h1 {
        font-size: 2.2rem;
    }

    .login-panel {
        padding: 20px;
    }

    .top-actions {
        display: grid;
        grid-template-columns: 42px 1fr 1fr;
    }

    .quick-stats strong {
        font-size: 1.55rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .modal {
        padding: 10px;
    }

    .modal-card {
        max-height: calc(100dvh - 20px);
    }

    .detail-drawer {
        border-left: 0;
    }
}
