/* ==========================================================================
   VaultX - application styles
   1. Design tokens (dark default, light, system)   6. Sidebar (+ rail mode)
   2. Base & typography                              7. Page header, menus, summary
   3. Controls (buttons, inputs, checkboxes)         8. File browser, selection bar, rail
   4. Boot, brand                                    9. Views, overlays, auth, viewer
   5. App shell & topbar                            10. Legacy editor rules, responsive
   Other stylesheets (editor.css, find-replace.css, folders.css, …) consume the
   tokens below and must not hard-code colours.
   ========================================================================== */

/* 1. Design tokens --------------------------------------------------------- */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --surface: #15171c;
  --surface2: #1b1e24;
  --surface3: #23262e;
  --raised: #262a32;
  --popover: #1c1f25;
  --sidebar-bg: #121418;
  --topbar-bg: rgba(15, 17, 21, .78);
  --input-bg: #111317;
  --line: #2a2e37;
  --line-soft: #1f2229;
  --line-strong: #3a3f4a;
  --text: #eceef2;
  --muted: #9aa1ad;
  --text-soft: #838a96;
  --accent: #7591ff;
  --accent-strong: #4263eb;
  --accent-hover: #4f6ff0;
  --accent-soft: rgba(117, 145, 255, .14);
  --accent-text: #ffffff;
  --brand-2: #8b5cf6;
  --green: #4ac08a;
  --green-text: var(--green); /* green for small text on --success-soft (4.5:1) */
  --red: #ff6b6b;
  --amber: #f5b942;
  --danger-strong: #d1343a;
  --danger-soft: rgba(255, 107, 107, .13);
  --success-soft: rgba(74, 192, 138, .13);
  --warning-soft: rgba(245, 185, 66, .13);
  --hover: rgba(255, 255, 255, .05);
  --active: rgba(255, 255, 255, .08);
  --selected: rgba(117, 145, 255, .13);
  --focus-ring: #7591ff;
  --scrim: rgba(4, 5, 8, .62);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, .3), 0 24px 64px rgba(0, 0, 0, .5);
  --star: #f5b942;
  --type-pdf: #ff8a8a;
  --type-pdf-soft: rgba(255, 107, 107, .12);
  --type-image: #b794ff;
  --type-image-soft: rgba(183, 148, 255, .12);
  --type-text: #4fd1a5;
  --type-text-soft: rgba(79, 209, 165, .11);
  --type-doc: #7591ff;
  --type-doc-soft: rgba(117, 145, 255, .12);
  --editor-bg: #111318;
  --editor-gutter: #15171c;
  --editor-gutter-text: #787f8b;
  --editor-text: #d9dce2;
  --editor-line: rgba(255, 255, 255, .045);
  --editor-selection: rgba(117, 145, 255, .32);
  --find-match: rgba(250, 200, 60, .28);
  --find-current: rgba(255, 145, 40, .62);
  --find-scope: rgba(117, 145, 255, .09);
  --bookmark: #7591ff;
  /* Legacy aliases (kept for older rules and other workstreams). */
  --blue: var(--accent);
  --blue-strong: var(--accent-strong);
  --blue-soft: var(--accent-soft);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface2: #f3f4f6;
  --surface3: #e9ebef;
  --raised: #ffffff;
  --popover: #ffffff;
  --sidebar-bg: #f1f2f5;
  --topbar-bg: rgba(247, 248, 250, .82);
  --input-bg: #ffffff;
  --line: #e1e4e9;
  --line-soft: #eceef2;
  --line-strong: #cdd2da;
  --text: #16181d;
  --muted: #5f6672;
  --text-soft: #686e79;
  --accent: #3b5bdb;
  --accent-strong: #3b5bdb;
  --accent-hover: #3451c6;
  --accent-soft: rgba(59, 91, 219, .09);
  --accent-text: #ffffff;
  --brand-2: #7c4dff;
  --green: #16834f;
  --green-text: #137245;
  --red: #d6293a;
  --amber: #a35f00;
  --danger-strong: #d6293a;
  --danger-soft: rgba(214, 41, 58, .08);
  --success-soft: rgba(22, 131, 79, .09);
  --warning-soft: rgba(214, 140, 0, .11);
  --hover: rgba(16, 24, 40, .045);
  --active: rgba(16, 24, 40, .08);
  --selected: rgba(59, 91, 219, .08);
  --focus-ring: #3b5bdb;
  --scrim: rgba(16, 24, 40, .38);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-md: 0 1px 3px rgba(16, 24, 40, .06), 0 6px 16px rgba(16, 24, 40, .08);
  --shadow-lg: 0 4px 10px rgba(16, 24, 40, .06), 0 20px 48px rgba(16, 24, 40, .16);
  --star: #b07400;
  --type-pdf: #c92a3a;
  --type-pdf-soft: rgba(214, 41, 58, .08);
  --type-image: #7048e8;
  --type-image-soft: rgba(112, 72, 232, .09);
  --type-text: #087a58;
  --type-text-soft: rgba(8, 122, 88, .09);
  --type-doc: #3b5bdb;
  --type-doc-soft: rgba(59, 91, 219, .09);
  --editor-bg: #ffffff;
  --editor-gutter: #f7f8fa;
  --editor-gutter-text: #767c86;
  --editor-text: #1d2026;
  --editor-line: rgba(59, 91, 219, .055);
  --editor-selection: rgba(59, 91, 219, .2);
  --find-match: rgba(255, 196, 0, .38);
  --find-current: rgba(255, 128, 0, .5);
  --find-scope: rgba(59, 91, 219, .07);
  --bookmark: #3b5bdb;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    color-scheme: light;
    --bg: #f7f8fa;
    --surface: #ffffff;
    --surface2: #f3f4f6;
    --surface3: #e9ebef;
    --raised: #ffffff;
    --popover: #ffffff;
    --sidebar-bg: #f1f2f5;
    --topbar-bg: rgba(247, 248, 250, .82);
    --input-bg: #ffffff;
    --line: #e1e4e9;
    --line-soft: #eceef2;
    --line-strong: #cdd2da;
    --text: #16181d;
    --muted: #5f6672;
    --text-soft: #686e79;
    --accent: #3b5bdb;
    --accent-strong: #3b5bdb;
    --accent-hover: #3451c6;
    --accent-soft: rgba(59, 91, 219, .09);
    --accent-text: #ffffff;
    --brand-2: #7c4dff;
    --green: #16834f;
    --green-text: #137245;
    --red: #d6293a;
    --amber: #a35f00;
    --danger-strong: #d6293a;
    --danger-soft: rgba(214, 41, 58, .08);
    --success-soft: rgba(22, 131, 79, .09);
    --warning-soft: rgba(214, 140, 0, .11);
    --hover: rgba(16, 24, 40, .045);
    --active: rgba(16, 24, 40, .08);
    --selected: rgba(59, 91, 219, .08);
    --focus-ring: #3b5bdb;
    --scrim: rgba(16, 24, 40, .38);
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-md: 0 1px 3px rgba(16, 24, 40, .06), 0 6px 16px rgba(16, 24, 40, .08);
    --shadow-lg: 0 4px 10px rgba(16, 24, 40, .06), 0 20px 48px rgba(16, 24, 40, .16);
    --star: #b07400;
    --type-pdf: #c92a3a;
    --type-pdf-soft: rgba(214, 41, 58, .08);
    --type-image: #7048e8;
    --type-image-soft: rgba(112, 72, 232, .09);
    --type-text: #087a58;
    --type-text-soft: rgba(8, 122, 88, .09);
    --type-doc: #3b5bdb;
    --type-doc-soft: rgba(59, 91, 219, .09);
    --editor-bg: #ffffff;
    --editor-gutter: #f7f8fa;
    --editor-gutter-text: #767c86;
    --editor-text: #1d2026;
    --editor-line: rgba(59, 91, 219, .055);
    --editor-selection: rgba(59, 91, 219, .2);
    --find-match: rgba(255, 196, 0, .38);
    --find-current: rgba(255, 128, 0, .5);
    --find-scope: rgba(59, 91, 219, .07);
    --bookmark: #3b5bdb;
  }
}

