:root {
  color-scheme: light;
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #edf2f8;
  --surface-3: #e4ebf4;
  --text: #172236;
  --muted: #65738a;
  --border: #d9e1ec;
  --primary: #5367e8;
  --primary-dark: #3f50c9;
  --primary-soft: #e7eaff;
  --accent: #23b3a6;
  --danger: #d9425f;
  --danger-soft: #fdecef;
  --success: #16856f;
  --shadow: 0 14px 45px rgba(31, 45, 78, .12);
  --shadow-small: 0 6px 18px rgba(31, 45, 78, .12);
  --radius: 18px;
  --radius-small: 10px;
  --sidebar-width: 248px;
  --topbar-height: 72px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101622;
  --surface: #182131;
  --surface-2: #202b3d;
  --surface-3: #2a3649;
  --text: #eef3fb;
  --muted: #a5b1c3;
  --border: #334157;
  --primary: #8998ff;
  --primary-dark: #7485f5;
  --primary-soft: #29335e;
  --danger: #ff7690;
  --danger-soft: #4a2630;
  --success: #63d2bb;
  --shadow: 0 16px 48px rgba(0, 0, 0, .35);
  --shadow-small: 0 6px 20px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 42%, transparent); outline-offset: 2px; }
input, select { width: 100%; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: var(--radius-small); padding: 11px 12px; }
input:hover, select:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
input:focus, select:focus { border-color: var(--primary); }
label { display: grid; gap: 7px; color: var(--muted); font-weight: 650; font-size: .9rem; }
h1, h2, h3, p { margin-top: 0; }
h1 { letter-spacing: -.035em; }
code { background: var(--surface-2); border-radius: 6px; padding: 2px 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 12px; top: -50px; z-index: 200; padding: 10px 14px; background: var(--text); color: var(--surface); border-radius: 8px; }
.skip-link:focus { top: 10px; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.025em; font-size: 1.12rem; }
.brand-large { font-size: 1.35rem; }
.brand-mark { position: relative; display: inline-grid; grid-template-columns: repeat(2, 11px); grid-template-rows: repeat(2, 11px); gap: 3px; transform: rotate(-8deg); }
.brand-mark span { display: block; border-radius: 4px; }
.brand-mark span:nth-child(1) { background: var(--primary); grid-row: span 2; }
.brand-mark span:nth-child(2) { background: var(--accent); }
.brand-mark span:nth-child(3) { background: #f0a14b; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 9px 15px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; font-weight: 700; transition: transform .15s ease, background .15s ease, border-color .15s ease; }
.button:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }
.button:active { transform: scale(.98); }
.button:disabled { opacity: .55; cursor: wait; }
.button-primary { border-color: var(--primary); background: var(--primary); color: white; }
.button-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.button-danger { border-color: var(--danger); background: var(--danger); color: white; }
.button-wide { width: 100%; }
.icon-button { display: inline-grid; place-items: center; min-width: 38px; min-height: 38px; border: 0; border-radius: 50%; background: transparent; cursor: pointer; color: var(--muted); }
.icon-button:hover { background: var(--surface-2); color: var(--text); }
.danger-text { color: var(--danger) !important; }
.eyebrow { margin-bottom: 8px; color: var(--primary); text-transform: uppercase; letter-spacing: .14em; font-size: .75rem; font-weight: 850; }
.form-error { margin: 8px 0; color: var(--danger); font-size: .9rem; }
.password-field { display: flex; align-items: center; position: relative; }
.password-field input { padding-right: 65px; }
.password-field .password-toggle { position: absolute; right: 5px; width: auto; border-radius: 8px; font-size: .78rem; }
.password-hint { color: var(--muted); font-size: .82rem; }
.popover { position: absolute; z-index: 70; background: var(--surface); border: 1px solid var(--border); border-radius: 13px; box-shadow: var(--shadow-small); }

