:root {
    --bg: #f4f4f5;
    --bg-elevated: #ffffff;
    --bg-soft: #f8f8f8;
    --text: #121212;
    --text-muted: #6a6a6a;
    --border: #e2e2e2;
    --border-strong: #c9c9c9;
    --radius: 16px;
    --radius-sm: 12px;
    --shadow-sm: 0 4px 18px rgba(10, 10, 10, 0.04);
    --shadow-md: 0 10px 28px rgba(10, 10, 10, 0.06);
    --space-1: 0.5rem;
    --space-2: 0.75rem;
    --space-3: 1rem;
    --space-4: 1.5rem;
    --space-5: 2rem;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    overflow-x: clip;
}

body {
    min-height: 100vh;
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text);
    line-height: 1.5;
    text-rendering: optimizeLegibility;
    background:
        radial-gradient(circle at 10% 0%, #ffffff 0%, transparent 35%),
        radial-gradient(circle at 90% 10%, #efefef 0%, transparent 30%),
        var(--bg);
}

a {
    color: inherit;
    text-decoration: none;
}

a:hover {
    text-decoration: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin-top: 0;
    letter-spacing: -0.02em;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: var(--space-4) 0;
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 var(--space-3);
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -0.75rem;
}

.row > * {
    width: 100%;
    padding: 0 0.75rem;
}

.col-sm-3,
.col-sm-9,
.col-md-6,
.col-lg-5,
.col-lg-6,
.col-lg-8 {
    flex: 0 0 auto;
    width: 100%;
}

@media (min-width: 576px) {
    .col-sm-3 {
        width: 25%;
    }

    .col-sm-9 {
        width: 75%;
    }
}

@media (min-width: 768px) {
    .col-md-6 {
        width: 50%;
    }

    .p-md-5 {
        padding: 2.5rem;
    }
}

@media (min-width: 992px) {
    .col-lg-5 {
        width: 41.666667%;
    }

    .col-lg-6 {
        width: 50%;
    }

    .col-lg-8 {
        width: 66.666667%;
    }
}

.d-flex {
    display: flex;
}

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

.justify-content-center {
    justify-content: center;
}

.justify-content-between {
    justify-content: space-between;
}

.align-items-center {
    align-items: center;
}

.align-items-start {
    align-items: flex-start;
}

.align-items-end {
    align-items: flex-end;
}

.gap-2 {
    gap: var(--space-1);
}

.gap-3 {
    gap: var(--space-3);
}

.g-4 {
    row-gap: var(--space-4);
}

.mb-0 {
    margin-bottom: 0;
}

.mb-2 {
    margin-bottom: var(--space-1);
}

.mb-3 {
    margin-bottom: var(--space-3);
}

.mb-4 {
    margin-bottom: var(--space-4);
}

.mt-2 {
    margin-top: var(--space-1);
}

.p-4 {
    padding: var(--space-4);
}

.h-100 {
    height: 100%;
}

.h2 {
    font-size: clamp(1.45rem, 1.15rem + 1.2vw, 2rem);
}

.h3 {
    font-size: clamp(1.2rem, 1rem + 0.9vw, 1.55rem);
}

.h5 {
    font-size: 1.08rem;
}

.h6 {
    font-size: 0.95rem;
}

.small {
    font-size: 0.84rem;
}

.text-muted,
.muted {
    color: var(--text-muted);
}

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.w-100 {
    width: 100%;
}

.navbar {
    width: 100%;
}

.app-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(10px);
    background: rgba(246, 246, 247, 0.9);
    border-bottom: 1px solid var(--border);
}

.navbar-brand {
    display: inline-block;
    font-size: 1rem;
}

.app-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    min-height: 68px;
}

.app-nav-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    min-width: 0;
}

.app-nav-form {
    margin: 0;
}

.brand {
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--text);
    flex-shrink: 0;
}

