/* ============================================================
   Exevio Files v2 — design system
   1. tokens  2. base  3. utilities  4. chrome  5. components
   6. pages   7. animations
   ============================================================ */

/* ---------- 1. Tokens ---------- */
:root {
  color-scheme: light;

  --brand-600: #9a5340;
  --brand-500: #af614b;
  --brand-400: #c07a63;
  --brand-soft: #f6ece8;
  --brand-glow: rgb(175 97 75 / .25);
  --brand-contrast: #ffffff;

  --bg: #faf8f6;
  --bg-gradient: radial-gradient(1200px 500px at 85% -10%, rgb(175 97 75 / .07), transparent 60%),
                 radial-gradient(900px 420px at -10% 0%, rgb(175 97 75 / .05), transparent 55%);
  --surface: #ffffff;
  --surface-2: #f4f0ed;
  --surface-3: #ece6e1;
  --border: #e8e2dd;
  --border-strong: #d6cec7;

  --text: #29231e;
  --text-2: #6f6660;
  --text-3: #9c938b;

  --ok: #2f8a5d;       --ok-soft: #e4f3ec;
  --danger: #c9403c;   --danger-soft: #faeae9;
  --warn: #b97d1f;     --warn-soft: #f9f0dd;
  --info: #3d78b8;     --info-soft: #e7f0f9;

  --radius-sm: 7px;
  --radius-md: 11px;
  --radius-lg: 16px;
  --radius-full: 999px;

  --shadow-1: 0 1px 2px rgb(30 22 17 / .05), 0 1px 4px rgb(30 22 17 / .04);
  --shadow-2: 0 4px 16px rgb(30 22 17 / .09);
  --shadow-3: 0 16px 48px rgb(30 22 17 / .18);

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;

  --fs-xs: .75rem;
  --fs-sm: .8125rem;
  --fs-base: .9375rem;
  --fs-lg: 1.0625rem;
  --fs-xl: 1.4rem;

  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-out: cubic-bezier(.22, .8, .36, 1);

  --z-nav: 30; --z-dropdown: 40; --z-modal: 50; --z-toast: 60;

  /* Incognito chrome (private area) — same in both themes */
  --incognito: #2a2733;
  --incognito-line: #4a4459;
  --incognito-text: #e7e3ef;
}

[data-theme="dark"] {
  color-scheme: dark;

  --brand-600: #cf8871;
  --brand-500: #c4765b;
  --brand-400: #a96047;
  --brand-soft: rgb(196 118 91 / .15);
  --brand-glow: rgb(196 118 91 / .35);
  --brand-contrast: #1d1613;

  --bg: #151210;
  --bg-gradient: radial-gradient(1200px 500px at 85% -10%, rgb(196 118 91 / .09), transparent 60%),
                 radial-gradient(900px 420px at -10% 0%, rgb(196 118 91 / .05), transparent 55%);
  --surface: #201b18;
  --surface-2: #2a2420;
  --surface-3: #342d28;
  --border: #362f29;
  --border-strong: #4c433c;

  --text: #eee8e3;
  --text-2: #a69d95;
  --text-3: #7a716a;

  --ok: #4fae7d;       --ok-soft: rgb(79 174 125 / .16);
  --danger: #e06561;   --danger-soft: rgb(224 101 97 / .16);
  --warn: #d9a04a;     --warn-soft: rgb(217 160 74 / .16);
  --info: #6ba2dd;     --info-soft: rgb(107 162 221 / .16);

  --shadow-1: 0 1px 2px rgb(0 0 0 / .5);
  --shadow-2: 0 4px 18px rgb(0 0 0 / .5);
  --shadow-3: 0 18px 60px rgb(0 0 0 / .65);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: background-color .35s ease, color .35s ease;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--brand-500); text-decoration: none; }
a:hover { color: var(--brand-600); }
img { max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
[x-cloak] { display: none !important; }

::selection { background: var(--brand-soft); color: var(--brand-600); }

:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- 3. Utilities ---------- */
.container { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: clamp(1rem, 3vw, 2rem); }
.mono { font-family: var(--font-mono); font-size: .85em; }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); font-size: var(--fs-sm); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.28em; }
.icon-sm { width: 1em; height: 1em; vertical-align: -0.18em; }
.icon-xs { width: .8em; height: .8em; }

/* ---------- 4. Chrome ---------- */
.navbar {
  position: sticky; top: 0; z-index: var(--z-nav);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  border-bottom: 1px solid var(--border);
}
.navbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 62px; }
.brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--text); font-size: var(--fs-lg); }
.brand:hover { color: var(--text); }
.brand-logo { border-radius: 50%; transition: transform .35s var(--ease-spring); }
.brand:hover .brand-logo { transform: rotate(-8deg) scale(1.06); }
.brand-name b { color: var(--brand-500); font-weight: 700; }
.navbar-actions { display: flex; align-items: center; gap: .5rem; }

.navbar-nav { display: flex; align-items: center; gap: .25rem; margin-left: auto; margin-right: .6rem; }
.nav-link {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .4rem .7rem;
  border-radius: var(--radius-full);
  color: var(--text-2); font-size: var(--fs-sm); font-weight: 600;
  transition: background-color .18s ease, color .18s ease;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.is-active { background: var(--brand-soft); color: var(--brand-600); }

/* Incognito chrome for the private area */
.navbar-private {
  background: color-mix(in srgb, var(--incognito) 88%, transparent);
  border-bottom-color: color-mix(in srgb, var(--incognito-line) 60%, transparent);
}
.navbar-private .brand-name, .navbar-private .user-chip-email { color: var(--incognito-text); }
.navbar-private .nav-link { color: color-mix(in srgb, var(--incognito-text) 70%, transparent); }
.navbar-private .nav-link:hover { background: rgb(255 255 255 / .08); color: var(--incognito-text); }
.navbar-private .nav-link.is-active { background: rgb(255 255 255 / .14); color: #fff; }
.navbar-private .btn-icon { color: color-mix(in srgb, var(--incognito-text) 75%, transparent); }
.navbar-private .btn-icon:hover { background: rgb(255 255 255 / .1); color: #fff; }
.navbar-private .user-chip { background: rgb(255 255 255 / .08); border-color: rgb(255 255 255 / .16); }
.navbar-private .user-chip:hover { border-color: rgb(255 255 255 / .3); }
.navbar-private .avatar-ring { box-shadow: 0 0 0 2px var(--incognito), 0 0 0 3.5px rgb(255 255 255 / .35); }

.private-banner {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  font-size: var(--fs-sm); color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .55rem .9rem;
  margin-bottom: 1rem;
}
.private-banner .icon { color: var(--text-3); }

.theme-toggle { position: relative; overflow: hidden; }
.theme-toggle .icon { position: absolute; inset: 0; margin: auto; transition: transform .45s var(--ease-spring), opacity .3s ease; }
:root[data-theme="light"] .theme-toggle .icon-sun { transform: translateY(130%) rotate(90deg); opacity: 0; }
:root[data-theme="light"] .theme-toggle .icon-moon { transform: none; opacity: 1; }
:root[data-theme="dark"] .theme-toggle .icon-moon { transform: translateY(-130%) rotate(-90deg); opacity: 0; }
:root[data-theme="dark"] .theme-toggle .icon-sun { transform: none; opacity: 1; }

.user-chip {
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .3rem .65rem .3rem .3rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color .2s ease, box-shadow .2s ease, transform .15s ease;
}
.user-chip:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); transform: translateY(-1px); }
.user-chip-email { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); }
.user-chip .chevron { transition: transform .25s var(--ease-out); color: var(--text-3); }
.user-chip .chevron.is-open { transform: rotate(180deg); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; overflow: hidden; flex: none;
  background: var(--brand-soft); display: inline-flex; align-items: center; justify-content: center;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-ring { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--brand-400); }
