/* ==========================================================================
   GCS — design system
   --------------------------------------------------------------------------
   Structure
     1. Tokens          6. Buttons & links     11. Folder grid
     2. Reset & base    7. Forms               12. File list
     3. Typography      8. Surfaces            13. Dialog
     4. Layout          9. Marketing           14. Upload progress
     5. App bar        10. Auth               15. Settings, shares, admin
                                               16. Utilities & motion

   Two themes, one set of semantic names. Light is the default; dark is applied
   by media query and can be forced either way with [data-theme] on <html>
   (see theme.js). Components only ever reference semantic tokens, so a theme
   switch never needs component changes.
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */

:root {
  color-scheme: light;

  /* Neutral ramp — very slightly cool, so the indigo accent stays distinct. */
  --n-0:   #ffffff;
  --n-25:  #fcfcfd;
  --n-50:  #f6f7f9;
  --n-100: #eef0f3;
  --n-200: #e2e5ea;
  --n-300: #cdd2da;
  --n-400: #a3abb8;
  --n-500: #737d8c;
  --n-600: #545e6d;
  --n-700: #3b4450;
  --n-800: #262d36;
  --n-900: #171c23;
  --n-950: #0f1319;

  /* Accent + semantics as ramps, mapped below. Calm indigo family. */
  --a-100: #e9ebfd;
  --a-200: #d3d6fa;
  --a-300: #b3b7f5;
  --a-400: #8f94ec;
  --a-500: #6366f1;
  --a-600: #4f46e5;
  --a-700: #4338ca;

  --ok-100: #d6f5e4;  --ok-500: #0f9d63;  --ok-700: #0a6b45;
  --warn-100: #fdeed2; --warn-500: #b5730c; --warn-700: #7d4f06;
  --bad-100: #fde3e3; --bad-500: #d33f3f; --bad-700: #9a2020;

  /* Semantic surface + text */
  --bg:            var(--n-50);
  --bg-accent:     #eef0fd;
  --surface:       var(--n-0);
  --surface-sunken:var(--n-100);
  --surface-hover: var(--n-50);
  --surface-active:var(--n-100);
  --border:        #e5e9f0;
  --border-strong: #d3d9e2;
  --text:          var(--n-900);
  --text-muted:    var(--n-600);
  --text-subtle:   var(--n-500);
  --text-invert:   var(--n-0);

  --accent:        var(--a-600);
  --accent-hover:  var(--a-700);
  --accent-soft:   var(--a-100);
  --accent-text:   var(--a-700);

  --ok:     var(--ok-500);
  --ok-soft:var(--ok-100);
  --warn:   var(--warn-500);
  --warn-soft: var(--warn-100);
  --bad:    var(--bad-500);
  --bad-soft: var(--bad-100);

  /* Elevation. Low-contrast and layered — depth should be felt, not seen. */
  --shadow-xs: 0 1px 2px rgba(16, 22, 32, .05);
  --shadow-sm: 0 1px 2px rgba(16, 22, 32, .06), 0 2px 6px rgba(16, 22, 32, .05);
  --shadow-md: 0 2px 4px rgba(16, 22, 32, .06), 0 8px 20px rgba(16, 22, 32, .08);
  --shadow-lg: 0 8px 16px rgba(16, 22, 32, .08), 0 24px 56px rgba(16, 22, 32, .14);
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);

  /* Space — 4px base. Named by role so layouts stay consistent. */
  --s-1: .25rem;  --s-2: .5rem;   --s-3: .75rem;  --s-4: 1rem;
  --s-5: 1.25rem; --s-6: 1.5rem;  --s-8: 2rem;    --s-10: 2.5rem;
  --s-12: 3rem;   --s-16: 4rem;   --s-20: 5rem;   --s-24: 6rem;

  /* Radius — softened one step so cards, inputs, and rows feel calmer. */
  --r-xs: 4px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-full: 999px;

  /* Type */
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --t-xs:   .75rem;
  --t-sm:   .8125rem;
  --t-base: .9375rem;
  --t-md:   1rem;
  --t-lg:   1.125rem;
  --t-xl:   1.375rem;
  --t-2xl:  1.75rem;
  --t-3xl:  2.25rem;
  --t-hero: clamp(2.25rem, 1.35rem + 3.4vw, 3.5rem);

  --measure: 68ch;
  --shell:  1180px;
  --bar-h:  60px;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
  :root:not([data-theme="light"]) {
    --bg:            #0e1116;
    --bg-accent:     #14161c;
    --surface:       #171b22;
    --surface-sunken:#12161c;
    --surface-hover: #1c212a;
    --surface-active:#222834;
    --border:        #262c36;
    --border-strong: #364050;
    --text:          #e8ecf2;
    --text-muted:    #9aa4b2;
    --text-subtle:   #6f7a89;
    --text-invert:   #0e1116;

    --accent:      #a5b4fc;
    --accent-hover:#c1c8ff;
    --accent-soft: #1e2033;
    --accent-text: #bec6ff;

    --ok:      #3ecf8e;  --ok-soft:   #10251c;
    --warn:    #e0a340;  --warn-soft: #2a2011;
    --bad:     #f4756e;  --bad-soft:  #2c1618;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4), 0 2px 6px rgba(0, 0, 0, .3);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, .35), 0 8px 20px rgba(0, 0, 0, .4);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, .4), 0 24px 56px rgba(0, 0, 0, .55);
    --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:            #0e1116;
  --bg-accent:     #14161c;
  --surface:       #171b22;
  --surface-sunken:#12161c;
  --surface-hover: #1c212a;
  --surface-active:#222834;
  --border:        #262c36;
  --border-strong: #364050;
  --text:          #e8ecf2;
  --text-muted:    #9aa4b2;
  --text-subtle:   #6f7a89;
  --text-invert:   #0e1116;
  --accent:      #a5b4fc;
  --accent-hover:#c1c8ff;
  --accent-soft: #1e2033;
  --accent-text: #bec6ff;
  --ok:      #3ecf8e;  --ok-soft:   #10251c;
  --warn:    #e0a340;  --warn-soft: #2a2011;
  --bad:     #f4756e;  --bad-soft:  #2c1618;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4), 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, .35), 0 8px 20px rgba(0, 0, 0, .4);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, .4), 0 24px 56px rgba(0, 0, 0, .55);
}