.app-shell {
    padding-top: var(--space-5);
    padding-bottom: var(--space-5);
}

.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-sm);
}

.page-title {
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid transparent;
    padding: 0.5rem 0.88rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 160ms ease;
    line-height: 1.2;
    min-height: 2.35rem;
    text-align: center;
}

.btn-sm {
    padding: 0.35rem 0.62rem;
    font-size: 0.82rem;
    min-height: 2rem;
}

.btn-primary {
    background: #1b1b1b;
    border-color: #1b1b1b;
    color: #ffffff;
}

.btn-primary:hover,
.btn-primary:focus {
    background: #2d2d2d;
    border-color: #2d2d2d;
    transform: translateY(-1px);
}

.btn-outline-secondary,
.btn-outline-primary,
.btn-outline-danger {
    background: #ffffff;
    border-color: var(--border-strong);
    color: var(--text);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus,
.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-danger:hover,
.btn-outline-danger:focus {
    background: var(--bg-soft);
    border-color: #adadad;
}

.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.3rem 0.72rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    min-height: 2rem;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.eyebrow {
    margin: 0 0 0.45rem;
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.auth-wrap {
    margin: 0 auto;
}

.auth-wrap-wide {
    max-width: 900px;
}

.auth-wrap-narrow {
    max-width: 480px;
}

.auth-panel {
    padding: var(--space-4);
}

.auth-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
    align-items: center;
}

.auth-copy {
    min-width: 0;
}

.step-list {
    margin: 0;
    padding-left: 1.2rem;
    color: var(--text-muted);
}

.step-list li {
    margin-bottom: 0.45rem;
}

.qr-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
    padding: var(--space-3);
}

.qr-frame {
    display: flex;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #ffffff;
    padding: var(--space-3);
    min-height: 224px;
    align-items: center;
}

.qr-frame svg {
    width: min(100%, 220px);
    height: auto;
    display: block;
}

.secret-box {
    display: grid;
    gap: 0.35rem;
    margin-top: var(--space-3);
}