/* Authentication */
.auth-page { overflow: hidden; }
.auth-shell { display: grid; grid-template-columns: minmax(340px, 1.1fr) minmax(380px, .9fr); min-height: 100vh; }
.auth-brand { position: relative; display: flex; flex-direction: column; justify-content: center; padding: clamp(48px, 9vw, 132px); color: white; overflow: hidden; background: radial-gradient(circle at 75% 20%, rgba(98, 220, 205, .6), transparent 28%), linear-gradient(145deg, #283891, #586ce7 55%, #4456c8); }
.auth-brand::before, .auth-brand::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.15); border-radius: 42px; transform: rotate(28deg); }
.auth-brand::before { width: 340px; height: 340px; right: -110px; bottom: -80px; }
.auth-brand::after { width: 180px; height: 180px; left: -70px; top: 10%; }
.auth-brand .brand { position: absolute; top: 42px; left: clamp(48px, 9vw, 132px); }
.auth-brand h1 { max-width: 650px; margin: 0 0 22px; font-size: clamp(2.6rem, 5vw, 5.7rem); line-height: .98; }
.auth-brand > p { max-width: 580px; color: rgba(255,255,255,.82); font-size: 1.12rem; line-height: 1.7; }
.security-note { position: absolute; bottom: 44px; display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.78); font-size: .88rem; }
.auth-card { align-self: center; width: min(430px, calc(100% - 48px)); margin: auto; padding: 32px; }
.auth-card h2 { margin-bottom: 30px; font-size: 2rem; }
.auth-card form { display: grid; gap: 12px; }
.auth-card input { padding: 14px; }
.auth-card .button { margin-top: 12px; min-height: 48px; }
.auth-help { margin-top: 28px; color: var(--muted); text-align: center; font-size: .9rem; }
.mobile-brand { display: none; }