/* Theme-independent tokens. */
:root {
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --font-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Code", "Cascadia Mono", Consolas, "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
  --topbar-h: 56px;
  --sidebar-w: 248px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  font-family: var(--font-ui);
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  scrollbar-color: var(--line-strong) transparent;
}
.theme-switching *,
.theme-switching *::before,
.theme-switching *::after { transition: none !important; }

/* 2. Base & typography ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 0; color: inherit; touch-action: manipulation; }
button:disabled { opacity: .5; cursor: not-allowed; }
a { color: var(--accent); text-decoration: none; touch-action: manipulation; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -.015em; }
h1 { font-size: 24px; font-weight: 650; line-height: 1.25; margin: 0 0 4px; }
::selection { background: var(--editor-selection); }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
[hidden] { display: none !important; }
kbd { font-family: var(--font-ui); font-size: 11px; font-weight: 500; line-height: 1; padding: 3px 5px; min-width: 18px; text-align: center; display: inline-block; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface2); color: var(--muted); white-space: nowrap; }
code { font-family: var(--font-mono); font-size: .92em; padding: 1px 4px; border-radius: 4px; background: var(--surface2); }
.icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: block; flex-shrink: 0; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.text-muted { color: var(--muted); }
.small { font-size: 13px; }
.mobile-only { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* 3. Controls ---------------------------------------------------------------- */
:where(input:not([type=checkbox], [type=radio], [type=range], [type=color], [type=file]), textarea, select) {
  color: var(--text);
  background-color: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  min-width: 0;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
:where(input:not([type=checkbox], [type=radio], [type=range], [type=color], [type=file]), textarea, select):hover { border-color: var(--line-strong); }
:where(input:not([type=checkbox], [type=radio], [type=range], [type=color], [type=file]), textarea, select):focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
:where(input, textarea, select):disabled { opacity: .55; cursor: not-allowed; }
:where(textarea) { resize: vertical; }
:where(input, textarea)::placeholder { color: var(--text-soft); opacity: 1; }
:where(select) {
  appearance: none;
  padding-right: 32px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%238b919c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
}
:where(input[type=checkbox], input[type=radio], input[type=range]) { accent-color: var(--accent-strong); }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 36px; padding: 7px 14px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--text);
  font-size: 14px; font-weight: 550; line-height: 1.2; white-space: nowrap; text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
}
.button:hover { text-decoration: none; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button .icon { width: 16px; height: 16px; }
.button.primary { background: var(--accent-strong); color: var(--accent-text); box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .14); }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); }
.button.secondary { background: var(--surface); border-color: var(--line); color: var(--text); box-shadow: var(--shadow-sm); }
.button.secondary:hover:not(:disabled) { background: var(--surface2); border-color: var(--line-strong); }
.button.ghost { background: transparent; color: var(--muted); }
.button.ghost:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.button.danger { background: var(--danger-strong); color: var(--accent-text); box-shadow: var(--shadow-sm); }
.button.danger:hover:not(:disabled) { filter: brightness(1.08); }
.button.secondary.danger { background: var(--surface); color: var(--red); border-color: var(--line); filter: none; }
.button.secondary.danger:hover:not(:disabled) { background: var(--danger-soft); }
.button.full { width: 100%; }
.button.small { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.button-caret .icon { width: 14px; height: 14px; opacity: .8; }

.icon-button {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 32px; height: 32px; padding: 0;
  border-radius: var(--radius-sm); background: transparent; color: var(--muted);
  transition: background-color .15s, color .15s;
}
.icon-button:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.icon-button:active:not(:disabled), .icon-button[aria-haspopup][aria-expanded="true"] { background: var(--active); color: var(--text); }
.icon-button .icon { width: 18px; height: 18px; }

/* Custom checkboxes (file selection). */
.file-select, .select-all {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px; min-height: 0; margin: 0; padding: 0; flex-shrink: 0;
  border: 1.5px solid var(--line-strong); border-radius: 4px;
  background: var(--surface) center / 12px 12px no-repeat;
  cursor: pointer; transition: background-color .12s, border-color .12s, box-shadow .12s;
}
.file-select:hover, .select-all:hover { border-color: var(--muted); }
.file-select:focus-visible, .select-all:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.file-select:checked, .select-all:checked, .select-all:indeterminate { background-color: var(--accent-strong); border-color: var(--accent-strong); }
.file-select:checked, .select-all:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m3.5 8.5 3 3 6-6.5' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.select-all:indeterminate {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* 4. Boot screen & brand ----------------------------------------------------- */
.boot { height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; color: var(--muted); }
.boot .logo-mark { width: 44px; height: 44px; border-radius: 12px; font-size: 24px; }
.boot-bar { height: 3px; width: 120px; background: var(--line); overflow: hidden; border-radius: 3px; }
.boot-bar::after { content: ""; display: block; height: 100%; width: 40%; border-radius: 3px; background: var(--accent); animation: boot-loading 1.1s infinite var(--ease); }
.boot p { font-size: 13px; margin: 0; }
@keyframes boot-loading { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

.logo-mark {
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 30px; height: 30px; padding-right: 3px; border-radius: 9px;
  background: linear-gradient(140deg, var(--accent-strong), var(--brand-2));
  color: var(--accent-text); font-size: 18px; line-height: 1; font-weight: 750; letter-spacing: -3px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), var(--shadow-sm);
}
.logo-mark > span { font-size: 15px; font-weight: 500; align-self: flex-end; margin-bottom: 20%; letter-spacing: 0; opacity: .85; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 17px; font-weight: 650; letter-spacing: -.025em; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-x { color: var(--accent); }

/* 5. App shell & topbar ------------------------------------------------------- */
.workspace { min-height: 100svh; }
.main-shell { margin-left: var(--sidebar-w); min-width: 0; min-height: 100svh; display: flex; flex-direction: column; transition: margin-left .18s var(--ease); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 12px; padding: 0 24px 0 32px;
  background: var(--topbar-bg);
  -webkit-backdrop-filter: saturate(1.5) blur(14px); backdrop-filter: saturate(1.5) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.search-box {
  flex: 1; max-width: 520px; height: 36px;
  display: flex; align-items: center; gap: 8px; padding: 0 6px 0 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-soft); cursor: text;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.search-box:hover { border-color: var(--line-strong); }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); color: var(--muted); }
.search-box .icon { width: 16px; height: 16px; }
.search-box input { flex: 1; width: 100%; height: 100%; padding: 0; border: 0; background: transparent; box-shadow: none; outline: none; font-size: 14px; }
.search-box input:focus, .search-box input:hover { box-shadow: none; border: 0; }
.search-box input:disabled { cursor: not-allowed; }
.search-box:has(input:disabled) { opacity: .6; cursor: not-allowed; }
.search-box kbd { flex-shrink: 0; }
.search-box input::-webkit-search-cancel-button { cursor: pointer; }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.private-indicator {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; margin-right: 6px;
  border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap;
}
.private-indicator .icon { width: 13px; height: 13px; color: var(--green); }
.topbar-divider { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.avatar {
  width: 32px; height: 32px; margin-left: 4px; border-radius: 50%; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, var(--accent-strong), var(--brand-2)); color: var(--accent-text);
  font-size: 12px; font-weight: 650; letter-spacing: .02em;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--line);
  transition: box-shadow .15s;
}
.avatar:hover, .avatar[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--accent); }
.content { flex: 1; width: 100%; max-width: 1600px; margin: 0 auto; padding: 28px 32px 48px; }
.workspace-footer { display: flex; justify-content: space-between; gap: 16px; padding: 14px 32px 20px; color: var(--text-soft); font-size: 12px; }
.workspace-footer > span { display: flex; align-items: center; gap: 6px; }
.workspace-footer .icon { width: 13px; height: 13px; }