.secret-code {
    display: block;
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: #ffffff;
    padding: 0.7rem;
    font-size: 0.92rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.auth-form {
    margin-top: var(--space-4);
    border-top: 1px solid var(--border);
    padding-top: var(--space-4);
}

.auth-form-compact {
    margin-top: 0;
    border-top: 0;
    padding-top: 0;
}

.form-field {
    margin-bottom: var(--space-3);
}

.field-help {
    margin: 0.4rem 0 0;
    color: var(--text-muted);
    font-size: 0.84rem;
}

.field-errors,
.form-errors {
    margin-top: 0.5rem;
    border: 1px solid #f0b8b8;
    border-radius: 10px;
    background: #fff6f6;
    color: #9f2424;
    padding: 0.6rem 0.72rem;
    font-size: 0.86rem;
    font-weight: 600;
}

.field-errors ul,
.form-errors ul {
    margin: 0;
    padding-left: 1rem;
}

.field-errors li,
.form-errors li {
    margin: 0.15rem 0;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #ffffff;
    color: var(--text-muted);
    padding: 0.22rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.status-on {
    border-color: #b8d8c3;
    background: #edf8f1;
    color: #27593a;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1);
}

.user-table-panel {
    overflow: hidden;
}

@media (min-width: 768px) {
    .auth-panel {
        padding: var(--space-5);
    }

    .auth-grid {
        grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
    }
}

@media (max-width: 720px) {
    .data-table,
    .data-table thead,
    .data-table tbody,
    .data-table tr,
    .data-table th,
    .data-table td {
        display: block;
    }

    .data-table thead {
        display: none;
    }

    .data-table tbody tr {
        border-bottom: 1px solid var(--border);
        padding: 0.85rem var(--space-3);
    }

    .data-table tbody tr:last-child {
        border-bottom: 0;
    }

    .data-table tbody tr:hover {
        background: transparent;
    }

    .data-table td {
        display: grid;
        grid-template-columns: minmax(6.5rem, 38%) minmax(0, 1fr);
        gap: var(--space-2);
        align-items: center;
        padding: 0.42rem 0;
        border: 0;
    }

    .data-table td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 0.72rem;
        font-weight: 700;
        letter-spacing: 0.05em;
        text-transform: uppercase;
    }

    .table-actions {
        justify-content: flex-start;
    }

    .table-actions .btn,
    .data-table td > form .btn {
        min-width: 96px;
    }
}

@media (max-width: 440px) {
    .auth-panel {
        padding: var(--space-3);
    }

    .qr-card {
        padding: var(--space-2);
    }

    .qr-frame {
        min-height: 196px;
        padding: var(--space-2);
    }

    .qr-frame svg {
        width: min(100%, 190px);
    }

    .data-table td {
        grid-template-columns: 1fr;
        gap: 0.28rem;
    }

    .table-actions {
        width: 100%;
    }
}

.list-group {
    padding-left: 0;
    margin: 0;
}

.list-group-item {
    display: block;
    list-style: none;
}

.list-group-item-action {
    transition: background-color 140ms ease;
}

.list-group-item-action:hover {
    background: #f2f2f2;
}

.list-minimal {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #ffffff;
}

.list-minimal .list-group-item {
    border: 0;
    border-bottom: 1px solid #ececec;
    padding: 0.92rem 1rem;
}

.list-minimal .list-group-item:last-child {
    border-bottom: 0;
}

.dashboard-copy {
    min-width: 0;
}

.dashboard-actions,
.file-list-actions {
    flex-wrap: wrap;
}

.file-list-item {
    min-width: 0;
}

.file-list-item .file-link {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.data-table thead th {
    padding: 0.65rem 1rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.data-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .12s;
}
.data-table tbody tr:last-child { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--bg-soft); }
.data-table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    font-size: 0.8rem;
    background: #f2f2f2;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    padding: 0.15rem 0.3rem;
    word-break: break-all;
}

form p {
    margin-bottom: 1rem;
}

form label {
    display: inline-block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

form input[type='text'],
form input[type='password'],
form input[type='email'],
form input[type='number'],
form input[type='file'],
form input[type='datetime-local'],
form select,
form textarea {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 0.62rem 0.72rem;
    background: #ffffff;
    color: var(--text);
    font: inherit;
}

form input:focus,
form select:focus,
form textarea:focus {
    outline: none;
    border-color: #9e9e9e;
    box-shadow: 0 0 0 3px rgba(25, 25, 25, 0.08);
}

.alert {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: var(--shadow-sm);
    color: var(--text);
    padding: 0.82rem 0.95rem;
    margin-bottom: 0.95rem;
}

.alert-success {
    border-left: 3px solid #4d4d4d;
}

.alert-error,
.alert-danger {
    border-left: 3px solid #2c2c2c;
}

.alert-warning,
.alert-info {
    border-left: 3px solid #7a7a7a;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

.flex-grow-1 {
    flex-grow: 1;
}

.flex-shrink-0 {
    flex-shrink: 0;
}

.ms-2 {
    margin-left: var(--space-1);
}

.fw-medium {
    font-weight: 500;
}

/* ── Approval badge (nav) ── */
.approval-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    background: #1b1b1b;
    color: #fff;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0 0.3rem;
    vertical-align: middle;
    line-height: 1;
}

/* ── Anonymous status badge ── */
.badge-anon-pending {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: #fffbeb;
    border: 1px solid #f5e09a;
    border-radius: 999px;
    padding: 0.25rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #92710a;
}

.badge-rejected {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: #fff5f5;
    border: 1px solid #f5c6c6;
    border-radius: 999px;
    padding: 0.25rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #c0392b;
}

.badge-anon-approved {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: #f0faf0;
    border: 1px solid #b2d8b2;
    border-radius: 999px;
    padding: 0.25rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #2e6b2e;
}

/* ── User searchable select ── */
.us-wrap {
    position: relative;
}

.us-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    min-height: 42px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 0.42rem 0.62rem;
    background: #ffffff;
    cursor: text;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.us-wrap--open .us-control {
    border-color: #9e9e9e;
    box-shadow: 0 0 0 3px rgba(25, 25, 25, 0.08);
}

.us-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: center;
}