/* 2. Reset & base ---------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--t-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p, figure, blockquote { margin: 0; }
ul, ol { margin: 0; padding: 0; }

/* CHG-569: the UA rule for [hidden] is `display: none` at author-origin-beating
   specificity only by being last-resort. Any component rule that sets `display`
   (grid/flex/block) silently defeats it, because component selectors outrank the
   UA sheet. That made `[hidden]` panels visible: "No matching files or folders"
   showed on a populated folder, and the S3 "save this secret now" block showed
   before any key was created. A hidden attribute must always win. */
[hidden] { display: none !important; }

/* CHG-569: no base anchor rule existed, so every link rendered in the UA's
   blue-and-underlined default - including the file names, the folder card, and
   the header nav, which made the whole app read as a wall of hyperlinks. */
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent-text); }

/* One focus treatment everywhere, keyboard-only. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--accent-soft); color: var(--accent-text); }

/* 3. Typography ------------------------------------------------------------ */

h1, h2, h3 { letter-spacing: -.02em; line-height: 1.18; font-weight: 640; }
h1 { font-size: var(--t-2xl); }
h2 { font-size: var(--t-lg); }
h3 { font-size: var(--t-md); }
p  { text-wrap: pretty; }

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: .875em;
  padding: .1em .35em;
  border-radius: var(--r-xs);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
}

/* Small uppercase label used above section headings. Single accent, never green. */
.eyebrow, .app-kicker {
  margin: 0 0 var(--s-2);
  font-size: var(--t-xs);
  font-weight: 620;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.lede, .hero-copy { color: var(--text-muted); max-width: var(--measure); }
.hero-copy { font-size: var(--t-lg); line-height: 1.5; }
.muted, .supporting-copy { color: var(--text-muted); }
.supporting-copy { font-size: var(--t-sm); }

/* 4. Layout ---------------------------------------------------------------- */

.page-shell {
  flex: 1 0 auto;
  width: min(var(--shell), 100% - var(--s-8));
  margin-inline: auto;
  padding-block: var(--s-8) var(--s-16);
}

.app-page-shell { padding-block: var(--s-6) var(--s-12); }

/* Reading-width page (privacy, admin). */
.narrow-section { max-width: 74ch; margin-inline: auto; padding-block: var(--s-8) var(--s-16); }
.centered-section { text-align: center; }
.centered-section .hero-copy { margin-inline: auto; }
.narrow-section > h1 { font-size: var(--t-3xl); margin-bottom: var(--s-3); }
.narrow-section > .hero-copy { margin-bottom: var(--s-8); }

/* 5. App bar --------------------------------------------------------------- */

.site-header, .site-footer {
  width: min(var(--shell), 100% - var(--s-8));
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: var(--s-4);
}
.site-header { min-height: var(--bar-h); }
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  width: 100%;
  max-width: none;
  padding-inline: max(var(--s-4), calc((100vw - var(--shell)) / 2));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.app-header::after {
  content: "";
  flex: 1;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 660;
  letter-spacing: -.02em;
  font-size: var(--t-md);
  color: var(--text);
  flex: 0 0 auto;
}
.brand:hover { color: var(--text); }
.brand-mark-image { width: 26px; height: 26px; border-radius: 9px; box-shadow: var(--shadow-xs); }

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  margin-left: auto;
  font-size: var(--t-base);
}