/* 6. Sidebar ------------------------------------------------------------------ */
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 30;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--sidebar-bg); border-right: 1px solid var(--line-soft);
  transition: width .18s var(--ease), transform .2s var(--ease);
}
.sidebar-header { height: var(--topbar-h); flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 10px 0 18px; }
.sidebar-toggle .icon { width: 18px; height: 18px; }
/* Middle section: primary nav stays put, the folder tree (#folder-nav) takes and scrolls the remaining height. */
.sidebar-scroll { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; padding: 6px 10px 0; }
.sidebar-scroll > * { flex-shrink: 0; }
.nav-primary, .nav-secondary { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; height: 34px; padding: 0 10px;
  border-radius: var(--radius-sm); background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 500; text-align: left; white-space: nowrap;
  transition: background-color .12s, color .12s;
}
.nav-item .icon { width: 18px; height: 18px; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); }
.nav-item.active .icon { color: var(--accent); }
.nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-count { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.nav-item.active .nav-count { color: var(--accent); }
.sidebar-section { display: flex; align-items: center; justify-content: space-between; height: 30px; margin: 18px 0 2px; padding: 0 2px 0 10px; color: var(--text-soft); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.sidebar-section .icon-button { width: 26px; height: 26px; }
.sidebar-section .icon-button .icon { width: 16px; height: 16px; }
.rail-only { display: none !important; }
.folder-nav { flex: 1 1 auto; min-height: 96px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; margin: 0 -10px; padding: 0 10px 8px; }
.sidebar-bottom { flex-shrink: 0; padding: 8px 10px 12px; border-top: 1px solid var(--line-soft); }
.storage-box {
  display: block; width: 100%; margin-top: 8px; padding: 10px 12px; text-align: left;
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  transition: border-color .15s, background-color .15s;
}
.storage-box:hover { border-color: var(--line-strong); }
.storage-head { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.storage-head .icon { width: 15px; height: 15px; color: var(--accent); }
.storage-head strong { font-weight: 550; }
#storage-percent { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress-track { display: block; height: 4px; margin: 8px 0 6px; overflow: hidden; border-radius: 4px; background: var(--active); }
.progress-track > span { display: block; width: 0; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent-strong), var(--accent)); transition: width .3s var(--ease); }
.storage-text { display: block; font-size: 12px; color: var(--muted); }
.progress-track.is-high > span { background: linear-gradient(90deg, var(--amber), var(--red)); }
.sidebar-scrim { position: fixed; inset: 0; z-index: 29; background: var(--scrim); animation: fade-in .15s ease-out; }

/* Rail mode (collapsed sidebar). body.sidebar-collapsed + #sidebar.collapsed. */
body.sidebar-collapsed { --sidebar-w: 64px; }
.sidebar.collapsed .sidebar-header { flex-direction: column; justify-content: center; height: auto; gap: 8px; padding: 13px 0 6px; }
.sidebar.collapsed .brand { gap: 0; }
.sidebar.collapsed .brand-name,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-count,
.sidebar.collapsed .sidebar-section,
.sidebar.collapsed .folder-nav,
.sidebar.collapsed .storage-text,
.sidebar.collapsed .storage-head strong,
.sidebar.collapsed #storage-percent,
.sidebar.collapsed #storage-label { display: none; }
.sidebar.collapsed .rail-only { display: flex !important; }
.sidebar.collapsed .sidebar-scroll,
.sidebar.collapsed .sidebar-bottom { padding-left: 12px; padding-right: 12px; }
.sidebar.collapsed .nav-item { justify-content: center; width: 40px; height: 40px; padding: 0; }
.sidebar.collapsed .rail-divider { width: 24px; height: 1px; margin: 10px 8px; background: var(--line); }
.sidebar.collapsed .storage-box { width: 40px; padding: 8px 6px; }
.sidebar.collapsed .storage-head { justify-content: center; }
.sidebar.collapsed .progress-track { margin: 6px 0 0; }

/* 7. Page header ------------------------------------------------------------- */
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-heading-text { min-width: 0; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-soft); }
.page-heading .breadcrumb { min-height: 20px; margin-bottom: 4px; display: flex; align-items: center; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.page-heading h1 { margin: 0; overflow-wrap: anywhere; }
.page-subtitle { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.heading-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Dropdown menus (role=menu). Used by "+ New", theme and account menus. */
.menu-wrap { position: relative; display: inline-flex; }
.menu, .file-context-menu {
  z-index: 60; min-width: 220px; max-width: calc(100vw - 16px); padding: 4px;
  background: var(--popover); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg);
  scrollbar-width: thin;
}
.menu { position: absolute; top: calc(100% + 6px); right: 0; animation: menu-in .14s var(--ease); transform-origin: top right; }
.menu.align-left { right: auto; left: 0; transform-origin: top left; }
.menu-item, .menu-action {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 32px; padding: 6px 10px;
  border-radius: var(--radius-xs); background: transparent; color: var(--text);
  font-size: 13px; font-weight: 450; text-align: left; white-space: nowrap; text-decoration: none;
}
.menu-item .icon, .menu-action .icon { width: 16px; height: 16px; color: var(--muted); }
.menu-item:hover, .menu-action:hover { background: var(--hover); text-decoration: none; }
.menu-item:focus-visible, .menu-action:focus-visible, .menu-item:focus, .menu-action:focus { background: var(--active); outline: none; }
.menu-item.danger, .menu-action.danger { color: var(--red); }
.menu-item.danger .icon, .menu-action.danger .icon { color: var(--red); }
.menu-item.danger:hover, .menu-action.danger:hover, .menu-item.danger:focus, .menu-action.danger:focus { background: var(--danger-soft); }
.menu-item[aria-checked="true"] .menu-check { visibility: visible; }
.menu-check { margin-left: auto; visibility: hidden; color: var(--accent); }
.menu-check .icon { width: 15px; height: 15px; color: var(--accent); }
.menu-shortcut { margin-left: auto; padding-left: 16px; font-size: 12px; color: var(--text-soft); }
.menu-separator { height: 1px; margin: 4px -4px; background: var(--line); }
.menu-label { padding: 8px 10px 6px; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.menu-label strong { display: block; color: var(--text); font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.menu-actions { display: grid; gap: 2px; }

/* Summary strip */
.summary-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.stat-icon { width: 32px; height: 32px; border-radius: 8px; background: var(--surface2); color: var(--muted); }
.stat-icon .icon { width: 17px; height: 17px; }
.stat-text { display: flex; flex-direction: column; min-width: 0; }
.stat-value { font-size: 16px; font-weight: 650; line-height: 1.25; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-label { font-size: 12px; line-height: 1.35; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 8. File browser --------------------------------------------------------------- */
.files-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
.file-area { min-width: 0; }
.file-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-tabs, .view-toggle { display: inline-flex; align-items: center; gap: 2px; padding: 3px; background: var(--surface2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.filter-tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.filter-tab {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border-radius: var(--radius-xs); background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 500; white-space: nowrap; transition: background-color .12s, color .12s;
}
.filter-tab:hover { color: var(--text); background: var(--hover); }
.filter-tab.active { background: var(--raised); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line-soft); }
.filter-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; background: var(--active); color: var(--muted); font-variant-numeric: tabular-nums; }
.filter-tab.active .filter-count { background: var(--accent-soft); color: var(--accent); }
.toolbar-options { display: flex; align-items: center; gap: 8px; }
.sort-control { position: relative; display: inline-flex; align-items: center; }
.sort-control > .icon { position: absolute; left: 9px; width: 15px; height: 15px; color: var(--text-soft); pointer-events: none; }
.sort-select { height: 34px; padding: 0 30px 0 30px; font-size: 13px; font-weight: 500; color: var(--text); background-color: var(--surface); }
.view-toggle .icon-button { width: 30px; height: 28px; border-radius: var(--radius-xs); }
.view-toggle .icon-button .icon { width: 16px; height: 16px; }
.view-toggle .icon-button.active { background: var(--raised); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line-soft); }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 10px; }
.section-heading h2 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }
.section-heading > span { font-size: 13px; color: var(--text-soft); font-variant-numeric: tabular-nums; }

[data-folder] { user-select: none; }

/* List view */
.file-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: clip; }
.table-head, .file-row {
  display: grid; align-items: center; column-gap: 12px;
  grid-template-columns: 18px minmax(0, 1fr) 92px 116px 108px;
  padding: 0 10px 0 16px;
}
.table-head {
  position: sticky; top: var(--topbar-h); z-index: 3;
  height: 38px; background: var(--surface2); border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 550; color: var(--muted);
}
.table-head .th-check { display: flex; align-items: center; }
.table-head .th-actions { text-align: right; }
.file-row {
  position: relative; min-height: 48px;
  border-bottom: 1px solid var(--line-soft);
  user-select: none; cursor: default;
  transition: background-color .1s;
  scroll-margin-top: calc(var(--topbar-h) + 48px); scroll-margin-bottom: 96px;
}
.file-row:last-child { border-bottom: 0; }
.file-row:hover { background: var(--hover); }
.file-row.selected { background: var(--selected); }
.file-row.selected::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--accent); }
.file-row:focus-visible, .file-tile:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.file-row > .file-select { position: relative; }
.file-name { display: flex; align-items: center; gap: 12px; min-width: 0; width: 100%; padding: 5px 0; background: transparent; color: inherit; text-align: left; border-radius: 4px; }
.file-name > div { min-width: 0; }
.file-name strong { display: block; font-size: 14px; font-weight: 500; line-height: 20px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-name small { display: block; font-size: 12px; line-height: 16px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-name:focus-visible { outline-offset: 0; }
.meta-extra { display: none; }
.file-size, .file-date { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.file-actions { display: flex; justify-content: flex-end; align-items: center; gap: 2px; }
.file-actions .icon-button { width: 30px; height: 30px; opacity: 0; transition: opacity .12s, background-color .12s, color .12s; }
.file-actions .icon-button .icon { width: 16px; height: 16px; }
.file-row:hover .file-actions .icon-button,
.file-row:focus-within .file-actions .icon-button,
.file-row.selected .file-actions .icon-button,
.file-actions .icon-button.is-starred { opacity: 1; }
.is-starred { color: var(--star) !important; }
.is-starred .icon { fill: currentColor; fill-opacity: .2; }
.file-table-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 0 2px; font-size: 12px; color: var(--text-soft); }

/* File-type badges */
.file-type-icon {
  position: relative; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 32px; height: 36px; border-radius: 7px;
  background: var(--type-doc-soft); color: var(--type-doc);
  font-size: 9px; font-weight: 700; letter-spacing: .02em;
  box-shadow: inset 0 0 0 1px var(--line-soft);
}
.file-type-icon.pdf { background: var(--type-pdf-soft); color: var(--type-pdf); }
.file-type-icon.image { background: var(--type-image-soft); color: var(--type-image); }
.file-type-icon.text { background: var(--type-text-soft); color: var(--type-text); }

/* Grid view */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; }
.file-tile {
  position: relative; display: flex; flex-direction: column; min-width: 0; padding: 10px 10px 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  user-select: none; cursor: default;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
  scroll-margin-top: calc(var(--topbar-h) + 16px); scroll-margin-bottom: 96px;
}
.file-tile:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.file-tile.selected { border-color: var(--accent); background: var(--selected); box-shadow: 0 0 0 1px var(--accent); }
.file-tile > .file-select { position: absolute; top: 18px; left: 18px; z-index: 1; opacity: 0; transition: opacity .12s; }
.file-tile:hover > .file-select, .file-tile:focus-within > .file-select, .file-tile.selected > .file-select, .file-tile > .file-select:checked { opacity: 1; }
.tile-top { position: relative; display: flex; align-items: center; justify-content: center; height: 92px; margin-bottom: 10px; border-radius: var(--radius-sm); background: var(--surface2); }
.file-tile .tile-top > .icon-button { position: absolute; top: 4px; right: 4px; }
.file-tile .tile-top > .icon-button:not(.is-starred) { opacity: 0; }
.file-tile:hover .tile-top > .icon-button, .file-tile:focus-within .tile-top > .icon-button { opacity: 1; }
.file-tile .file-type-icon { width: 44px; height: 52px; border-radius: 9px; font-size: 11px; }
.file-tile .file-name { display: block; padding: 0 4px; }
.file-tile .file-name small { margin-top: 1px; }
.tile-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; padding-left: 4px; font-size: 12px; color: var(--text-soft); }
.tile-meta > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta .icon-button { width: 28px; height: 28px; }