.avatar-sm { width: 22px; height: 22px; }

.footer { margin-top: auto; padding: 1.4rem 0 1.6rem; color: var(--text-3); font-size: var(--fs-sm); }
.footer-inner { display: flex; justify-content: center; }
.footer a { font-weight: 600; }

.page-main { padding-top: 1.6rem; padding-bottom: 2.2rem; width: 100%; }

/* ---------- 5. Components ---------- */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-weight: 600; font-size: var(--fs-sm);
  padding: .56rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease,
              transform .15s var(--ease-out), box-shadow .2s ease;
  will-change: transform;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.btn-primary { background: var(--brand-500); color: var(--brand-contrast); box-shadow: 0 2px 10px var(--brand-glow); }
.btn-primary:hover { background: var(--brand-600); transform: translateY(-1px); box-shadow: 0 5px 18px var(--brand-glow); }
.btn-outline { border-color: var(--border-strong); color: var(--text); background: var(--surface); }
.btn-outline:hover { border-color: var(--brand-400); color: var(--brand-600); background: var(--brand-soft); transform: translateY(-1px); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 4px 14px rgb(201 64 60 / .35); }
.btn-lg { padding: .75rem 1.3rem; font-size: var(--fs-base); border-radius: var(--radius-md); }
.btn-block { width: 100%; }

.btn-icon {
  width: 34px; height: 34px; padding: 0;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--brand-soft); color: var(--brand-600); transform: translateY(-1px); }
.btn-icon:active { transform: scale(.9); }
.btn-icon-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-icon .icon { width: 18px; height: 18px; }

.btn-text {
  display: inline-flex; align-items: center; gap: .35rem;
  color: var(--brand-500); font-size: var(--fs-sm); font-weight: 600;
  transition: color .2s ease;
}
.btn-text:hover { color: var(--brand-600); text-decoration: underline; }

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

/* Fields */
.field { display: block; margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.field-label { display: block; font-size: var(--fs-sm); font-weight: 600; margin-bottom: .35rem; color: var(--text-2); }
.field-optional { font-weight: 400; color: var(--text-3); }
.field-hint { display: block; font-size: var(--fs-xs); color: var(--text-3); margin-top: .35rem; }
.field-error { display: block; font-size: var(--fs-sm); color: var(--danger); margin-top: .4rem; font-weight: 500; }
.field-error-center { text-align: center; }

.input, .select {
  width: 100%;
  font: inherit; font-size: var(--fs-base);
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: .52rem .8rem;
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.input::placeholder { color: var(--text-3); }
.input:hover, .select:hover { border-color: var(--brand-400); }
.input:focus, .select:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3.5px var(--brand-glow);
}
.input-error { border-color: var(--danger) !important; }
.input-error:focus { box-shadow: 0 0 0 3.5px rgb(201 64 60 / .22); }
.input-lg { padding: .7rem .9rem; }
.input[type="number"] { -moz-appearance: textfield; }

.select {
  appearance: none; cursor: pointer; padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999086' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .6rem center;
}
.select-block { display: block; width: 100%; }
.select-wrap .select { width: auto; min-width: 118px; }

.search-wrap { position: relative; display: inline-flex; align-items: center; }
.search-icon { position: absolute; left: .7rem; color: var(--text-3); pointer-events: none; }
.search-spinner { position: absolute; right: .7rem; color: var(--brand-500); pointer-events: none; }
.input-search { padding-left: 2.1rem; min-width: 230px; }
.input-search:focus { min-width: 260px; }
.input-search { transition: border-color .2s ease, box-shadow .2s ease, min-width .3s var(--ease-out); }

/* Badges */
.badge {
  display: inline-flex; align-items: center;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em;
  text-transform: capitalize;
  padding: .18rem .6rem; border-radius: var(--radius-full);
}
.badge-admin { background: var(--brand-soft); color: var(--brand-600); }
.badge-member { background: var(--info-soft); color: var(--info); }
.badge-suspended { background: var(--danger-soft); color: var(--danger); }
.badge-guest { background: var(--warn-soft); color: var(--warn); }
.badge-muted { background: var(--surface-2); color: var(--text-3); margin-left: .5rem; text-transform: none; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  transition: background-color .35s ease, border-color .35s ease;
}
/* No overflow clipping — tooltips and menus must escape the card. Rounded
   corners are enforced per-child instead. */
.card-table { overflow: visible; }
.card-table > :first-child { border-radius: calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px) 0 0; }
.card-table > :last-child { border-radius: 0 0 calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px); }
.table tbody tr:last-child td:first-child { border-bottom-left-radius: calc(var(--radius-lg) - 1px); }
.table tbody tr:last-child td:last-child { border-bottom-right-radius: calc(var(--radius-lg) - 1px); }
.card-title { display: flex; align-items: center; gap: .5rem; font-size: var(--fs-lg); font-weight: 700; }
.card-title .icon { color: var(--brand-500); }

/* Toolbar */
.card-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: .9rem;
  flex-wrap: wrap;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.toolbar-actions { display: flex; gap: .55rem; flex-wrap: wrap; }
.toolbar-filters { display: flex; gap: .55rem; align-items: center; flex-wrap: wrap; }