.account-name {
  padding-inline: var(--s-2) var(--s-3);
  color: var(--text-muted);
  font-size: var(--t-sm);
  max-width: 14ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-link, .header-icon-link {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding-inline: var(--s-3);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: var(--t-base);
  /* CHG-569: "Log out" wrapped to two lines at 420px, doubling the bar height. */
  white-space: nowrap;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.header-link:hover, .header-icon-link:hover {
  color: var(--text);
  background: var(--surface-hover);
}
/* CHG-569: "Log out" is a <button> wearing .header-link. Without this it kept
   the UA button border and background, so it rendered as a raised box in the
   middle of a flat nav bar. */
button.header-link {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: var(--t-base);
  cursor: pointer;
}
.header-icon-link {
  width: 34px;
  padding: 0;
  justify-content: center;
  font-weight: 700;
  font-size: var(--t-sm);
  border: 1px solid var(--border);
}

/* Theme switch */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  transition: background .12s var(--ease), color .12s var(--ease);
}
.theme-toggle:hover { background: var(--surface-hover); color: var(--text); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun  { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun  { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* App shell: persistent section nav beside the page (signed-in views). */
.app-shell {
  flex: 1 0 auto;
  width: min(calc(var(--shell) + 264px), 100% - var(--s-8));
  margin-inline: auto;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: var(--s-8);
  align-items: start;
}
.app-shell .page-shell {
  width: auto;
  min-width: 0;
  margin-inline: 0;
}
.app-sidebar {
  position: sticky;
  top: calc(var(--bar-h) + var(--s-6));
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  min-height: calc(100vh - var(--bar-h) - var(--s-12));
  padding-block: var(--s-6) var(--s-4);
}
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 40px;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  color: var(--text-muted);
  font-size: var(--t-base);
  font-weight: 560;
}
.side-nav a:hover { background: var(--surface-hover); color: var(--text); }
.side-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 660; }
.side-nav svg { width: 18px; height: 18px; flex: 0 0 auto; }
.side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid var(--border);
  padding-top: var(--s-3);
}
.side-link {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: var(--s-1) var(--s-3);
  border-radius: var(--r-sm);
  color: var(--text-subtle);
  font-size: var(--t-sm);
  text-align: left;
  width: 100%;
}
.side-link:hover { background: var(--surface-hover); color: var(--text); }
button.side-link { border: 0; background: transparent; font: inherit; cursor: pointer; }
/* Drawer toggle lives in the header on app pages; desktop never needs it. */
.nav-toggle {
  display: none;
  place-items: center;
  width: 34px; height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
}
.nav-toggle:hover { background: var(--surface-hover); color: var(--text); }
.nav-toggle svg { width: 18px; height: 18px; }

.site-footer {
  flex: 0 0 auto;
  min-height: 64px;
  border-top: 1px solid var(--border);
  color: var(--text-subtle);
  font-size: var(--t-sm);
}

/* 6. Buttons & links ------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 38px;
  padding: var(--s-2) var(--s-4);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font-size: var(--t-base);
  font-weight: 560;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  transition: background .13s var(--ease), border-color .13s var(--ease),
              color .13s var(--ease), box-shadow .13s var(--ease), transform .08s var(--ease);
}
.button:hover { color: var(--text); }
.button:active { transform: translateY(.5px); }
.button:disabled, .button[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.button svg { width: 16px; height: 16px; flex: 0 0 auto; }

.button-primary {
  background: linear-gradient(180deg, color-mix(in srgb, #fff 9%, transparent), transparent 55%), var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-xs);
}
.button-primary:hover {
  background: linear-gradient(180deg, color-mix(in srgb, #fff 9%, transparent), transparent 55%), var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .button-primary { color: #12121a; }
  :root[data-theme="dark"] .button-primary { color: #12121a; }
}

.button-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.button-secondary:hover { background: var(--surface-hover); color: var(--text); }

.button-ghost { color: var(--text-muted); }
.button-ghost:hover { background: var(--surface-hover); color: var(--text); }

.button-danger {
  background: var(--bad-soft);
  border-color: color-mix(in srgb, var(--bad) 35%, transparent);
  color: var(--bad);
}
.button-danger:hover { background: var(--bad); border-color: var(--bad); color: #fff; }

.button-wide { width: 100%; }
.button-sm { min-height: 32px; padding: var(--s-1) var(--s-3); font-size: var(--t-sm); }

.action-row { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-block: var(--s-6) var(--s-3); }
.back-link { margin-top: var(--s-6); font-size: var(--t-sm); color: var(--text-subtle); }
.back-link a:hover, a:hover { color: var(--accent-text); }

/* 7. Forms ----------------------------------------------------------------- */

.stack-form { display: grid; gap: var(--s-2); margin-top: var(--s-5); }
.stack-form label, .dialog-field label, .form-field label {
  font-size: var(--t-sm);
  font-weight: 540;
  color: var(--text-muted);
}
.form-field { display: grid; gap: var(--s-2); }
.field-help { font-size: var(--t-xs); color: var(--text-subtle); margin: 0; }
  /* CHG-574: per-user storage settings. A divider between independent controls
     in the same card, and a radio group for the binary encryption choice. The
     group is a fieldset so the browser's own grouping semantics and arrow-key
     navigation work with no extra scripting. */
  .card-divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: var(--s-5) 0 var(--s-4);
  }
  .radio-set {
    border: 0;
    padding: 0;
    margin: 0 0 var(--s-3);
    display: grid;
    gap: var(--s-2);
  }
  .radio {
    display: flex;
    align-items: flex-start;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    cursor: pointer;
  }
  .radio:hover { border-color: var(--border-strong); }
  .radio input { margin: 0; flex: none; }
  /* The radio itself is a small hit target, so the visible focus ring goes on
     the whole label. Matches the global :focus-visible treatment at line ~213. */
  .radio:has(input:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

input[type="text"], input[type="password"], input[type="search"],
input[type="email"], input[type="url"], select, textarea {
  width: 100%;
  min-height: 38px;
  padding: var(--s-2) var(--s-3);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  transition: border-color .13s var(--ease), box-shadow .13s var(--ease);
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-subtle); }
input:hover, select:hover, textarea:hover { border-color: var(--text-subtle); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input:disabled, input[readonly] { background: var(--surface-sunken); color: var(--text-muted); }

.search-field { position: relative; display: flex; align-items: center; }
.search-field svg {
  position: absolute;
  left: var(--s-3);
  width: 16px; height: 16px;
  color: var(--text-subtle);
  pointer-events: none;
}
.search-field input { padding-left: var(--s-8); }
input[type="search"]::-webkit-search-cancel-button { filter: grayscale(1) opacity(.6); }

.inline-control { display: flex; gap: var(--s-2); align-items: stretch; }
.inline-control input { flex: 1 1 auto; min-width: 0; font-family: var(--font-mono); font-size: var(--t-sm); }
.inline-control .button { flex: 0 0 auto; }
.inline-form { display: inline; margin: 0; }

/* Checkbox: real input, custom box, so it stays keyboard- and SR-correct. */
.file-check { position: relative; display: grid; place-items: center; }
.file-check input {
  appearance: none;
  width: 17px; height: 17px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-xs);
  background: var(--surface);
  cursor: pointer;
  transition: background .12s var(--ease), border-color .12s var(--ease);
}
.file-check input:hover { border-color: var(--accent); }
.file-check input:checked {
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3.5 8.5 3 3 6-6'/%3E%3C/svg%3E") center/13px no-repeat;
  border-color: var(--accent);
}
.file-check span { position: absolute; inset: 0; pointer-events: none; }

