/* ==========================================================================
   Cloud Storage — "the archive room"
   Paper neutrals tinted toward manila, ink-green brand, vermilion stamp accent.
   See /.impeccable.md for the design context behind these choices.
   ========================================================================== */

:root {
  /* ── Al Amal brand (tokens from the Al Amal Business Console / portal sign-in) ── */
  --brand-900: #08334f;
  --brand-800: #0a4468;
  --brand-700: #0b517b;
  --brand-600: #16618c;
  --brand-500: #1e7dab;
  --brand-400: #2aaade;
  --brand-200: #a9d6ee;
  --brand-100: #dceefa;
  --brand-050: #eff7fc;
  --brand-grad: linear-gradient(90deg, #124e78 0%, #1e7dab 52%, #2aaade 100%);
  --rail: #082638;
  --rail-line: #153f5c;
  --rail-text: #9fc2d8;

  /* ── Light ── */
  --paper: #f2f7fb;
  --paper-raised: #ffffff;
  --paper-sunk: #eef4f9;
  --line: #dde7ee;
  --line-strong: #c4d5e2;

  --ink: #0c2c44;
  --ink-2: #3f5a70;
  --ink-3: #5a7287;

  --brand: var(--brand-600);
  --brand-hover: var(--brand-700);
  --brand-soft: var(--brand-100);
  --on-brand: #ffffff;

  --stamp: var(--brand-500);
  --stamp-soft: var(--brand-050);
  --danger: #c0392f;
  --danger-soft: #fbeceb;
  --ok: #0f7049;

  /* page surfaces */
  --surface: rgb(255 255 255 / 0.86);
  --surface-line: #dde7ee;
  --header-bg: rgb(242 247 251 / 0.8);
  --selection: #a9d6ee;
  --mark: #a9d6ee;
  --highlight: #dceefa;
  --crumb-bg: var(--brand-100);
  --crumb-ink: var(--brand-800);
  --focus-ring: rgb(30 125 171 / 0.22);
  --overlay: rgb(242 247 251 / 0.86);
  --backdrop: rgb(8 38 56 / 0.45);
  --auth-art: var(--rail);
  --toast-error: #c0392f;
  --glow-1: rgb(42 170 222 / 0.16);
  --glow-2: rgb(30 125 171 / 0.09);
  --grain: 0.03;
  --logo-light: block;
  --logo-dark: none;

  /* Folder materials (the same in both themes: they are physical objects) */
  --manila: oklch(0.872 0.075 84);
  --manila-hi: oklch(0.905 0.06 86);
  --manila-back: oklch(0.8 0.085 78);
  --manila-edge: oklch(0.71 0.09 70);
  --sheet: oklch(0.988 0.004 95);
  --sheet-line: oklch(0.9 0.012 95);

  --shadow-sm: 0 1px 2px rgb(11 58 90 / 0.06);
  --shadow-md: 0 1px 2px rgb(11 58 90 / 0.05), 0 6px 16px -4px rgb(11 58 90 / 0.1);
  --shadow-lg: 0 12px 40px -8px rgb(11 58 90 / 0.22);
  --shadow-surface: 0 1px 2px rgb(11 58 90 / 0.05), 0 18px 48px -18px rgb(11 58 90 / 0.18);

  /* Type */
  --font-display: "Young Serif", "Iowan Old Style", Georgia, serif;
  --font-ui: "Schibsted Grotesk", ui-sans-serif, system-ui, sans-serif;
  --t-small: 0.8125rem;
  --t-body: 0.9375rem;
  --t-lg: 1.1875rem;
  --t-xl: 1.75rem;
  --t-2xl: 2.5rem;

  /* Space (4pt) */
  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  --space-4xl: 96px;
  --gutter: clamp(16px, 4vw, 48px);

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* Motion: one language everywhere */
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 140ms;
  --dur: 200ms;
  --dur-slow: 420ms;

  color-scheme: light;
}

/* ── Dark (Al Amal console dark theme) ── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #061722;
    --paper-raised: #0b2635;
    --paper-sunk: #0f2f42;
    --line: #1c4560;
    --line-strong: #2a5876;
    --ink: #e8f3fa;
    --ink-2: #a9c6da;
    --ink-3: #7ba0ba;
    --brand: var(--brand-400);
    --brand-hover: #4dbbe6;
    --brand-soft: #123c58;
    --on-brand: #04141e;
    --stamp: var(--brand-400);
    --stamp-soft: #0f3348;
    --danger: #f5928a;
    --danger-soft: #3d1c1a;
    --ok: #5fd3a5;
    --surface: rgb(11 38 53 / 0.8);
    --surface-line: #1c4560;
    --header-bg: rgb(6 23 34 / 0.78);
    --selection: #1d5578;
    --mark: #1d5578;
    --highlight: #123c58;
    --crumb-bg: #123c58;
    --crumb-ink: #dceefa;
    --focus-ring: rgb(42 170 222 / 0.3);
    --overlay: rgb(6 23 34 / 0.86);
    --backdrop: rgb(2 10 16 / 0.65);
    --auth-art: #04141e;
    --toast-error: #b8352c;
    --glow-1: rgb(42 170 222 / 0.14);
    --glow-2: rgb(30 125 171 / 0.1);
    --grain: 0.05;
    --logo-light: none;
    --logo-dark: block;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow-md: 0 1px 2px rgb(0 0 0 / 0.28), 0 6px 16px -4px rgb(0 0 0 / 0.42);
    --shadow-lg: 0 12px 40px -8px rgb(0 0 0 / 0.6);
    --shadow-surface: 0 1px 0 rgb(255 255 255 / 0.04) inset, 0 24px 60px -24px rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #061722;
  --paper-raised: #0b2635;
  --paper-sunk: #0f2f42;
  --line: #1c4560;
  --line-strong: #2a5876;
  --ink: #e8f3fa;
  --ink-2: #a9c6da;
  --ink-3: #7ba0ba;
  --brand: var(--brand-400);
  --brand-hover: #4dbbe6;
  --brand-soft: #123c58;
  --on-brand: #04141e;
  --stamp: var(--brand-400);
  --stamp-soft: #0f3348;
  --danger: #f5928a;
  --danger-soft: #3d1c1a;
  --ok: #5fd3a5;
  --surface: rgb(11 38 53 / 0.8);
  --surface-line: #1c4560;
  --header-bg: rgb(6 23 34 / 0.78);
  --selection: #1d5578;
  --mark: #1d5578;
  --highlight: #123c58;
  --crumb-bg: #123c58;
  --crumb-ink: #dceefa;
  --focus-ring: rgb(42 170 222 / 0.3);
  --overlay: rgb(6 23 34 / 0.86);
  --backdrop: rgb(2 10 16 / 0.65);
  --auth-art: #04141e;
  --toast-error: #b8352c;
  --glow-1: rgb(42 170 222 / 0.14);
  --glow-2: rgb(30 125 171 / 0.1);
  --grain: 0.05;
  --logo-light: none;
  --logo-dark: block;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
  --shadow-md: 0 1px 2px rgb(0 0 0 / 0.28), 0 6px 16px -4px rgb(0 0 0 / 0.42);
  --shadow-lg: 0 12px 40px -8px rgb(0 0 0 / 0.6);
  --shadow-surface: 0 1px 0 rgb(255 255 255 / 0.04) inset, 0 24px 60px -24px rgb(0 0 0 / 0.6);
  color-scheme: dark;
}

/* ───────────── Base ───────────── */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--t-body) / 1.55 var(--font-ui);
  font-feature-settings: "tnum";
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 400; }

