:root {
    color-scheme: light;
    --bg: #f8fafd;
    --panel: #ffffff;
    --panel-muted: #f1f5fb;
    --line: #dde5f0;
    --line-strong: #cad5e5;
    --text: #1f2937;
    --muted: #64748b;
    --accent: #1a73e8;
    --accent-strong: #1558b0;
    --danger: #c53929;
    --success: #188038;
    --radius: 18px;
    --shadow: 0 8px 24px rgba(34, 55, 88, 0.06);
    --wrap: 1440px;
}

html.dark {
    color-scheme: dark;
    --bg: #0f1723;
    --panel: #16202f;
    --panel-muted: #1d2a3b;
    --line: #2a3950;
    --line-strong: #36506f;
    --text: #eff5ff;
    --muted: #97a6ba;
    --accent: #8ab4f8;
    --accent-strong: #a8c7fa;
    --danger: #f28b82;
    --success: #81c995;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
}

@media (prefers-color-scheme: dark) {
    html:not(.light) {
        color-scheme: dark;
    }
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Ubuntu, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.4;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
progress {
    font: inherit;
}

button {
    appearance: none;
}

.wrap {
    width: min(var(--wrap), calc(100vw - 2rem));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    backdrop-filter: blur(10px);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
}

.brand-lockup {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.04em;
}

.brand-note {
    color: var(--muted);
    font-size: 0.82rem;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    min-height: 2.2rem;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel-muted);
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.app-shell,
.login-shell {
    padding: 1rem 0 2rem;
}

.drive-layout {
    display: grid;
    gap: 1rem;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
}

.listing-header h2,
.login-card h1,
.dialog-header h2 {
    margin: 0.2rem 0 0;
    font-size: clamp(1.15rem, 1.9vw, 1.6rem);
    line-height: 1.1;
    letter-spacing: -0.04em;
}

.eyebrow {
    margin: 0;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
    font-weight: 700;
}

.panel-note,
.hero-copy,
.listing-note,
.item-meta,
.status-line {
    color: var(--muted);
}

.nav-list {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.nav-item {
    display: grid;
    gap: 0.15rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-muted);
    padding: 0.75rem 0.85rem;
}

.nav-item-active {
    border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
    background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}

.drop-target {
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.drop-target.drag-active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, var(--panel));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}

.nav-item-title {
    font-size: 0.86rem;
    font-weight: 600;
}

.nav-item-meta {
    color: var(--muted);
    font-size: 0.8rem;
    word-break: break-word;
}

.sidebar-current {
    margin-top: 0.65rem;
    font-size: 0.95rem;
    font-weight: 600;
}

.stack-form,
.login-form label,
.dialog-card label {
    display: grid;
    gap: 0.45rem;
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="file"] {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    color: var(--text);
    padding: 0.72rem 0.85rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input::placeholder {
    color: var(--muted);
    opacity: 1;
}

input[type="file"] {
    color: var(--text);
}

input[type="file"]::file-selector-button {
    margin-right: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel-muted);
    color: var(--text);
    padding: 0.45rem 0.7rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

input[type="file"]::-webkit-file-upload-button {
    margin-right: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel-muted);
    color: var(--text);
    padding: 0.45rem 0.7rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}

.toolbar-shell {
    padding: 0.85rem 1rem;
}

.toolbar-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.toolbar-left {
    min-width: 0;
}

.crumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.crumbs a {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background: var(--panel-muted);
    border: 1px solid var(--line);
    font-size: 0.86rem;
    font-weight: 600;
}

.toolbar-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-top: 0.45rem;
    color: var(--muted);
    font-size: 0.84rem;
}

.toolbar-search {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: min(30rem, 100%);
}

.toolbar-search input[type="search"] {
    flex: 1;
    min-width: 12rem;
    background: var(--panel-muted);
}

.actions-shell {
    padding: 0.85rem 1rem 1rem;
}

.actions-tabs {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
}

.action-tab {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel-muted);
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 600;
}

.action-tab-active {
    background: color-mix(in srgb, var(--accent) 8%, var(--panel));
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
}

.actions-grid {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 0.75rem;
}

.action-card {
    align-content: start;
    padding: 0.85rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-muted);
}

.action-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--muted);
}

.compact-note {
    font-size: 0.82rem;
    margin: 0;
}

.button-row,
.inline-form,
.actions-cell,
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.inline-form,
.actions-cell {
    flex-wrap: nowrap;
}