.select-all-button { cursor: pointer; }
.select-all-button input { width: 15px; height: 15px; min-height: 0; accent-color: var(--accent); margin: 0; }

/* 8. Surfaces -------------------------------------------------------------- */

.card, .feature-card, .prose-card, .toc-card, .share-card, .notice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.card { padding: var(--s-6); display: grid; align-content: start; gap: var(--s-1); }
.card h2 { margin-bottom: var(--s-1); }
.card > .stack-form { margin-top: var(--s-4); }

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-2);
}

.flash, .alert {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-5);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--t-base);
}
.alert { display: block; margin-inline: auto; max-width: 480px; }
.flash-success {
  border-color: color-mix(in srgb, var(--ok) 32%, transparent);
  background: var(--ok-soft);
  color: var(--ok);
}
.flash-error, .alert-error {
  border-color: color-mix(in srgb, var(--bad) 32%, transparent);
  background: var(--bad-soft);
  color: var(--bad);
}
.flash-warn {
  border-color: color-mix(in srgb, var(--warn) 32%, transparent);
  background: var(--warn-soft);
  color: var(--warn);
}
.flash-close {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: var(--r-full);
  background: color-mix(in srgb, currentColor 12%, transparent);
  color: inherit;
  font-size: 16px;
  line-height: 1;
}
.flash-close:hover { background: color-mix(in srgb, currentColor 22%, transparent); }