h1 {
  font: 400 var(--t-2xl) / 1.08 var(--font-display);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

h2 { font: 400 var(--t-xl) / 1.15 var(--font-display); letter-spacing: -0.01em; }

h3 { font: 600 var(--t-body) / 1.3 var(--font-ui); }

p { margin: 0; max-width: 68ch; }

a { color: inherit; }

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

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

::selection { background: var(--selection); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip-path: inset(50%);
  white-space: nowrap;
}

.label {
  font-size: var(--t-small);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.muted { color: var(--ink-3); }

[hidden] { display: none !important; }

/* ───────────── Buttons ───────────── */

.btn {
  --btn-bg: transparent;
  --btn-fg: var(--ink);
  --btn-line: var(--line-strong);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: 40px;
  padding: 0 var(--space-md);
  border: 1px solid var(--btn-line);
  border-radius: var(--r-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 600;
  font-size: var(--t-body);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { --btn-bg: var(--paper-sunk); }

.btn:active { transform: scale(0.97); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn svg { width: 18px; height: 18px; flex: none; }

.btn-primary {
  --btn-bg: var(--brand);
  --btn-fg: var(--on-brand);
  --btn-line: var(--brand);
  box-shadow: 0 1px 0 oklch(1 0 0 / 0.15) inset, var(--shadow-sm);
}

.btn-primary:hover { --btn-bg: var(--brand-hover); --btn-line: var(--brand-hover); }

.btn-quiet { --btn-line: transparent; }

.btn-danger { --btn-fg: var(--danger); --btn-line: oklch(0.85 0.06 25); }

.btn-danger:hover { --btn-bg: var(--danger-soft); }

.btn-block { width: 100%; min-height: 46px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-2);
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.icon-btn svg { width: 18px; height: 18px; }

.icon-btn:hover { background: var(--paper-sunk); color: var(--ink); }

.icon-btn:active { transform: scale(0.92); }

.icon-btn.is-danger:hover { background: var(--danger-soft); color: var(--danger); }

/* Tooltip from aria-label, for icon-only buttons */
[data-tip] { position: relative; }

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  translate: -50% 4px;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out), translate var(--dur-fast) var(--ease-out);
  z-index: 5;
}

[data-tip]:hover::after, [data-tip]:focus-visible::after {
  opacity: 1;
  translate: -50% 0;
  transition-delay: 350ms;
}

/* ───────────── Upload button ───────────── */

.btn-upload { padding-inline: var(--space-md) var(--space-lg); overflow: hidden; }

.btn-upload .upload-glyph {
  position: relative;
  display: grid;
  width: 20px; height: 20px;
}

.btn-upload .upload-glyph svg { grid-area: 1 / 1; width: 20px; height: 20px; }

.btn-upload .arrow { transition: transform var(--dur) var(--ease-expo); }

.btn-upload:hover .arrow { transform: translateY(-3px); }

.btn-upload::before {
  /* a soft swell from the icon on hover */
  content: "";
  position: absolute;
  left: 18px; top: 50%;
  width: 24px; height: 24px;
  margin-top: -12px;
  border-radius: 50%;
  background: oklch(1 0 0 / 0.14);
  transform: scale(0);
  transition: transform var(--dur-slow) var(--ease-expo);
}

.btn-upload:hover::before { transform: scale(7); }

.btn-upload .ring { display: none; }

.btn-upload.is-uploading .arrow-set { display: none; }

.btn-upload.is-uploading .ring { display: block; }

.ring circle.track { stroke: oklch(1 0 0 / 0.25); }

.ring circle.fill {
  stroke: var(--on-brand);
  stroke-dasharray: 50.27;
  stroke-dashoffset: calc(50.27 * (1 - var(--progress, 0)));
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset var(--dur) linear;
}

.btn-upload.is-done .arrow-set .arrow { animation: none; }

.check-draw path {
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  animation: draw 360ms var(--ease-out) forwards;
}

@keyframes draw { to { stroke-dashoffset: 0; } }

/* ───────────── Fields ───────────── */

.field { display: grid; gap: var(--space-2xs); }

.field > span { font-size: var(--t-small); font-weight: 600; color: var(--ink-2); }

.input, .select {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-sm);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--paper-raised);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.input:hover, .select:hover { border-color: var(--ink-3); }

.input:focus, .select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23476a5c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.form-error {
  min-height: 1.4em;
  color: var(--danger);
  font-size: var(--t-small);
  font-weight: 500;
}

.form-error:not(:empty) { animation: nudge 300ms var(--ease-out); }

@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
}

/* ───────────── App header ───────────── */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-lg);
  height: 64px;
  padding: 0 var(--gutter);
  background: var(--header-bg);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--surface-line);
  view-transition-name: app-header;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: 400 1.25rem/1 var(--font-display);
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}

.brand-mark { width: 30px; height: 24px; flex: none; transition: transform var(--dur-slow) var(--ease-expo); }
.brand:hover .brand-mark { transform: rotate(-6deg) translateY(-1px); }

/* Navigation: a pill track with a thumb that glides to the hovered / current page */
.nav {
  position: relative;
  display: flex;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--surface-line);
  border-radius: var(--r-pill);
  background: color-mix(in oklch, var(--paper-sunk) 70%, transparent);
  isolation: isolate;
}

.nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  color: var(--ink-3);
  font-weight: 600;
  font-size: var(--t-small);
  text-decoration: none;
  transition: color var(--dur) var(--ease-out);
}

.nav a svg { width: 16px; height: 16px; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }

.nav-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: var(--thumb-w, 0px);
  z-index: -1;
  border-radius: var(--r-pill);
  background: var(--paper-raised);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--surface-line);
  transform: translateX(var(--thumb-x, 0px));
  transition: transform 420ms var(--ease-expo), width 420ms var(--ease-expo);
}

.header-center { display: contents; }
.search-slot, .search { justify-self: center; width: min(460px, 100%); }

.header-tools { display: flex; align-items: center; gap: var(--space-xs); justify-self: end; }

.theme-toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--surface-line);
  border-radius: 50%;
  background: color-mix(in oklch, var(--paper-raised) 60%, transparent);
  color: var(--ink-2);
  overflow: hidden;
  transition: color var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.theme-toggle:hover { color: var(--ink); background: var(--paper-raised); }
.theme-toggle:active { transform: scale(0.92); }
.theme-toggle svg { grid-area: 1 / 1; width: 19px; height: 19px; transition: transform 520ms var(--ease-expo), opacity 260ms var(--ease-out); }
.theme-toggle .t-sun, .theme-toggle .t-moon, .theme-toggle .t-auto { opacity: 0; transform: rotate(-90deg) scale(0.5); }
:root[data-theme-mode="light"] .theme-toggle .t-sun,
:root[data-theme-mode="dark"] .theme-toggle .t-moon,
:root[data-theme-mode="auto"] .theme-toggle .t-auto,
:root:not([data-theme-mode]) .theme-toggle .t-auto { opacity: 1; transform: none; }

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 4px 4px 4px 4px;
  border: 1px solid var(--surface-line);
  border-radius: var(--r-pill);
  background: color-mix(in oklch, var(--paper-raised) 60%, transparent);
}

.user-chip .avatar { width: 30px; height: 30px; font-size: 14px; }
.user-chip .who { display: grid; line-height: 1.15; padding-right: 2px; }
.user-chip .who b { font-weight: 600; font-size: var(--t-small); }

.role-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.role-tag[data-role="Admin"] { color: var(--stamp); }
.role-tag[data-role="Manager"] { color: var(--brand); }

/* ───────────── Search ───────────── */

.search {
  position: relative;
  flex: 1;
  max-width: 460px;
  margin-inline: auto;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  height: 40px;
  padding: 0 var(--space-md);
  isolation: isolate;
}

