/* ── Reset & base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
    /* Dark theme (default) */
    --bg-base:     #020617;
    --bg-surface:  #0f172a;
    --bg-elevated: #1e293b;
    --bg-hover:    #1e293b;
    --border:      #1f2937;
    --border-focus:#3b82f6;
    --text-primary:#e2e8f0;
    --text-muted:  #64748b;
    --text-dim:    #475569;
    --accent:      #3b82f6;
    --accent-hover:#2563eb;
    --accent-subtle:rgba(59,130,246,.12);
    --success:     #22c55e;
    --success-bg:  rgba(34,197,94,.1);
    --danger:      #ef4444;
    --danger-bg:   rgba(239,68,68,.1);
    --warning:     #f59e0b;
    --warning-bg:  rgba(245,158,11,.1);
    --radius-sm:   6px;
    --radius:      10px;
    --radius-lg:   16px;
    --shadow:      0 4px 24px rgba(0,0,0,.4);
    --shadow-sm:   0 1px 4px rgba(0,0,0,.3);
    --sidebar-w:   260px;
    --topbar-h:    56px;
    --transition:  .15s ease;
}

[data-theme="light"] {
    --bg-base:     #f1f5f9;
    --bg-surface:  #ffffff;
    --bg-elevated: #f8fafc;
    --bg-hover:    #f1f5f9;
    --border:      #e2e8f0;
    --text-primary:#0f172a;
    --text-muted:  #64748b;
    --text-dim:    #94a3b8;
    --accent-subtle:rgba(59,130,246,.08);
    --shadow:      0 4px 24px rgba(0,0,0,.1);
    --shadow-sm:   0 1px 4px rgba(0,0,0,.08);
}

html { height: 100%; }

body {
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    height: 100%;
    overflow: hidden;
}

/* ── Screens ──────────────────────────────────────────────────────────────── */
.screen { height: 100vh; }

/* ── Login ────────────────────────────────────────────────────────────────── */
#screen-login, #screen-webauthn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    padding: 2rem;
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.login-logo {
    width: 56px; height: 56px;
    background: var(--accent-subtle);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
    margin-bottom: 1.5rem;
}

.login-logo.key-icon { color: var(--warning); background: var(--warning-bg); }

.login-title { font-size: 1.5rem; font-weight: 700; margin-bottom: .25rem; }
.login-subtitle { color: var(--text-muted); margin-bottom: 2rem; }

/* ── WebAuthn status ──────────────────────────────────────────────────────── */
.webauthn-status {
    display: flex;
    align-items: center;
    gap: .75rem;
    background: var(--warning-bg);
    border: 1px solid var(--warning);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    color: var(--warning);
    font-weight: 500;
}

.webauthn-pulse {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--warning);
    animation: pulse 1.2s ease infinite;
    flex-shrink: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .5; transform: scale(.85); }
}

/* ── App layout ───────────────────────────────────────────────────────────── */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: 1fr;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: .875rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex; align-items: center; gap: .625rem;
    font-weight: 700; font-size: .9375rem;
    color: var(--text-primary);
}

.sidebar-logo svg { color: var(--accent); }

.tree-nav {
    overflow-y: auto;
    flex: 1;
    padding: .5rem 0;
}

.tree-loading {
    display: flex; justify-content: center;
    padding: 2rem;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: .375rem;
    padding: .375rem .75rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    margin: 1px .5rem;
    color: var(--text-muted);
    transition: background var(--transition), color var(--transition);
    user-select: none;
    font-size: .8125rem;
}

.tree-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.tree-item.active { background: var(--accent-subtle); color: var(--accent); }
.tree-item .tree-toggle { flex-shrink: 0; transition: transform .15s; }
.tree-item .tree-toggle.open { transform: rotate(90deg); }
.tree-children { margin-left: 1rem; }

/* ── Main ─────────────────────────────────────────────────────────────────── */
.main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    gap: 1rem;
    flex-shrink: 0;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: .25rem;
    min-width: 0;
    flex: 1;
}

.breadcrumb-item {
    background: none; border: none;
    color: var(--text-muted); cursor: pointer;
    padding: .25rem .5rem;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; gap: .375rem;
    font-size: .8125rem; white-space: nowrap;
    transition: background var(--transition), color var(--transition);
}

.breadcrumb-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.breadcrumb-item:last-child { color: var(--text-primary); font-weight: 500; }
.breadcrumb-sep { color: var(--text-dim); font-size: .75rem; }

.topbar-actions {
    display: flex; align-items: center; gap: .5rem;
    flex-shrink: 0;
}

.search-wrapper {
    position: relative;
    display: flex; align-items: center;
}