.status-pill, .privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: .1rem var(--s-2);
  border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
  border-radius: var(--r-full);
  background: var(--ok-soft);
  color: var(--ok);
  font-size: var(--t-xs);
  font-weight: 560;
  letter-spacing: .01em;
  text-transform: capitalize;
}
.privacy-badge {
  border-color: var(--border);
  background: var(--surface-sunken);
  color: var(--text-subtle);
}
.privacy-badge span { font-size: .8em; }

/* 9. Marketing ------------------------------------------------------------- */

.hero-section { max-width: 780px; padding-block: var(--s-16) var(--s-12); }
.hero-section h1 { font-size: var(--t-hero); margin-bottom: var(--s-4); }
/* Pill eyebrow on the landing hero so the page opens with one soft accent. */
.hero-section .eyebrow {
  display: inline-block;
  padding: .28rem var(--s-3);
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
  border-radius: var(--r-full);
  background: var(--accent-soft);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-4);
  padding-bottom: var(--s-8);
}
.feature-card {
  padding: var(--s-5);
  transition: transform .14s var(--ease), border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.feature-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  box-shadow: var(--shadow-md);
}
.feature-card p { margin-top: var(--s-2); font-size: var(--t-base); }
.feature-number {
  display: block;
  margin-bottom: var(--s-8);
  font-size: var(--t-xs);
  font-weight: 660;
  font-variant-numeric: tabular-nums;
  color: var(--accent-text);
}
.notice-card {
  max-width: 780px;
  padding: var(--s-5) var(--s-6);
  border-left: 3px solid var(--accent);
}
.notice-card p { margin-top: var(--s-2); }

.toc-card { display: grid; gap: var(--s-1); padding: var(--s-4) var(--s-5); margin-bottom: var(--s-6); font-size: var(--t-base); }
.toc-card strong { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-subtle); margin-bottom: var(--s-1); }
.toc-card a { color: var(--text-muted); }
.toc-card a:hover { color: var(--accent-text); }

.prose-card { padding: var(--s-6); margin-bottom: var(--s-4); scroll-margin-top: calc(var(--bar-h) + var(--s-4)); }
.prose-card ul { list-style: none; display: grid; gap: var(--s-2); margin-top: var(--s-3); }
.prose-card li { position: relative; padding-left: var(--s-5); color: var(--text-muted); }
.prose-card li::before {
  content: "";
  position: absolute;
  left: 2px; top: .62em;
  width: 5px; height: 5px;
  border-radius: var(--r-full);
  background: var(--border-strong);
}
.prose-card p { margin-top: var(--s-3); color: var(--text-muted); }
.prose-card a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }

/* 10. Auth ----------------------------------------------------------------- */

.auth-section { display: grid; place-items: center; padding-block: var(--s-12) var(--s-16); }
.auth-card {
  width: min(430px, 100%);
  padding: var(--s-8);
  background: linear-gradient(180deg, var(--bg-accent), var(--surface) 42%);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
}
.auth-card-header { margin-bottom: var(--s-2); }
.auth-card-header h1 { font-size: var(--t-2xl); margin-bottom: var(--s-2); }
.auth-card .hero-copy { font-size: var(--t-base); }
.auth-form { margin-top: var(--s-6); }
.auth-form .button { margin-top: var(--s-3); }
.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-block: var(--s-5);
  color: var(--text-subtle);
  font-size: var(--t-xs);
}
.auth-divider::before, .auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-note { margin-top: var(--s-4); text-align: center; }
.auth-card .back-link { text-align: center; }