.card-subbar {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap;
  padding: .65rem 1.1rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  transition: background-color .35s ease;
}
.search-note { font-size: var(--fs-sm); color: var(--text-2); }
.search-clear { margin-left: .4rem; font-weight: 600; }

/* Breadcrumbs */
.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: .15rem; font-size: var(--fs-sm); }
.crumb {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .18rem .5rem; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
  transition: background-color .18s ease, color .18s ease;
}
a.crumb:hover { background: var(--brand-soft); color: var(--brand-600); }
.crumb-current { color: var(--text); font-weight: 700; }
.crumb-sep { color: var(--text-3); }

/* Tabs */
.tabs { display: flex; gap: .25rem; padding: 0 1.1rem; border-bottom: 1px solid var(--border); }
.tab {
  position: relative;
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .75rem .9rem;
  color: var(--text-2); font-weight: 600; font-size: var(--fs-sm);
  transition: color .2s ease;
}
.tab:hover { color: var(--text); }
.tab::after {
  content: ""; position: absolute; left: .6rem; right: .6rem; bottom: -1px; height: 2.5px;
  background: var(--brand-500); border-radius: 2px 2px 0 0;
  transform: scaleX(0); transition: transform .25s var(--ease-out);
}
.tab.is-active { color: var(--brand-600); }
.tab.is-active::after { transform: scaleX(1); }
.tab-count {
  font-size: var(--fs-xs); background: var(--surface-2); color: var(--text-3);
  border-radius: var(--radius-full); padding: .05rem .45rem; font-variant-numeric: tabular-nums;
}
.tab.is-active .tab-count { background: var(--brand-soft); color: var(--brand-600); }

/* Table — never scrolls inside its card: it fits (fluid columns) or the
   layout switches to stacked cards. */
.table-wrap { overflow: visible; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: var(--fs-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3);
  padding: .7rem .8rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: .65rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background-color .18s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }

.th-sort { display: inline-flex; align-items: center; gap: .3rem; color: inherit; transition: color .2s ease; }
.th-sort:hover { color: var(--brand-500); }
.th-sort .sort-arrow { opacity: 0; transform: rotate(180deg); transition: opacity .2s ease, transform .25s var(--ease-out); }
.th-sort:hover .sort-arrow { opacity: .5; }
.th-sort.is-active { color: var(--brand-600); }
.th-sort.is-active .sort-arrow { opacity: 1; }
.th-sort.is-active .sort-arrow.is-asc { transform: rotate(0deg); }

.col-icon { width: 50px; }
.col-actions { width: 1%; text-align: right; }
.col-size, .col-downloads { white-space: nowrap; }

/* Generated file badges — one shape, hue per category, extension as label.
   Every format gets a consistent icon in both themes, no image assets. */
.fbadge {
  --fb-h: 220;
  --fb-stroke: hsl(var(--fb-h) 42% 42%);
  --fb-bg: hsl(var(--fb-h) 60% 95%);
  --fb-fold: hsl(var(--fb-h) 50% 84%);
  position: relative;
  display: inline-flex; flex: none;
  width: var(--fb-size, 34px); height: var(--fb-size, 34px);
  transition: transform .25s var(--ease-spring);
}
[data-theme="dark"] .fbadge {
  --fb-stroke: hsl(var(--fb-h) 55% 68%);
  --fb-bg: hsl(var(--fb-h) 35% 20% / .85);
  --fb-fold: hsl(var(--fb-h) 40% 32%);
}
.fbadge svg { width: 100%; height: 100%; display: block; }
.fbadge b {
  position: absolute; left: 6%; right: 2%; bottom: 16%;
  text-align: center;
  font-size: calc(var(--fb-size, 34px) * .26);
  font-weight: 800; letter-spacing: 0;
  line-height: 1;
  color: var(--fb-stroke);
  pointer-events: none;
  overflow: hidden;
}
.cat-folder  { --fb-h: 16; }
.cat-folder  { --fb-stroke: var(--brand-500); --fb-bg: var(--brand-soft); }
.cat-image   { --fb-h: 150; }
.cat-video   { --fb-h: 262; }
.cat-audio   { --fb-h: 330; }
.cat-doc     { --fb-h: 216; }
.cat-sheet   { --fb-h: 122; }
.cat-slides  { --fb-h: 25; }
.cat-archive { --fb-h: 43; }
.cat-code    { --fb-h: 190; }
.cat-exe     { --fb-h: 0; }
.cat-font    { --fb-h: 280; }
.cat-plain   { --fb-stroke: hsl(220 8% 50%); --fb-bg: hsl(220 10% 94%); --fb-fold: hsl(220 8% 84%); }
[data-theme="dark"] .cat-plain { --fb-stroke: hsl(220 8% 66%); --fb-bg: hsl(220 8% 22% / .85); --fb-fold: hsl(220 8% 32%); }

tr:hover .fbadge { transform: scale(1.1) rotate(-3deg); }

