:root {
  color-scheme: light;
  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-soft: #edf3f5;
  --ink: #10263f;
  --muted: #667889;
  --line: #dce5e9;
  --accent: #0f806f;
  --accent-strong: #096b5d;
  --accent-soft: #dbf3ed;
  --accent-contrast: #ffffff;
  --danger: #bd3639;
  --danger-soft: #fee9e9;
  --shadow: 0 18px 45px rgba(22, 43, 65, 0.12);
  --radius: 14px;
  --sidebar: 226px;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1722;
  --surface: #132230;
  --surface-raised: #182a3a;
  --surface-soft: #1c3040;
  --ink: #eef6f7;
  --muted: #9fb0bb;
  --line: #2a3d4b;
  --accent: #55d6be;
  --accent-strong: #78e3cf;
  --accent-soft: #163f3a;
  --accent-contrast: #06211e;
  --danger: #ff8d8d;
  --danger-soft: #48272c;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
}

html[data-theme="christmas"] {
  color-scheme: dark;
  --bg: #071e18;
  --surface: #0d2b22;
  --surface-raised: #12362a;
  --surface-soft: #1b4637;
  --ink: #fff8e8;
  --muted: #c9d5c5;
  --line: #315b48;
  --accent: #e34b50;
  --accent-strong: #f26064;
  --accent-soft: #4b2528;
  --accent-contrast: #ffffff;
  --danger: #f1c66a;
  --danger-soft: #493d25;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
}

html[data-theme="matrix"] {
  color-scheme: dark;
  --bg: #020704;
  --surface: #06120a;
  --surface-raised: #08190d;
  --surface-soft: #0d2714;
  --ink: #9cffad;
  --muted: #5dbd72;
  --line: #175b29;
  --accent: #35ff69;
  --accent-strong: #79ff96;
  --accent-soft: #0b3518;
  --accent-contrast: #001b08;
  --danger: #ff6173;
  --danger-soft: #3a141b;
  --shadow: 0 0 30px rgba(38, 255, 91, 0.12);
  --font-ui: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

html[data-theme="retro"] {
  color-scheme: dark;
  --bg: #16113f;
  --surface: #251b5e;
  --surface-raised: #302275;
  --surface-soft: #40308c;
  --ink: #fff7c7;
  --muted: #b9b0e9;
  --line: #6554bd;
  --accent: #ffd84b;
  --accent-strong: #ffe783;
  --accent-soft: #51461d;
  --accent-contrast: #20164f;
  --danger: #ff5a9d;
  --danger-soft: #542047;
  --shadow: 6px 6px 0 #09061e;
  --font-ui: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

html[data-theme="terminal"] {
  color-scheme: dark;
  --bg: #12110c;
  --surface: #1c1a12;
  --surface-raised: #242116;
  --surface-soft: #302b19;
  --ink: #e9c46a;
  --muted: #aa9255;
  --line: #5e4e27;
  --accent: #a7c66b;
  --accent-strong: #c0da87;
  --accent-soft: #334021;
  --accent-contrast: #12170b;
  --danger: #e17b53;
  --danger-soft: #45271b;
  --shadow: 0 15px 38px rgba(0, 0, 0, 0.46);
  --font-ui: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

html[data-theme="christmas"] .topbar { border-bottom-color: #8f6c3b; }
html[data-theme="matrix"] .brand, html[data-theme="matrix"] .eyebrow { text-shadow: 0 0 10px rgba(53, 255, 105, .55); }
html[data-theme="retro"] :is(.button, .icon-button, .nav-item, input, select, .dialog, .file-row, .theme-menu) { border-radius: 4px; }
html[data-theme="terminal"] :is(.button, .icon-button, .nav-item, input, select, .dialog, .file-row, .theme-menu) { border-radius: 2px; }

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 34%, transparent);
  outline-offset: 2px;
}

[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 12%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 35%),
    linear-gradient(145deg, var(--bg), color-mix(in srgb, var(--surface-soft) 75%, var(--bg)));
}

.login-card {
  width: min(100%, 430px);
  padding: 42px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--ink);
  color: var(--accent);
}
.brand-mark svg { width: 32px; height: 32px; fill: currentColor; }
.brand-mark.small { width: 34px; height: 34px; border-radius: 10px; }
.brand-mark.small svg { width: 22px; height: 22px; }