.us-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: #f0f0f0;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 0.18rem 0.42rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
}

.us-tag-label {
    line-height: 1;
}

.us-tag-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    border-radius: 4px;
    transition: color 120ms ease, background 120ms ease;
}

.us-tag-remove:hover {
    color: var(--text);
    background: #e0e0e0;
}

.us-search {
    flex: 1 1 80px;
    min-width: 80px;
    border: none;
    outline: none;
    background: transparent;
    font: inherit;
    font-size: 0.9rem;
    color: var(--text);
    padding: 0;
    line-height: 1.4;
}

.us-search::placeholder {
    color: #b0b0b0;
}

.us-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    max-height: 220px;
    overflow-y: auto;
    z-index: 50;
    padding: 0.3rem;
}

.us-option {
    padding: 0.55rem 0.7rem;
    border-radius: 7px;
    font-size: 0.88rem;
    cursor: pointer;
    color: var(--text);
    transition: background 120ms ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.us-option:hover {
    background: #f2f2f2;
}

.us-option--selected {
    color: var(--text);
    font-weight: 500;
}

.us-option--selected::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    background: #1b1b1b;
    border-radius: 3px;
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 9px;
}

.us-option:not(.us-option--selected)::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--border-strong);
    border-radius: 3px;
    flex-shrink: 0;
}

.us-empty {
    padding: 0.55rem 0.7rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}

/* ── Exhausted file state ── */
.file-exhausted {
    opacity: 0.5;
}

.file-exhausted .file-link {
    text-decoration: line-through;
    color: var(--text-muted);
    pointer-events: none;
}

.badge-exhausted {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 999px;
    padding: 0.28rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #999;
}

.exhausted-notice {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.55rem 0.9rem;
    font-size: 0.88rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ── Copy button ── */
.btn-copy {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
    flex-shrink: 0;
    padding: 0;
}

.btn-copy:hover {
    background: var(--bg-soft);
    border-color: var(--border-strong);
    color: var(--text);
    transform: translateY(-1px);
}

.btn-copy.copied {
    border-color: #5cb85c;
    color: #5cb85c;
    background: #f2faf2;
}

.btn-copy::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%);
    background: #1b1b1b;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 500;
    padding: 0.22rem 0.48rem;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 120ms ease;
    z-index: 10;
}

.btn-copy:hover::after,
.btn-copy.copied::after {
    opacity: 1;
}

.btn-copy .icon-check {
    display: none;
}

.btn-copy.copied .icon-clipboard {
    display: none;
}

.btn-copy.copied .icon-check {
    display: block;
}

@media (max-width: 768px) {
    .container {
        padding-right: var(--space-2);
        padding-left: var(--space-2);
    }

    .app-nav-inner {
        align-items: flex-start;
        min-height: 0;
        padding-top: var(--space-2);
        padding-bottom: var(--space-2);
    }

    .app-nav-actions {
        gap: 0.45rem;
    }

    .app-shell {
        padding-top: var(--space-4);
        padding-bottom: var(--space-4);
    }

    .panel {
        border-radius: 14px;
    }

    .p-4,
    .p-md-5 {
        padding: 1.15rem;
    }

    .text-truncate {
        white-space: normal;
    }

    .dashboard-header {
        align-items: stretch;
    }

    .dashboard-copy,
    .dashboard-actions {
        width: 100%;
    }

    .dashboard-actions .btn {
        flex: 1 1 11rem;
    }

    .file-list-item {
        align-items: flex-start;
    }

    .file-list-actions {
        justify-content: flex-end;
        max-width: 45%;
    }
}