/* Drag & drop targets */
.drop-target { outline: 2px dashed var(--accent) !important; outline-offset: -2px; background: var(--accent-soft) !important; }

/* Floating selection bar (bottom centre of the main area; over the file column when the details rail is shown).
   z-index stays below the phone drawer scrim (29) so an open drawer covers it. The dock is a size container:
   the bar drops button labels step by step when the column gets narrow (see the @container rules below). */
.selection-dock { position: fixed; left: var(--sidebar-w); right: 0; bottom: 20px; z-index: 25; display: flex; justify-content: center; padding: 0 16px; pointer-events: none; transition: left .18s var(--ease); container: selection-dock / inline-size; }
.selection-bar {
  pointer-events: auto; display: flex; align-items: center; gap: 2px; max-width: 100%; padding: 6px;
  overflow-x: auto; scrollbar-width: none; /* last resort only (e.g. large text zoom); the container rules keep it fitting */
  background: var(--popover); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(16px) scale(.98);
  transition: opacity .15s ease, transform .2s var(--ease), visibility 0s linear .2s;
}
.selection-bar.is-visible { opacity: 1; visibility: visible; transform: none; transition: opacity .15s ease, transform .2s var(--ease), visibility 0s; }
.selection-bar.is-arming { pointer-events: none; } /* first 400 ms after it appears (workspace.js syncSelectionBar) */
.selection-count { padding: 0 10px 0 8px; font-size: 13px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.selection-bar .button { min-height: 32px; padding: 5px 10px; gap: 6px; border: 0; background: transparent; box-shadow: none; color: var(--text); font-size: 13px; font-weight: 500; }
.selection-bar .button .icon { width: 16px; height: 16px; color: var(--muted); }
.selection-bar .button:hover:not(:disabled) { background: var(--hover); }
.selection-bar .button.danger { color: var(--red); background: transparent; filter: none; }
.selection-bar .button.danger .icon { color: var(--red); }
.selection-bar .button.danger:hover:not(:disabled) { background: var(--danger-soft); }
.selection-bar .icon-button { width: 32px; height: 32px; }
.selection-divider { flex-shrink: 0; width: 1px; height: 20px; margin: 0 4px; background: var(--line); }
.selection-bar > * { flex-shrink: 0; }
/* Narrow file column (tablets, 1024–1180 px, 1280 px with the rail): every action switches to its short label
   (workspace.js selectionBarMarkup; aria-label and tooltip keep the full text). */
.selection-bar .button-label-short { display: none; }
@container selection-dock (max-width: 759px) {
  .selection-bar .button-label { display: none; }
  .selection-bar .button-label-short { display: inline; }
}
/* Very narrow: every action is an icon button. */
@container selection-dock (max-width: 559px) {
  .selection-bar :is(.button-label, .button-label-short) { display: none; }
}
body.has-selection .content { padding-bottom: 104px; }
body.has-selection .toast-region,
body.has-selection .transfer-progress { bottom: 84px; }

/* Details rail (≥1280 px) */
.details-rail { display: none; flex-direction: column; gap: 12px; position: sticky; top: calc(var(--topbar-h) + 20px); }
.upload-card {
  padding: 18px 16px 16px; text-align: center;
  background: var(--surface); border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  transition: border-color .15s, background-color .15s;
}
.upload-card:hover { border-color: var(--accent); }
.upload-card .upload-symbol { display: inline-flex; width: 40px; height: 40px; align-items: center; justify-content: center; margin-bottom: 10px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.upload-card .upload-symbol .icon { width: 19px; height: 19px; }
.upload-card h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.upload-card p { margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.upload-card .button { width: 100%; }
.upload-card > small { display: block; margin-top: 8px; font-size: 11px; color: var(--text-soft); }
.info-card { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.info-card h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 13px; font-weight: 600; }
.info-card h3 .icon { width: 16px; height: 16px; color: var(--green); }
.info-card > p { margin: 0; font-size: 12px; line-height: 1.55; color: var(--muted); }
.recycle-card h3 .icon { color: var(--muted); }
.security-points { display: flex; flex-direction: column; gap: 7px; }
.security-point { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.security-point .icon { width: 14px; height: 14px; color: var(--green); }
.info-link { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 12px; padding: 10px 0 0; border-top: 1px solid var(--line-soft); background: transparent; color: var(--accent); font-size: 12px; font-weight: 550; }
.info-link .icon { width: 14px; height: 14px; transition: transform .15s; }
.info-link:hover .icon { transform: translateX(2px); }
.tip-card h3 .icon { color: var(--muted); }
.shortcut-list { display: grid; gap: 6px; margin: 0; }
.shortcut-list > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.shortcut-list dt { min-width: 0; }
.shortcut-list dd { margin: 0; display: flex; gap: 3px; flex-shrink: 0; }
.shortcut-list kbd { font-size: 10px; padding: 2px 4px; }

/* Empty states */
.empty-state { max-width: 420px; margin: 0 auto; padding: 56px 24px; text-align: center; }
.empty-state .empty-icon { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; margin-bottom: 16px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); box-shadow: 0 0 0 8px var(--hover); }
.empty-state .empty-icon .icon { width: 24px; height: 24px; }
.empty-state h2 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.empty-state p { margin: 0 auto 20px; max-width: 320px; font-size: 13px; color: var(--muted); text-wrap: balance; }
.empty-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.empty-hint { margin-top: 18px !important; margin-bottom: 0 !important; font-size: 12px !important; color: var(--text-soft) !important; }

/* 9. Views: panels (Document tools, Security), shares, activity ---------------- */
.panels-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; align-items: stretch; }
.panel { min-width: 0; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
/* Cards in a row share one height: the last footnote or action row sits at the bottom (the row before keeps a gap). */
.panels-grid > .panel { display: flex; flex-direction: column; }
.panels-grid > .panel > :last-child:not(.panel-header) { margin-top: auto; }
.panels-grid > .panel > :nth-last-child(2):not(.panel-header) { margin-bottom: 16px; }
.panel-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.panel-header > div { min-width: 0; }
.panel-heading-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 36px; height: 36px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); }
.panel-heading-icon .icon { width: 18px; height: 18px; }
.panel h2 { margin: 0 0 2px; font-size: 15px; font-weight: 600; }
.panel p { font-size: 13px; }
.panel-header p { margin: 0; color: var(--muted); }
.panel .form-actions, .panel-actions { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px; margin-top: 16px; }
.panel form .button[type=submit] { margin-top: 4px; }
.detail-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.detail-row:last-child { border-bottom: 0; }
.detail-row > span:first-child { color: var(--muted); }
.detail-row strong { min-width: 0; font-weight: 550; text-align: right; overflow-wrap: anywhere; }
.security-note { margin: 16px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-soft); border-left: 3px solid var(--accent); background: var(--surface2); color: var(--muted); font-size: 12px !important; }
.session-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; background: var(--success-soft); color: var(--green-text); font-size: 12px; font-weight: 550; white-space: nowrap; }
.session-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tool-footnote { margin: 14px 0 0; font-size: 12px !important; line-height: 1.6; color: var(--text-soft); }
.supported-formats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.format-chip { padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface2); color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.share-list-head { display: flex; align-items: center; justify-content: space-between; padding: 0 16px; height: 38px; background: var(--surface2); border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 550; color: var(--muted); }
.share-row { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--line-soft); transition: background-color .1s; }
.share-row:hover { background: var(--hover); }
.share-row:last-child { border-bottom: 0; }
.share-row-info { flex: 1; min-width: 0; }
.share-row-info strong { display: block; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-row-info p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.share-row-info .lock-chip { display: inline-flex; align-items: center; gap: 4px; color: var(--amber); vertical-align: -2px; }
.share-row-info .lock-chip .icon { width: 12px; height: 12px; }
.activity-list { max-height: 60vh; overflow: auto; margin: 0 -8px; scrollbar-width: thin; }
.activity-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 8px; border-radius: var(--radius-sm); font-size: 13px; }
.activity-row:hover { background: var(--hover); }
.activity-row > .icon { width: 30px; height: 30px; padding: 7px; border-radius: 50%; background: var(--surface2); color: var(--muted); }
.activity-row strong { font-weight: 550; }
.activity-row small { display: block; margin-top: 1px; font-size: 12px; color: var(--text-soft); }
.activity-row > div { min-width: 0; overflow-wrap: anywhere; }
.viewer-loader { display: flex; align-items: center; justify-content: center; gap: 10px; height: 100%; min-height: 160px; color: var(--muted); font-size: 13px; }
.viewer-loader::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; text-align: left; font-size: 13px; font-weight: 500; }
.field > span, .field > label { font-size: 13px; font-weight: 500; color: var(--text); }
.field > span .text-muted { font-weight: 400; }
.field small { font-size: 12px; font-weight: 400; line-height: 1.5; color: var(--muted); }
.field input, .field select { height: 36px; font-weight: 400; }
.field textarea { min-height: 120px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row .field { min-width: 0; }
.form-error { margin-bottom: 16px; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--danger-soft); background: var(--danger-soft); color: var(--red); font-size: 13px; }
.form-hint { margin: 14px 0; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-soft); background: var(--surface2); color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.form-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.alert.error { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--danger-soft); background: var(--danger-soft); color: var(--red); font-size: 14px; }