.search-box::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--paper-sunk);
  transform: scaleX(0.97);
  transition: transform var(--dur-slow) var(--ease-expo), background-color var(--dur) var(--ease-out),
    border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}

.search:focus-within .search-box::before {
  transform: scaleX(1);
  background: var(--paper-raised);
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--focus-ring), var(--shadow-md);
}

.search-box svg { width: 18px; height: 18px; color: var(--ink-3); flex: none; transition: color var(--dur) var(--ease-out), transform var(--dur) var(--ease-expo); }

.search:focus-within .search-box svg { color: var(--brand); transform: rotate(-8deg) scale(1.06); }

.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  outline: none;
}

.search input::placeholder { color: var(--ink-3); }

.search kbd {
  padding: 1px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  font: 600 11px/1.5 var(--font-ui);
  color: var(--ink-3);
  transition: opacity var(--dur-fast) var(--ease-out);
}

.search:focus-within kbd { opacity: 0; }

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  max-height: min(60vh, 460px);
  overflow-y: auto;
  padding: var(--space-xs);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--paper-raised);
  box-shadow: var(--shadow-lg);
  transform-origin: top center;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-expo);
}

.search.is-open .search-results { opacity: 1; transform: none; pointer-events: auto; }

.search-results::after {
  /* progress hairline while a query is in flight */
  content: "";
  position: absolute;
  top: 0; left: 16px; right: 16px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand);
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0;
}

.search.is-loading .search-results::after { animation: loading-line 900ms var(--ease-in-out) infinite; opacity: 1; }

@keyframes loading-line {
  0% { transform: scaleX(0); transform-origin: left; }
  50% { transform: scaleX(1); transform-origin: left; }
  50.01% { transform-origin: right; }
  100% { transform: scaleX(0); transform-origin: right; }
}

.search-hit {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs);
  border-radius: var(--r-md);
  text-decoration: none;
  animation: rise var(--dur) var(--ease-out) both;
  animation-delay: calc(min(var(--i, 0), 7) * 28ms);
}

.search-hit[aria-selected="true"], .search-hit:hover { background: var(--paper-sunk); }

.search-hit .hit-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.search-hit .hit-where { font-size: var(--t-small); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.search-hit mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }

.search-empty { padding: var(--space-lg) var(--space-md); color: var(--ink-3); text-align: center; }

.mini-folder { width: 32px; height: 26px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ───────────── Page layout ───────────── */

.page {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: var(--space-xl) var(--gutter) var(--space-4xl);
}

.page-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.page-head .actions { display: flex; gap: var(--space-xs); flex-wrap: wrap; justify-content: flex-end; }

.page-meta { margin-top: var(--space-xs); color: var(--ink-3); }

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  margin: 0 0 var(--space-sm);
  padding: 0;
  list-style: none;
  font-size: var(--t-small);
}

.crumbs a, .crumbs span {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  color: var(--ink-2);
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.crumbs a:hover { background: var(--crumb-bg); color: var(--crumb-ink); }

.crumbs li + li::before { content: "/"; color: var(--line-strong); margin-right: 2px; }

.crumbs [aria-current] { color: var(--crumb-ink); font-weight: 600; background: var(--crumb-bg); }

.section { margin-top: var(--space-2xl); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--line);
}

/* ───────────── Folder object ───────────── */

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: var(--space-xl) var(--space-lg);
}

.folder {
  position: relative;
  display: grid;
  gap: 2px;
  padding: var(--space-xs);
  margin: calc(-1 * var(--space-xs));
  border-radius: var(--r-lg);
  text-decoration: none;
  color: inherit;
  animation: folder-in var(--dur-slow) var(--ease-expo) both;
  animation-delay: calc(min(var(--i, 0), 10) * 34ms);
  -webkit-tap-highlight-color: transparent;
}

@keyframes folder-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

.folder-art {
  position: relative;
  aspect-ratio: 5 / 4;
  margin-bottom: var(--space-xs);
  perspective: 700px;
  transform-style: preserve-3d;
}

.folder-back {
  position: absolute;
  inset: 12% 0 0 0;
  border-radius: 4px 10px 10px 10px;
  background: linear-gradient(to bottom, var(--manila-back), oklch(0.77 0.085 76));
  box-shadow: inset 0 0 0 1px oklch(0.7 0.09 72 / 0.35);
}

.folder-back::before {
  /* the index tab */
  content: "";
  position: absolute;
  bottom: 100%;
  left: 0;
  width: 42%;
  height: 15%;
  min-height: 12px;
  border-radius: 8px 8px 0 0;
  background: var(--manila-back);
  clip-path: polygon(0 0, 82% 0, 100% 100%, 0 100%);
}

.folder-sheet {
  position: absolute;
  left: 8%; right: 8%;
  top: 18%; bottom: 8%;
  border-radius: 3px;
  background:
    repeating-linear-gradient(to bottom, transparent 0 9px, var(--sheet-line) 9px 10px) 12% 22% / 64% 46% no-repeat,
    var(--sheet);
  box-shadow: 0 1px 2px oklch(0.3 0.04 70 / 0.14);
  transform-origin: bottom center;
  transition: transform var(--dur-slow) var(--ease-expo);
}

.folder-sheet:nth-of-type(2) { transform: translate(2%, 5%) rotate(-2.5deg); }
.folder-sheet:nth-of-type(3) { transform: translate(-2%, 9%) rotate(2deg); background: oklch(0.97 0.02 230); }
.folder-sheet:nth-of-type(4) { transform: translate(1%, 13%) rotate(-1deg); background: oklch(0.97 0.025 50); }

.folder-art[data-fill="0"] .folder-sheet { display: none; }
.folder-art[data-fill="1"] .folder-sheet:nth-of-type(n+3) { display: none; }
.folder-art[data-fill="2"] .folder-sheet:nth-of-type(n+4) { display: none; }

.folder-front {
  position: absolute;
  inset: 28% 0 0 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 9%;
  border-radius: 6px 6px 10px 10px;
  background:
    linear-gradient(to bottom, var(--manila-hi) 0 2px, transparent 2px),
    linear-gradient(170deg, var(--manila) 30%, oklch(0.845 0.08 80));
  box-shadow: inset 0 0 0 1px oklch(0.7 0.09 72 / 0.3), 0 -1px 0 oklch(0.95 0.03 86);
  transform-origin: bottom center;
  transition: transform var(--dur-slow) var(--ease-expo), box-shadow var(--dur-slow) var(--ease-expo);
}

.folder-count {
  padding: 2px 8px;
  border: 1px solid oklch(0.58 0.12 40 / 0.5);
  border-radius: 4px;
  color: oklch(0.5 0.13 38);
  font: 400 var(--t-small)/1.2 var(--font-display);
  transform: rotate(-4deg);
  opacity: 0.85;
}

.folder-name {
  font: 400 1.0625rem/1.25 var(--font-display);
  overflow-wrap: anywhere;
  transition: color var(--dur-fast) var(--ease-out);
}

.folder-meta { font-size: var(--t-small); color: var(--ink-3); }

.folder::after {
  /* the shadow on the desk */
  content: "";
  position: absolute;
  left: 14%; right: 14%;
  top: calc(var(--space-xs) + 0px);
  aspect-ratio: 5 / 4;
  width: auto;
  z-index: -1;
  border-radius: 50%;
  box-shadow: 0 34px 26px -24px oklch(0.3 0.05 70 / 0.34);
  transition: box-shadow var(--dur-slow) var(--ease-expo);
  pointer-events: none;
}