.file-cell { min-width: 0; max-width: min(420px, 26vw); }
.file-name-row { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.file-name {
  font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.file-name-link { color: var(--text); }
.file-name-link:hover { color: var(--brand-600); }
.file-flag { color: var(--text-3); display: inline-flex; transition: color .2s ease, transform .2s var(--ease-spring); }
.share-flag[hidden] { display: none; }

/* Folder trail on search results: [folder] / [folder] / name */
.path-crumb {
  display: inline-flex; flex: none;
  color: var(--text-3);
  padding: .1rem;
  border-radius: var(--radius-sm);
  transition: color .18s ease, background-color .18s ease, transform .18s var(--ease-spring);
}
.path-crumb:hover { color: var(--brand-600); background: var(--brand-soft); transform: scale(1.12); }
.path-sep { color: var(--text-3); flex: none; user-select: none; }
.file-flag:hover { color: var(--brand-500); transform: scale(1.2); }
.file-sub { display: block; font-size: var(--fs-xs); color: var(--text-3); margin-top: .1rem; }
.file-url {
  display: block; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--fs-xs); color: var(--brand-500);
  margin-top: .15rem; text-align: left;
  transition: color .18s ease;
}
.file-url:hover { color: var(--brand-600); text-decoration: underline; }

.stack-cell { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.uploader-cell { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.uploader-email {
  font-size: var(--fs-sm); max-width: clamp(90px, 13vw, 180px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* The tight clamp is for the files table's crowded column — users has room */
.table-users .uploader-email { max-width: none; }

.row-actions { display: inline-flex; gap: .1rem; opacity: .55; transition: opacity .2s ease; }
tr:hover .row-actions, .row-actions:focus-within { opacity: 1; }

/* Freshly uploaded rows: strong flash, then a subtle tint that fades by 20s.
   The highlight params are stripped from the URL, so refresh clears it. */
.row-new td { animation: rowNew 20s linear 1 both; }
.row-dir { cursor: default; }

/* Empty state */
.empty { text-align: center; padding: 3.2rem 1rem; }
.empty-icon {
  width: 52px; height: 52px; color: var(--text-3); opacity: .6;
  animation: float 3.5s ease-in-out infinite;
}
.empty-title { font-weight: 700; font-size: var(--fs-lg); margin-top: .8rem; }
.empty-sub { color: var(--text-3); font-size: var(--fs-sm); margin-top: .25rem; }

/* Dropdown menu */
.menu-wrap { position: relative; display: inline-block; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 230px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
  padding: .4rem;
  z-index: var(--z-dropdown);
  transform-origin: top right;
}
.menu-right { right: 0; left: auto; }
.menu-enter { transition: opacity .18s var(--ease-out), transform .18s var(--ease-out); }
.menu-leave { transition: opacity .13s ease-in, transform .13s ease-in; }
.menu-enter-start { opacity: 0; transform: scale(.92) translateY(-6px); }
.menu-enter-end { opacity: 1; transform: scale(1) translateY(0); }
.menu-header { padding: .55rem .65rem .6rem; border-bottom: 1px solid var(--border); margin-bottom: .35rem; }
.menu-email { font-size: var(--fs-sm); font-weight: 600; margin-bottom: .3rem; word-break: break-all; }
.menu-sep { height: 1px; background: var(--border); margin: .35rem 0; }
.menu-item {
  display: flex; align-items: center; gap: .6rem;
  width: 100%; text-align: left;
  padding: .5rem .65rem;
  border-radius: var(--radius-sm);
  color: var(--text); font-size: var(--fs-sm); font-weight: 500;
  transition: background-color .15s ease, color .15s ease, transform .15s ease;
}
.menu-item:hover { background: var(--brand-soft); color: var(--brand-600); transform: translateX(2px); }
.menu-item:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.menu-item:disabled:hover { background: none; color: var(--text); }
.menu-item .icon { width: 17px; height: 17px; color: var(--text-3); transition: color .15s ease; }
.menu-item:hover .icon { color: inherit; }
.menu-item-danger:hover { background: var(--danger-soft); color: var(--danger); }

/* Modal */
.modal {
  width: min(480px, calc(100vw - 2rem));
  /* Never taller than the screen: the body scrolls, the header and actions stay */
  max-height: calc(100dvh - 2rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-3);
  padding: 0;
  overflow: visible;
}
.modal[open] { display: flex; flex-direction: column; }
.modal[open] > form { display: flex; flex-direction: column; min-height: 0; }
.modal-header, .modal-actions { flex: none; }
.modal-body {
  overflow-y: auto;
  min-height: 0;
  overscroll-behavior: contain; /* don't chain the scroll to the page behind */
}
/* Belt and braces: with a modal open the page itself must not scroll */
html:has(dialog[open]) { overflow: hidden; }
.modal-sm { width: min(400px, calc(100vw - 2rem)); }
.modal[open] { animation: modalIn .3s var(--ease-spring); }
.modal[data-closing] { animation: modalOut .17s ease-in forwards; }
.modal::backdrop { background: rgb(15 10 8 / .55); backdrop-filter: blur(3px); }
.modal[open]::backdrop { animation: fadeIn .25s ease; }
.modal[data-closing]::backdrop { animation: fadeOut .17s ease forwards; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.05rem 1.2rem .9rem;
}
.modal-title { display: flex; align-items: center; gap: .55rem; font-size: var(--fs-lg); font-weight: 700; }
.modal-title .icon { color: var(--brand-500); }
.modal-body { padding: 0 1.2rem 1.1rem; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: .55rem;
  padding: .9rem 1.2rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.modal-actions-center { justify-content: center; }

.modal-confirm { text-align: center; padding-top: 1.6rem; }
.modal-confirm .modal-title { justify-content: center; }
.confirm-icon {
  width: 58px; height: 58px; margin: 0 auto .9rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  animation: popIn .4s var(--ease-spring);
}
.confirm-icon .icon { width: 26px; height: 26px; }
.confirm-icon-danger { background: var(--danger-soft); color: var(--danger); }
.confirm-text { color: var(--text-2); font-size: var(--fs-sm); margin-top: .5rem; overflow-wrap: anywhere; }
.confirm-type { margin: 1rem auto 0; max-width: 260px; }
.confirm-type .input { text-align: center; }

/* File preview */
.file-icon-btn { display: block; border-radius: var(--radius-sm); }
.file-icon-btn:hover .fbadge { transform: scale(1.15) rotate(-3deg); }
.file-icon-btn:focus-visible { outline-offset: 3px; }

.modal-preview { width: min(860px, calc(100vw - 2rem)); }
.modal-preview .modal-header { border-bottom: 1px solid var(--border); padding-bottom: .8rem; }
.modal-title-file { min-width: 0; flex: 1; }
.preview-title-name {
  font-size: var(--fs-base);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.preview-header-actions { display: flex; gap: .25rem; flex: none; }
.preview-body {
  padding: 1rem 1.2rem 1.2rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 180px;
}
.preview-loading { display: flex; align-items: center; gap: .55rem; color: var(--text-3); font-size: var(--fs-sm); padding: 2rem 0; }
.preview-error { color: var(--text-2); font-size: var(--fs-sm); padding: 2rem 0; text-align: center; }
.preview-image {
  max-width: 100%; max-height: 68vh;
  border-radius: var(--radius-sm);
  animation: fadeRise .3s var(--ease-out);
}
.preview-video { width: 100%; max-height: 68vh; border-radius: var(--radius-sm); background: #000; }
.preview-audio-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 1.2rem; padding: 1.4rem 0; }
.preview-audio-icon { width: 46px; height: 46px; color: var(--brand-500); }
.preview-audio { width: 100%; }
.preview-pdf { width: 100%; height: 70vh; border: 0; border-radius: var(--radius-sm); background: var(--surface-2); }
.zip-list-wrap { width: 100%; }
.zip-list-summary { font-size: var(--fs-xs); color: var(--text-3); margin-bottom: .5rem; }
.zip-list {
  list-style: none; margin: 0; padding: .3rem;
  max-height: 60vh; overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.zip-item {
  display: flex; align-items: center; gap: .55rem;
  padding: .3rem .5rem;
  padding-left: calc(.5rem + var(--depth, 0) * 1.1rem);
  border-radius: var(--radius-sm);
}
.zip-item:hover { background: var(--surface); }
.zip-item-name {
  flex: 1; min-width: 0;
  font-size: var(--fs-sm);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.zip-item-name.is-dir { font-weight: 600; }
.zip-item-size { font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; flex: none; }

.preview-text {
  width: 100%; margin: 0;
  max-height: 65vh; overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem;
  font-family: var(--font-mono); font-size: .8rem; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
  text-align: left;
}

/* Syntax colours — one palette, tuned per theme */
:root {
  --tok-comment: #8a8079;
  --tok-string:  #2f7d4f;
  --tok-number:  #b06a1f;
  --tok-keyword: #9a5340;
  --tok-literal: #8250b8;
  --tok-name:    #2f6fa8;
  --tok-tag:     #b3453f;
  --tok-punct:   #8a8079;
}
[data-theme="dark"] {
  --tok-comment: #7c736b;
  --tok-string:  #8ecf9f;
  --tok-number:  #e0b070;
  --tok-keyword: #e69a7c;
  --tok-literal: #c39bea;
  --tok-name:    #86b8e6;
  --tok-tag:     #ef8f88;
  --tok-punct:   #8a8079;
}
.preview-text .tok-comment  { color: var(--tok-comment); font-style: italic; }
.preview-text .tok-string   { color: var(--tok-string); }
.preview-text .tok-number   { color: var(--tok-number); }
.preview-text .tok-keyword,
.preview-text .tok-atrule   { color: var(--tok-keyword); font-weight: 600; }
.preview-text .tok-literal  { color: var(--tok-literal); }
.preview-text .tok-property,
.preview-text .tok-attr,
.preview-text .tok-variable,
.preview-text .tok-function { color: var(--tok-name); }
.preview-text .tok-tag,
.preview-text .tok-doctype,
.preview-text .tok-selector,
.preview-text .tok-entity   { color: var(--tok-tag); }
.preview-text .tok-punct    { color: var(--tok-punct); }
.preview-text .tok-heading  { color: var(--tok-keyword); font-weight: 700; }
.preview-text .tok-strong   { font-weight: 700; }
.preview-text .tok-em       { font-style: italic; }
.preview-text .tok-link     { color: var(--tok-name); text-decoration: underline; }
.preview-text .tok-cdata    { color: var(--tok-comment); }

/* Dropzone */
.dropzone {
  position: relative;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  margin-bottom: 1rem;
  background: var(--surface-2);
  transition: border-color .25s ease, background-color .25s ease, transform .2s var(--ease-out);
}
.dropzone:hover { border-color: var(--brand-400); background: var(--brand-soft); }
.dropzone:hover .dropzone-icon { transform: translateY(-4px); }
.dropzone.is-dragover {
  border-color: var(--brand-500);
  background: var(--brand-soft);
  transform: scale(1.015);
  animation: dropPulse 1.2s ease-in-out infinite;
}
.dropzone.has-file { cursor: default; padding: .9rem 1rem; }
.dropzone-icon { width: 34px; height: 34px; color: var(--brand-500); transition: transform .3s var(--ease-spring); }
.dropzone-title { font-weight: 700; margin-top: .5rem; }
.dropzone-sub { color: var(--text-3); font-size: var(--fs-sm); margin-top: .15rem; }
.dropzone-browse { color: var(--brand-500); font-weight: 600; text-decoration: underline; transition: color .15s ease; }
.dropzone-browse:hover { color: var(--brand-600); }
.dropzone-picked { display: flex; align-items: center; gap: .7rem; text-align: left; }
.dropzone-file-icon { width: 30px; height: 30px; color: var(--brand-500); }
.dropzone-file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dropzone-file-name { font-weight: 600; font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone-file-size { color: var(--text-3); font-size: var(--fs-xs); }

/* Folder ZIP modal */
.zip-target { display: flex; align-items: center; gap: .7rem; margin-bottom: 1rem; }
.zip-target-meta { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.zip-target-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zip-target-sub { font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.zip-progress { display: flex; align-items: center; gap: .7rem; }
.zip-note { display: flex; align-items: center; gap: .45rem; font-size: var(--fs-sm); color: var(--text-3); margin-top: .7rem; }
.zip-note-error { color: var(--danger); }

/* Upload name-collision choice */
.conflict-box {
  border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border));
  background: var(--warn-soft);
  border-radius: var(--radius-md);
  padding: .8rem;
  margin-bottom: 1rem;
  animation: fadeRise .3s var(--ease-out);
}
.conflict-head {
  display: flex; align-items: center; gap: .5rem;
  color: var(--warn); font-size: var(--fs-sm); font-weight: 600;
  margin-bottom: .65rem;
}
.conflict-head b { overflow-wrap: anywhere; }
.conflict-option {
  display: flex; align-items: flex-start; gap: .6rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .55rem .7rem;
  margin-top: .45rem;
  cursor: pointer;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.conflict-option:hover { border-color: var(--brand-400); }
.conflict-option.is-picked { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-glow); }
.conflict-option input { margin-top: .2rem; accent-color: var(--brand-500); }
.conflict-option span { display: flex; flex-direction: column; line-height: 1.35; }
.conflict-option b { font-size: var(--fs-sm); }
.conflict-option em { font-style: normal; font-size: var(--fs-xs); color: var(--text-3); }

/* Progress */
.upload-progress { display: flex; align-items: center; gap: .7rem; margin-top: .9rem; }
.progress { flex: 1; height: 8px; background: var(--surface-3); border-radius: var(--radius-full); overflow: hidden; }
.progress-bar {
  height: 100%; border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--brand-400), var(--brand-500), var(--brand-400));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  transition: width .25s var(--ease-out);
}
.upload-pct { font-variant-numeric: tabular-nums; font-size: var(--fs-sm); font-weight: 700; color: var(--brand-600); min-width: 42px; text-align: right; }
.btn-uploading { display: inline-flex; align-items: center; gap: .5rem; }
.btn-cancel-upload { color: var(--danger); }
.btn-cancel-upload:hover { background: var(--danger-soft); color: var(--danger); }

/* Settings page */
.page-settings { max-width: 860px; display: flex; flex-direction: column; gap: 1.1rem; }
.settings-form, .settings-body { padding: 1.1rem; }
.settings-group { padding-bottom: 1.1rem; margin-bottom: 1.1rem; border-bottom: 1px dashed var(--border); }
.settings-group:last-of-type { border-bottom: 0; margin-bottom: 0; }
.settings-heading {
  font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3); margin-bottom: .7rem;
}
.input-narrow { max-width: 180px; }
.settings-actions { display: flex; justify-content: flex-end; }

.scan-error { color: var(--danger); font-size: var(--fs-sm); margin-top: .8rem; }
.scan-results { margin-top: 1rem; }
.scan-summary { font-size: var(--fs-sm); color: var(--text-2); font-variant-numeric: tabular-nums; }
.scan-warning {
  display: flex; align-items: flex-start; gap: .6rem;
  background: var(--warn-soft); color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border));
  border-radius: var(--radius-md);
  padding: .75rem .9rem; margin-top: .8rem;
  font-size: var(--fs-sm); line-height: 1.45;
}
.scan-warning .icon { flex: none; margin-top: .1rem; }
.scan-block { margin-top: 1.2rem; }
.scan-block-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-bottom: .5rem; }
.scan-block-head h3 { font-size: var(--fs-base); font-weight: 700; }
.scan-block-actions { display: flex; align-items: center; gap: .8rem; }
.btn-sm { padding: .35rem .7rem; font-size: var(--fs-xs); }
.scan-list {
  list-style: none; margin: 0; padding: .3rem;
  max-height: 340px; overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.scan-item {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  padding: .35rem .55rem; border-radius: var(--radius-sm);
}
.scan-item:hover { background: var(--surface); }
.scan-pick { display: flex; align-items: center; gap: .5rem; min-width: 0; cursor: pointer; font-size: var(--fs-sm); }
.scan-pick input { accent-color: var(--brand-500); flex: none; }
.scan-key { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-meta { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; flex: none; }
.scan-clean { display: flex; align-items: center; gap: .45rem; color: var(--ok); font-size: var(--fs-sm); margin-top: 1rem; }

.backup-list { list-style: none; margin: .8rem 0 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.backup-item {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  padding: .6rem .75rem; border-bottom: 1px solid var(--border);
}
.backup-item:last-child { border-bottom: 0; }
.backup-meta { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.backup-name { font-weight: 600; font-size: var(--fs-sm); }
.backup-sub { font-size: var(--fs-xs); color: var(--text-3); }

/* Sharing section (edit modals) */
.share-section { border-top: 1px dashed var(--border); margin-top: 1.1rem; padding-top: .9rem; }
.share-head .field-label { display: flex; align-items: center; gap: .35rem; margin-bottom: .1rem; }
.share-head .field-hint { margin-top: 0; }
.share-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.share-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--brand-soft); color: var(--brand-600);
  font-size: var(--fs-xs); font-weight: 600;
  border-radius: var(--radius-full);
  padding: .25rem .3rem .25rem .65rem;
  animation: popIn .25s var(--ease-spring);
  max-width: 100%;
}
.share-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-chip-inherited {
  background: var(--surface-2); color: var(--text-2);
  padding-right: .65rem;
}
.share-chip-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  color: inherit; opacity: .65;
  transition: opacity .15s ease, background-color .15s ease, transform .15s var(--ease-spring);
}
.share-chip-remove:hover { opacity: 1; background: rgb(0 0 0 / .1); transform: scale(1.1); }
.share-empty { font-size: var(--fs-xs); color: var(--text-3); margin-top: .6rem; }
.share-add { display: flex; gap: .5rem; margin-top: .7rem; }
.share-add .input { flex: 1; }

/* iOS-style switch */
.switch { position: relative; display: inline-flex; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
  display: inline-block; width: 42px; height: 25px;
  background: var(--surface-3);
  border-radius: var(--radius-full);
  transition: background-color .25s ease;
  pointer-events: none;
}
.switch-knob {
  position: absolute; top: 2.5px; left: 2.5px;
  width: 20px; height: 20px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgb(0 0 0 / .3);
  transition: transform .25s var(--ease-spring);
}
.switch input:checked + .switch-track { background: var(--ok); }
.switch input:checked + .switch-track .switch-knob { transform: translateX(17px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .5; }

.share-notify {
  display: flex; align-items: flex-start; gap: .6rem;
  margin-top: .8rem;
  cursor: pointer;
}
.share-notify-text { display: flex; flex-direction: column; line-height: 1.35; }
.share-notify-label { font-size: var(--fs-sm); color: var(--text-2); }
.share-notify-hint { font-size: var(--fs-xs); color: var(--text-3); }

/* Public folder upload (invited guests) */
.public-upload { margin-top: 1.2rem; }
.public-upload-actions { display: flex; gap: .5rem; }
.public-upload-actions .btn-outline { flex: 1; }
.public-upload-hint { font-size: var(--fs-xs); color: var(--text-3); margin-top: .5rem; }
.folder-list-flush { border: 0; margin: 0; }
.folder-list-flush .folder-row { padding: .7rem 1.1rem; }
.page-narrow { max-width: 720px; }

/* Whole-page drop overlay */
.page-drop-overlay {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
  pointer-events: none;
}
.page-drop-frame {
  width: min(560px, 100%);
  border: 2.5px dashed var(--brand-500);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow-3), 0 0 0 8px var(--brand-glow);
  padding: 3rem 2rem;
  text-align: center;
  animation: dropPulse 1.4s ease-in-out infinite;
}
.page-drop-icon { width: 46px; height: 46px; color: var(--brand-500); animation: float 1.6s ease-in-out infinite; }
.page-drop-title { font-size: var(--fs-xl); font-weight: 800; margin-top: .9rem; letter-spacing: -.01em; }
.page-drop-sub { color: var(--text-2); font-size: var(--fs-sm); margin-top: .3rem; }
.overlay-enter { transition: opacity .2s ease; }
.overlay-leave { transition: opacity .15s ease; }
.overlay-enter-start { opacity: 0; }
.overlay-enter-end { opacity: 1; }

/* Public folder page */
.folder-card { width: min(560px, 100%); }
.folder-list {
  list-style: none; margin: 1.4rem 0 0; padding: 0;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: visible; /* tooltips must not clip at the edges */
}
.folder-row:first-child { border-radius: calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px) 0 0; }
.folder-row:last-child { border-radius: 0 0 calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px); }
.folder-row {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--border);
  animation: fadeRise .4s var(--ease-out) backwards;
  transition: background-color .15s ease;
}
.folder-row:last-child { border-bottom: 0; }
.folder-row:hover { background: var(--surface-2); }
.folder-row-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.folder-row-name {
  font-weight: 600; font-size: var(--fs-sm); color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
a.folder-row-name:hover { color: var(--brand-600); }
.folder-row-sub { font-size: var(--fs-xs); color: var(--text-3); }
.folder-empty { margin-top: 1.4rem; }

/* Toasts — a manual popover so the stack sits in the top layer, above open
   <dialog> modals and their blurred backdrop. Resets undo popover UA styles. */
.toast-stack {
  position: fixed; inset: auto 1rem 1rem auto; z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: .6rem;
  max-width: min(380px, calc(100vw - 2rem));
  width: auto; height: auto;
  margin: 0; border: 0; padding: 0;
  background: transparent; overflow: visible;
  pointer-events: none;
  color: inherit;
}
.toast-stack:popover-open { display: flex; }
.toast { pointer-events: auto; }
.toast {
  position: relative;
  display: flex; align-items: center; gap: .6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
  padding: .75rem .85rem;
  overflow: hidden;
}
.toast-icon { width: 20px; height: 20px; flex: none; }
.toast-ok .toast-icon { color: var(--ok); }
.toast-error .toast-icon { color: var(--danger); }
.toast-info .toast-icon { color: var(--info); }
.toast-message { flex: 1; font-size: var(--fs-sm); font-weight: 500; overflow-wrap: anywhere; }
.toast-close { color: var(--text-3); flex: none; display: inline-flex; padding: .2rem; border-radius: var(--radius-sm); transition: color .15s ease, background-color .15s ease; }
.toast-close:hover { color: var(--text); background: var(--surface-2); }
.toast-timer {
  position: absolute; left: 0; right: 0; bottom: 0; height: 2.5px;
  background: currentColor; opacity: .18;
  transform-origin: left;
  animation: toastTimer 4.5s linear forwards;
}
.toast-enter { transition: opacity .3s var(--ease-out), transform .3s var(--ease-spring); }
.toast-leave { transition: opacity .2s ease-in, transform .2s ease-in; }
.toast-enter-start { opacity: 0; transform: translateX(60%) scale(.9); }
.toast-enter-end { opacity: 1; transform: translateX(0) scale(1); }
.toast-leave-end { opacity: 0; transform: translateY(40%) scale(.92); }

/* "Uploaded" popup (bottom center) */
.upload-popup {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex; align-items: center; gap: .8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
  padding: .7rem .8rem .7rem 1rem;
  max-width: min(480px, calc(100vw - 2rem));
}
.upload-popup-check {
  width: 34px; height: 34px; flex: none;
  border-radius: 50%;
  background: var(--ok-soft); color: var(--ok);
  display: inline-flex; align-items: center; justify-content: center;
  animation: popIn .4s var(--ease-spring);
}
.upload-popup-meta { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.upload-popup-label { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.upload-popup-name {
  font-weight: 600; font-size: var(--fs-sm);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.btn-copy-link { flex: none; }
.btn-copy-link.is-copied { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.popup-enter { transition: opacity .3s var(--ease-out), transform .3s var(--ease-spring); }
.popup-leave { transition: opacity .25s ease-in, transform .25s ease-in; }
.popup-enter-start { opacity: 0; transform: translateX(-50%) translateY(20px) scale(.95); }
.popup-enter-end { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }

/* Pagination */
.pagination-bar {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap;
  padding: .85rem 1.1rem;
  border-top: 1px solid var(--border);
}
.pagination-caption { font-size: var(--fs-sm); color: var(--text-3); }
.pagination-caption b { color: var(--text-2); }
.pagination-totals { font-size: var(--fs-sm); color: var(--text-3); font-variant-numeric: tabular-nums; }
.pagination-totals b { color: var(--text-2); }
.pagination { display: flex; align-items: center; gap: .25rem; }
.page-link {
  min-width: 32px; height: 32px; padding: 0 .45rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-2);
  font-variant-numeric: tabular-nums;
  transition: background-color .18s ease, color .18s ease, transform .18s var(--ease-out);
}
.page-link:hover { background: var(--brand-soft); color: var(--brand-600); transform: translateY(-1px); }
.page-link.is-current { background: var(--brand-500); color: var(--brand-contrast); box-shadow: 0 2px 8px var(--brand-glow); }
.page-link.is-disabled { opacity: .35; pointer-events: none; }
.page-ellipsis { color: var(--text-3); padding: 0 .2rem; }

/* Tooltips (CSS only). Hidden tooltips are display:none so they never
   contribute to scrollable overflow (a 3px ghost scrollbar otherwise). */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 7px); left: 50%;
  transform: translateX(-50%) translateY(4px) scale(.96);
  background: var(--text); color: var(--bg);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.35;
  padding: .3rem .55rem; border-radius: var(--radius-sm);
  white-space: nowrap;
  display: none; opacity: 0; pointer-events: none;
  transition: opacity .18s ease .15s, transform .18s var(--ease-out) .15s,
              display .18s allow-discrete .15s;
  z-index: var(--z-dropdown);
}
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  display: block;
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}
@starting-style {
  [data-tip]:hover::after, [data-tip]:focus-visible::after {
    opacity: 0;
    transform: translateX(-50%) translateY(4px) scale(.96);
  }
}
.tip-under[data-tip]::after { bottom: auto; top: calc(100% + 6px); transform: translateX(-50%) translateY(-4px) scale(.96); }
.tip-under[data-tip]:hover::after { transform: translateX(-50%) translateY(0) scale(1); }

/* ---------- 6. Pages ---------- */

/* Auth shell (login / pin / unlock / error) */
.page-bare { justify-content: center; }
.auth-shell {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.2rem;
  padding: 2rem 1rem;
}
.auth-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: 2.2rem 1.9rem;
  text-align: center;
}
.auth-logo { border-radius: 50%; box-shadow: 0 6px 20px var(--brand-glow); }
.auth-file-icon { display: inline-block; }
.auth-title { font-size: var(--fs-xl); font-weight: 800; margin-top: 1.1rem; letter-spacing: -.01em; }
.auth-title-file { font-size: var(--fs-lg); overflow-wrap: anywhere; }
.auth-sub { color: var(--text-2); font-size: var(--fs-sm); margin-top: .45rem; line-height: 1.55; }
.auth-form { margin-top: 1.4rem; text-align: left; }
.auth-form .btn-block { margin-top: .4rem; }
.auth-notice {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--ok-soft); color: var(--ok);
  font-size: var(--fs-sm); font-weight: 600;
  border-radius: var(--radius-full);
  padding: .3rem .8rem; margin-top: .9rem;
  animation: popIn .35s var(--ease-spring);
}
.auth-alt {
  display: flex; align-items: center; justify-content: center; gap: 1.2rem; flex-wrap: wrap;
  margin-top: 1.3rem;
}
.auth-footer { color: var(--text-3); font-size: var(--fs-sm); }
.auth-footer a { font-weight: 600; }
.auth-lock-note {
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--warn-soft); color: var(--warn);
  font-size: var(--fs-sm); font-weight: 600;
  border-radius: var(--radius-full);
  padding: .35rem .85rem; margin-top: 1rem;
}