/* 11. Folder rows (unified row list — Fixes #38) ------------------------------ */

.content-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
  flex-wrap: wrap;
}
.content-heading h1 { font-size: var(--t-2xl); }
.content-count { font-size: var(--t-sm); color: var(--text-subtle); }

/* 12. File list ------------------------------------------------------------ */

.file-folder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
  margin-bottom: var(--s-4);
}
.file-folder-heading { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.file-folder-heading h1 {
  font-size: var(--t-xl);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-back-link { color: var(--text-muted); font-size: var(--t-base); flex: 0 0 auto; }
.folder-back-link:hover { color: var(--accent-text); }
.folder-back-separator { color: var(--border-strong); }

.file-folder-actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.folder-file-search { width: 230px; }
/* List toolbar (filter + sort side by side) and the sort control itself. */
.list-toolbar {
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: var(--s-4);
}
.list-toolbar .folder-file-search { flex: 1 1 220px; width: auto; }
.sort-field {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--t-sm);
  font-weight: 540;
  color: var(--text-muted);
  flex: 0 0 auto;
}
.sort-field select { width: auto; }
/* Sunken toolbar search: quiet until focused, so the row reads calmer. */
.folder-file-search input { background: var(--surface-sunken); border-color: transparent; }
.folder-file-search input:hover { border-color: var(--border-strong); }
.folder-file-search input:focus { background: var(--surface); border-color: var(--accent); }
.import-button { cursor: pointer; }
.upload-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-form-hidden { display: none; }

.file-folder-list-heading {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--border);
  font-size: var(--t-sm);
  color: var(--text-subtle);
}
.folder-location { margin-left: auto; font-family: var(--font-mono); font-size: var(--t-xs); }

.file-list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  overflow: clip;
}

.file-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  transition: background .1s var(--ease);
}
.file-row:last-child { border-bottom: 0; }
.file-row:hover { background: var(--surface-hover); }
.file-row:focus-within { background: var(--surface-hover); }
.file-row:has(.file-check input:checked) { background: var(--accent-soft); }
/* Folder rows carry no checkbox: three columns instead of four. */
.file-row.file-row-no-check { grid-template-columns: auto 1fr auto; }

.file-type-icon {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  flex: 0 0 auto;
}
.file-type-icon img { width: 18px; height: 18px; }
.file-type-icon.folder-icon { background: var(--accent-soft); }

.file-main { min-width: 0; }
.file-name {
  display: block;
  font-size: var(--t-base);
  font-weight: 520;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-name:hover { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }
.file-meta { font-size: var(--t-xs); color: var(--text-subtle); margin: 0; }

.file-actions { display: flex; align-items: center; gap: var(--s-1); flex: 0 0 auto; }

.load-more-row { display: flex; justify-content: center; padding-block: var(--s-6); }

.file-action {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  height: 30px;
  padding-inline: var(--s-3);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--t-sm);
  font-weight: 520;
  white-space: nowrap;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.file-action:hover { background: var(--surface-active); color: var(--text); }
.file-action svg { width: 15px; height: 15px; }
.file-action-primary { color: var(--text); }
.file-action-primary:hover { background: var(--accent-soft); color: var(--accent-text); }
.file-delete-form { display: inline; margin: 0; }
.file-delete-action { color: var(--text-subtle); }
.file-delete-action:hover { background: var(--bad-soft); color: var(--bad); }

/* Row overflow menu — the point of the redesign. Secondary and destructive
   actions stop competing with Download/Open for attention; the destructive one
   is additionally separated by a rule so it never reads as a peer. */
.row-menu { position: relative; flex: 0 0 auto; }
.row-menu-trigger {
  display: inline-grid;
  place-items: center;
  width: 30px; height: 30px;
  min-height: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
}
.row-menu-trigger:hover { background: var(--surface-active); color: var(--text); border-color: var(--border); }
.row-menu-trigger svg { width: 16px; height: 16px; }
/* The toolbar variant reuses .button for sizing, so undo the fixed square. */
.row-menu-trigger.button {
  width: auto;
  min-height: 32px;
  padding-inline: var(--s-2);
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: var(--shadow-xs);
}
.row-menu-trigger.button:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }
.row-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  min-width: 176px;
  padding: var(--s-1);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
}
.row-menu-panel[hidden] { display: none; }
.row-menu-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-2) var(--s-3);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font-size: var(--t-base);
  text-align: left;
  text-decoration: none;
}
.row-menu-item:hover { background: var(--surface-hover); color: var(--text); }
.row-menu-item svg { width: 15px; height: 15px; color: var(--text-subtle); flex: 0 0 auto; }
.row-menu-item:hover svg { color: var(--accent-text); }
.row-menu-sep { height: 1px; margin: var(--s-1) var(--s-2); background: var(--border); }
.row-menu-item-danger { color: var(--bad); }
.row-menu-item-danger svg { color: var(--bad); }
.row-menu-item-danger:hover { background: var(--bad-soft); color: var(--bad); }