@media (hover: hover) {
  .folder:hover .folder-front { transform: rotateX(-26deg); box-shadow: inset 0 0 0 1px oklch(0.7 0.09 72 / 0.3), 0 10px 18px -6px oklch(0.3 0.05 70 / 0.25); }
  .folder:hover .folder-sheet:nth-of-type(2) { transform: translate(2%, -6%) rotate(-3.5deg); }
  .folder:hover .folder-sheet:nth-of-type(3) { transform: translate(-3%, -1%) rotate(3deg); }
  .folder:hover .folder-sheet:nth-of-type(4) { transform: translate(1%, 4%) rotate(-1.5deg); }
  .folder:hover .folder-name { color: var(--brand); }
}

.folder:focus-visible { outline-offset: 4px; }

.folder:focus-visible .folder-front { transform: rotateX(-20deg); }

/* Opening: the cover swings down as we navigate in */
.folder.is-opening .folder-front { transform: rotateX(-64deg); transition-duration: 260ms; }
.folder.is-opening .folder-sheet:nth-of-type(2) { transform: translate(2%, -16%) rotate(-4deg); }
.folder.is-opening .folder-sheet:nth-of-type(3) { transform: translate(-3%, -10%) rotate(4deg); }

.folder.is-new { animation: folder-arrive 700ms var(--ease-expo) both; }

@keyframes folder-arrive {
  0% { opacity: 0; transform: translateY(-18px) rotate(-3deg) scale(1.04); }
  60% { opacity: 1; transform: translateY(2px) rotate(0.5deg); }
  100% { transform: none; }
}

/* Draft folder: inline naming, no modal */
.folder.is-draft .folder-front { transform: rotateX(-14deg); }

.folder.is-draft { animation: folder-arrive 500ms var(--ease-expo) both; }

.folder-draft-input {
  width: 100%;
  min-height: 36px;
  padding: 0 var(--space-xs);
  border: 1px solid var(--brand);
  border-radius: var(--r-sm);
  background: var(--paper-raised);
  font: 400 1rem/1.2 var(--font-display);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.folder-draft-input:focus { outline: none; }

.folder-draft-hint { font-size: 12px; color: var(--ink-3); }

/* Folder card actions (admin) */
.folder-tools {
  position: absolute;
  top: 4px; right: 4px;
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--r-pill);
  background: var(--paper-raised);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(-4px) scale(0.96);
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-expo);
  z-index: 2;
}

.folder:hover .folder-tools, .folder:focus-within .folder-tools { opacity: 1; transform: none; }

@media (hover: none) { .folder-tools { opacity: 1; transform: none; } }

/* ───────────── File list ───────────── */

.file-list { margin: 0; padding: 0; list-style: none; }

.file-row {
  display: grid;
  grid-template-rows: 1fr;
  animation: rise var(--dur-slow) var(--ease-expo) both;
  animation-delay: calc(min(var(--i, 0), 10) * 26ms + 80ms);
  transition: grid-template-rows var(--dur-slow) var(--ease-expo), opacity var(--dur) var(--ease-out);
}

.file-row > .file-inner { overflow: hidden; min-height: 0; }

.file-row.is-leaving { grid-template-rows: 0fr; opacity: 0; }

.file-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 120px 110px auto;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-xs) var(--space-xs) var(--space-xs) 0;
  border-bottom: 1px solid var(--line);
  transition: background-color var(--dur-fast) var(--ease-out);
}

.file-row:hover .file-inner { background: linear-gradient(to right, transparent, var(--paper-sunk) 4%, var(--paper-sunk) 96%, transparent); }

.file-main {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
  padding: var(--space-2xs) 0;
  border: 0;
  background: none;
  text-align: left;
}

.file-main:hover .file-name { color: var(--brand); }

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  transition: color var(--dur-fast) var(--ease-out);
}

.file-orig { display: block; font-size: 12px; color: var(--ink-3); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.file-text { min-width: 0; }

.file-cell { font-size: var(--t-small); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.file-actions { display: flex; gap: 2px; justify-content: flex-end; }

/* Type tags: small index cards, tinted by kind */
.type-tag {
  --tag-h: 85;
  --tag-c: 0.04;
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 50px;
  border-radius: 4px 10px 4px 4px;
  background:
    linear-gradient(225deg, oklch(0.86 calc(var(--tag-c) * 1.4) var(--tag-h)) 0 9px, transparent 9px),
    oklch(0.95 var(--tag-c) var(--tag-h));
  box-shadow: inset 0 0 0 1px oklch(0.82 calc(var(--tag-c) * 1.5) var(--tag-h));
  color: oklch(0.42 calc(var(--tag-c) * 3) var(--tag-h));
  font: 700 10px/1 var(--font-ui);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: transform var(--dur) var(--ease-expo);
}

.file-main:hover .type-tag { transform: rotate(-4deg) translateY(-2px); }

.type-tag[data-kind="pdf"] { --tag-h: 30; --tag-c: 0.05; }
.type-tag[data-kind="sheet"] { --tag-h: 150; --tag-c: 0.045; }
.type-tag[data-kind="image"] { --tag-h: 235; --tag-c: 0.04; }
.type-tag[data-kind="doc"] { --tag-h: 255; --tag-c: 0.04; }
.type-tag[data-kind="slides"] { --tag-h: 55; --tag-c: 0.055; }
.type-tag[data-kind="video"] { --tag-h: 340; --tag-c: 0.035; }
.type-tag[data-kind="audio"] { --tag-h: 195; --tag-c: 0.04; }
.type-tag[data-kind="archive"] { --tag-h: 70; --tag-c: 0.035; }
.type-tag[data-kind="code"] { --tag-h: 175; --tag-c: 0.035; }
.type-tag[data-kind="text"] { --tag-h: 95; --tag-c: 0.02; }

.file-row.is-highlight .file-inner { animation: highlight 1600ms var(--ease-out); }

@keyframes highlight {
  0%, 30% { background: var(--highlight); }
  100% { background: transparent; }
}

/* Download: arrow drops into the tray while busy */
.dl-btn .dl-arrow { transition: transform var(--dur) var(--ease-expo); }
.dl-btn:hover .dl-arrow { transform: translateY(2px); }
.dl-btn.is-busy .dl-arrow { animation: drop 700ms var(--ease-in-out) infinite; }
.dl-btn.is-done { color: var(--ok); }

@keyframes drop {
  0% { transform: translateY(-5px); opacity: 0; }
  40% { opacity: 1; }
  80%, 100% { transform: translateY(3px); opacity: 0; }
}

/* Hold-to-confirm (delete) */
.hold-btn { position: relative; overflow: hidden; isolation: isolate; }

.hold-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--danger-soft);
  transform: scaleX(0);
  transform-origin: left;
}

.hold-btn.is-holding::before { transform: scaleX(1); transition: transform var(--hold-ms, 900ms) linear; }

.hold-btn.is-holding { color: var(--danger); }

/* ───────────── Empty states ───────────── */

.empty {
  display: grid;
  justify-items: start;
  gap: var(--space-sm);
  max-width: 460px;
  padding: var(--space-2xl) 0;
  animation: rise var(--dur-slow) var(--ease-expo) both;
}

.empty .folder-art { width: 160px; }

.empty p { color: var(--ink-2); }

.drop-hint {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-lg);
  color: var(--ink-2);
  transition: border-color var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out);
}

.drop-hint svg { width: 28px; height: 28px; color: var(--ink-3); }

.drop-hint:hover { border-color: var(--brand); background: var(--brand-soft); }

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

/* ───────────── Drop overlay & upload tray ───────────── */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: var(--space-xl);
  background: var(--overlay);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease-out);
}

.drop-overlay.is-active { opacity: 1; }

.drop-overlay .drop-frame {
  display: grid;
  justify-items: center;
  gap: var(--space-md);
  width: min(560px, 100%);
  padding: var(--space-3xl) var(--space-xl);
  border: 2px dashed var(--brand);
  border-radius: 24px;
  background: var(--paper-raised);
  text-align: center;
  transform: scale(0.96);
  transition: transform var(--dur-slow) var(--ease-expo);
}