@media (max-width: 520px) {
    .app-nav-inner {
        flex-direction: column;
        gap: var(--space-2);
    }

    .app-nav-actions {
        justify-content: flex-start;
        width: 100%;
    }

    .app-nav-actions .btn,
    .app-nav-actions .chip {
        flex: 1 1 calc(50% - var(--space-1));
    }

    .app-nav-form {
        display: flex;
        flex: 1 1 calc(50% - var(--space-1));
    }

    .app-nav-form .btn {
        width: 100%;
    }

    .dashboard-actions {
        align-items: stretch;
    }

    .dashboard-actions .chip {
        flex: 1 1 calc(50% - var(--space-1));
    }

    .dashboard-actions .btn {
        flex-basis: 100%;
    }

    .file-list-item {
        flex-direction: column;
    }

    .file-list-actions {
        justify-content: flex-start;
        max-width: none;
        width: 100%;
    }
}

@media (max-width: 360px) {
    .container {
        padding-right: 0.6rem;
        padding-left: 0.6rem;
    }

    .app-nav-actions .btn,
    .app-nav-actions .chip,
    .app-nav-form {
        flex-basis: 100%;
    }

    .list-minimal .list-group-item {
        padding-right: 0.85rem;
        padding-left: 0.85rem;
    }
}

/* === My Drive === */

:root {
    --drive-grid-cols: repeat(auto-fill, minmax(140px, 1fr));
    --drive-item-radius: 12px;
    --scan-pending: #f5a623;
    --scan-clean: #27ae60;
    --scan-infected: #e03c3c;
    --scan-error: #e03c3c;
    --scan-skipped: #7f8c8d;
    --danger: #e03c3c;
}

/* Toolbar */
.drive-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0 var(--space-3);
    flex-wrap: wrap;
}

.drive-toolbar-left { display: flex; gap: var(--space-1); }
.drive-toolbar-center { flex: 1; min-width: 0; }
.drive-toolbar-right { display: flex; align-items: center; gap: var(--space-1); }

.drive-search-wrap { width: 100%; max-width: 360px; }
.drive-search-input {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.85rem;
    font-size: 0.9rem;
    background: var(--bg-elevated);
    outline: none;
    transition: border-color .15s;
}
.drive-search-input:focus { border-color: #a0a0a0; }

.drive-sort-select {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    background: var(--bg-elevated);
    cursor: pointer;
}

.drive-view-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.35rem 0.5rem;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: background .15s, color .15s;
}
.drive-view-btn:hover, .drive-view-btn.active {
    background: var(--bg-soft);
    color: var(--text);
}

/* Breadcrumb */
.drive-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    font-size: 0.9rem;
    margin-bottom: var(--space-3);
    padding: var(--space-1) 0;
}
.drive-breadcrumb-root, .drive-breadcrumb-item {
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
}
.drive-breadcrumb-root:hover, .drive-breadcrumb-item:hover { color: var(--text); }
.drive-breadcrumb-sep { color: var(--text-muted); }
.drive-breadcrumb-current { font-weight: 600; }

/* Drop Zone */
.drive-drop-zone {
    position: relative;
    min-height: 300px;
}

.drive-drop-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(74, 144, 217, 0.08);
    border: 2px dashed #4a90d9;
    border-radius: var(--radius);
    z-index: 5;
    align-items: center;
    justify-content: center;
}
.drive-drop-overlay--active {
    display: flex;
}
.drive-drop-message {
    font-size: 1.1rem;
    color: #4a90d9;
    font-weight: 600;
    pointer-events: none;
}

/* Grid View */
.drive-items-container { min-height: 200px; }
.drive-grid {
    display: grid;
    grid-template-columns: var(--drive-grid-cols);
    gap: var(--space-3);
    padding: var(--space-2) 0;
}