.checkbox-row {
    color: var(--muted);
}

.primary-button,
.ghost-button,
.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.35rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    padding: 0.58rem 0.95rem;
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover {
    transform: translateY(-1px);
}

.primary-button {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.primary-button:hover {
    background: var(--accent-strong);
}

.ghost-button {
    background: transparent;
    color: var(--text);
}

.ghost-button:hover {
    border-color: var(--line-strong);
    background: color-mix(in srgb, var(--panel-muted) 75%, transparent);
}

.danger-button {
    border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
    color: var(--danger);
    background: transparent;
}

.danger-button:hover {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.small {
    min-height: 1.95rem;
    padding: 0.36rem 0.68rem;
    font-size: 0.8rem;
}

.actions-cell {
    white-space: nowrap;
}

.actions-cell .ghost-button,
.actions-cell .danger-button,
.actions-cell .inline-form {
    flex: 0 0 auto;
}

.actions-cell .ghost-button,
.actions-cell .danger-button {
    min-width: 6rem;
}

.actions-cell .inline-form {
    margin: 0;
}

.listing-panel {
    overflow: hidden;
    padding: 0;
}

.listing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.45rem 1rem 0.9rem;
    border-bottom: 1px solid var(--line);
}

.listing-note {
    margin: 0;
    font-size: 0.84rem;
}

.listing-table {
    width: 100%;
    border-collapse: collapse;
}

.listing-table th,
.listing-table td {
    padding: 0.8rem 1rem;
    border-top: 1px solid var(--line);
    vertical-align: middle;
}

.listing-table thead th {
    border-top: 0;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: color-mix(in srgb, var(--panel-muted) 70%, transparent);
}

.listing-table tbody tr:hover {
    background: color-mix(in srgb, var(--panel-muted) 42%, transparent);
}

.item-row-draggable {
    cursor: grab;
}

.item-row-draggable.is-dragging {
    opacity: 0.45;
}

.name-cell {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.item-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 10px;
    border: 1px solid var(--line);
    font-size: 0.76rem;
    font-weight: 800;
    background: var(--panel-muted);
}

.item-icon-folder {
    color: var(--accent);
}

.item-icon-file {
    color: var(--muted);
}

.item-link {
    font-weight: 600;
    font-size: 0.92rem;
}

.item-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3.9rem;
    padding: 0.28rem 0.52rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel-muted);
    font-size: 0.72rem;
    font-weight: 700;
}

.badge-folder {
    color: var(--accent);
}

.badge-file {
    color: var(--muted);
}

.item-meta {
    margin-top: 0.18rem;
    font-size: 0.74rem;
}

.empty-state {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--muted);
}

.flash {
    margin-bottom: 1rem;
    border-radius: 14px;
    border: 1px solid var(--line);
    padding: 0.8rem 0.95rem;
    background: var(--panel);
}

.flash-success {
    border-color: color-mix(in srgb, var(--success) 45%, var(--line));
}

.flash-error {
    border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
}

.upload-panel.is-drop-target {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}

progress {
    width: 100%;
    margin-top: 0.6rem;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.login-card {
    width: min(30rem, 100%);
}

.login-form {
    display: grid;
    gap: 0.95rem;
}

.rename-dialog {
    border: 0;
    padding: 0;
    background: transparent;
}

.rename-dialog::backdrop {
    background: rgba(8, 15, 28, 0.5);
}

.dialog-card {
    width: min(28rem, calc(100vw - 2rem));
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 1rem;
}

.dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.7rem;
    margin-top: 1rem;
}

@media (max-width: 1080px) {
    .drive-layout {
        grid-template-columns: 1fr;
    }

    .toolbar-main,
    .listing-header {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-search {
        min-width: 0;
        width: 100%;
    }

    .actions-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 780px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .top-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .toolbar-search,
    .actions-cell,
    .inline-form,
    .dialog-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .listing-table,
    .listing-table thead,
    .listing-table tbody,
    .listing-table tr,
    .listing-table th,
    .listing-table td {
        display: block;
        width: 100%;
    }

    .listing-table thead {
        display: none;
    }

    .listing-table tbody tr {
        padding: 0.8rem 0;
        border-top: 1px solid var(--line);
    }

    .listing-table td {
        border: 0;
        padding: 0.35rem 1rem;
    }
}