.eyebrow { margin: 24px 0 5px; color: var(--accent); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.15em; }
.login-card h1 { margin: 0 0 28px; font-size: clamp(1.8rem, 5vw, 2.35rem); line-height: 1.12; letter-spacing: -0.035em; }
.login-card label, .dialog label { display: block; margin-bottom: 8px; font-size: 0.9rem; font-weight: 700; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 50px; }
input[type="password"], input[type="text"], input[type="search"], select {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
}
.password-wrap .icon-button { position: absolute; right: 5px; top: 4px; }
.form-error { min-height: 23px; margin: 7px 0 8px; color: var(--danger); font-size: 0.87rem; }
.login-note { margin: 22px 0 0; color: var(--muted); font-size: 0.82rem; text-align: center; }

.button, .icon-button, .nav-item {
  border: 0;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, transform 150ms ease;
}
.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 15px;
  border-radius: 10px;
  font-weight: 750;
  font-size: 0.9rem;
}
.button:active, .icon-button:active { transform: translateY(1px); }
.button.wide { width: 100%; min-height: 48px; }
.button.primary { color: var(--accent-contrast); background: var(--accent); }
.button.primary:hover { background: var(--accent-strong); }
.button.secondary { background: var(--surface); border: 1px solid var(--line); }
.button.secondary:hover, .button.ghost:hover { background: var(--surface-soft); }
.button.ghost, .button.danger-ghost { background: transparent; }
.button.danger, .button.danger-ghost { color: #fff; background: var(--danger); }
.button.danger-ghost { color: var(--danger); background: transparent; }
.button.danger-ghost:hover { background: var(--danger-soft); }
.button.compact { padding-inline: 11px; }
.icon-button {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 10px;
  background: transparent;
}
.icon-button:hover { background: var(--surface-soft); }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template: 68px 1fr / var(--sidebar) 1fr;
}
.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(220px, 620px) 1fr;
  align-items: center;
  gap: 22px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--surface) 91%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); font-weight: 820; text-decoration: none; letter-spacing: -0.02em; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box > .icon { position: absolute; left: 14px; color: var(--muted); }