.drive-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: var(--space-3) var(--space-2);
    border-radius: var(--drive-item-radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    text-align: center;
    position: relative;
}
.drive-item:hover {
    background: var(--bg-soft);
    border-color: var(--border);
}
.drive-item.selected {
    background: rgba(74, 144, 217, 0.08);
    border-color: #4a90d9;
}

.drive-item-icon { display: flex; align-items: center; justify-content: center; }
.drive-item-thumb {
    width: 100%;
    height: 90px;
    overflow: hidden;
    border-radius: 6px;
    background: var(--bg-soft);
}
.drive-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.drive-item-name {
    font-size: 0.8rem;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    unicode-bidi: plaintext;
    width: 100%;
}

/* List View */
.drive-list { display: flex; flex-direction: column; gap: 0; }
.drive-list-header {
    display: grid;
    grid-template-columns: 2.5rem 1fr 9rem 5.5rem 6rem 9rem auto;
    align-items: center;
    gap: var(--space-2);
    padding: 0.35rem var(--space-2);
    border-bottom: 2px solid var(--border);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    user-select: none;
    position: sticky;
    top: 0;
    background: var(--bg-elevated);
    z-index: 1;
}
.drive-list-header-col { white-space: nowrap; display: flex; align-items: center; gap: 0.2rem; }
.drive-list-header-sortable { cursor: pointer; }
.drive-list-header-sortable:hover { color: var(--text); }
.drive-list-sort-arrow { font-size: 0.75rem; }
.drive-list-sort-arrow--hidden { visibility: hidden; }
.drive-list-row {
    display: grid;
    grid-template-columns: 2.5rem 1fr 9rem 5.5rem 6rem 9rem auto;
    align-items: center;
    gap: var(--space-2);
    padding: 0.65rem var(--space-2);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .12s;
}
.drive-list-row:hover { background: var(--bg-soft); }
.drive-list-row:last-child { border-bottom: 0; }
.drive-list-icon { display: flex; align-items: center; }
.drive-list-thumb {
    width: 2.5rem;
    height: 2.5rem;
    overflow: hidden;
    border-radius: 4px;
    background: var(--bg-soft);
    flex-shrink: 0;
}
.drive-list-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.drive-list-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    unicode-bidi: plaintext;
    font-size: 0.9rem;
}
.drive-list-type {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.drive-list-meta, .drive-list-date, .drive-list-downloads {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Scan Badges */
.drive-scan-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.1rem 0.35rem;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.drive-scan-pending  { background: rgba(245,166,35,.15); color: var(--scan-pending); }
.drive-scan-clean    { background: rgba(39,174,96,.12); color: var(--scan-clean); }
.drive-scan-infected { background: rgba(224,60,60,.12); color: var(--scan-infected); }
.drive-scan-error    { background: rgba(224,60,60,.12); color: var(--scan-error); }
.drive-scan-skipped  { background: rgba(127,140,141,.1); color: var(--scan-skipped); }

/* Upload Tray */
.drive-upload-tray {
    position: fixed;
    bottom: var(--space-3);
    right: var(--space-3);
    width: 300px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.drive-tray-row {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
    box-shadow: var(--shadow-sm);
    font-size: 0.82rem;
}
.drive-tray-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    unicode-bidi: plaintext;
    margin-bottom: 0.25rem;
}
.drive-tray-bar {
    height: 4px;
    background: var(--bg-soft);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.2rem;
}
.drive-tray-progress { height: 100%; background: #4a90d9; border-radius: 2px; transition: width .2s; width: 0; }
.drive-tray-status { color: var(--text-muted); font-size: 0.75rem; }
.drive-tray-done { opacity: .6; }
.drive-tray-error .drive-tray-progress { background: var(--danger); }

/* Context Menu */
.drive-context-menu {
    position: fixed;
    display: none;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 200;
    min-width: 160px;
    padding: 0.3rem 0;
}
.drive-menu-item {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    text-align: left;
    font-size: 0.875rem;
    cursor: pointer;
    color: var(--text);
    transition: background .12s;
}
.drive-menu-item:hover { background: var(--bg-soft); }
.drive-menu-item:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.45;
}
.drive-menu-item:disabled:hover { background: transparent; }
.drive-menu-item--danger { color: var(--danger); }
.drive-menu-divider { border: 0; border-top: 1px solid var(--border); margin: 0.25rem 0; }

/* Preview Lightbox */
.drive-preview {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 420;
}
.drive-preview--open {
    display: block;
}
.drive-preview-lock {
    overflow: hidden;
}
.drive-preview-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 18, 20, 0.82);
}
.drive-preview-panel {
    position: absolute;
    inset: 3vh 3vw;
    display: grid;
    grid-template-rows: auto 1fr;
    min-width: 0;
    min-height: 0;
    background: var(--bg-elevated);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}