/* PIN boxes */
.pin-group { display: flex; justify-content: center; gap: .7rem; margin: .4rem 0 1rem; }
.pin-box {
  width: 56px; height: 62px;
  text-align: center;
  font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  caret-color: var(--brand-500);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s var(--ease-spring);
}
.pin-box:hover { border-color: var(--brand-400); }
.pin-box:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 4px var(--brand-glow);
  transform: scale(1.07);
}

/* Error page */
.error-code {
  font-size: 4.6rem; font-weight: 800; line-height: 1;
  background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  letter-spacing: -.03em;
}
.error-code + .auth-title { margin-top: .6rem; }
.auth-card > .btn { margin-top: 1.4rem; }

/* ---------- Responsive: tables → stacked cards ---------- */
/* The table stays a table on desktop; it tightens progressively so it always
   fits its card without inner scrolling. */
@media (max-width: 1320px) {
  .table-files th, .table-files td { padding-inline: .55rem; }
}
@media (max-width: 1150px) {
  .table-files th, .table-files td { padding-inline: .45rem; }
  .file-cell { max-width: 22vw; }
  .uploader-email { max-width: 11vw; }
  .table-files .btn-icon { width: 30px; height: 30px; }
}
@media (max-width: 1000px) and (min-width: 901px) {
  .file-cell { max-width: 20vw; }
}
/* Phones / small tablets: compact stacked cards —
   [badge] name / url / meta, then uploader + actions on one bottom row. */