.search-icon {
    position: absolute; left: .625rem;
    color: var(--text-dim); pointer-events: none;
}

#search-input {
    background: var(--bg-base);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: .4rem .625rem .4rem 2rem;
    font-size: .8125rem;
    width: 200px;
    outline: none;
    transition: border-color var(--transition), width var(--transition);
}

#search-input:focus { border-color: var(--border-focus); width: 260px; }

.search-deep-toggle {
    display: flex; align-items: center; gap: .25rem;
    color: var(--text-muted); font-size: .75rem;
    margin-left: .5rem; cursor: pointer; white-space: nowrap;
}

/* ── File area ────────────────────────────────────────────────────────────── */
.file-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

/* ── Toolbar ──────────────────────────────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    flex-shrink: 0;
}

.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: .5rem; }

.selection-count {
    font-size: .8125rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ── Drop zone ────────────────────────────────────────────────────────────── */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-muted);
    transition: border-color var(--transition), background var(--transition);
}

.drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-subtle);
    color: var(--accent);
}

.drop-zone svg { margin-bottom: .75rem; opacity: .6; }
.drop-zone p { font-size: .9375rem; }

/* ── Upload queue ─────────────────────────────────────────────────────────── */
.upload-queue {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.upload-item {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem 1rem;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto 6px;
    gap: .375rem .75rem;
    align-items: center;
}

.upload-name { font-size: .875rem; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-status { font-size: .75rem; color: var(--text-muted); text-align: right; white-space: nowrap; }

.upload-progress {
    grid-column: 1 / -1;
    height: 4px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
}

.upload-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 99px;
    transition: width .2s linear;
}

.upload-progress-bar.done  { background: var(--success); }
.upload-progress-bar.error { background: var(--danger); }

/* ── File list ────────────────────────────────────────────────────────────── */
.file-list { flex: 1; }
.file-list.empty { display: flex; align-items: center; justify-content: center; padding: 4rem; }

.empty-state { text-align: center; color: var(--text-muted); }
.empty-state svg { opacity: .3; margin-bottom: 1rem; }
.empty-state p { font-size: .9375rem; }

/* ── List view ────────────────────────────────────────────────────────────── */
.list-view { width: 100%; border-collapse: collapse; }

.list-view thead th {
    padding: .5rem 1rem;
    text-align: left;
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.list-view thead th:hover { color: var(--text-primary); }
.sort-arrow { margin-left: .25rem; opacity: .5; }
.sort-arrow.active { opacity: 1; color: var(--accent); }

.list-view tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
    cursor: pointer;
}

.list-view tbody tr:hover { background: var(--bg-hover); }
.list-view tbody tr.selected { background: var(--accent-subtle); }

.list-view td { padding: .625rem 1rem; }

.file-name-cell {
    display: flex; align-items: center; gap: .625rem;
    min-width: 0;
}

.file-icon { flex-shrink: 0; }
.file-icon.dir { color: #f59e0b; }
.file-icon.img { color: #a78bfa; }
.file-icon.video { color: #ec4899; }
.file-icon.audio { color: #06b6d4; }
.file-icon.doc  { color: #f97316; }
.file-icon.code { color: #22c55e; }
.file-icon.archive { color: #64748b; }
.file-icon.generic { color: var(--text-dim); }

.file-label {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: .875rem;
}

.file-label a {
    color: inherit; text-decoration: none;
}

.file-label a:hover { color: var(--accent); }

.file-size, .file-date { color: var(--text-muted); font-size: .8125rem; white-space: nowrap; }

.file-actions {
    display: flex; gap: .25rem;
    opacity: 0;
    transition: opacity var(--transition);
}

.list-view tbody tr:hover .file-actions { opacity: 1; }
.list-view tbody tr.selected .file-actions { opacity: 1; }

.file-check { width: 36px; }
.file-check input[type="checkbox"] { cursor: pointer; accent-color: var(--accent); }

/* ── Grid view ────────────────────────────────────────────────────────────── */
.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .75rem;
}

.grid-item {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem .75rem;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    display: flex; flex-direction: column; align-items: center; gap: .5rem;
    position: relative;
    user-select: none;
}

.grid-item:hover { border-color: var(--accent); background: var(--bg-hover); }
.grid-item.selected { border-color: var(--accent); background: var(--accent-subtle); }

.grid-item .file-icon { font-size: 2rem; }

.grid-item-name {
    font-size: .75rem; word-break: break-all;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    text-align: center; line-height: 1.3;
}

.grid-item-size { font-size: .6875rem; color: var(--text-muted); }

.grid-item-check {
    position: absolute; top: .375rem; left: .375rem;
    opacity: 0; transition: opacity var(--transition);
}

.grid-item:hover .grid-item-check,
.grid-item.selected .grid-item-check { opacity: 1; }

.grid-item-menu {
    position: absolute; top: .375rem; right: .375rem;
    opacity: 0; transition: opacity var(--transition);
}

.grid-item:hover .grid-item-menu { opacity: 1; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: .375rem;
    padding: .5rem 1rem;
    border-radius: var(--radius-sm);
    border: none; cursor: pointer;
    font-size: .875rem; font-weight: 500;
    transition: opacity var(--transition), background var(--transition);
    white-space: nowrap;
}

.btn:disabled { opacity: .5; cursor: default; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: .85; }

.btn-ghost {
    background: transparent; color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }

.btn-sm { padding: .375rem .75rem; font-size: .8125rem; }
.btn-full { width: 100%; justify-content: center; }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    background: none; border: none;
    color: var(--text-muted); cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
}

.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.field { margin-bottom: 1.125rem; }

label {
    display: block;
    font-size: .8125rem; font-weight: 500;
    color: var(--text-muted);
    margin-bottom: .375rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="search"] {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: .625rem .875rem;
    font-size: .9375rem;
    outline: none;
    transition: border-color var(--transition);
}

input:focus { border-color: var(--border-focus); }

.form-error {
    background: var(--danger-bg);
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    color: var(--danger);
    padding: .625rem .875rem;
    font-size: .875rem;
    margin-bottom: 1rem;
}

/* ── Overlay & Modal ──────────────────────────────────────────────────────── */
.overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(2px);
    z-index: 40;
}

.modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%; max-width: 440px;
    z-index: 50;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1rem; font-weight: 600; }

.modal-body { padding: 1.5rem; }

.modal-footer {
    display: flex; justify-content: flex-end; gap: .5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

/* ── Settings panel ───────────────────────────────────────────────────────── */
.settings-panel {
    position: fixed; top: 0; right: 0;
    width: 380px; height: 100vh;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    z-index: 50;
    display: flex; flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.settings-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.125rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.settings-header h2 { font-size: 1rem; font-weight: 600; }

.settings-body {
    overflow-y: auto;
    flex: 1;
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.settings-section h3 {
    font-size: .75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .08em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--border);
}

.key-item {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .875rem 1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .5rem;
}

.key-item-icon {
    width: 36px; height: 36px;
    background: var(--warning-bg);
    color: var(--warning);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.key-item-info { flex: 1; min-width: 0; }
.key-item-name { font-size: .875rem; font-weight: 500; }
.key-item-date { font-size: .75rem; color: var(--text-muted); margin-top: .125rem; }

.toggle-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: .75rem 0;
    border-bottom: 1px solid var(--border);
}

.toggle-label { font-size: .875rem; }
.toggle-desc  { font-size: .75rem; color: var(--text-muted); margin-top: .125rem; }

.toggle {
    position: relative;
    width: 44px; height: 24px;
    flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-track {
    position: absolute; inset: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 99px;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

.toggle input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }

.toggle-track::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition);
}

.toggle input:checked + .toggle-track::after { transform: translateX(20px); }

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

.spinner-center {
    display: flex; align-items: center; justify-content: center;
    padding: 3rem;
}

.spinner-center .spinner { width: 28px; height: 28px; color: var(--accent); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toasts ───────────────────────────────────────────────────────────────── */
.toasts {
    position: fixed;
    bottom: 1.5rem; right: 1.5rem;
    z-index: 100;
    display: flex; flex-direction: column; gap: .5rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem 1rem;
    font-size: .875rem;
    max-width: 340px;
    box-shadow: var(--shadow);
    display: flex; align-items: center; gap: .625rem;
    pointer-events: auto;
    animation: slideUp .2s ease;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }

.toast-icon { flex-shrink: 0; font-size: 1rem; }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Context menu ─────────────────────────────────────────────────────────── */
.context-menu {
    position: fixed;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .375rem;
    z-index: 60;
    min-width: 160px;
}

.context-item {
    display: flex; align-items: center; gap: .5rem;
    padding: .5rem .75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: .875rem;
    color: var(--text-primary);
    transition: background var(--transition);
}

.context-item:hover { background: var(--bg-hover); }
.context-item.danger { color: var(--danger); }
.context-item.danger:hover { background: var(--danger-bg); }
.context-sep { height: 1px; background: var(--border); margin: .25rem 0; }

/* ── Info row (settings) ─────────────────────────────────────────────────── */
.info-row {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
    padding: .625rem 0;
    border-bottom: 1px solid var(--border);
}

.info-row:last-child { border-bottom: none; }
.info-label { font-size: .8125rem; color: var(--text-muted); white-space: nowrap; }
.info-value { font-size: .8125rem; text-align: right; word-break: break-all; }

/* ── Badge ────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .125rem .5rem;
    border-radius: 99px;
    font-size: .6875rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-muted   { background: var(--bg-elevated); color: var(--text-muted); }

/* ── Drag state ───────────────────────────────────────────────────────────── */
body.dragging-files .file-area { outline: 2px dashed var(--accent); outline-offset: -8px; }

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Responsive ───────────────────────────────────────────────────────────── */

/* Hamburger: desktop = hidden */
#sidebar-toggle { display: none; }

/* Sidebar backdrop: mobile only */
.sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(2px);
    z-index: 30;
}

@media (max-width: 768px) {

    /* ── Layout ── */
    .app-layout { grid-template-columns: 1fr; }

    /* ── Sidebar: slide-in overlay ── */
    .sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100dvh;
        width: 280px;
        z-index: 35;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(0,0,0,.5);
    }

    /* ── Hamburger ── */
    #sidebar-toggle { display: inline-flex; }

    /* ── Topbar ── */
    .topbar { padding: 0 .625rem; gap: .375rem; }

    /* Breadcrumb scrolls instead of wrapping */
    .breadcrumb {
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .breadcrumb::-webkit-scrollbar { display: none; }
    .breadcrumb-item { font-size: .75rem; padding: .25rem .375rem; }

    /* Compact search */
    #search-input { width: 110px; font-size: .8125rem; }
    #search-input:focus { width: 140px; }
    .search-deep-toggle { display: none; }

    /* Hide low-priority topbar actions on small screens */
    #view-toggle, #theme-toggle { display: none; }

    /* Replace text logout with icon */
    #logout-btn {
        width: 32px; height: 32px;
        padding: 0;
        justify-content: center;
        font-size: 0; /* hide text */
        border: 1px solid var(--border);
    }
    #logout-btn::before {
        content: '';
        display: inline-block;
        width: 14px; height: 14px;
        background: currentColor;
        mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpolyline points='16 17 21 12 16 7'/%3E%3Cline x1='21' y1='12' x2='9' y2='12'/%3E%3C/svg%3E") center/contain no-repeat;
        -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpolyline points='16 17 21 12 16 7'/%3E%3Cline x1='21' y1='12' x2='9' y2='12'/%3E%3C/svg%3E") center/contain no-repeat;
    }

    /* ── File area ── */
    .file-area { padding: .75rem .625rem; }

    /* ── Toolbar ── */
    .toolbar { flex-wrap: wrap; gap: .5rem; }
    .toolbar-left { flex: 1; min-width: 0; }
    .toolbar-left .btn { flex: 1; justify-content: center; min-width: 0; }
    .toolbar-right { flex: 1; flex-wrap: wrap; gap: .375rem; }
    .toolbar-right .btn { flex: 1; justify-content: center; font-size: .75rem; padding: .375rem .5rem; }

    /* ── List view: hide non-essential columns ── */
    .list-view thead th:nth-child(3),
    .list-view thead th:nth-child(4),
    .list-view tbody td:nth-child(3),
    .list-view tbody td:nth-child(4) { display: none; }

    /* Show action buttons always (no hover on touch) */
    .file-actions { opacity: 1; }
    .icon-btn.action-rename, .icon-btn.action-delete, .icon-btn.action-zip {
        width: 28px; height: 28px;
    }

    /* ── Grid view ── */
    .grid-view { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: .5rem; }
    .grid-item { padding: .75rem .5rem; }
    .grid-item-check, .grid-item-menu { opacity: 1; }

    /* ── Modal: bottom sheet ── */
    .modal {
        top: auto; bottom: 0;
        left: 0; right: 0;
        transform: none;
        max-width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    /* ── Settings: bottom sheet ── */
    .settings-panel {
        top: auto; bottom: 0;
        right: 0; left: 0;
        width: 100%;
        height: 92dvh;
        border-left: none;
        border-top: 1px solid var(--border);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    /* ── Toasts: full width at bottom ── */
    .toasts { left: .75rem; right: .75rem; bottom: .75rem; }
    .toast { max-width: 100%; }

    /* ── Context menu: wider touch targets ── */
    .context-item { padding: .75rem 1rem; font-size: .9375rem; }

    /* ── Drop zone ── */
    .drop-zone { padding: 2rem 1rem; }
    .drop-zone p { font-size: .875rem; }
}

@media (max-width: 420px) {
    #search-input { width: 80px; }
    #search-input:focus { width: 110px; }
    .breadcrumb-item { font-size: .6875rem; }
    .grid-view { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: .375rem; }
}