/* Modal dialog */
.modal, .viewer { color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0; box-shadow: var(--shadow-lg); max-height: calc(100svh - 32px); }
.modal { width: 480px; max-width: calc(100% - 32px); overflow: hidden; }
.modal[open], .viewer[open] { animation: dialog-in .18s var(--ease); }
dialog::backdrop { background: var(--scrim); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.modal #modal-content { display: flex; flex-direction: column; max-height: calc(100svh - 34px); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 14px 8px 24px; flex-shrink: 0; }
.modal-header h2 { margin: 0; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.modal-body { padding: 6px 24px 22px; overflow: auto; scrollbar-width: thin; }
.modal-body > p { margin: 0 0 16px; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.modal-body > p strong { color: var(--text); font-weight: 600; }
.modal-body .detail-row strong { overflow-wrap: anywhere; min-width: 0; }
.modal-body .link-output { width: 100%; margin-bottom: 4px; font-family: var(--font-mono); font-size: 12px; }
.modal-body > form:last-child > .form-actions:last-child { position: sticky; bottom: -22px; margin: 22px -24px -22px; padding: 14px 24px; background: var(--surface2); border-top: 1px solid var(--line-soft); }
.modal-footer-note { margin: 14px 0 0; font-size: 12px; color: var(--muted); }
.selection-confirm-list { max-height: 180px; overflow: auto; margin: 0 0 4px; padding: 8px 12px 8px 28px; border-radius: var(--radius-sm); background: var(--surface2); font-size: 13px; overflow-wrap: anywhere; }

/* File context menu (workspace.js showFileMenu). */
.file-context-menu { position: fixed; z-index: 150; min-width: 232px; max-height: calc(100svh - 16px); overflow: auto; animation: menu-in .12s var(--ease); }
.context-title { max-width: 280px; padding: 7px 10px 6px; margin-bottom: 2px; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Toasts (bottom-right stack) */
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 300; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; max-width: min(420px, calc(100vw - 32px)); pointer-events: none; transition: bottom .2s var(--ease); }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; max-width: 100%;
  padding: 10px 14px 10px 12px; border-radius: 10px;
  background: var(--popover); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  font-size: 13px; line-height: 1.45; overflow-wrap: anywhere;
  animation: toast-in .22s var(--ease);
}
.toast .icon { width: 16px; height: 16px; margin-top: 1px; color: var(--green); }
.toast.error { box-shadow: var(--shadow-lg), inset 3px 0 0 var(--red); }
.toast.error .icon { color: var(--red); }
.toast.leaving { animation: toast-out .18s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Drag & drop upload overlay */
.drop-overlay { position: fixed; inset: 12px; z-index: 250; display: flex; align-items: center; justify-content: center; text-align: center; pointer-events: none; border: 2px dashed var(--accent); border-radius: 18px; background: var(--accent-soft); animation: fade-in .12s ease-out; }
.drop-overlay > div { pointer-events: none; padding: 28px 36px; border-radius: 16px; background: var(--popover); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.drop-overlay .icon { width: 40px; height: 40px; margin: 0 auto 8px; color: var(--accent); }
.drop-overlay h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.drop-overlay p { margin: 0; color: var(--muted); font-size: 13px; }

/* Upload progress */
.transfer-progress { position: fixed; left: calc(var(--sidebar-w) + 24px); bottom: 20px; z-index: 160; display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 14px; border-radius: 12px; background: var(--popover); border: 1px solid var(--line); box-shadow: var(--shadow-lg); font-size: 13px; animation: toast-in .2s var(--ease); transition: bottom .2s var(--ease); }
.transfer-progress::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.transfer-progress .button { min-height: 30px; padding: 4px 10px; font-size: 13px; }
/* Toasts and the upload pill move into the top-most modal dialog (app.js placeToasts); the selection bar and the
   sidebar are behind it, so their offsets do not apply there. The text editor keeps its status bar visible. */
dialog[open] > .toast-region, dialog[open] > .transfer-progress { bottom: 20px; }
dialog[open] > .transfer-progress { left: 20px; }
.viewer.viewer-editor[open] > .toast-region, .viewer.viewer-editor[open] > .transfer-progress { bottom: 48px; }
.upload-progress { margin: 8px 0 0; color: var(--accent); font-size: 12px; }

/* Auth & shared pages (sign-in layout is completed in auth.css) */
.auth-page { min-height: 100svh; background: radial-gradient(900px 480px at 50% -8%, var(--accent-soft), transparent 70%), var(--bg); }
.auth-page > .auth-card { margin: 12vh auto 0; padding: 32px; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-md); }
.auth-page > .auth-card .brand { margin-bottom: 24px; }
.auth-page > .auth-card h2 { font-size: 20px; font-weight: 650; margin: 0 0 6px; }
body.auth-page { display: block; padding: 48px 24px; }
.shared-card { max-width: 920px !important; margin: 0 auto !important; padding: 28px 32px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-md); }
.shared-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 28px; }
.shared-header .private-indicator, .auth-page > .auth-card .shared-header .brand { margin: 0; }
.shared-card h1 { margin: 6px 0 6px; font-size: 24px; overflow-wrap: anywhere; }
.shared-card .eyebrow { margin: 0; color: var(--accent); }
.shared-card .field { max-width: 420px; }
.shared-card form { margin-top: 20px; }
.shared-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 0 18px; font-size: 13px; color: var(--muted); }
.shared-meta span { display: inline-flex; align-items: center; gap: 6px; }
.shared-meta .icon { width: 14px; height: 14px; }
.shared-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.shared-text { max-height: 65vh; overflow: auto; margin: 20px 0; padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--editor-bg); color: var(--editor-text); font: 14px/1.7 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; scrollbar-width: thin; }
.shared-preview { display: block; width: 100%; height: 65vh; margin: 20px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface2); }
.shared-image { display: block; max-width: 100%; max-height: 65vh; margin: 20px auto; object-fit: contain; border-radius: var(--radius-sm); }
.shared-foot { display: flex; align-items: center; gap: 6px; margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--text-soft); }
.shared-foot .icon { width: 13px; height: 13px; }
.noscript { max-width: 480px; margin: 40px auto; padding: 16px 20px; text-align: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); }