.file-meta-mobile { display: none; }
@media (max-width: 900px) {
  .table-files, .table-files tbody { display: block; }
  .table-files thead { display: none; }
  .table-files tbody tr {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: start;
    column-gap: .7rem;
    padding: .8rem .9rem .6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin: .7rem;
    background: var(--surface);
    box-shadow: var(--shadow-1);
  }
  .table-files td { display: block; border: 0; padding: 0; min-width: 0; }
  .table-files .col-icon { grid-column: 1; grid-row: 1; padding-top: .1rem; }
  .table-files .col-file { grid-column: 2; grid-row: 1; }
  .table-files .file-cell { max-width: none; min-width: 0; }
  .table-files .col-size, .table-files .col-downloads { display: none; }
  .file-meta-mobile {
    display: block;
    font-size: var(--fs-xs); color: var(--text-3);
    margin-top: .25rem;
  }
  .table-files .col-uploaded { grid-column: 2; grid-row: 2; margin-top: .5rem; min-width: 0; }
  .table-files .col-uploaded .stack-cell { flex-direction: row; align-items: center; min-width: 0; }
  .table-files .col-uploaded .uploader-email { font-size: var(--fs-xs); max-width: 55vw; }
  .table-files .col-uploaded .tip-under { display: none; }
  .table-files .col-actions { grid-column: 1 / -1; grid-row: 3; justify-self: end; width: auto; margin-top: .25rem; }
  .table-files .row-actions { opacity: 1; gap: 0; }
  .table-files .row-actions .btn-icon { width: 32px; height: 32px; }
  .table-files .row-empty { display: block; border: 0; margin: 0; box-shadow: none; }
}