.drop-overlay.is-active .drop-frame { transform: none; }

.drop-overlay .folder-art { width: 150px; }

.drop-overlay.is-active .folder-front { transform: rotateX(-34deg); }

.drop-overlay.is-active .folder-sheet:nth-of-type(2) { transform: translate(2%, -10%) rotate(-4deg); }

.tray {
  position: fixed;
  right: var(--gutter);
  bottom: var(--space-lg);
  z-index: 40;
  width: min(420px, calc(100vw - 32px));
  max-height: min(70vh, 620px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--paper-raised);
  box-shadow: var(--shadow-lg);
  transform: translateY(calc(100% + 40px));
  transition: transform var(--dur-slow) var(--ease-expo);
}

.tray.is-open { transform: none; }

.tray-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-md) var(--space-sm) var(--space-lg);
}

.tray-head h3 { font: 400 var(--t-lg)/1.2 var(--font-display); }

.tray-list { margin: 0; padding: 0 var(--space-sm); list-style: none; overflow-y: auto; }

.tray-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border-radius: var(--r-md);
  animation: rise var(--dur) var(--ease-out) both;
  animation-delay: calc(min(var(--i, 0), 6) * 30ms);
}

.tray-item + .tray-item { border-top: 1px solid var(--line); border-radius: 0; }

.tray-item .type-tag { width: 34px; height: 40px; font-size: 9px; }

.tray-item .input { min-height: 36px; font-weight: 600; }

.tray-item .sub { margin-top: 2px; font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tray-item .bar {
  height: 4px;
  margin-top: 6px;
  border-radius: 4px;
  background: var(--paper-sunk);
  overflow: hidden;
}

.tray-item .bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
  transform: scaleX(var(--p, 0));
  transform-origin: left;
  transition: transform var(--dur) linear;
}

.tray-item[data-state="done"] .bar i { background: var(--ok); }
.tray-item[data-state="error"] .bar i { background: var(--danger); transform: scaleX(1); }
.tray-item[data-state="error"] .sub { color: var(--danger); }

.tray-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md) var(--space-md);
  border-top: 1px solid var(--line);
}

.state-icon { width: 22px; height: 22px; color: var(--ok); }

/* ───────────── Dialogs (preview, share) ───────────── */

dialog {
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  max-width: none;
  max-height: none;
}

dialog::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out), overlay var(--dur) allow-discrete, display var(--dur) allow-discrete;
}

dialog[open]::backdrop { opacity: 1; }

@starting-style { dialog[open]::backdrop { opacity: 0; } }

.preview {
  width: min(1100px, calc(100vw - 32px));
  height: min(86vh, 900px);
  margin: auto;
  border-radius: var(--r-lg);
  background: var(--paper-raised);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  transition: opacity var(--dur) var(--ease-out), transform var(--dur-slow) var(--ease-expo),
    overlay var(--dur) allow-discrete, display var(--dur) allow-discrete;
}

.preview[open] { opacity: 1; transform: none; display: grid; grid-template-rows: auto 1fr; }

@starting-style { .preview[open] { opacity: 0; transform: translateY(12px) scale(0.97); } }

.preview-head {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-sm) var(--space-sm) var(--space-lg);
  border-bottom: 1px solid var(--line);
}

.preview-head .title { flex: 1; min-width: 0; }

.preview-head h2 { font-size: var(--t-lg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.preview-head .sub { font-size: var(--t-small); color: var(--ink-3); }

.preview-body {
  position: relative;
  min-height: 0;
  overflow: auto;
  background: var(--paper-sunk);
}

.preview-body > .stage { min-height: 100%; display: grid; place-items: center; padding: var(--space-lg); }

.preview-body img { max-width: 100%; max-height: calc(86vh - 120px); border-radius: var(--r-sm); box-shadow: var(--shadow-md); animation: rise var(--dur-slow) var(--ease-expo); }

.preview-body iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--paper-sunk); }

.preview-body video, .preview-body audio { max-width: 100%; max-height: calc(86vh - 120px); }

.preview-body pre {
  margin: 0;
  padding: var(--space-lg);
  min-height: 100%;
  background: var(--paper-raised);
  font: 13px/1.6 ui-monospace, "Cascadia Code", Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 4;
}

.doc-page {
  width: min(820px, 100%);
  margin: var(--space-lg) auto;
  padding: var(--space-2xl) clamp(20px, 6vw, 72px);
  background: var(--paper-raised);
  box-shadow: var(--shadow-md);
  line-height: 1.65;
}

.doc-page img { max-width: 100%; height: auto; box-shadow: none; }

.doc-page table { border-collapse: collapse; }

.doc-page td, .doc-page th { border: 1px solid var(--line); padding: 4px 8px; }

.sheet-wrap { display: grid; grid-template-rows: auto 1fr; height: 100%; }

.sheet-tabs { display: flex; gap: 2px; padding: var(--space-xs) var(--space-md) 0; overflow-x: auto; background: var(--paper-sunk); }

.sheet-tabs button {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: var(--paper);
  color: var(--ink-2);
  font-size: var(--t-small);
  font-weight: 600;
}

.sheet-tabs button[aria-selected="true"] { background: var(--paper-raised); color: var(--ink); }

.sheet-scroll { overflow: auto; background: var(--paper-raised); }

.sheet-table { border-collapse: collapse; font-size: 13px; }

.sheet-table th, .sheet-table td {
  max-width: 320px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-table thead th, .sheet-table tbody th {
  position: sticky;
  background: var(--paper-sunk);
  color: var(--ink-3);
  font-weight: 600;
  z-index: 1;
}

.sheet-table thead th { top: 0; }

.sheet-table tbody th { left: 0; text-align: right; }

.sheet-note { padding: var(--space-xs) var(--space-md); font-size: var(--t-small); color: var(--ink-3); }

.no-preview { display: grid; justify-items: center; gap: var(--space-sm); text-align: center; }

.no-preview .type-tag { width: 84px; height: 100px; font-size: 16px; border-radius: 6px 18px 6px 6px; }

.spinner {
  width: 28px; height: 28px;
  border: 2.5px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Share sheet slides in from the right */
.sheet-dialog {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(460px, 100vw);
  height: 100dvh;
  margin: 0;
  background: var(--paper-raised);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease-expo), overlay var(--dur-slow) allow-discrete, display var(--dur-slow) allow-discrete;
}

.sheet-dialog[open] { transform: none; display: grid; grid-template-rows: auto 1fr; }

@starting-style { .sheet-dialog[open] { transform: translateX(100%); } }

.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-md); padding: var(--space-lg) var(--space-lg) var(--space-md); }

.sheet-body { overflow-y: auto; padding: 0 var(--space-lg) var(--space-xl); display: grid; align-content: start; gap: var(--space-lg); }

.share-create { display: grid; grid-template-columns: 1fr auto; gap: var(--space-xs); align-items: end; }

.new-link {
  display: grid;
  gap: var(--space-xs);
  padding: var(--space-md);
  border-radius: var(--r-md);
  background: var(--brand-soft);
  animation: rise var(--dur-slow) var(--ease-expo);
}

.new-link .row { display: flex; gap: var(--space-xs); }

.new-link input { font-size: var(--t-small); }

.link-list { margin: 0; padding: 0; list-style: none; }

.link-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--line);
  animation: rise var(--dur) var(--ease-out) both;
  animation-delay: calc(min(var(--i, 0), 6) * 30ms);
}

.link-item.is-dead { opacity: 0.55; }

.uses {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.uses-dots { display: inline-flex; gap: 3px; }

.uses-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }

