:root {
    --bg: #edf3eb;
    --bg-deep: #dfe9de;
    --surface: rgba(255, 255, 252, 0.92);
    --surface-strong: rgba(255, 255, 255, 0.97);
    --surface-soft: rgba(243, 247, 240, 0.86);
    --line: rgba(23, 42, 31, 0.1);
    --line-strong: rgba(23, 42, 31, 0.18);
    --text: #18211b;
    --muted: #5b6b61;
    --accent: #1d7f56;
    --accent-strong: #13543a;
    --accent-soft: rgba(29, 127, 86, 0.12);
    --danger: #b04131;
    --danger-strong: #8d3022;
    --shadow-lg: 0 28px 70px rgba(33, 58, 43, 0.14);
    --shadow-md: 0 16px 38px rgba(28, 47, 36, 0.1);
    --radius-xl: 30px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Bahnschrift", "Segoe UI Variable", "Trebuchet MS", sans-serif;
    color: var(--text);
    background:
        radial-gradient(
            circle at top left,
            rgba(244, 187, 92, 0.2),
            transparent 28%
        ),
        radial-gradient(
            circle at 88% 14%,
            rgba(29, 127, 86, 0.16),
            transparent 24%
        ),
        linear-gradient(180deg, #f5f8f2 0%, var(--bg) 36%, var(--bg-deep) 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.16) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.16), transparent 70%);
    opacity: 0.32;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
.upload-zone:focus-visible {
    outline: 3px solid rgba(29, 127, 86, 0.24);
    outline-offset: 2px;
}

.hidden {
    display: none !important;
}

.shell {
    position: relative;
    min-height: 100vh;
    overflow-x: hidden;
}

.ambient {
    position: absolute;
    border-radius: 999px;
    filter: blur(22px);
    opacity: 0.72;
    pointer-events: none;
}

.ambient-a {
    top: -90px;
    left: -40px;
    width: 280px;
    height: 280px;
    background: rgba(240, 162, 70, 0.22);
}

.ambient-b {
    right: -60px;
    top: 90px;
    width: 360px;
    height: 360px;
    background: rgba(29, 127, 86, 0.18);
}

.layout {
    position: relative;
    z-index: 1;
    width: min(1360px, calc(100% - 32px));
    margin: 0 auto;
    padding: 36px 0 56px;
    display: grid;
    gap: 20px;
}

body.is-authenticated .layout {
    padding-top: 22px;
}

.hero {
    display: grid;
    gap: 12px;
    padding: 16px 4px 8px;
    max-width: 760px;
    animation: fade-up 420ms ease;
}

body.is-authenticated .hero {
    display: none;
}

.eyebrow {
    margin: 0;
    font-size: 12px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent);
}

.hero h1,
.panel h2,
.gallery-head h3,
.dialog h3 {
    margin: 0;
    font-family: "Rockwell", "Georgia", serif;
    letter-spacing: 0.01em;
}

.hero h1 {
    font-size: clamp(42px, 8vw, 76px);
    line-height: 0.95;
}

.hero-copy {
    margin: 0;
    font-size: 18px;
    line-height: 1.7;
    color: var(--muted);
}

.panel {
    padding: 24px;
    border-radius: var(--radius-xl);
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.97),
        rgba(247, 250, 245, 0.88)
    );
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(14px);
}

.auth-panel {
    max-width: 520px;
}

.app-panel {
    overflow: hidden;
    display: grid;
    gap: 18px;
}

.panel-head,
.gallery-head,
.app-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.app-head {
    padding: 20px 22px;
    border-radius: 26px;
    background:
        linear-gradient(
            135deg,
            rgba(20, 42, 31, 0.96),
            rgba(29, 127, 86, 0.88)
        ),
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent);
    color: white;
}

.app-head h2 {
    font-size: clamp(28px, 3vw, 40px);
}

.app-head .subtle {
    color: rgba(255, 255, 255, 0.78);
    max-width: 760px;
}

.app-head .secondary,
.app-head .ghost {
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
}

.auth-form,
.dialog-body {
    display: grid;
    gap: 16px;
}

.auth-form {
    margin-top: 18px;
    max-width: 420px;
}

.overview-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.overview-card {
    display: grid;
    gap: 10px;
    padding: 18px 18px 16px;
    border-radius: 24px;
    background: var(--surface-soft);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.64);
}

.overview-card-path {
    background:
        linear-gradient(
            135deg,
            rgba(29, 127, 86, 0.12),
            rgba(244, 187, 92, 0.12)
        ),
        var(--surface-strong);
}