/* Viewer frame (images, PDF, unsupported). Text documents are styled by editor.css. */
.viewer { width: 1100px; max-width: calc(100% - 32px); height: 86svh; overflow: hidden; }
.viewer #viewer-content { display: flex; flex-direction: column; height: 100%; }
.viewer-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 10px 12px 10px 20px; border-bottom: 1px solid var(--line); background: var(--surface); flex-shrink: 0; }
.viewer-header > h2 { margin: 0; font-size: 15px; font-weight: 600; }
.viewer-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.viewer-title > div { min-width: 0; }
.viewer-title h2 { margin: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-title small { display: block; font-size: 12px; color: var(--muted); }
.viewer-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.viewer-actions .button { min-height: 32px; padding: 5px 12px; font-size: 13px; }
.viewer-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--surface2); }
.viewer-body > .empty-state { margin: auto; }
.viewer-body pre { flex: 1; margin: 0; padding: 24px; overflow: auto; font: 14px/1.8 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--editor-text); background: var(--editor-bg); }
.viewer-body iframe { flex: 1; width: 100%; border: 0; background: var(--surface2); }
.viewer-body > img { margin: auto; max-width: 100%; max-height: 100%; padding: 24px; object-fit: contain; }
.viewer-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 30px; padding: 4px 16px; border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 12px; flex-shrink: 0; }
.extraction-notice { padding: 8px 20px; border-bottom: 1px solid var(--line-soft); background: var(--warning-soft); color: var(--text); font-size: 12px; flex-shrink: 0; }

/* 10. Legacy text-editor and column-view rules (tokenised).
   editor.css (editor workstream) loads later and refines/overrides these. */