.uses-dots i.spent { background: var(--line-strong); }

/* ───────────── Toasts ───────────── */

.toasts {
  position: fixed;
  left: 50%;
  bottom: var(--space-lg);
  z-index: 100;
  display: grid;
  gap: var(--space-xs);
  justify-items: center;
  translate: -50% 0;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px var(--space-md);
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--paper);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--dur-slow) var(--ease-expo) both;
  pointer-events: auto;
}

.toast svg { width: 18px; height: 18px; flex: none; }

.toast[data-kind="error"] { background: var(--toast-error); color: oklch(0.98 0.01 25); }

.toast.is-leaving { animation: toast-out var(--dur) var(--ease-out) forwards; }

@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } }

@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(0.98); } }

/* ───────────── Auth pages ───────────── */

.auth {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  min-height: 100dvh;
}

.auth-art {
  position: relative;
  display: grid;
  align-content: space-between;
  padding: var(--space-2xl) clamp(24px, 5vw, 72px);
  background: var(--auth-art);
  overflow: hidden;
}

.auth-art h1 { max-width: 13ch; font-size: clamp(2.25rem, 4.2vw, 3.75rem); }

.auth-art .lede { margin-top: var(--space-md); color: var(--ink-2); font-size: var(--t-lg); max-width: 34ch; }

.desk {
  position: relative;
  height: clamp(220px, 34vh, 340px);
  margin-top: var(--space-xl);
}

.desk .folder-art {
  position: absolute;
  width: clamp(150px, 16vw, 210px);
  animation: settle 900ms var(--ease-expo) both;
}

.desk .folder-art:nth-child(1) { left: 2%; bottom: 8%; rotate: -7deg; animation-delay: 120ms; }
.desk .folder-art:nth-child(2) { left: 30%; bottom: 22%; rotate: 4deg; animation-delay: 220ms; }
.desk .folder-art:nth-child(3) { left: 56%; bottom: 4%; rotate: -2deg; animation-delay: 320ms; }

.desk .folder-art:nth-child(2) .folder-front { transform: rotateX(-22deg); }

@keyframes settle {
  from { opacity: 0; transform: translateY(-40px) rotate(6deg); }
  to { opacity: 1; transform: none; }
}

.auth-main {
  display: grid;
  place-items: center;
  padding: var(--space-2xl) var(--gutter);
}

.auth-card { width: min(380px, 100%); display: grid; gap: var(--space-lg); }

.auth-card form { display: grid; gap: var(--space-md); }

.auth-step { animation: step-in var(--dur-slow) var(--ease-expo) both; }

@keyframes step-in { from { opacity: 0; transform: translateX(16px); } }

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-sm);
  color: var(--ink-3);
  font-size: var(--t-small);
}

.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); }

.code-boxes { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--space-xs); }

.code-boxes input {
  width: 100%;
  height: 54px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--paper-raised);
  text-align: center;
  font: 400 1.5rem/1 var(--font-display);
  transition: border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.code-boxes input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus-ring); transform: translateY(-2px); }

.code-boxes input:not(:placeholder-shown) { border-color: var(--ink-3); }

/* ───────────── Users & account ───────────── */

.panel {
  padding: var(--space-lg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--paper-raised);
}

.create-user {
  display: grid;
  grid-template-columns: 1.1fr 1.1fr auto auto;
  align-items: end;
  gap: var(--space-sm);
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  position: relative;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--paper-sunk);
  isolation: isolate;
}

.segmented input { position: absolute; opacity: 0; pointer-events: none; }

.segmented label {
  padding: 8px 14px;
  border-radius: var(--r-pill);
  font-size: var(--t-small);
  font-weight: 600;
  text-align: center;
  color: var(--ink-2);
  cursor: pointer;
  transition: color var(--dur) var(--ease-out);
}

.segmented .thumb {
  position: absolute;
  top: 3px; bottom: 3px; left: 3px;
  width: calc((100% - 6px) / var(--count, 3));
  z-index: -1;
  border-radius: var(--r-pill);
  background: var(--paper-raised);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line);
  transform: translateX(calc(var(--index, 0) * 100%));
  transition: transform var(--dur-slow) var(--ease-expo);
}

.segmented input:checked + label { color: var(--ink); }

.segmented input:focus-visible + label { outline: 2px solid var(--brand); outline-offset: -2px; }

.pw-field { position: relative; }

.pw-field .input { padding-right: 44px; }

.pw-field .icon-btn { position: absolute; right: 5px; top: 5px; }

.user-table { width: 100%; border-collapse: collapse; }

.user-table th { text-align: left; padding: var(--space-xs) var(--space-sm); border-bottom: 1px solid var(--line-strong); }

.user-table td { padding: var(--space-sm); border-bottom: 1px solid var(--line); vertical-align: middle; }

.user-table tr { animation: rise var(--dur-slow) var(--ease-expo) both; animation-delay: calc(min(var(--i, 0), 10) * 26ms); }

.user-table tr.is-leaving { animation: toast-out var(--dur) var(--ease-out) forwards; }

.user-name { display: flex; align-items: center; gap: var(--space-sm); font-weight: 600; }

.avatar {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: oklch(0.9 0.05 var(--h, 85));
  color: oklch(0.38 0.08 var(--h, 85));
  font: 400 15px/1 var(--font-display);
  text-transform: uppercase;
}

.badges { display: flex; gap: var(--space-2xs); flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--paper-sunk);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
}

.badge svg { width: 12px; height: 12px; }

.badge.is-on { background: var(--brand-soft); color: var(--brand); }

.row-actions { display: flex; gap: var(--space-2xs); justify-content: flex-end; align-items: center; }

.inline-reset { display: flex; gap: var(--space-2xs); animation: rise var(--dur) var(--ease-out); }

.inline-reset .input { min-height: 34px; width: 180px; }

.security-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--space-lg); align-items: start; }

.security-grid .panel { display: grid; gap: var(--space-md); }

.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-md); }

.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-small); font-weight: 600; color: var(--ink-3); }

.status-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }

.status-dot.is-on { color: var(--ok); }

.status-dot.is-on::before { background: var(--ok); box-shadow: 0 0 0 3px oklch(0.55 0.11 150 / 0.18); }

.qr-step { display: grid; grid-template-columns: 168px 1fr; gap: var(--space-md); align-items: center; animation: rise var(--dur-slow) var(--ease-expo); }

.qr-step img { width: 168px; height: 168px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--sheet); image-rendering: pixelated; }

.secret { font: 600 13px/1.5 ui-monospace, Consolas, monospace; letter-spacing: 0.06em; word-break: break-all; color: var(--ink-2); }

.key-list { margin: 0; padding: 0; list-style: none; }

.key-list li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: var(--space-sm) 0; border-bottom: 1px solid var(--line); animation: rise var(--dur) var(--ease-out) both; }

/* ───────────── Public share ───────────── */

.public-wrap { width: min(1000px, 100%); margin: 0 auto; padding: var(--space-2xl) var(--gutter) var(--space-4xl); }

.gate {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--space-xl);
  align-items: center;
  margin-top: var(--space-2xl);
  animation: rise var(--dur-slow) var(--ease-expo) both;
}

.gate .folder-art { width: 200px; }

.gate .actions { display: flex; gap: var(--space-xs); margin-top: var(--space-lg); }

.ticket {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  margin-top: var(--space-md);
  padding: 6px 12px;
  border: 1.5px solid color-mix(in oklch, var(--stamp) 60%, transparent);
  border-radius: 4px;
  color: var(--stamp);
  font: 400 var(--t-small)/1.3 var(--font-display);
  transform: rotate(-1.5deg);
}

