:root {
    --bg: #f7f8fa;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #667085;
    --border: #e4e7ec;
    --hover: #f2f4f7;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-text: #ffffff;
    --danger: #c0352b;
    --folder: #f2b84b;
    --file: #8a94a6;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .06);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111418;
        --surface: #1a1e24;
        --text: #e6e8eb;
        --muted: #98a2b3;
        --border: #2b313a;
        --hover: #222830;
        --accent: #4f8cff;
        --accent-hover: #6a9dff;
        --danger: #ff6b5e;
        --folder: #e0a93a;
        --file: #7d8798;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px rgba(0, 0, 0, .3);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

a { color: var(--accent); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

button, .button {
    font: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}
button:hover, .button:hover { background: var(--hover); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
button.link:hover { text-decoration: underline; background: none; }
button.wide { width: 100%; justify-content: center; margin-top: 18px; padding: 10px; }
button:focus-visible, .button:focus-within, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

input {
    font: inherit;
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}

/* sign-in and error pages */
.center-page { display: grid; place-items: center; padding: 16px; }
.card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
    box-shadow: var(--shadow);
}
.card h1 { font-size: 20px; margin: 0 0 8px; }
.login label { display: block; margin: 14px 0 6px; font-weight: 600; }
.alert {
    padding: 10px 12px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    color: var(--danger);
    margin-bottom: 4px;
}

.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; color: var(--text); text-decoration: none; }
.brand-large { font-size: 20px; margin-bottom: 4px; }
.logo { width: 26px; height: 26px; fill: var(--accent); }

/* file browser */
.app { display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.search { max-width: 420px; margin: 0 auto; background: var(--bg); }
.user { display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.user form { margin: 0; }

.content { position: relative; flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px 24px 40px; }

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

.where { display: flex; align-items: center; gap: 8px; min-width: 0; }
.icon-button { padding: 6px; }
.icon-button svg { width: 18px; height: 18px; fill: currentColor; }
.icon-button:disabled { opacity: .4; cursor: default; background: var(--surface); }

.files tbody tr.row { cursor: default; user-select: none; }
.files tbody tr.row:focus { outline: none; }
.files tbody tr.selected { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.files tbody tr.selected:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.files tbody tr.row:focus-visible td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.up-row { color: var(--muted); }
.up-row:hover { cursor: pointer !important; }
.icon.up { fill: var(--muted); }

.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 18px; font-weight: 600; min-width: 0; }
.crumbs a { color: var(--text); text-decoration: none; padding: 2px 6px; border-radius: 6px; }
.crumbs a:hover { background: var(--hover); }
.crumbs .sep { color: var(--muted); }
.crumbs .current { padding: 2px 6px; }

.message { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; background: var(--hover); }
.message.error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

.files {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}
/* round the corner cells instead of clipping the table, so row menus can extend past it */
.files thead th:first-child { border-top-left-radius: 12px; }
.files thead th:last-child { border-top-right-radius: 12px; }
.files tbody tr:last-child td:first-child { border-bottom-left-radius: 12px; }
.files tbody tr:last-child td:last-child { border-bottom-right-radius: 12px; }
.files th, .files td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.files tbody tr:last-child td { border-bottom: 0; }
.files th { font-weight: 600; color: var(--muted); font-size: 13px; background: var(--surface); }
.files th .sort { border: 0; background: none; padding: 0; color: inherit; font-weight: 600; }
.files th .sort[aria-sort="ascending"]::after { content: " \2191"; }
.files th .sort[aria-sort="descending"]::after { content: " \2193"; }
.files tbody tr:hover { background: var(--hover); }
.col-date { width: 190px; }
.col-size { width: 110px; text-align: right !important; }
.col-menu { width: 48px; }

.name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.name a { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name a:hover { color: var(--accent); text-decoration: underline; }
.icon { width: 22px; height: 22px; flex: none; }
.icon.folder { fill: var(--folder); }
.icon.file { fill: var(--file); }

.menu { position: relative; }
.menu > button { border: 0; background: none; padding: 4px 8px; font-size: 18px; line-height: 1; color: var(--muted); }
.menu > button:hover { background: var(--border); }
.menu ul {
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 10;
    min-width: 150px;
    margin: 4px 0 0;
    padding: 6px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
}
.menu ul.up { top: auto; bottom: 100%; margin: 0 0 4px; }
.menu li button { width: 100%; border: 0; background: none; padding: 7px 10px; justify-content: flex-start; }
.menu li button:hover { background: var(--hover); }
.menu li button.danger { color: var(--danger); }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.uploads { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.upload {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.upload .bar { grid-column: 1 / -1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.upload .bar > div { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.upload.failed { grid-template-columns: 1fr auto auto; }
.upload .dismiss { border: 0; background: none; padding: 0 4px; font-size: 18px; line-height: 1; color: var(--muted); }
.upload .dismiss:hover { background: var(--hover); color: var(--text); }
.upload.failed .bar > div { background: var(--danger); }
.upload.failed .status { color: var(--danger); }

.dropzone {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 20;
    place-items: center;
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    border: 3px dashed var(--accent);
    font-size: 22px;
    font-weight: 600;
    color: var(--accent);
}
.dragging .dropzone { display: grid; }

@media (max-width: 700px) {
    .topbar { padding: 10px 16px; flex-wrap: wrap; }
    .search { order: 3; max-width: none; flex-basis: 100%; }
    .user .muted { display: none; }
    .content { padding: 16px; }
    .col-date { display: none; }
    .col-size { width: 80px; }
}