/* 13. Dialog --------------------------------------------------------------- */

.create-folder-dialog {
  width: min(440px, calc(100% - var(--s-8)));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.create-folder-dialog::backdrop { background: rgba(10, 13, 18, .48); backdrop-filter: blur(2px); }
.create-folder-form { display: grid; gap: var(--s-4); padding: var(--s-6); }
.dialog-heading h2 { font-size: var(--t-lg); }
.dialog-heading p:last-child { margin-top: var(--s-1); font-size: var(--t-sm); }
.dialog-field { display: grid; gap: var(--s-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-2); }
/* Upload conflict dialog: one full-width decision per row, danger-free.
   Rename swaps the menu for its own Back/confirm row. */
.upload-conflict-dialog {
  width: min(440px, calc(100% - var(--s-8)));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.upload-conflict-dialog::backdrop { background: rgba(10, 13, 18, .48); backdrop-filter: blur(2px); }
.upload-conflict-form { display: grid; gap: var(--s-4); padding: var(--s-6); }
.dialog-actions-stacked { display: grid; gap: var(--s-2); margin-top: var(--s-2); }
.dialog-actions-stacked .button { width: 100%; }

/* 14. Upload progress ------------------------------------------------------ */

.upload-toast {
  position: fixed;
  right: var(--s-5);
  bottom: var(--s-5);
  z-index: 50;
  width: min(370px, calc(100% - var(--s-8)));
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
.upload-toast[hidden] { display: none; }
.upload-toast-heading { display: flex; align-items: center; gap: var(--s-2); font-size: var(--t-base); }
.upload-spinner {
  width: 15px; height: 15px;
  flex: 0 0 auto;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: var(--r-full);
  animation: spin .7s linear infinite;
}
.upload-toast-track {
  height: 4px;
  margin: var(--s-3) 0 var(--s-2);
  background: var(--surface-sunken);
  border-radius: var(--r-full);
  overflow: hidden;
}
.upload-toast-track > span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width .18s var(--ease);
}
.upload-toast-details {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  font-size: var(--t-xs);
  color: var(--text-subtle);
}
.upload-toast-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}
.upload-toast-percent { font-variant-numeric: tabular-nums; }
.upload-toast-count { font-variant-numeric: tabular-nums; }
.upload-progress { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Drop target feedback */
.is-dragging { outline: 2px dashed var(--accent); outline-offset: -6px; background: var(--accent-soft); }

/* 15. Settings, shares, admin --------------------------------------------- */

.page-header { max-width: 720px; margin-bottom: var(--s-6); }
.page-header h1 { font-size: var(--t-3xl); margin-bottom: var(--s-3); }
.page-header .lede { font-size: var(--t-md); }

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s-4);
  align-items: start;
}
.settings-grid > .card:only-child { grid-column: 1 / -1; max-width: 720px; }

.account-list { display: grid; gap: var(--s-2); margin-top: var(--s-4); }
.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
}
.account-row p { margin: var(--s-1) 0 0; font-size: var(--t-sm); }