.file-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-lg);
  align-items: center;
  padding: var(--space-lg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--paper-raised);
  animation: rise var(--dur-slow) var(--ease-expo) both;
}

.file-card .type-tag { width: 64px; height: 76px; font-size: 13px; }

/* ───────────── Responsive ───────────── */

@media (max-width: 960px) {
  .file-inner { grid-template-columns: minmax(0, 1fr) 80px auto; }
  .file-cell.by, .file-cell.when { display: none; }
  .create-user { grid-template-columns: 1fr 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding-bottom: 0; }
  .desk { height: 170px; }
  .desk .folder-art { width: 120px; }
}

@media (max-width: 720px) {
  .page-head { grid-template-columns: 1fr; align-items: start; }
  .page-head .actions { justify-content: flex-start; }
  .page-head h1 { font-size: 2.1rem; }
  .folder-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: var(--space-lg) var(--space-md); }
  .file-inner { grid-template-columns: minmax(0, 1fr) auto; }
  .file-cell.size { display: none; }
  .file-actions .icon-btn { width: 38px; height: 38px; }
  .create-user { grid-template-columns: 1fr; }
  .user-table thead { display: none; }
  .user-table tr { display: grid; grid-template-columns: 1fr auto; gap: var(--space-xs); padding: var(--space-sm) 0; border-bottom: 1px solid var(--line); }
  .user-table td { border: 0; padding: 0; }
  .user-table td.role-cell, .user-table td.badges-cell { grid-column: 1 / -1; }
  .gate { grid-template-columns: 1fr; }
  .gate .folder-art { width: 140px; }
  .qr-step { grid-template-columns: 1fr; justify-items: start; }
  .file-card { grid-template-columns: auto 1fr; }
  .file-card .actions { grid-column: 1 / -1; }
  .auth-art .lede { display: none; }
}

@media (hover: none) {
  .file-actions .icon-btn { color: var(--ink-2); }
}

/* ───────────── Reduced motion ───────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
  .hold-btn.is-holding::before { transition-duration: var(--hold-ms, 900ms) !important; }
  .folder:hover .folder-front, .folder.is-opening .folder-front { transform: none; }
}

/* View transitions between folders */
::view-transition-old(root) { animation: vt-out 160ms var(--ease-out) both; }
::view-transition-new(root) { animation: vt-in 320ms var(--ease-expo) both; }