.overview-label {
    font-size: 12px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
}

.overview-card strong {
    font-size: clamp(20px, 2vw, 28px);
    line-height: 1.2;
    word-break: break-word;
}

.toolbar {
    display: grid;
    grid-template-columns:
        minmax(280px, 1.6fr)
        minmax(180px, 0.78fr)
        minmax(170px, 0.72fr)
        minmax(240px, 1fr);
    gap: 14px;
    padding: 18px;
    border-radius: 26px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    align-items: start;
}

label {
    display: grid;
    gap: 8px;
}

.field {
    min-width: 0;
}

.field > span {
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

.field-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.field-hint {
    color: var(--muted);
    line-height: 1.45;
    font-size: 13px;
}

input[type="text"],
input[type="search"],
input[type="password"],
select {
    width: 100%;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(22, 40, 29, 0.12);
    background: rgba(255, 255, 255, 0.94);
    color: var(--text);
    transition:
        border-color 120ms ease,
        box-shadow 120ms ease,
        transform 120ms ease;
}

input[type="text"]:focus,
input[type="search"]:focus,
input[type="password"]:focus,
select:focus {
    outline: none;
    border-color: rgba(29, 127, 86, 0.44);
    box-shadow: 0 0 0 4px rgba(29, 127, 86, 0.1);
    transform: translateY(-1px);
}

.primary,
.secondary,
.ghost,
.danger {
    border: 1px solid transparent;
    padding: 12px 16px;
    border-radius: 14px;
    transition:
        transform 120ms ease,
        opacity 120ms ease,
        background 120ms ease,
        border-color 120ms ease,
        box-shadow 120ms ease;
}

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

.primary {
    color: white;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    box-shadow: 0 10px 24px rgba(29, 127, 86, 0.22);
}

.secondary {
    color: var(--text);
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(22, 40, 29, 0.1);
}

.ghost {
    color: var(--text);
    background: rgba(22, 40, 29, 0.06);
    border-color: rgba(22, 40, 29, 0.08);
}

.danger {
    color: white;
    background: linear-gradient(135deg, var(--danger), var(--danger-strong));
    box-shadow: 0 10px 24px rgba(176, 65, 49, 0.18);
}

.badge,
.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 9px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(22, 40, 29, 0.08);
    color: var(--muted);
    font-size: 13px;
}

.subtle {
    margin: 0;
    color: var(--muted);
}

.actions,
.stats,
.upload-actions,
.file-actions,
.dialog-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.stats {
    justify-content: flex-end;
}

.stats .pill {
    max-width: 100%;
}

.workspace-shell {
    display: grid;
    grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    max-height: min(80vh, 980px);
}

.directory-sidebar,
.workspace-main {
    min-height: 0;
}

.directory-sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    display: grid;
    gap: 16px;
    padding: 20px;
    border-radius: 28px;
    background:
        linear-gradient(
            180deg,
            rgba(245, 250, 244, 0.94),
            rgba(234, 241, 232, 0.92)
        ),
        rgba(255, 255, 255, 0.76);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md);
    max-height: inherit;
    overflow: auto;
}

.directory-sidebar-head {
    display: grid;
    gap: 4px;
}

.directory-current {
    display: grid;
    gap: 8px;
    padding: 16px 18px;
    border-radius: 20px;
    background:
        linear-gradient(
            135deg,
            rgba(29, 127, 86, 0.1),
            rgba(255, 255, 255, 0.9)
        ),
        rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(29, 127, 86, 0.12);
}

.directory-current-label {
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

#directory-current-path {
    font-size: 18px;
    line-height: 1.35;
    word-break: break-all;
}

.directory-toolbar {
    display: grid;
    gap: 12px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.breadcrumb button {
    padding: 8px 12px;
    border: 1px solid rgba(22, 40, 29, 0.08);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
}

.breadcrumb-sep {
    color: var(--muted);
    font-size: 13px;
}

.directory-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    max-height: min(54vh, 560px);
    overflow: auto;
    padding-right: 4px;
}

.directory-card {
    display: grid;
    gap: 6px;
    padding: 14px 16px;
    border: 1px solid rgba(22, 40, 29, 0.08);
    border-radius: 18px;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.98),
        rgba(239, 244, 238, 0.92)
    );
    text-align: left;
    transition:
        transform 120ms ease,
        border-color 120ms ease,
        box-shadow 120ms ease;
}