.empty-state {
  margin-top: var(--s-4);
  padding: var(--s-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
}
.empty-state p { margin-top: var(--s-1); font-size: var(--t-sm); }

.no-linked-account-state, .empty-folders-state, .empty-folder-state, .no-search-results, .empty-search-state {
  display: grid;
  justify-items: center;
  gap: var(--s-2);
  padding: var(--s-16) var(--s-6);
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-xl);
  background: var(--surface);
}
.no-linked-account-state h1 { font-size: var(--t-xl); }
.no-linked-account-state .button { margin-top: var(--s-3); }
.no-linked-account-icon, .empty-folder-icon {
  display: grid;
  place-items: center;
  width: 56px; height: 56px;
  margin-bottom: var(--s-2);
  border-radius: var(--r-lg);
  background: var(--accent-soft);
}
.no-linked-account-icon img, .empty-folder-icon img { width: 26px; height: 26px; }
.no-search-results, .empty-search-state { padding: var(--s-10) var(--s-6); }
.empty-folders-state strong, .empty-folder-state strong { font-size: var(--t-md); }
.empty-folder-link { color: var(--accent-text); font-size: var(--t-sm); }

.share-page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
  margin-bottom: var(--s-5);
}
.share-page-actions { display: flex; gap: var(--s-2); }
.share-manager {
  padding: var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.share-manager-list { display: grid; gap: var(--s-2); margin-top: var(--s-4); }
.share-manager-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
}
.share-manager-details { min-width: 0; }
.share-manager-details strong { display: block; overflow-wrap: anywhere; }
.share-manager-details p { font-size: var(--t-sm); color: var(--text-subtle); margin-top: var(--s-1); }
.share-parent-link { color: var(--accent-text); font-size: var(--t-sm); }

.share-status { margin-block: var(--s-6); color: var(--text-muted); }
.share-card { padding: var(--s-8); margin-block: var(--s-6); }
.file-icon {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  margin: 0 auto var(--s-5);
  border-radius: var(--r-lg);
  background: var(--accent-soft);
}
.file-icon img { width: 26px; height: 26px; }
.share-card h1 { font-size: var(--t-xl); overflow-wrap: anywhere; }
.share-card .button-wide { margin-top: var(--s-5); }
.share-path { margin-top: var(--s-4); font-family: var(--font-mono); font-size: var(--t-xs); color: var(--text-subtle); overflow-wrap: anywhere; }
.share-folder-list { display: grid; gap: var(--s-1); margin-block: var(--s-4); text-align: left; }
.share-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
  font-size: var(--t-base);
}
.share-entry a { color: var(--accent-text); font-weight: 540; }

/* 16. Utilities & motion --------------------------------------------------- */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.hidden, .is-hidden { display: none !important; }

@media (max-width: 900px) {
  .settings-grid { grid-template-columns: 1fr; }
  .feature-grid { grid-template-columns: 1fr; }
  .section-heading, .content-heading, .share-page-heading { flex-direction: column; align-items: stretch; }
  .file-folder-actions { width: 100%; }
  .folder-file-search { flex: 1 1 200px; width: auto; }
  /* Sidebar becomes an off-canvas drawer; the scrim is body::after so no
     markup is needed for it. */
  .app-shell { display: block; width: calc(100% - var(--s-8)); }
  .app-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(280px, 84vw);
    z-index: 60;
    background: var(--surface);
    border-right: 1px solid var(--border);
    transform: translateX(-102%);
    transition: transform .18s var(--ease);
    padding: var(--s-5) var(--s-4);
    min-height: 0;
    max-height: none;
  }
  body.nav-open .app-sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open { overflow: hidden; }
  body.nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(10, 13, 18, .45);
  }
  .nav-toggle { display: inline-grid; }
}
@media (max-width: 720px) {
  .site-header, .site-footer, .page-shell { width: calc(100% - var(--s-6)); }
  .app-header { padding-inline: var(--s-3); }
  .account-name { display: none; }
  .header-link { padding-inline: var(--s-2); }
  /* CHG-569: at 420px the nav overflowed and clipped "Log out" once the links
     were told not to wrap. Let the bar take a second row instead of hiding or
     truncating a control. */
  .app-header { height: auto; min-height: var(--bar-h); flex-wrap: wrap; padding-block: var(--s-2); row-gap: var(--s-1); }
  .app-header .site-nav { margin-left: auto; flex: 0 0 auto; }
  .hero-section { padding-block: var(--s-10) var(--s-8); }
  .auth-card { padding: var(--s-6); }
  .card { padding: var(--s-5); }
  .upload-toast { right: var(--s-3); left: var(--s-3); bottom: var(--s-3); width: auto; }
  .file-row { grid-template-columns: auto auto 1fr auto; }
  .share-manager-row { flex-direction: column; align-items: stretch; }
}
@media (max-width: 560px) {
  .account-row { align-items: flex-start; flex-direction: column; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