.drive-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    min-height: 3.5rem;
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid var(--border);
}
.drive-preview-title-wrap {
    min-width: 0;
}
.drive-preview-title {
    display: block;
    max-width: min(58vw, 760px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    unicode-bidi: plaintext;
    font-weight: 600;
    font-size: 0.95rem;
}
.drive-preview-meta {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 0.1rem;
}
.drive-preview-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}
.drive-preview-action,
.drive-preview-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-elevated);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, opacity .15s;
}
.drive-preview-action:hover,
.drive-preview-nav:hover {
    background: var(--bg-soft);
    border-color: var(--border-strong);
}
.drive-preview-nav:disabled {
    opacity: 0.3;
    cursor: default;
}
.drive-preview-nav:disabled:hover {
    background: var(--bg-elevated);
    border-color: var(--border);
}
.drive-preview-stage {
    position: relative;
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-columns: 3.5rem 1fr 3.5rem;
    background: #101114;
}
.drive-preview-content {
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3);
}
.drive-preview-content--image {
    background:
        linear-gradient(45deg, rgba(255,255,255,0.04) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255,255,255,0.04) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.04) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.04) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.drive-preview-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.28);
}
.drive-preview-loader,
.drive-preview-empty {
    color: rgba(255,255,255,0.82);
    text-align: center;
}
.drive-preview-empty {
    max-width: 24rem;
    padding: var(--space-4);
}
.drive-preview-empty-icon {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}
.drive-preview-empty p {
    color: rgba(255,255,255,0.68);
    margin: 0;
}
.drive-preview-nav {
    align-self: center;
    justify-self: center;
    z-index: 1;
}