.directory-card:hover {
    transform: translateX(4px);
    border-color: rgba(29, 127, 86, 0.22);
    box-shadow: 0 10px 26px rgba(29, 127, 86, 0.08);
}

.directory-card strong {
    font-size: 15px;
}

.directory-card span {
    color: var(--muted);
    font-size: 13px;
    word-break: break-all;
}

.directory-empty {
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px dashed rgba(22, 40, 29, 0.12);
}

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

.workspace-main {
    display: grid;
    gap: 18px;
    padding-right: 6px;
    overflow: auto;
    max-height: inherit;
    overscroll-behavior: contain;
}

.upload-zone {
    padding: 26px;
    border-radius: 28px;
    border: 1.5px dashed rgba(29, 127, 86, 0.26);
    background:
        radial-gradient(
            circle at top right,
            rgba(244, 187, 92, 0.18),
            transparent 34%
        ),
        linear-gradient(
            135deg,
            rgba(255, 255, 255, 0.96),
            rgba(239, 245, 238, 0.92)
        );
    display: grid;
    grid-template-columns: minmax(280px, 1.25fr) auto auto;
    align-items: center;
    gap: 18px;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.66);
    transition:
        border-color 120ms ease,
        transform 120ms ease,
        box-shadow 120ms ease;
}

.upload-zone.dragging {
    border-color: rgba(29, 127, 86, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 18px 36px rgba(29, 127, 86, 0.12);
}

.upload-zone.is-busy {
    cursor: progress;
}

.upload-copy {
    display: grid;
    gap: 8px;
}

.upload-copy strong {
    font-size: clamp(24px, 2.2vw, 32px);
    line-height: 1.1;
}

.upload-copy p {
    margin: 0;
    max-width: 680px;
    color: var(--muted);
    line-height: 1.55;
}

.upload-copy .eyebrow {
    color: var(--accent);
    max-width: none;
}

.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(22, 40, 29, 0.08);
    font-size: 14px;
    color: var(--muted);
}

.inline-check input {
    width: 16px;
    height: 16px;
    margin: 0;
    transform: none !important;
}

.upload-list {
    display: grid;
    gap: 10px;
}

.upload-item {
    display: grid;
    grid-template-columns: minmax(240px, 340px) 1fr auto;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(22, 40, 29, 0.08);
}

.upload-main {
    min-width: 0;
}

.upload-main strong {
    display: block;
    word-break: break-all;
}

.upload-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.upload-item.done {
    border-left: 4px solid rgba(29, 127, 86, 0.78);
}

.upload-item.error {
    border-left: 4px solid rgba(176, 65, 49, 0.82);
}

.upload-status {
    margin: 6px 0 0;
    color: var(--muted);
}

.progress {
    position: relative;
    align-self: center;
    height: 10px;
    border-radius: 999px;
    background: rgba(22, 40, 29, 0.08);
    overflow: hidden;
}

.progress-value {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    background: linear-gradient(
        90deg,
        rgba(29, 127, 86, 0.84),
        rgba(244, 187, 92, 0.9)
    );
    border-radius: inherit;
}

.gallery-head {
    margin-top: 2px;
    padding: 6px 2px 0;
}

.batch-bar {
    position: sticky;
    top: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(22, 40, 29, 0.08);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 24px rgba(28, 47, 36, 0.08);
}

.gallery {
    position: relative;
    display: block;
    min-height: 0;
}

.file-card {
    position: relative;
    display: grid;
    gap: 10px;
    padding: 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(22, 40, 29, 0.08);
    box-shadow: 0 12px 28px rgba(28, 47, 36, 0.06);
    content-visibility: auto;
    contain-intrinsic-size: 340px;
    overflow: hidden;
    transition:
        transform 120ms ease,
        box-shadow 120ms ease,
        border-color 120ms ease;
}

.gallery.virtualized .file-card {
    position: absolute;
}

.file-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 36px rgba(28, 47, 36, 0.1);
    border-color: rgba(29, 127, 86, 0.14);
}

.file-card.selected {
    border-color: rgba(29, 127, 86, 0.4);
    box-shadow:
        inset 0 0 0 1px rgba(29, 127, 86, 0.18),
        0 18px 36px rgba(28, 47, 36, 0.1);
}

.file-card.pending {
    opacity: 0.74;
}

.file-select-wrap {
    position: absolute;
    left: 10px;
    top: 10px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(22, 40, 29, 0.08);
    color: var(--muted);
    font-size: 12px;
    box-shadow: 0 6px 12px rgba(28, 47, 36, 0.08);
}

.file-select {
    width: 15px;
    height: 15px;
    margin: 0;
    transform: none !important;
}