/* App chrome */
.app-shell { display: grid; grid-template: var(--topbar-height) calc(100vh - var(--topbar-height)) / var(--sidebar-width) minmax(0, 1fr) auto; }
.topbar { grid-column: 1 / -1; z-index: 50; display: grid; grid-template-columns: var(--sidebar-width) minmax(240px, 720px) 1fr auto auto; align-items: center; gap: 12px; height: var(--topbar-height); padding: 0 20px 0 24px; background: var(--bg); }
.search-bar { position: relative; display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 8px 0 16px; border-radius: 24px; background: var(--surface-2); }
.search-bar > span { color: var(--muted); font-size: 1.4rem; }
.search-bar input { border: 0; padding: 0; background: transparent; }
.search-bar input:focus { outline: none; }
.search-options { top: 55px; right: 0; width: 300px; padding: 18px; display: grid; gap: 10px; }
.avatar-button { width: 40px; height: 40px; border: 3px solid var(--surface); border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; cursor: pointer; font-weight: 850; box-shadow: 0 0 0 1px var(--border); }
.account-wrap { position: relative; }
.account-menu { top: 48px; right: 0; width: 240px; padding: 10px; }
.account-menu strong, .account-menu span { display: block; padding: 4px 9px; }
.account-menu span { color: var(--muted); font-size: .83rem; margin-bottom: 8px; }
.account-menu a, .account-menu button { display: flex; width: 100%; padding: 10px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; }
.account-menu a:hover, .account-menu button:hover { background: var(--surface-2); }
.sidebar { grid-row: 2; display: flex; flex-direction: column; min-width: 0; padding: 18px 14px 22px; background: var(--bg); }
.new-button { position: relative; align-self: flex-start; min-height: 52px; padding: 12px 22px; border: 0; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-small); }
.new-button span { color: var(--primary); font-size: 1.55rem; font-weight: 400; }
.new-menu { top: 76px; left: 18px; width: 210px; padding: 8px; }
.new-menu button { display: block; width: 100%; padding: 11px; border: 0; border-radius: 8px; background: transparent; text-align: left; cursor: pointer; }
.new-menu button:hover { background: var(--surface-2); }
.side-nav { display: grid; gap: 4px; margin-top: 28px; }
.nav-item { display: flex; align-items: center; gap: 13px; width: 100%; padding: 11px 14px; border: 0; border-radius: 20px; background: transparent; cursor: pointer; text-align: left; font-weight: 650; }
.nav-item span { width: 22px; color: var(--muted); text-align: center; font-size: 1.1rem; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item.active span { color: var(--primary); }
.storage-card { margin-top: auto; padding: 14px; color: var(--muted); font-size: .78rem; }
.storage-label { display: flex; justify-content: space-between; color: var(--text); font-weight: 750; }
.progress-track { height: 7px; margin: 10px 0; overflow: hidden; border-radius: 10px; background: var(--surface-3); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .35s ease; }
.storage-card p { margin: 0; }
.file-main { position: relative; grid-column: 2; grid-row: 2; min-width: 0; margin: 0 8px 12px 0; overflow: auto; border-radius: 22px; background: var(--surface); }
.file-toolbar { position: sticky; top: 0; z-index: 12; display: flex; align-items: center; justify-content: space-between; min-height: 96px; padding: 20px 24px 14px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); }
.file-toolbar h1 { margin: 0 0 8px; font-size: 1.45rem; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.toolbar-actions select { width: 150px; padding: 8px 10px; }
.breadcrumbs { display: flex; gap: 4px; overflow: hidden; }
.breadcrumbs button { max-width: 180px; overflow: hidden; border: 0; background: transparent; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.breadcrumbs button:not(:last-child)::after { content: "›"; padding-left: 8px; }
.bulk-toolbar { position: sticky; top: 96px; z-index: 11; display: flex; align-items: center; gap: 8px; min-height: 52px; margin: 0 18px 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 13px; background: var(--primary-soft); }
.bulk-toolbar strong { margin-right: auto; }
.bulk-toolbar button { border: 0; border-radius: 8px; background: transparent; padding: 8px; cursor: pointer; }
.bulk-toolbar button:hover { background: var(--surface); }
.file-list { min-height: 250px; padding: 4px 18px 36px; }
.file-header, .file-row { display: grid; grid-template-columns: 36px minmax(240px, 1fr) minmax(130px, .34fr) minmax(115px, .25fr) 110px 42px; align-items: center; gap: 12px; min-height: 52px; padding: 0 10px; border-bottom: 1px solid var(--border); }
.file-header { position: sticky; top: 96px; z-index: 8; background: var(--surface); color: var(--muted); font-size: .78rem; font-weight: 750; }
.file-row { border-radius: 9px; cursor: default; user-select: none; }
.file-row:hover { background: var(--surface-2); }
.file-row.selected { background: var(--primary-soft); }
.file-row.drag-over { outline: 2px solid var(--primary); background: var(--primary-soft); }
.file-check { width: 17px; height: 17px; accent-color: var(--primary); }
.file-name { display: flex; align-items: center; min-width: 0; gap: 12px; }
.file-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-icon { display: inline-grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px; background: var(--surface-2); color: var(--primary); font-weight: 900; }
.file-icon.folder { background: #fff1cb; color: #b4780e; }
html[data-theme="dark"] .file-icon.folder { background: #4b4025; color: #ffd271; }
.file-meta { overflow: hidden; color: var(--muted); font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.row-menu { opacity: 0; }
.file-row:hover .row-menu, .file-row.selected .row-menu, .row-menu:focus { opacity: 1; }
.grid-view { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; align-content: start; padding: 12px 22px 36px; }
.grid-view .file-header { display: none; }
.grid-view .file-row { position: relative; display: grid; grid-template-columns: 28px 1fr 32px; grid-template-rows: auto 1fr auto; gap: 8px; min-height: 178px; padding: 12px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface-2); }
.grid-view .file-name { grid-column: 1 / -1; grid-row: 2; flex-direction: column; justify-content: center; }
.grid-view .file-name .file-icon { width: 62px; height: 62px; font-size: 1.5rem; }
.grid-view .file-meta.owner, .grid-view .file-meta.size { display: none; }
.grid-view .file-meta.modified { grid-column: 1 / 3; grid-row: 3; }
.grid-view .row-menu { grid-column: 3; grid-row: 1; opacity: 1; }
.empty-state { display: grid; place-items: center; align-content: center; min-height: 370px; padding: 40px; text-align: center; color: var(--muted); }
.empty-state h2 { color: var(--text); margin-bottom: 8px; }
.empty-illustration { display: grid; place-items: center; width: 86px; height: 86px; margin-bottom: 22px; border-radius: 28px; background: var(--primary-soft); color: var(--primary); font-size: 2.4rem; transform: rotate(-5deg); }
.skeleton-list { display: grid; gap: 13px; padding: 15px 28px; }
.skeleton-list span, .skeleton-line { height: 34px; border-radius: 9px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.details-panel { grid-column: 3; grid-row: 2; width: 320px; margin: 0 8px 12px 0; overflow: auto; border-radius: 22px; background: var(--surface); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 22px; border-bottom: 1px solid var(--border); }
.panel-heading h2 { margin: 0; font-size: 1.15rem; }
.details-content { padding: 22px; }
.detail-preview { display: grid; place-items: center; height: 150px; margin-bottom: 22px; border-radius: 14px; background: var(--surface-2); font-size: 3.2rem; }
.detail-list { display: grid; grid-template-columns: 90px 1fr; gap: 12px 8px; font-size: .85rem; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.drop-overlay { position: fixed; inset: var(--topbar-height) 0 0 var(--sidebar-width); z-index: 100; padding: 22px; background: rgba(52, 69, 145, .16); backdrop-filter: blur(4px); }
.drop-overlay div { display: grid; place-items: center; align-content: center; width: 100%; height: 100%; border: 3px dashed var(--primary); border-radius: 24px; background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--primary); }
.drop-overlay strong { font-size: 1.5rem; }
.drop-overlay span { margin-top: 8px; color: var(--muted); }
.context-menu { position: fixed; z-index: 120; min-width: 185px; padding: 7px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.context-menu button { display: block; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px; background: transparent; text-align: left; cursor: pointer; }
.context-menu button:hover { background: var(--surface-2); }
.upload-panel { position: fixed; z-index: 80; right: 20px; bottom: 0; width: min(420px, calc(100vw - 30px)); max-height: 52vh; overflow: hidden; border: 1px solid var(--border); border-bottom: 0; border-radius: 15px 15px 0 0; background: var(--surface); box-shadow: var(--shadow); }
.upload-panel header { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; background: var(--text); color: var(--surface); }
#upload-queue { max-height: 42vh; overflow: auto; }
.upload-item { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.upload-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item small { color: var(--muted); }
.upload-actions { grid-row: 1 / 3; grid-column: 2; display: flex; align-items: center; }
.upload-progress { grid-column: 1 / -1; height: 4px; overflow: hidden; border-radius: 5px; background: var(--surface-3); }
.upload-progress span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .15s linear; }
.upload-item.failed .upload-progress span { background: var(--danger); }

/* Dialogs */
dialog { width: min(500px, calc(100vw - 30px)); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(13, 19, 32, .5); backdrop-filter: blur(3px); }
dialog form { display: grid; gap: 13px; padding: 24px; }
dialog h2 { margin-bottom: 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 12px; }
.folder-picker { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.folder-choice { display: flex; width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--border); background: transparent; text-align: left; cursor: pointer; }
.folder-choice:hover, .folder-choice.active { background: var(--primary-soft); color: var(--primary); }
.share-add { display: grid; grid-template-columns: 1fr 110px auto; gap: 8px; }
#share-list { display: grid; gap: 6px; }
.share-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; padding: 8px; border-radius: 9px; background: var(--surface-2); }
.share-row span { color: var(--muted); font-size: .8rem; }
#public-link-result { display: grid; grid-template-columns: 1fr auto auto; gap: 7px; }
.preview-dialog { width: min(1100px, calc(100vw - 24px)); max-width: none; height: min(780px, calc(100vh - 24px)); }
.preview-dialog[open] { display: grid; grid-template-rows: auto 1fr; }
.preview-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.preview-header strong { margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-body { display: grid; place-items: center; min-height: 0; overflow: auto; background: #111723; }
.preview-body img, .preview-body video { max-width: 100%; max-height: 100%; }
.preview-body audio { width: min(600px, 90%); }
.preview-body iframe { width: 100%; height: 100%; border: 0; background: white; }
.preview-body pre { align-self: stretch; justify-self: stretch; margin: 0; padding: 24px; overflow: auto; color: #dce6f6; white-space: pre-wrap; overflow-wrap: anywhere; }
.preview-fallback { color: white; text-align: center; }

/* Admin and setup */
.admin-header, .public-header { display: flex; align-items: center; justify-content: space-between; min-height: 72px; padding: 0 clamp(20px, 4vw, 64px); border-bottom: 1px solid var(--border); background: var(--surface); }
.admin-header > div { display: flex; gap: 8px; }
.admin-main { width: min(1180px, calc(100% - 36px)); margin: 40px auto 80px; }
.admin-intro { margin-bottom: 28px; }
.admin-intro h1 { margin-bottom: 8px; font-size: 2.4rem; }
.admin-intro p { color: var(--muted); }
.admin-card { margin-bottom: 22px; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 5px 20px rgba(31,45,78,.05); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-heading h2 { margin-bottom: 5px; }
.section-heading p { margin: 0; color: var(--muted); }
.admin-form { display: grid; grid-template-columns: 1fr 1.2fr 1.25fr .7fr .7fr; align-items: end; gap: 14px; }
.form-span { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; }
.form-span .password-hint { margin: 0 auto 0 0; }
.table-search { width: min(280px, 100%); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; }
.user-cell strong, .user-cell span { display: block; }
.user-cell span { color: var(--muted); font-size: .8rem; }
.status-pill { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 20px; font-size: .75rem; font-weight: 800; }
.status-pill.enabled { color: var(--success); background: color-mix(in srgb, var(--success) 15%, transparent); }
.status-pill.disabled { color: var(--danger); background: var(--danger-soft); }
.table-actions { display: flex; justify-content: flex-end; gap: 4px; }
.table-actions button { border: 0; border-radius: 7px; background: transparent; padding: 7px; cursor: pointer; }
.table-actions button:hover { background: var(--surface-2); }
.setup-page, .error-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 30% 10%, var(--primary-soft), transparent 32%), var(--bg); }
.setup-shell { width: min(760px, 100%); }
.setup-shell > .brand { margin-bottom: 22px; }
.setup-card { padding: clamp(24px, 5vw, 48px); border: 1px solid var(--border); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.setup-form { display: grid; gap: 12px; }
.alert { margin: 15px 0; padding: 13px 15px; border-radius: 10px; }
.alert-error { color: var(--danger); background: var(--danger-soft); }
.alert-success { color: var(--success); background: color-mix(in srgb, var(--success) 14%, transparent); }
.error-shell { width: min(560px, 100%); text-align: center; }
.error-code { margin-top: 45px; color: var(--primary); font-size: 6rem; font-weight: 900; letter-spacing: -.08em; }
.error-shell p { color: var(--muted); }

/* Public sharing */
.public-header span { color: var(--muted); }
.public-main { width: min(1000px, calc(100% - 32px)); margin: 40px auto; }
.public-title { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.public-title h1 { margin: 0; }
.public-list, .public-preview { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.public-row { display: grid; grid-template-columns: 50px 1fr auto; align-items: center; min-height: 66px; padding: 8px 18px; border-bottom: 1px solid var(--border); }
.public-row:hover { background: var(--surface-2); }
.public-row > span:last-child { color: var(--muted); }
.public-preview { display: grid; place-items: center; min-height: 540px; background: #111723; }
.public-preview img, .public-preview video { max-width: 100%; max-height: 720px; }
.public-preview iframe { width: 100%; height: 720px; border: 0; }
.public-preview audio { width: min(600px, 90%); }

.toast-region { position: fixed; z-index: 250; right: 18px; top: 18px; display: grid; gap: 8px; width: min(380px, calc(100vw - 36px)); }
.toast { display: flex; align-items: center; gap: 10px; padding: 13px 15px; border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 11px; background: var(--surface); box-shadow: var(--shadow-small); animation: toast-in .22s ease; }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
.mobile-only { display: none; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 0 minmax(0,1fr) auto; }
  .topbar { grid-template-columns: auto auto minmax(160px,1fr) auto auto; padding-left: 10px; }
  .mobile-only { display: inline-grid; }
  .sidebar { position: fixed; z-index: 90; top: var(--topbar-height); bottom: 0; left: 0; width: var(--sidebar-width); transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); background: var(--surface); }
  .sidebar.open { transform: translateX(0); }
  .file-main { grid-column: 2; margin-left: 8px; }
  .drop-overlay { left: 0; }
  .admin-form { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .auth-shell { display: block; padding: 28px 0; }
  .auth-brand { display: none; }
  .auth-card { margin-top: 8vh; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
  .mobile-brand { display: inline-flex; margin-bottom: 44px; }
  .topbar { grid-template-columns: auto 1fr auto auto; }
  .topbar > .brand { display: none; }
  .search-bar { grid-column: 2; }
  .file-toolbar { min-height: 86px; padding: 16px; }
  .file-header { display: none; }
  .file-row { grid-template-columns: 28px minmax(0,1fr) 38px; min-height: 65px; }
  .file-row .owner, .file-row .size { display: none; }
  .file-row .modified { grid-column: 2; grid-row: 2; }
  .file-name { grid-column: 2; }
  .row-menu { grid-column: 3; grid-row: 1 / 3; opacity: 1; }
  .bulk-toolbar { top: 86px; overflow-x: auto; }
  .details-panel { position: fixed; z-index: 95; inset: var(--topbar-height) 0 0 auto; width: min(360px, 100vw); margin: 0; border-radius: 0; box-shadow: var(--shadow); }
  .toolbar-actions select { display: none; }
  .admin-form { grid-template-columns: 1fr; }
  .form-span { grid-column: 1; align-items: stretch; flex-direction: column; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .public-title { align-items: flex-start; flex-direction: column; }
  .public-header > span { display: none; }
  .share-add, #public-link-result { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .topbar { gap: 4px; padding-right: 8px; }
  .search-bar { height: 42px; }
  .file-main { margin: 0; border-radius: 0; }
  .file-list { padding-inline: 7px; }
  .grid-view { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; padding: 8px; }
  .grid-view .file-row { min-height: 160px; }
  .file-toolbar { padding-inline: 12px; }
  .file-toolbar h1 { font-size: 1.2rem; }
  .breadcrumbs { max-width: 210px; }
  .admin-card { padding: 17px; }
  .admin-main { width: min(100% - 20px, 1180px); margin-top: 22px; }
  .public-row { grid-template-columns: 44px 1fr; }
  .public-row > span:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Visibility must win over component display:grid/flex declarations. */
[hidden] { display: none !important; }
.file-toolbar { position: relative; flex-wrap: wrap; gap: 12px; background: var(--surface); backdrop-filter: none; }
.file-toolbar > div:first-child { min-width: 0; }
.toolbar-actions { flex-wrap: wrap; }
.filter-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 0 24px 16px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.filter-bar label { margin: 0; color: var(--muted); font-size: .85rem; }
.filter-bar select { width: auto; min-width: 130px; min-height: 44px; }
.refresh-button { min-height: 44px; white-space: nowrap; }
.refresh-icon { display: inline-block; font-size: 1.25rem; }
.is-refreshing .refresh-icon { animation: refresh-spin .8s linear infinite; }
@keyframes refresh-spin { to { transform: rotate(360deg); } }
.load-error { margin: 12px 24px; padding: 14px; border-radius: 10px; background: var(--surface-2); color: var(--text); }
.bulk-toolbar, .file-header { position: relative; top: auto; }
.breadcrumbs { max-width: 100%; overflow-x: auto; }
.breadcrumbs button { flex-shrink: 0; min-height: 32px; }
@media (max-width: 1100px) {
  .file-header, .list-view .file-row { grid-template-columns: 28px minmax(0,1fr) 110px 100px 72px 44px; gap: 8px; }
  .details-panel { position: fixed; z-index: 95; inset: var(--topbar-height) 0 0 auto; width: min(360px, 100vw); margin: 0; }
}
@media (max-width: 760px) {
  .app-shell { height: 100dvh; }
  .file-toolbar { align-items: flex-start; gap: 10px; }
  .toolbar-actions { width: 100%; gap: 6px; }
  .toolbar-actions select { display: block; flex: 1; min-width: 90px; width: 90px; min-height: 44px; }
  .filter-bar { display: grid; grid-template-columns: auto minmax(0,1fr); margin: 0 12px 12px; gap: 8px; }
  .filter-bar select { width: 100%; min-width: 0; }
  .list-view .file-row { grid-template-columns: 28px minmax(0,1fr) 44px; gap: 4px 8px; padding-block: 8px; }
  .icon-button, .avatar-button { min-width: 44px; min-height: 44px; }
  input, select, textarea { font-size: 16px; }
  .search-bar { min-width: 0; padding-inline: 8px; }
  .search-bar input { min-width: 0; }
  .bulk-toolbar { flex-wrap: wrap; overflow: visible; margin-inline: 12px; }
  .bulk-toolbar button { min-height: 44px; }
  .upload-panel { right: 8px; width: calc(100vw - 16px); max-height: 45dvh; }
  dialog { max-height: 90dvh; overflow-y: auto; }
  .preview-header { flex-wrap: wrap; }
  .preview-header strong { min-width: 0; max-width: 45vw; }
}
@media (pointer: coarse) { .row-menu { opacity: 1; } .file-check { width: 24px; height: 24px; } }
@media (prefers-reduced-motion: reduce) { .is-refreshing .refresh-icon, .skeleton-list span { animation: none; } }