@media (max-width: 640px) {
  .table-users .uploader-email { max-width: 55vw; }
  .table-users thead, .table-whitelist thead { display: none; }
  .table-users tbody tr, .table-whitelist tbody tr {
    display: block;
    padding: .8rem .9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin: .7rem;
    background: var(--surface);
  }
  .table-users td, .table-whitelist td { display: flex; align-items: center; justify-content: space-between; gap: .8rem; border: 0; padding: .22rem 0; }
  .table-users td[data-label]::before, .table-whitelist td[data-label]::before {
    content: attr(data-label);
    font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-3);
  }
  .table-users .row-empty, .table-whitelist .row-empty { display: block; border: 0; margin: 0; }
  .table-users .row-empty td, .table-whitelist .row-empty td { display: block; }

  .user-chip-email { display: none; }
  /* Navbar: labels would push the actions off-screen, so the area switch
     becomes icon-only (its active pill still shows where you are). */
  .nav-link-label { display: none; }
  .nav-link { padding: .45rem .6rem; }
  .navbar-nav { gap: .1rem; margin-right: .25rem; }
  .navbar-inner { gap: .5rem; }
  .card-toolbar { padding: .85rem .9rem; }
  .toolbar-filters { width: 100%; }
  .toolbar-filters .search-wrap { flex: 1; }
  .input-search, .input-search:focus { min-width: 0; width: 100%; }
  .field-row { grid-template-columns: 1fr; }
  .pin-box { width: 48px; height: 56px; }
}

/* ---------- 7. Animations ---------- */
.anim-rise { animation: fadeRise .5s var(--ease-out) backwards; animation-delay: .1s; }
.anim-pop { animation: popIn .45s var(--ease-spring) backwards; }
.anim-float { animation: float 4s ease-in-out infinite; }
.anim-shake { animation: shake .45s var(--ease-out); }

@keyframes fadeRise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.92) translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes modalIn {
  from { opacity: 0; transform: scale(.93) translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes modalOut {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: scale(.95) translateY(8px); }
}
@keyframes rowNew {
  0% { background-color: color-mix(in srgb, var(--brand-500) 22%, transparent); }
  6% { background-color: color-mix(in srgb, var(--brand-500) 22%, transparent); }
  12% { background-color: color-mix(in srgb, var(--brand-500) 9%, transparent); }
  80% { background-color: color-mix(in srgb, var(--brand-500) 9%, transparent); }
  100% { background-color: transparent; }
}
@keyframes dropPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--brand-glow); }
  50% { box-shadow: 0 0 0 8px transparent; }
}
@keyframes toastTimer { from { transform: scaleX(1); } to { transform: scaleX(0); } }

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