.thumb {
    padding: 0;
    border: none;
    background: transparent;
}

.thumb img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 16px;
    display: block;
    background: rgba(22, 40, 29, 0.05);
    transition: transform 120ms ease;
}

.thumb:hover img {
    transform: scale(1.01);
}

.file-meta {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.meta-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.file-name {
    font-size: 16px;
    line-height: 1.2;
    min-height: calc(1.2em * 2);
    word-break: break-word;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.file-size {
    flex-shrink: 0;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(29, 127, 86, 0.08);
    color: var(--accent-strong);
    font-size: 11px;
    font-weight: 700;
}

.file-key {
    margin: 0;
    color: var(--muted);
    word-break: break-all;
    font-size: 12px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
}

.file-extra {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-time {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 2px;
}

.file-actions button {
    width: 100%;
    min-width: 0;
    min-height: 36px;
    padding: 8px 8px;
    font-size: 12px;
    border-radius: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-actions .copy-url {
    color: white;
    background: linear-gradient(135deg, var(--text), #2d4134);
    border-color: transparent;
}

.gallery.list-mode {
    display: block;
}

.gallery.list-mode .file-card {
    grid-template-columns: 84px minmax(0, 1fr) auto;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 18px;
    align-items: center;
}

.gallery.list-mode .thumb img {
    aspect-ratio: 1 / 1;
    border-radius: 14px;
}

.gallery.list-mode .file-select-wrap {
    left: 8px;
    top: 8px;
    padding: 4px 8px;
    font-size: 11px;
}

.gallery.list-mode .file-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 0;
}

.gallery.list-mode .file-actions button {
    width: auto;
    min-height: 32px;
    padding: 7px 10px;
}

.gallery.list-mode .file-meta {
    gap: 4px;
}

.gallery.list-mode .meta-top {
    align-items: center;
}

.gallery.list-mode .file-name {
    font-size: 15px;
    line-height: 1.18;
    min-height: 1.18em;
    -webkit-line-clamp: 1;
}

.gallery.list-mode .file-size {
    padding: 4px 8px;
}

.gallery.list-mode .file-key {
    -webkit-line-clamp: 1;
}

.empty-state {
    padding: 28px 24px;
    text-align: center;
    border-radius: 24px;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.96),
        rgba(243, 247, 240, 0.92)
    );
    border: 1px dashed rgba(22, 40, 29, 0.14);
    color: var(--muted);
}

.form-error {
    margin: 0;
    color: var(--danger);
}

.dialog {
    width: min(560px, calc(100% - 24px));
    border: none;
    padding: 0;
    border-radius: 28px;
    background: rgba(255, 255, 252, 0.98);
    box-shadow: 0 34px 110px rgba(16, 28, 21, 0.28);
}

.dialog::backdrop {
    background: rgba(24, 33, 27, 0.36);
    backdrop-filter: blur(6px);
}

.dialog-body {
    padding: 24px;
}

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1180px) {
    .overview-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .workspace-shell {
        grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
    }

    .upload-zone {
        grid-template-columns: minmax(220px, 1fr) auto;
    }

    .inline-check {
        grid-column: 1 / -1;
        justify-self: start;
    }
}

@media (max-width: 940px) {
    .layout {
        width: min(100%, calc(100% - 22px));
    }

    .app-head,
    .panel-head,
    .gallery-head {
        flex-direction: column;
        align-items: stretch;
    }

    .overview-strip,
    .toolbar,
    .workspace-shell {
        grid-template-columns: 1fr;
    }

    .directory-sidebar {
        position: static;
        max-height: none;
        overflow: visible;
    }

    .workspace-main {
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .upload-zone {
        grid-template-columns: 1fr;
    }

    .gallery.list-mode .file-card {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .layout {
        padding-top: 18px;
        padding-bottom: 30px;
    }

    .panel {
        padding: 18px;
    }

    .overview-strip {
        gap: 12px;
    }

    .overview-card {
        padding: 16px;
    }

    .sidebar-actions,
    .file-actions {
        grid-template-columns: 1fr;
    }

    .actions,
    .stats,
    .upload-actions,
    .dialog-actions,
    .batch-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .batch-bar {
        position: static;
    }

    .upload-item {
        grid-template-columns: 1fr;
    }

    .upload-row-actions {
        justify-content: flex-start;
    }

    .meta-top {
        flex-direction: column;
        align-items: flex-start;
    }

    .file-select-wrap {
        right: 12px;
        left: auto;
    }
}