/* Modal */
.drive-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 300;
}
.drive-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 310;
    width: 90%;
    max-width: 420px;
}
.drive-modal-body {
    background: var(--bg-elevated);
    border-radius: var(--radius);
    padding: var(--space-4);
    box-shadow: var(--shadow-md);
}
.drive-modal-title { font-size: 1.05rem; font-weight: 600; margin-bottom: var(--space-3); }
.drive-modal-input {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.85rem;
    font-size: 0.95rem;
    margin-bottom: var(--space-3);
    outline: none;
    transition: border-color .15s;
}
.drive-modal-input:focus { border-color: #a0a0a0; }
.drive-modal-actions { display: flex; justify-content: flex-end; gap: var(--space-1); }
.drive-modal--wide { max-width: 520px; }

/* Folder Picker (Move dialog) */
.drive-folder-picker {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: var(--space-3);
}
.drive-picker-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.15rem 0.25rem;
    padding: 0.45rem 0.75rem;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
}
.drive-picker-bc-item {
    cursor: pointer;
    color: var(--link, #4a90d9);
    padding: 0.1rem 0.15rem;
    border-radius: 3px;
}
.drive-picker-bc-item:hover { background: var(--bg-elevated); text-decoration: underline; }
.drive-picker-bc-sep { color: var(--text-muted); font-size: 0.75rem; }
.drive-picker-inner {
    max-height: 220px;
    overflow-y: auto;
}
.drive-picker-folder {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.875rem;
    transition: background .12s;
}
.drive-picker-folder:last-child { border-bottom: 0; }
.drive-picker-folder:hover { background: var(--bg-soft); }
.drive-picker-empty {
    padding: 1.1rem 0.75rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
}

/* Toast */
.drive-toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-3);
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.drive-toast {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    box-shadow: var(--shadow-sm);
    opacity: 0;
    transform: translateX(20px);
    transition: opacity .25s, transform .25s;
    max-width: 320px;
    word-break: break-word;
}
.drive-toast--visible { opacity: 1; transform: translateX(0); }
.drive-toast--success { background: rgba(39,174,96,.15); border: 1px solid rgba(39,174,96,.3); color: #1a7a42; }
.drive-toast--error   { background: rgba(224,60,60,.12); border: 1px solid rgba(224,60,60,.25); color: #a02020; }
.drive-toast--info    { background: var(--bg-soft); border: 1px solid var(--border); color: var(--text); }

/* Skeleton */
.drive-skeleton-grid {
    display: grid;
    grid-template-columns: var(--drive-grid-cols);
    gap: var(--space-3);
    padding: var(--space-2) 0;
}
.drive-skeleton-item { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; padding: var(--space-3) var(--space-2); }
.drive-skeleton-icon { width: 40px; height: 40px; border-radius: 8px; }
.drive-skeleton-name { width: 80px; height: 12px; border-radius: 6px; }
.skeleton-shimmer {
    background: linear-gradient(90deg, #e8e8e8 25%, #f4f4f4 50%, #e8e8e8 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Empty State */
.drive-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
    text-align: center;
    grid-column: 1 / -1;
}
.drive-empty-icon { color: var(--text-muted); opacity: .4; margin-bottom: var(--space-3); }
.drive-empty-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; }
.drive-empty-hint { font-size: 0.875rem; color: var(--text-muted); }

/* Responsive Drive */
@media (max-width: 640px) {
    :root { --drive-grid-cols: repeat(auto-fill, minmax(100px, 1fr)); }
    .drive-toolbar { flex-direction: column; align-items: stretch; }
    .drive-toolbar-center { max-width: 100%; }
    .drive-upload-tray { width: calc(100vw - 2rem); right: 1rem; }
    .drive-list-row { grid-template-columns: 2rem 1fr auto; }
    .drive-list-meta, .drive-list-date { display: none; }
    .drive-context-menu {
        min-width: 190px;
        max-width: calc(100vw - 1rem);
    }
    .drive-menu-item {
        padding: 0.7rem 1rem;
        font-size: 0.95rem;
    }
    .drive-preview-panel {
        inset: 0;
        border-radius: 0;
        border: 0;
    }
    .drive-preview-header {
        min-height: 3.25rem;
        padding: 0.55rem 0.65rem;
    }
    .drive-preview-title {
        max-width: calc(100vw - 7rem);
        font-size: 0.88rem;
    }
    .drive-preview-meta {
        font-size: 0.72rem;
    }
    .drive-preview-action {
        width: 2.25rem;
        height: 2.25rem;
    }
    .drive-preview-stage {
        grid-template-columns: 1fr;
    }
    .drive-preview-content {
        grid-area: 1 / 1;
        padding: 0.75rem;
    }
    .drive-preview-nav {
        grid-area: 1 / 1;
        width: 2.6rem;
        height: 2.6rem;
        background: rgba(255,255,255,0.9);
    }
    .drive-preview-nav--prev {
        justify-self: start;
        margin-left: 0.5rem;
    }
    .drive-preview-nav--next {
        justify-self: end;
        margin-right: 0.5rem;
    }
}