.viewer-body.has-text-editor { display: flex; flex-direction: column; overflow: hidden; padding: 0; min-height: 0; background: var(--editor-bg); }
.editor-toolbar { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); flex-shrink: 0; max-height: 165px; overflow: auto; }
.editor-toolbar button { min-height: 30px; padding: 4px 9px; border: 1px solid var(--line); border-radius: var(--radius-xs); background: var(--surface2); color: var(--text); font-size: 12px; white-space: nowrap; }
.editor-toolbar button:hover, .editor-toolbar button[aria-pressed=true] { background: var(--accent-soft); border-color: var(--accent); }
.editor-toolbar label { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.editor-toolbar input, .editor-toolbar select { min-height: 30px; max-width: 78px; padding: 3px 6px; font-size: 12px; border-radius: var(--radius-xs); }
.editor-toolbar select { padding-right: 26px; background-position: right 6px center; }
.editor-divider { height: 22px; margin: 0 3px; border-left: 1px solid var(--line); }
.numbered-editor { position: relative; display: flex; flex: 1; min-height: 160px; overflow: hidden; background: var(--editor-bg); }
.line-gutter { width: 65px; flex-shrink: 0; overflow: hidden; background: var(--editor-gutter); border-right: 1px solid var(--line-soft); user-select: none; }
.line-track { position: relative; }
.line-track button { position: absolute; left: 0; right: 0; width: 100%; padding: 0 13px 0 3px; border-radius: 0; background: transparent; color: var(--editor-gutter-text); text-align: right; font: 12px/24px var(--font-mono); }
.line-track button:hover, .line-track button.current-line { color: var(--editor-text); background: var(--editor-line); }
.viewer-body textarea.code-text { flex: 1; display: block; width: 0; min-width: 0; height: 100%; padding: 12px; border: 0; border-radius: 0; outline: 0; resize: none; box-shadow: none; background: transparent; color: var(--editor-text); caret-color: var(--accent); font: 14px/24px var(--font-mono); tab-size: 4; white-space: pre; overflow: auto; overflow-wrap: normal; }
.viewer-body textarea.code-text:focus { box-shadow: none; }
.viewer-body textarea.code-text.wrapped { white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; }
.line-measure { position: absolute; left: 0; top: 0; z-index: -1; visibility: hidden; pointer-events: none; padding: 0 12px; font: 14px/24px var(--font-mono); tab-size: 4; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; }
.line-measure > div { min-height: 24px; }
.separator-toolbar { max-height: none; overflow: visible; background: var(--surface2); border-bottom: 1px solid var(--line); }
.separator-toolbar strong { margin-right: 5px; font-size: 12px; }
.separator-toolbar [data-delimiter] { min-width: 34px; font-family: var(--font-mono); font-weight: 700; }
.separator-toolbar [aria-pressed="true"] { background: var(--accent-strong); color: var(--accent-text); border-color: var(--accent-strong); }
#separator-scope { margin-left: auto; font-size: 12px; color: var(--muted); }
.column-panel { display: flex; flex: 1; flex-direction: column; min-height: 140px; overflow: hidden; background: var(--editor-bg); }
.column-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.column-sheet { position: relative; min-width: 100%; min-height: 100%; }
.column-guides { position: absolute; inset: 0; display: flex; pointer-events: none; }
.column-guides > span { flex: none; border-right: 1px solid var(--line); }
.column-guides > span:first-child { background: var(--editor-gutter); }
.column-table { position: relative; border-collapse: separate; border-spacing: 0; table-layout: fixed; font: 14px/24px var(--font-mono); }
.column-table th, .column-table td { min-width: 0; padding: 0; border-right: 1px solid var(--line); }
.column-table thead th { position: sticky; top: 0; z-index: 3; height: 28px; background: var(--surface2); color: var(--muted); font-weight: 500; text-align: center; border-bottom: 1px solid var(--line); }
.column-table thead th:first-child { left: 0; z-index: 4; }
.column-table tbody th { position: sticky; left: 0; z-index: 2; background: var(--editor-gutter); }
.column-table tbody th button { display: block; width: 100%; height: 26px; padding: 0 8px; background: transparent; color: var(--editor-gutter-text); text-align: right; font: 13px/26px var(--font-mono); }
.column-table td { position: relative; background: transparent; }
.column-table input.column-cell { display: block; width: 100%; min-width: 0; height: 26px; min-height: 26px; padding: 0 6px; border: 0; border-radius: 0; outline: none; box-shadow: none; background: transparent; color: var(--editor-text); font: 14px/26px var(--font-mono); }
.column-table .column-current-row td { background: var(--editor-line); }
.column-table .column-current-row th, .column-table .column-current-header { background: var(--accent-soft); color: var(--text); }
.column-table .column-current-row th button { color: var(--text); }
.column-table .column-row-selected td, .column-table .column-row-selected th { background: var(--editor-selection); }
.column-table td.column-selected-cell { background: var(--editor-selection); }
.column-table .column-selected-header { background: var(--editor-selection); color: var(--text); }
.column-table td.column-active-cell { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.column-table td.column-active-cell input { background: transparent; color: var(--editor-text); caret-color: var(--accent); }
.column-table td.column-active-cell::after { content: ""; position: absolute; right: -2px; bottom: -2px; z-index: 1; width: 5px; height: 5px; background: var(--accent); pointer-events: none; }
.column-heading { display: block; width: 100%; height: 100%; padding: 0; background: transparent; color: inherit; font: inherit; text-align: center; }
.column-resize { position: absolute; inset: 0 -4px 0 auto; z-index: 1; width: 9px; cursor: col-resize; touch-action: none; }
.column-resize:hover, .column-resize:focus-visible { background: var(--accent-soft); outline: 1px solid var(--accent); outline-offset: -1px; }
.column-resizing, .column-resizing * { cursor: col-resize !important; user-select: none; }
.column-pagebar { display: flex; align-items: center; gap: 8px; flex-shrink: 0; padding: 5px 10px; border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 12px; }
.column-pagebar > span { margin-right: auto; }
.column-pagebar button { padding: 3px 8px; border: 1px solid var(--line); border-radius: var(--radius-xs); background: var(--surface2); color: var(--text); font-size: 12px; }
.column-pagebar button:disabled { cursor: default; }
.column-selection-status { color: var(--accent); font-size: 12px; }
.column-pagebar > span.column-selection-status { margin-right: 6px; }
.editor-context-menu { position: fixed; z-index: 300; width: 220px; max-width: calc(100vw - 16px); max-height: calc(100svh - 16px); overflow: auto; padding: 4px; background: var(--popover); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); }
.editor-context-menu button { display: block; width: 100%; min-height: 30px; padding: 6px 10px; border-radius: var(--radius-xs); background: transparent; color: var(--text); font-size: 13px; text-align: left; }
.editor-context-menu button:hover, .editor-context-menu button:focus { background: var(--active); outline: 0; }
.editor-context-menu button:disabled { opacity: .4; cursor: default; }
.editor-context-menu button.danger { color: var(--red); }
.editor-menu-divider { margin: 4px -4px; border-top: 1px solid var(--line); }
.editor-find { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; flex-shrink: 0; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 12px; }
.editor-find > input { flex: 1; min-width: 130px; max-width: 360px; padding: 5px 9px; font-size: 13px; }
.editor-find label { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.editor-find button { padding: 5px 9px; border: 1px solid var(--line); border-radius: var(--radius-xs); background: var(--surface2); color: var(--text); font-size: 12px; }
.editor-find [role=status] { min-width: 70px; color: var(--muted); }
.editor-find [data-find=close] { margin-left: auto; }
.editor-confirm { width: 360px; max-width: calc(100vw - 32px); padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.editor-confirm::backdrop { background: var(--scrim); }
.editor-confirm h3 { margin: 0 0 10px; font-size: 17px; }
.editor-confirm p { font-size: 13px; color: var(--muted); }
.editor-confirm > div { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.editor-confirm button { padding: 7px 14px; border-radius: var(--radius-sm); background: var(--surface2); border: 1px solid var(--line); color: var(--text); font-size: 13px; }
.editor-confirm [data-confirm=delete] { background: var(--danger-strong); border-color: var(--danger-strong); color: var(--accent-text); }

/* Responsive ------------------------------------------------------------------- */
@media (min-width: 1280px) {
  .files-layout { grid-template-columns: minmax(0, 1fr) 248px; }
  .details-rail { display: flex; }
  /* Centre the selection bar over the file column so it never covers the details rail.
     Mirrors .content (max-width 1600px, centred; 32px side padding) and the rail column (248px + 24px gap). */
  .selection-dock {
    --dock-gutter: max(0px, (100vw - var(--sidebar-w) - 1600px) / 2);
    left: calc(var(--sidebar-w) + var(--dock-gutter) + 32px);
    right: calc(var(--dock-gutter) + 32px + 248px + 24px);
    padding: 0;
  }
}
@media (min-width: 1600px) {
  .files-layout { grid-template-columns: minmax(0, 1fr) 272px; gap: 28px; }
  .content { padding: 32px 40px 48px; }
  .topbar { padding-left: 40px; }
  .selection-dock { left: calc(var(--sidebar-w) + var(--dock-gutter) + 40px); right: calc(var(--dock-gutter) + 40px + 272px + 28px); }
}
@media (max-width: 1100px) {
  .topbar .private-indicator { display: none; }
  .table-head, .file-row { grid-template-columns: 18px minmax(0, 1fr) 80px 96px 100px; }
}
@media (max-width: 800px) {
  :root { --sidebar-w: 0px; --topbar-h: 56px; }
  body.sidebar-collapsed { --sidebar-w: 0px; }
  .mobile-only { display: inline-flex !important; }
  .sidebar { width: min(288px, 86vw); transform: translateX(-100%); box-shadow: none; visibility: hidden; transition: transform .22s var(--ease), visibility 0s linear .22s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); visibility: visible; transition: transform .22s var(--ease), visibility 0s; }
  .sidebar-header { padding-right: 8px; }
  .main-shell { margin-left: 0; }
  .topbar { gap: 8px; padding: 0 12px; }
  .search-box { max-width: none; }
  .search-box kbd { display: none; }
  .topbar-divider { display: none; }
  .content { padding: 20px 16px 40px; }
  .page-heading { align-items: center; margin-bottom: 16px; }
  .page-heading h1 { font-size: 22px; }
  .heading-actions .button-label, .heading-actions .button-caret { display: none; }
  .heading-actions .button { width: 40px; min-height: 40px; padding: 0; }
  .heading-actions .button .icon { width: 18px; height: 18px; }
  .summary-strip { gap: 8px; margin-bottom: 18px; }
  .stat { padding: 10px 12px; gap: 10px; }
  .stat-icon { display: none; }
  .stat-value { font-size: 15px; }
  .workspace-footer { padding: 12px 16px 20px; }
  .panels-grid { grid-template-columns: 1fr; }
  .selection-dock { left: 0; bottom: 12px; padding: 0 12px; }
  .selection-bar { width: 100%; justify-content: space-between; overflow-x: auto; scrollbar-width: none; }
  .selection-bar :is(.button-label, .button-label-short) { display: none; }
  .selection-bar .button { padding: 5px 9px; min-height: 40px; }
  .selection-bar .button .icon { width: 18px; height: 18px; }
  .selection-divider { display: none; }
  .transfer-progress { left: 12px; right: 12px; bottom: 12px; }
  .toast-region { left: 12px; right: 12px; bottom: 12px; max-width: none; align-items: stretch; }
  /* Full-width stack at the bottom: selection bar (12–66px), then the upload pill, then toasts. */
  body.has-selection .toast-region, body.has-selection .transfer-progress { bottom: 72px; }
  body:has(> .transfer-progress) .toast-region { bottom: 68px; }
  body.has-selection:has(> .transfer-progress) .toast-region { bottom: 128px; }
  dialog[open] > .toast-region, dialog[open] > .transfer-progress { bottom: 12px; }
  dialog[open] > .transfer-progress { left: 12px; }
  .viewer.viewer-editor[open] > .toast-region, .viewer.viewer-editor[open] > .transfer-progress { bottom: 48px; }
  dialog[open]:has(> .transfer-progress) > .toast-region { bottom: 68px; }
  .viewer.viewer-editor[open]:has(> .transfer-progress) > .toast-region { bottom: 104px; }
  :where(input:not([type=checkbox], [type=radio], [type=range], [type=color], [type=file]), select, textarea) { font-size: 16px; }
  .table-head, .file-row { grid-template-columns: 18px minmax(0, 1fr) 84px 76px; }
  .table-head > .th-size, .file-size { display: none; }
  .file-actions [data-action="share"] { display: none; }
  .file-actions .icon-button { width: 36px; height: 36px; }
  .viewer { width: 100%; max-width: calc(100% - 16px); height: calc(100svh - 16px); max-height: calc(100svh - 16px); }
  .viewer-header { padding: 8px 8px 8px 14px; }
  .viewer-actions .button span:last-child { display: none; }
  .viewer-actions .button { padding: 5px 8px; }
  .modal-header { padding: 14px 10px 6px 20px; }
  .modal-body { padding: 4px 20px 20px; }
  .modal-body > form:last-child > .form-actions:last-child { bottom: -20px; margin: 20px -20px -20px; padding: 12px 20px; }
  .editor-toolbar { max-height: 190px; }
  .editor-toolbar button { min-height: 36px; }
  .line-gutter { width: 49px; }
  .column-table input.column-cell { font-size: 16px; height: 36px; min-height: 36px; line-height: 36px; }
  .column-table tbody th button { height: 36px; line-height: 36px; }
  .column-pagebar { flex-wrap: wrap; gap: 5px; padding: 6px; }
  .editor-context-menu button { min-height: 36px; }
  .file-context-menu .menu-action { min-height: 40px; }
  .separator-toolbar { padding: 7px; gap: 4px; }
  #separator-scope { width: 100%; text-align: right; }
}
@media (max-width: 560px) {
  .topbar-end > #activity-button { display: none; }
  .content { padding: 16px 12px 36px; }
  .page-heading-text .breadcrumb { margin-bottom: 2px; }
  .page-subtitle { font-size: 13px; }
  .summary-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat { padding: 9px 10px; border-radius: 10px; }
  .stat-value { font-size: 14px; }
  .stat-label { font-size: 11px; }
  .file-toolbar { gap: 8px; margin-bottom: 14px; }
  .filter-tabs { flex: 1 1 100%; }
  .filter-tab { flex: 1 0 auto; justify-content: center; padding: 0 8px; }
  .filter-tab:not(.active) .filter-count { display: none; }
  .toolbar-options { width: 100%; justify-content: space-between; }
  .table-head, .file-row { grid-template-columns: 18px minmax(0, 1fr) 76px; column-gap: 10px; padding: 0 6px 0 12px; }
  .table-head > .th-date, .file-date { display: none; }
  .meta-extra { display: inline; }
  .file-row { min-height: 48px; }
  .file-name { gap: 10px; }
  .file-type-icon { width: 30px; height: 34px; font-size: 8px; }
  .file-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile-top { height: 76px; }
  .panel { padding: 16px; }
  .share-row { flex-wrap: wrap; padding: 12px; }
  .share-row .file-type-icon { display: none; }
  .share-row .button { margin-left: auto; }
  .viewer-title .file-type-icon { display: none; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .detail-row { font-size: 13px; }
  .workspace-footer > span:first-child { display: none; }
  .workspace-footer > span:last-child { margin-left: auto; }
  body.auth-page { padding: 16px 12px; }
  .shared-card { padding: 20px !important; }
  .shared-card h1 { font-size: 20px; }
}
@media (hover: none) {
  .file-actions .icon-button, .file-tile .tile-top > .icon-button, .file-tile > .file-select { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
}