.search-box input { min-height: 42px; padding: 8px 50px 8px 43px; background: var(--surface-soft); border-color: transparent; }
.search-box kbd { position: absolute; right: 12px; padding: 1px 7px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; font-size: 0.75rem; }
.top-actions { display: flex; justify-content: flex-end; gap: 4px; }
.theme-control { position: relative; }
.theme-menu { position: absolute; z-index: 90; top: calc(100% + 10px); right: 0; width: 225px; padding: 7px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); }
.theme-option { width: 100%; min-height: 42px; display: flex; align-items: center; gap: 11px; padding: 8px 10px; color: var(--ink); background: transparent; border: 0; border-radius: 8px; cursor: pointer; text-align: left; font-size: .86rem; }
.theme-option:hover, .theme-option[aria-checked="true"] { background: var(--surface-soft); }
.theme-option[aria-checked="true"] { font-weight: 800; }
.theme-swatch { width: 20px; height: 20px; flex: 0 0 auto; border: 2px solid color-mix(in srgb, var(--ink) 28%, transparent); border-radius: 50%; background: linear-gradient(135deg, var(--swatch-a) 0 50%, var(--swatch-b) 50%); }
.theme-option[data-theme-choice="light"] { --swatch-a: #f4f7f9; --swatch-b: #0f806f; }
.theme-option[data-theme-choice="dark"] { --swatch-a: #0d1722; --swatch-b: #55d6be; }
.theme-option[data-theme-choice="christmas"] { --swatch-a: #0d2b22; --swatch-b: #e34b50; }
.theme-option[data-theme-choice="matrix"] { --swatch-a: #020704; --swatch-b: #35ff69; }
.theme-option[data-theme-choice="retro"] { --swatch-a: #251b5e; --swatch-b: #ffd84b; }
.theme-option[data-theme-choice="terminal"] { --swatch-a: #1c1a12; --swatch-b: #e9c46a; }

.sidebar {
  position: sticky;
  top: 68px;
  height: calc(100vh - 68px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.sidebar nav { display: grid; gap: 5px; }
.nav-item {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 10px;
  background: transparent;
  font-weight: 700;
  text-align: left;
}
.nav-item:hover { background: var(--surface-soft); }
.nav-item.active { color: var(--accent-strong); background: var(--accent-soft); }
.storage-card { padding: 14px 10px; }
.storage-label { display: flex; justify-content: space-between; gap: 10px; font-size: 0.79rem; font-weight: 750; }
.meter { height: 6px; margin: 9px 0; overflow: hidden; background: var(--surface-soft); border-radius: 999px; }
.meter span { display: block; width: 0; height: 100%; background: var(--accent); border-radius: inherit; transition: width 350ms ease; }
.storage-card p { margin: 0; color: var(--muted); font-size: 0.76rem; }

.workspace { min-width: 0; padding: 28px clamp(20px, 4vw, 48px) 72px; }
.workspace-head { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.workspace-actions, .toolbar-group { display: flex; align-items: center; gap: 8px; }
.breadcrumbs { min-width: 0; display: flex; align-items: center; overflow: hidden; white-space: nowrap; }
.breadcrumb { max-width: 210px; overflow: hidden; padding: 6px; color: var(--muted); background: transparent; border: 0; border-radius: 7px; font-size: 0.96rem; font-weight: 700; text-overflow: ellipsis; cursor: pointer; }
.breadcrumb:last-child { color: var(--ink); font-size: 1.18rem; font-weight: 820; }
.breadcrumb:hover { background: var(--surface-soft); }
.breadcrumb-separator { flex: 0 0 auto; color: var(--muted); }
.breadcrumb-separator .icon { width: 16px; height: 16px; }

.view-toolbar { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 12px; border-bottom: 1px solid var(--line); }
.view-toolbar p { margin: 0; color: var(--muted); font-size: 0.87rem; }
.select-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.toolbar-group select { width: auto; min-height: 38px; padding: 7px 32px 7px 11px; font-size: 0.85rem; }
.selection-bar { min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 12px 0 0; padding: 6px 8px 6px 15px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line)); border-radius: 12px; }
.selection-bar > div { display: flex; align-items: center; gap: 2px; }
.selection-bar strong { font-size: 0.9rem; }

.file-surface { position: relative; min-height: 430px; padding-top: 14px; }
.file-list { display: grid; gap: 4px; }
.file-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 38px minmax(180px, 1fr) minmax(105px, .4fr) minmax(120px, .42fr) 45px;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 7px 7px 7px 10px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: default;
  user-select: none;
}
.file-row:hover { background: var(--surface); border-color: var(--line); }
.file-row.selected { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.file-check { width: 18px; height: 18px; accent-color: var(--accent); }
.file-name { min-width: 0; display: flex; align-items: center; gap: 12px; }
.file-icon { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; color: var(--muted); background: var(--surface-soft); border-radius: 10px; }
.file-icon.folder { color: var(--accent-strong); background: var(--accent-soft); }
.file-icon .icon { width: 21px; height: 21px; }
.file-title { min-width: 0; overflow: hidden; font-weight: 710; text-overflow: ellipsis; white-space: nowrap; }
.file-subtitle { display: none; color: var(--muted); font-size: 0.78rem; }
.file-meta { overflow: hidden; color: var(--muted); font-size: 0.84rem; text-overflow: ellipsis; white-space: nowrap; }
.file-menu { position: relative; }
.file-menu-popover { position: absolute; z-index: 20; top: 42px; right: 2px; width: 170px; padding: 6px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow); }
.file-menu-popover button { width: 100%; display: flex; align-items: center; gap: 9px; padding: 9px 10px; background: transparent; border: 0; border-radius: 7px; text-align: left; cursor: pointer; }
.file-menu-popover button:hover { background: var(--surface-soft); }
.file-menu-popover button.danger-text { color: var(--danger); }

.file-list.grid-view { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.grid-view .file-row { position: relative; min-height: 154px; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; padding: 15px; background: var(--surface); border-color: var(--line); }
.grid-view .file-row:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(25, 48, 68, 0.08); }
.grid-view .file-row.selected { background: var(--accent-soft); }
.grid-view .file-check { position: absolute; top: 13px; left: 13px; }
.grid-view .file-name { width: 100%; display: block; }
.grid-view .file-icon { width: 48px; height: 48px; margin-bottom: 16px; }
.grid-view .file-title { display: block; }
.grid-view .file-subtitle { display: block; margin-top: 3px; }
.grid-view .file-meta { display: none; }
.grid-view .file-menu { position: absolute; top: 9px; right: 8px; }

.loading-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; padding-top: 4px; }
.loading-grid span { height: 142px; background: linear-gradient(100deg, var(--surface-soft) 20%, var(--surface) 38%, var(--surface-soft) 56%); background-size: 220% 100%; border-radius: 12px; animation: shimmer 1.35s infinite; }
@keyframes shimmer { to { background-position-x: -220%; } }
.empty-state { min-height: 390px; display: grid; place-content: center; justify-items: center; text-align: center; }
.empty-icon { width: 62px; height: 62px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); border-radius: 18px; }
.empty-icon .icon { width: 30px; height: 30px; }
.empty-state h2 { margin: 18px 0 3px; font-size: 1.1rem; }
.empty-state p { margin: 0 0 18px; color: var(--muted); }

.drop-overlay { position: fixed; z-index: 80; inset: 16px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent-soft) 92%, transparent); border: 3px dashed var(--accent); border-radius: 24px; backdrop-filter: blur(10px); }
.drop-overlay > div { display: grid; justify-items: center; gap: 7px; }
.drop-overlay .icon { width: 46px; height: 46px; margin-bottom: 8px; color: var(--accent); }
.drop-overlay strong { font-size: 1.35rem; }
.drop-overlay span { color: var(--muted); }

.upload-panel { position: fixed; z-index: 60; right: 24px; bottom: 20px; width: min(430px, calc(100vw - 32px)); max-height: min(520px, calc(100vh - 100px)); overflow: hidden; background: var(--surface-raised); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.upload-panel > header { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 13px 8px 17px; }
.upload-panel header > div { display: flex; align-items: baseline; gap: 8px; }
.upload-panel header span { color: var(--muted); font-size: 0.78rem; }
.overall-progress { height: 4px; background: var(--surface-soft); }
.overall-progress span { display: block; width: 0; height: 100%; background: var(--accent); transition: width 180ms linear; }
.upload-queue { max-height: 380px; overflow: auto; padding: 4px 12px 12px; }
.upload-item { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; align-items: center; gap: 10px; min-height: 54px; border-bottom: 1px solid var(--line); }
.upload-item:last-child { border: 0; }
.upload-item .file-icon { width: 32px; height: 32px; border-radius: 8px; }
.upload-name { overflow: hidden; font-size: .86rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.upload-status { color: var(--muted); font-size: .74rem; }
.mini-progress { height: 3px; margin-top: 4px; overflow: hidden; background: var(--surface-soft); border-radius: 3px; }
.mini-progress span { display: block; width: 0; height: 100%; background: var(--accent); }
.upload-item.error .upload-status { color: var(--danger); }

.dialog { width: min(460px, calc(100vw - 28px)); padding: 0; color: var(--ink); background: var(--surface-raised); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(4, 12, 20, 0.56); backdrop-filter: blur(3px); }
.dialog form { padding: 20px; }
.dialog header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.dialog h2 { margin: 3px 0 0; font-size: 1.16rem; }
.dialog header p { margin: 3px 0 0; color: var(--muted); font-size: .82rem; }
.dialog footer { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.dialog-help { margin: 7px 0 0; color: var(--muted); font-size: .8rem; }
.dialog > header, .dialog > footer { padding: 18px 20px; }
.preview-dialog { width: min(1600px, calc(100vw - 24px)); height: min(94dvh, 1080px); max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow: hidden; }
.preview-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.preview-dialog.expanded { inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; border: 0; border-radius: 0; }
.preview-dialog > header { min-width: 0; margin: 0; padding-block: 13px; border-bottom: 1px solid var(--line); }
.preview-dialog > header > div:first-child { min-width: 0; }
.preview-dialog h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-header-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 5px; }
.pdf-zoom-controls { height: 40px; display: flex; align-items: center; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.pdf-zoom-controls .icon-button { width: 36px; height: 38px; border-radius: 0; }
.pdf-zoom-level { min-width: 53px; height: 38px; padding: 0 5px; color: var(--ink); background: transparent; border: 0; border-inline: 1px solid var(--line); cursor: pointer; font-size: .76rem; font-weight: 800; }
.preview-content { min-height: 0; display: grid; place-items: center; overflow: auto; background: color-mix(in srgb, var(--bg) 82%, #000); }
.preview-content img, .preview-content video { max-width: 100%; max-height: 100%; }
.preview-content iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.preview-content audio { width: min(560px, 90%); }
.preview-content pre { width: 100%; height: 100%; margin: 0; padding: 22px; overflow: auto; color: var(--ink); background: var(--surface); font: 0.86rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.preview-unavailable { padding: 36px; color: var(--muted); text-align: center; }
.preview-content.pdf-preview { display: block; overflow: auto; overscroll-behavior: contain; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; }
.pdf-viewer { width: max-content; min-width: 100%; min-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 16px; }
.pdf-page { position: relative; flex: 0 0 auto; display: grid; place-items: center; overflow: hidden; color: #52606d; background: #ffffff; box-shadow: 0 3px 18px rgba(0, 0, 0, .24); }
.pdf-page canvas { width: 100%; height: 100%; display: block; }
.pdf-page-status, .pdf-loading { color: var(--muted); font-size: .84rem; }
.pdf-loading { min-height: 100%; display: grid; place-items: center; padding: 30px; }
.pdf-error { max-width: 420px; display: grid; justify-items: center; gap: 16px; padding: 34px; color: var(--muted); text-align: center; }
.pdf-error p { margin: 0; }

.toast-region { position: fixed; z-index: 100; right: 22px; top: 84px; display: grid; gap: 10px; pointer-events: none; }
.toast { width: min(360px, calc(100vw - 36px)); padding: 13px 16px; color: var(--ink); background: var(--surface-raised); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; box-shadow: var(--shadow); animation: toast-in 180ms ease-out; }
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-7px); } }

.mobile-only { display: none; }
.scrim { display: none; }

@media (max-width: 840px) {
  .app-shell { display: block; padding-top: 62px; }
  .topbar { position: fixed; height: 62px; grid-template-columns: 40px auto 1fr auto; gap: 8px; padding: 0 12px; }
  .mobile-only { display: inline-grid; }
  .brand { grid-column: 2; }
  .brand span:last-child { display: none; }
  .search-box { grid-column: 3; }
  .search-box kbd { display: none; }
  .top-actions { grid-column: 4; }
  .sidebar { position: fixed; z-index: 70; top: 0; left: 0; width: min(280px, 84vw); height: 100vh; padding-top: 78px; transform: translateX(-105%); transition: transform 180ms ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .scrim { position: fixed; z-index: 65; inset: 0; display: block; background: rgba(4,12,20,.45); }
  .workspace { padding: 22px 14px 60px; }
  .workspace-head { align-items: flex-start; }
  .workspace-actions { gap: 5px; }
  .workspace-actions .button span { display: none; }
  .workspace-actions .button { padding-inline: 11px; }
  .view-toolbar { margin-top: 8px; }
  .file-row { grid-template-columns: 30px minmax(0,1fr) 42px; gap: 8px; }
  .file-meta { display: none; }
  .file-subtitle { display: block; }
  .selection-bar { position: sticky; z-index: 15; top: 71px; align-items: flex-start; padding: 9px; }
  .selection-bar > div { flex-wrap: wrap; justify-content: flex-end; }
  .selection-bar .button { width: 40px; overflow: hidden; padding: 0; font-size: 0; }
  .selection-bar .button .icon { width: 20px; }
  .toast-region { right: 10px; top: 72px; }
}

@media (max-width: 520px) {
  .login-card { padding: 30px 24px; border-radius: 20px; }
  .topbar { grid-template-columns: 40px 36px minmax(0, 1fr) 84px; }
  .workspace-head { gap: 8px; }
  .breadcrumb { max-width: 105px; }
  .breadcrumb:not(:last-of-type) { display: none; }
  .breadcrumb-separator { display: none; }
  .toolbar-group select { max-width: 125px; }
  .file-list.grid-view { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .grid-view .file-row { min-height: 140px; padding: 12px; }
  .grid-view .file-title { font-size: .88rem; }
  .grid-view .file-subtitle { font-size: .72rem; }
  .upload-panel { right: 8px; bottom: 8px; width: calc(100vw - 16px); }
  .preview-dialog { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; border: 0; border-radius: 0; }
  .preview-dialog > header { gap: 6px; padding: 8px; }
  .preview-dialog h2 { max-width: 92px; font-size: .9rem; }
  .preview-dialog header p { display: none; }
  .preview-header-actions { gap: 3px; }
  .preview-download-label { display: none; }
  #preview-download { width: 40px; padding: 0; }
  #preview-expand { display: none; }
  .pdf-viewer { gap: 10px; padding: 8px; }
}

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