@keyframes vt-out { to { opacity: 0; transform: scale(0.99); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

/* ───────────── Progress button (download & delete) ─────────────
   idle arrow → shaft retracts into a dot that flies to the ring → vibrating string while the
   ring fills → check (success) / red flat line (fail). Drawn by js/progress-button.js. */

.pb {
  --pb-fill: var(--brand);
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  transition: color var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.pb:not(.is-active):hover { background: var(--paper-sunk); color: var(--ink); }
.pb:active { transform: scale(0.92); }
.pb[data-pb-kind="delete"] { --pb-fill: var(--danger); }
.pb[data-pb-kind="delete"]:not(.is-active):hover { background: var(--danger-soft); color: var(--danger); }

.pb-svg { width: 36px; height: 36px; overflow: visible; display: block; }

.pb-bg {
  fill: var(--pb-fill);
  transform-box: view-box;
  transform-origin: 20px 20px;
  transform: scale(0.4);
  opacity: 0;
  transition: transform 380ms var(--ease-expo), opacity 160ms var(--ease-out), fill 240ms var(--ease-out);
}

.pb.is-active { color: var(--on-brand); }
.pb.is-active .pb-bg { transform: scale(1); opacity: 1; }
.pb.is-fail { --pb-fill: var(--danger); animation: pb-shake 380ms var(--ease-out); }

.pb-main, .pb-shaft, .pb-body {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pb-track, .pb-ring { fill: none; stroke: currentColor; opacity: 0; transition: opacity 220ms var(--ease-out); }
.pb-track { stroke-opacity: 0.25; stroke-width: 2; }
.pb-ring { stroke-width: 2.4; stroke-linecap: round; }
.pb.is-active .pb-track, .pb.is-active .pb-ring,
.pb.is-holding .pb-track, .pb.is-holding .pb-ring { opacity: 1; }
.pb.is-holding { color: var(--danger); background: var(--danger-soft); }

/* download: the shaft pulls up and becomes the dot that launches to the top of the ring */
.pb-shaft {
  transform-box: view-box;
  transform-origin: 20px 9.5px;
  transition: transform 220ms var(--ease-in-out), opacity 120ms 140ms;
}
.pb.is-launched .pb-shaft { transform: scaleY(0.04); opacity: 0; }
.pb.is-active:not(.is-launched) .pb-shaft { opacity: 0; transition: none; }
.pb-dot { fill: currentColor; opacity: 0; transform-box: view-box; }
.pb.is-launched .pb-dot { animation: pb-dot 520ms var(--ease-out) 60ms both; }

@keyframes pb-dot {
  0% { opacity: 0; transform: translateY(13px); }
  15% { opacity: 1; transform: translateY(13px); }
  70% { opacity: 1; transform: translateY(-5.5px); }
  100% { opacity: 0; transform: translateY(-5.5px) scale(0.6); }
}

/* delete: the bin drops away while the lid becomes the line */
.pb-body {
  transform-box: view-box;
  transform-origin: 20px 28px;
  transition: opacity 180ms var(--ease-out), transform 320ms var(--ease-expo);
}
.pb.is-active .pb-body { opacity: 0; transform: translateY(5px) scale(0.6); }

@keyframes pb-shake {
  0%, 100% { translate: 0; }
  25% { translate: -3px 0; }
  50% { translate: 3px 0; }
  75% { translate: -1.5px 0; }
}

/* Labelled variant: a regular .btn with the round icon at its start */
.btn.pb {
  width: auto;
  height: auto;
  border-radius: var(--r-pill);
  padding: 0 var(--space-md) 0 4px;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  gap: 6px;
  grid-auto-flow: column;
}
.btn.pb .pb-svg { width: 32px; height: 32px; color: var(--ink-2); }
.btn.pb.is-active { color: var(--ink); }
.btn.pb.is-active .pb-svg { color: var(--on-brand); }
.pb-label { min-width: 4.5ch; font-variant-numeric: tabular-nums; }

/* Row status while a download runs (replaces the size cell text) */
.file-cell.size .dl-progress { color: var(--brand); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Rows/folders added in place animate alone, so nothing else re-plays */
.file-row.is-new { animation: row-arrive 520ms var(--ease-expo) both; }
@keyframes row-arrive {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}
.is-static { animation: none !important; }

@media (prefers-reduced-motion: reduce) {
  .pb, .pb * { animation: none !important; transition: none !important; }
}

/* ═════════════ Page design: ambient room, hero, desk surface ═════════════ */

html { background: var(--paper); }

body {
  background:
    radial-gradient(1100px 620px at 88% -12%, var(--glow-1), transparent 62%),
    radial-gradient(900px 560px at -8% 6%, var(--glow-2), transparent 60%),
    var(--paper);
  background-attachment: fixed;
  transition: background-color var(--dur-slow) var(--ease-out), color var(--dur-slow) var(--ease-out);
}

/* paper grain: barely-there texture so large surfaces don't look like flat plastic */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.3 0 0 0 0 0.42 0 0 0 0 0.55 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

.page {
  width: min(1280px, 100%);
  padding-top: clamp(28px, 5vw, 56px);
  view-transition-name: page;
}

/* Hero: the title block sits on the room, the content sits on the desk */
.page-head {
  position: relative;
  margin-bottom: var(--space-xl);
  padding-inline: 4px;
}

.page-head h1 {
  font-size: clamp(2.25rem, 4.4vw, 3.5rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
}

.page-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--space-sm);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.page-eyebrow::before {
  content: "";
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand-grad);
}

.page-meta { font-size: var(--t-body); }

.page-head .actions {
  padding: 6px;
  border: 1px solid var(--surface-line);
  border-radius: var(--r-pill);
  background: var(--surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
}

.page-head .actions:empty { display: none; }
.page-head .actions .btn { min-height: 38px; }
.page-head .actions .btn:not(.btn-primary) { --btn-line: transparent; }

/* The desk: one framed surface that holds folders and files */
.desk-surface {
  position: relative;
  padding: clamp(18px, 3vw, 36px);
  border: 1px solid var(--surface-line);
  border-radius: var(--r-xl);
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  box-shadow: var(--shadow-surface);
}

.desk-surface > .section { margin-top: 0; }
.desk-surface > .section:empty { display: none; }
.desk-surface > .section:not(:empty) ~ .section:not(:empty) { margin-top: var(--space-2xl); }
.desk-surface .empty { padding: var(--space-xl) var(--space-sm); }

.section-head { border-bottom-color: var(--surface-line); }
.section-head .label { color: var(--ink-2); }
.section-head .muted {
  min-width: 26px;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: var(--paper-sunk);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.section-head .muted:empty { display: none; }

.file-inner { border-bottom-color: var(--surface-line); }
.file-row:last-child .file-inner { border-bottom: 0; }
.file-row:hover .file-inner { background: linear-gradient(to right, transparent, var(--paper-sunk) 3%, var(--paper-sunk) 97%, transparent); }

/* panels on the other pages use the same surface language */
.panel {
  border-color: var(--surface-line);
  border-radius: var(--r-xl);
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow-surface);
  padding: clamp(18px, 3vw, 32px);
}

.user-table th, .user-table td { border-bottom-color: var(--surface-line); }

.app-footer {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 0 var(--gutter) var(--space-xl);
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  color: var(--ink-3);
  font-size: 12px;
}

/* dialogs and inputs follow the theme */
.preview, .sheet-dialog, .tray, .search-results { background: var(--paper-raised); border-color: var(--surface-line); }

/* Sign-in page */
.auth-art {
  background:
    radial-gradient(700px 480px at 20% 110%, var(--glow-2), transparent 65%),
    radial-gradient(600px 400px at 100% 0%, var(--glow-1), transparent 60%),
    var(--auth-art);
  border-right: 1px solid var(--surface-line);
}
.auth-card { padding: clamp(20px, 3vw, 36px); border: 1px solid var(--surface-line); border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-surface); }
.auth-theme { position: fixed; top: 16px; right: 16px; z-index: 5; }

/* Public share page */
.gate { padding: clamp(20px, 4vw, 40px); border: 1px solid var(--surface-line); border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-surface); }
.public-wrap .file-card { border-radius: var(--r-xl); border-color: var(--surface-line); background: var(--surface); box-shadow: var(--shadow-surface); }

/* ═════════════ Page transitions ═════════════
   Between pages (Files / Users / Security, sign-in to app): cross-document view transitions.
   The header stays put, the nav thumb glides, the page content lifts out and settles in.
   Between folders: same-document transitions with direction (deeper = from the right),
   and the folder you open morphs into the page title. */

@view-transition { navigation: auto; }

::view-transition-old(root), ::view-transition-new(root) { animation: none; }
::view-transition-group(app-header) { animation: none; }

::view-transition-old(page) { animation: page-out 200ms var(--ease-out) both; }
::view-transition-new(page) { animation: page-in 520ms var(--ease-expo) both; }

@keyframes page-out { to { opacity: 0; transform: translateY(-10px) scale(0.985); filter: blur(3px); } }
@keyframes page-in { from { opacity: 0; transform: translateY(18px) scale(0.995); filter: blur(4px); } }

/* folder navigation direction */
:root.vt-forward::view-transition-old(page) { animation: page-out-left 220ms var(--ease-out) both; }
:root.vt-forward::view-transition-new(page) { animation: page-in-right 520ms var(--ease-expo) both; }
:root.vt-back::view-transition-old(page) { animation: page-out-right 220ms var(--ease-out) both; }
:root.vt-back::view-transition-new(page) { animation: page-in-left 520ms var(--ease-expo) both; }

@keyframes page-out-left { to { opacity: 0; transform: translateX(-28px); filter: blur(2px); } }
@keyframes page-in-right { from { opacity: 0; transform: translateX(36px); filter: blur(3px); } }
@keyframes page-out-right { to { opacity: 0; transform: translateX(28px); filter: blur(2px); } }
@keyframes page-in-left { from { opacity: 0; transform: translateX(-36px); filter: blur(3px); } }

/* the opened folder's name becomes the page title */
::view-transition-group(folder-title) { animation-duration: 520ms; animation-timing-function: var(--ease-expo); }
::view-transition-old(folder-title), ::view-transition-new(folder-title) { height: 100%; object-fit: contain; object-position: left center; }

/* theme switch: the new theme spreads in a circle from the toggle */
:root.theme-swap .app-header, :root.theme-swap .page { view-transition-name: none !important; }
:root.theme-swap::view-transition-old(root) { animation: none; }
:root.theme-swap::view-transition-new(root) { animation: theme-reveal 620ms var(--ease-in-out) both; }
@keyframes theme-reveal {
  from { clip-path: circle(0 at var(--reveal-x, 100%) var(--reveal-y, 0)); }
  to { clip-path: circle(150vmax at var(--reveal-x, 100%) var(--reveal-y, 0)); }
}

/* browsers without view transitions still get a gentle entrance */
@supports not (view-transition-name: none) {
  .page { animation: page-in 520ms var(--ease-expo) both; }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .nav-thumb { transition: none; }
}

/* ═════════════ Responsive header & surfaces ═════════════ */

@media (max-width: 1040px) {
  .user-chip .who { display: none; }
}

@media (max-width: 820px) {
  .app-header {
    height: auto;
    grid-template-columns: auto 1fr;
    grid-template-areas: "brand tools" "nav nav" "search search";
    row-gap: 10px;
    padding-block: 10px;
  }
  .app-header .brand { grid-area: brand; }
  .app-header .nav { grid-area: nav; justify-self: start; }
  .app-header .search { grid-area: search; width: 100%; max-width: none; justify-self: stretch; }
  .app-header .header-tools { grid-area: tools; }
  .desk-surface, .panel { border-radius: 20px; }
  .page-head .actions { border-radius: 18px; }
  .auth-card { border: 0; background: transparent; box-shadow: none; padding: 0; }
}


/* ═════════════ Al Amal brand: logo lockup ═════════════ */
.brand { gap: 12px; }
.brand-logo { height: 34px; width: auto; display: block; }
.brand-logo.on-light { display: var(--logo-light); }
.brand-logo.on-dark { display: var(--logo-dark); }
.brand-divider { width: 1px; height: 26px; background: var(--line-strong); }
.brand-product { font: 400 1.0625rem/1 var(--font-display); color: var(--ink); letter-spacing: -0.005em; }
.brand:hover .brand-product { color: var(--brand); }

/* sign-in art panel is the navy Al Amal "rail" in both themes */
.auth-art { color: #e8f3fa; }
.auth-art .brand-logo { height: 42px; }
.auth-art .brand-divider { background: var(--rail-line); height: 32px; }
.auth-art .brand-product { color: #e8f3fa; font-size: 1.2rem; }
.auth-art h1 { color: #ffffff; }
.auth-art .lede { color: var(--rail-text); }

@media (max-width: 1040px) { .brand-divider, .brand-product { display: none; } }
@media (max-width: 960px) { .auth-art .brand-divider, .auth-art .brand-product { display: block; } }
