/* myCloud web interface — corporate design system.
 *
 * One hand-written stylesheet, served from the binary. No build step, no CDN,
 * no icon font, no webfont CDN: Inter, the Lucide icons and the brand artwork
 * are all embedded, so the CSP stays at `default-src 'self'` and a page renders
 * in a single round trip on an air-gapped network.
 *
 * Structure
 *   1. fonts
 *   2. design tokens (light + dark)
 *   3. base typography, form controls, focus
 *   4. application shell (top bar, brand, nav, main)
 *   5. components (buttons, cards, tables, badges, dropzone, dialogs, toast)
 *   6. page pieces (login, settings, trash, shares, admin, preview)
 *   7. responsive, reduced motion, print
 *
 * Conventions
 *   · spacing uses the --s* scale, never raw pixels;
 *   · colour is always a token, so dark mode needs no component overrides;
 *   · `--accent` is the teal brand colour used for state, `--brand` is the navy
 *     used for surfaces such as the top bar and primary buttons.
 */

/* ------------------------------------------------------------------ 1. fonts */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/inter-regular.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/inter-medium.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/inter-semibold.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/inter-bold.woff2") format("woff2");
}

/* ----------------------------------------------------------------- 2. tokens */

:root {
  color-scheme: light dark;

  /* brand */
  --brand: #0b1f33;
  --brand-2: #12293f;
  --brand-3: #1b3a56;
  --teal: #12d6c4;
  --teal-deep: #0a9ba5;
  --coral: #ff6b57;

  /* surfaces */
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --surface-3: #e8eef6;
  --line: #e3e9f2;
  --line-strong: #cfd9e6;

  /* ink */
  --text: #101b2b;
  --muted: #5a6b82;
  --faint: #8494a8;

  /* semantic */
  --accent: #0b7c86;
  --accent-hover: #096a73;
  --accent-soft: #e4f7f6;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --danger-hover: #93190f;
  --danger-soft: #fdeceb;
  --ok: #0f6b4f;
  --ok-soft: #e6f5ef;
  --warn: #9a5406;
  --warn-soft: #fdf3e3;

  /* geometry */
  --radius-xs: 6px;
  --radius-sm: 9px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* spacing scale */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  /* elevation — two levels only: resting and lifted */
  --shadow-xs: 0 1px 2px rgba(11, 31, 51, .06);
  --shadow-sm: 0 1px 2px rgba(11, 31, 51, .05), 0 2px 8px -4px rgba(11, 31, 51, .12);
  --shadow: 0 2px 4px rgba(11, 31, 51, .04), 0 12px 28px -16px rgba(11, 31, 51, .28);
  --shadow-lg: 0 24px 64px -24px rgba(11, 31, 51, .45);

  --ring: 0 0 0 3px rgba(18, 214, 196, .42);
  --ease: cubic-bezier(.32, .72, 0, 1);
  --dur: 140ms;

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

  --topbar-h: 56px;
  --content-max: 1240px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #08192a;
    --brand-2: #0e2337;
    --brand-3: #16344d;

    --bg: #060f19;
    --surface: #0d1a27;
    --surface-2: #122232;
    --surface-3: #182c40;
    --line: #1d3147;
    --line-strong: #2a425c;

    --text: #e8eef7;
    --muted: #9db0c6;
    --faint: #75889f;

    --accent: #2fe0cd;
    --accent-hover: #6bebdc;
    --accent-soft: #0f3b3d;
    --accent-ink: #04211f;
    --danger: #ff8a7d;
    --danger-hover: #ffa79c;
    --danger-soft: #3a1512;
    --ok: #5fd6a8;
    --ok-soft: #0e3328;
    --warn: #f0b95f;
    --warn-soft: #34260c;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4), 0 2px 8px -4px rgba(0, 0, 0, .5);
    --shadow: 0 2px 6px rgba(0, 0, 0, .35), 0 16px 32px -20px rgba(0, 0, 0, .7);
    --shadow-lg: 0 24px 64px -20px rgba(0, 0, 0, .8);
    --ring: 0 0 0 3px rgba(47, 224, 205, .35);
  }
}

/* ------------------------------------------------------------------- 3. base */

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  font-feature-settings: "cv05" 1, "ss03" 1; /* Inter: single-storey a? no — keep defaults; these are safe alternates */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -.015em;
  color: var(--text);
}

h1 {
  font-size: 21px;
  line-height: 1.25;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
}

h3 {
  font-size: 14px;
  line-height: 1.35;
}

p {
  margin: 0 0 var(--s3);
}

a {
  color: var(--accent);
  text-decoration: none;
  border-radius: var(--radius-xs);
  transition: color var(--dur) var(--ease);
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.faint {
  color: var(--faint);
}

.small {
  font-size: 12.5px;
}

.mono,
pre,
code {
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-ligatures: none;
}

pre {
  margin: 0;
  padding: var(--s3) var(--s4);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 22rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.hr {
  height: 1px;
  margin: var(--s5) 0;
  background: var(--line);
  border: 0;
}

.spacer {
  flex: 1 1 auto;
}

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.inline {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  margin: 0;
}

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

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

/* Focus: one visible ring everywhere, keyboard-only. */
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
}

/* ---- form controls ------------------------------------------------------ */

/* Field rows: two controls per line where there is room, one where there is
   not. Uses auto-fit so a 360 px phone gets a single column without a query. */
.stack > .row,
form > .row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--s3);
  align-items: start;
}

label {
  display: block;
  margin: 0 0 var(--s1);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .01em;
}

label.check {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

input[type="text"],
input[type="search"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 8px 11px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13.5px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    background-color var(--dur) var(--ease);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--faint);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

input[type="checkbox"],
input[type="radio"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

select {
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

input[type="submit"] {
  width: auto;
}

/* -------------------------------------------------------------- 4. shell */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--s5);
  height: var(--topbar-h);
  padding: 0 var(--s5);
  color: #eaf2fb;
  background: linear-gradient(180deg, var(--brand-2) 0%, var(--brand) 100%);
  border-bottom: 1px solid rgba(18, 214, 196, .28);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, var(--shadow-sm);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #ffffff;
  text-decoration: none;
  border-radius: var(--radius-sm);
  padding: 4px 2px;
  flex: 0 0 auto;
}

.brand:hover {
  color: #ffffff;
  text-decoration: none;
}

.brand .mark,
.mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
}

.brand .mark svg,
.mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

.brand .label,
.brand .wordmark {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -.022em;
  line-height: 1;
}

.brand .label::first-letter {
  letter-spacing: -.022em;
}

/* a <label> that behaves like a primary button (opens the file picker) */
label.btn {
  cursor: pointer;
}

label.btn:focus-within {
  box-shadow: var(--ring);
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: var(--s1);
  height: 100%;
}

.topbar nav a {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  height: 34px;
  padding: 0 var(--s3);
  color: #c6d6e6;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.topbar nav a:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, .08);
  text-decoration: none;
}

.topbar nav a[aria-current="page"],
.topbar nav a.active {
  color: #ffffff;
  background: rgba(18, 214, 196, .16);
  box-shadow: inset 0 -2px 0 var(--teal);
}

.topbar .icon,
.topbar svg.icon {
  width: 16px;
  height: 16px;
  opacity: .9;
}

.who {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  max-width: 240px;
  padding: 3px 4px 3px 3px;
  color: #e8eff8;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
}

.who .name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: var(--radius-pill);
  color: var(--brand);
  background: var(--teal);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .12);
}

.avatar.big {
  width: 40px;
  height: 40px;
  font-size: 15px;
}

.topbar button.ghost,
.topbar .btn.ghost {
  color: #d5e2ef;
  background: transparent;
  border-color: rgba(255, 255, 255, .18);
  box-shadow: none;
}

.topbar button.ghost:hover,
.topbar .btn.ghost:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .3);
}

main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s6) var(--s5) var(--s7);
}

.page-head {
  display: flex;
  align-items: flex-end;
  gap: var(--s4);
  margin: 0 0 var(--s5);
  flex-wrap: wrap;
}

.page-head h1 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.page-head .sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.page-head .actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-left: auto;
  flex-wrap: wrap;
}

/* breadcrumbs */
.crumbs {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  margin: 0 0 var(--s2);
  padding: 0;
  list-style: none;
  color: var(--faint);
  font-size: 12.5px;
}

.crumbs a,
.crumbs .sep {
  color: var(--faint);
}

.crumbs a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.crumbs a .icon {
  width: 14px;
  height: 14px;
}

.crumbs .sep {
  padding: 0 6px;
  opacity: .7;
}

.crumbs [aria-current="page"] {
  color: var(--text);
  font-weight: 500;
}

.section-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin: 0 0 var(--s3);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .075em;
  text-transform: uppercase;
}

.section-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ----------------------------------------------------------- 5. components */

/* ---- buttons ------------------------------------------------------------ */

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease), color var(--dur) var(--ease);
}

button:hover,
.btn:hover {
  background: var(--surface-2);
  border-color: var(--faint);
  text-decoration: none;
}

button:active,
.btn:active {
  transform: translateY(.5px);
  box-shadow: none;
}

button .icon,
.btn .icon {
  width: 15px;
  height: 15px;
}

/* primary — the brand navy in light mode, teal in dark mode */
button.primary,
button[type="submit"]:not(.ghost):not(.quiet):not(.danger),
.btn.primary {
  color: #ffffff;
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: var(--shadow-sm);
}

button.primary:hover,
button[type="submit"]:not(.ghost):not(.quiet):not(.danger):hover,
.btn.primary:hover {
  color: #ffffff;
  background: var(--brand-3);
  border-color: var(--brand-3);
}

@media (prefers-color-scheme: dark) {

  button.primary,
  button[type="submit"]:not(.ghost):not(.quiet):not(.danger),
  .btn.primary {
    color: var(--accent-ink);
    background: var(--teal);
    border-color: var(--teal);
  }

  button.primary:hover,
  button[type="submit"]:not(.ghost):not(.quiet):not(.danger):hover,
  .btn.primary:hover {
    color: var(--accent-ink);
    background: var(--accent-hover);
    border-color: var(--accent-hover);
  }
}

/* ghost — outlined, transparent */
button.ghost,
.btn.ghost {
  color: var(--text);
  background: transparent;
  border-color: var(--line-strong);
  box-shadow: none;
}

button.ghost:hover,
.btn.ghost:hover {
  background: var(--surface-2);
  border-color: var(--faint);
}

/* quiet — icon-only, no chrome until hover */
button.quiet,
.btn.quiet {
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

button.quiet:hover,
.btn.quiet:hover {
  color: var(--text);
  background: var(--surface-3);
  border-color: transparent;
}

button.danger,
.btn.danger {
  color: var(--danger);
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  box-shadow: none;
}

button.danger:hover,
.btn.danger:hover {
  color: #ffffff;
  background: var(--danger);
  border-color: var(--danger);
}

button.danger.solid,
.btn.danger.solid {
  color: #ffffff;
  background: var(--danger);
  border-color: var(--danger);
}

button.danger.solid:hover,
.btn.danger.solid:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

button[disabled],
.btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
}

/* a link that looks like a subtle action */
.link {
  color: var(--accent);
  font-weight: 500;
}

/* ---- cards -------------------------------------------------------------- */

.card {
  padding: var(--s5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

/* Cards that host their own layout (a table, a card-head, an explicit body, a
   flush list) supply their own padding. Markup in the wild mixes both forms, so
   this is handled structurally rather than by asking every template to agree. */
.card.flush,
.card:has(> .card-body),
.card:has(> .card-head),
.card:has(> table),
.card:has(> .filelist) {
  padding: 0;
}

/* A card that hosts a file list must NOT clip: the per-row action menu is a
   native <details> popover and has to be able to hang outside the table. The
   rounded corners are then drawn by the table cells themselves. */
.card.flush:has(> .filelist),
.card:has(> .filelist) {
  overflow: visible;
}

.filelist thead th:first-child {
  border-top-left-radius: calc(var(--radius-lg) - 1px);
}

.filelist thead th:last-child {
  border-top-right-radius: calc(var(--radius-lg) - 1px);
}

.filelist tbody tr:last-child td:first-child {
  border-bottom-left-radius: calc(var(--radius-lg) - 1px);
}

.filelist tbody tr:last-child td:last-child {
  border-bottom-right-radius: calc(var(--radius-lg) - 1px);
}

.card > * + * {
  margin-top: var(--s4);
}

.card > h2 {
  margin-bottom: 2px;
}

.card > p.muted {
  margin-top: -2px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 55%, var(--surface));
}

.card-head h2 {
  font-size: 14px;
  font-weight: 600;
}

.card-head .hint {
  color: var(--faint);
  font-size: 12.5px;
}

.card-body {
  padding: var(--s5);
}

.card-body > * + * {
  margin-top: var(--s4);
}

.card.flush .card-body {
  padding: 0;
}

/* ---- pills and badges --------------------------------------------------- */

.pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .01em;
  text-transform: none;
  white-space: nowrap;
}

.pill.accent,
.badge.accent {
  color: var(--accent);
  background: var(--accent-soft);
}

.pill.ok,
.badge.ok {
  color: var(--ok);
  background: var(--ok-soft);
}

.pill.danger,
.badge.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.pill .icon,
.badge .icon {
  width: 12px;
  height: 12px;
}

/* ---- toolbar ------------------------------------------------------------ */

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin: 0 0 var(--s4);
  flex-wrap: wrap;
}

.toolbar form {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  margin: 0;
}

.toolbar input[type="search"] {
  width: 232px;
}

/* ---- file list (real table) --------------------------------------------- */

.filelist {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}

/* `table-layout: fixed` is only correct for the file browser, whose template
   ships a <colgroup>. The admin/trash/version tables have their own column
   counts and must size to content. */
.filelist:has(> colgroup) {
  table-layout: fixed;
}

/* action cells: a row of controls, right aligned */
.filelist .row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.filelist thead th {
  padding: 9px var(--s4);
  color: var(--faint);
  background: color-mix(in srgb, var(--surface-2) 70%, var(--surface));
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.filelist thead th.size,
.filelist thead th.actions,
.filelist thead th.row-actions {
  text-align: right;
}

.filelist tbody td {
  padding: 9px var(--s4);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.filelist tbody tr:last-child td {
  border-bottom: 0;
}

.filelist tbody tr {
  transition: background-color var(--dur) var(--ease);
}

.filelist tbody tr:hover {
  background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface));
}

.filelist tbody tr.selected {
  background: var(--accent-soft);
}

.filelist .name-cell {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
}

/* Explicit column widths: with `table-layout: fixed` the name column takes the
   remaining space and can never push the actions out of the card. */
.filelist col.col-name { width: auto; }
.filelist col.col-size { width: 116px; }
.filelist col.col-time { width: 176px; }
.filelist col.col-actions { width: 56px; }

.filelist .name-cell a.n,
.filelist .name-cell .n {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filelist .name-cell a.n:hover {
  color: var(--accent);
}

.filelist .name-cell a,
.filelist .name-cell .name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filelist .name-cell a:hover {
  color: var(--accent);
}

.filelist .name-cell .name {
  cursor: default;
}

.type-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: var(--radius-sm);
  color: var(--accent);
  background: var(--accent-soft);
}

.type-icon .icon {
  width: 16px;
  height: 16px;
}

.type-icon.dir,
.type-icon.folder {
  color: var(--teal-deep);
  background: color-mix(in srgb, var(--teal) 16%, transparent);
}

.type-icon.deleted {
  color: var(--muted);
  background: var(--surface-3);
}

.filelist .size,
.filelist .time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.filelist td.size {
  text-align: right;
  white-space: nowrap;
}

.filelist td.actions,
.filelist td.row-actions {
  text-align: right;
  white-space: nowrap;
}

.filelist .orig-path {
  display: block;
  margin-top: 2px;
  color: var(--faint);
  font-size: 12px;
}

.filelist .shared,
.filelist .badge.shared {
  margin-left: var(--s2);
}

/* a directory row reads as a folder, a deleted row as de-emphasised */
.filelist tr.dir .name-cell .name,
.filelist tr.dir .name-cell a {
  font-weight: 500;
}

.filelist tr.deleted .name-cell a,
.filelist tr.deleted .name-cell .name {
  color: var(--muted);
}

.empty-row td {
  padding: var(--s7) var(--s4) !important;
  border-bottom: 0 !important;
  text-align: center;
}

/* ---- empty state -------------------------------------------------------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  padding: var(--s5) var(--s4);
  color: var(--muted);
  text-align: center;
}

.empty strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.empty p {
  margin: 0;
  font-size: 13px;
  max-width: 46ch;
}

.empty h3 {
  margin: var(--s1) 0 0;
  font-size: 15px;
}

/* the icon disc above the message */
.empty .bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
}

/* an empty state inside its own card needs no second frame */
.card.flush:has(> .empty) {
  border: 0;
  background: transparent;
  box-shadow: none;
}

/* ---- dropzone ----------------------------------------------------------- */

.toolbar .newfolder .field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-left: 10px;
  color: var(--faint);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.toolbar .newfolder .field:focus-within {
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.toolbar .newfolder .field .icon {
  width: 15px;
  height: 15px;
}

.toolbar .newfolder .field input {
  width: 200px;
  padding-left: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.toolbar .newfolder .field input:focus {
  box-shadow: none;
}

.quota {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-top: var(--s4);
}

.quota .meter {
  width: 180px;
}

.empty .icon {
  width: 30px;
  height: 30px;
  color: var(--faint);
}

.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  padding: 9px var(--s4);
  margin: 0 0 var(--s3);
  color: var(--muted);
  background: color-mix(in srgb, var(--surface-2) 60%, var(--surface));
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.3;
  text-align: center;
  /* The German hint is noticeably longer than the English one, so the line has
     to be able to wrap instead of pushing the zone wider than the page. */
  flex-wrap: wrap;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease),
    color var(--dur) var(--ease);
}

.dropzone strong {
  color: var(--text);
  font-weight: 600;
}

/* "choose files" is a <label> that opens the picker; the global label rule
   makes labels block-level, which would break the dropzone onto two lines. */
.dropzone label {
  display: inline;
  margin: 0;
  color: var(--accent);
  font-size: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.dropzone label:hover {
  color: var(--accent-hover);
}

.dropzone .icon {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.dropzone.active,
.dropzone.dragover {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* ---- key/value, meter --------------------------------------------------- */

/* One grid for the whole list, so every value starts at the same x — a grid per
   row would align each row against its own widest label. `display: contents`
   on the row wrapper lets its two cells join this grid. */
.kv {
  display: grid;
  grid-template-columns: minmax(132px, max-content) minmax(0, 1fr);
  gap: 8px var(--s5);
  margin: 0;
  font-size: 13px;
}

/* Two shapes exist in the templates: a flat <dt>/<dd> list and a wrapper
   <div> per row holding <span class="k">/<span class="v">. Both are normalised
   here so labels line up in one column. */
.kv > div {
  display: contents;
}

.kv dt,
.kv .k {
  color: var(--muted);
  font-weight: 500;
  align-self: baseline;
}

.kv dd,
.kv .v {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.kv .n {
  font-variant-numeric: tabular-nums;
}

.meter,
.bar {
  position: relative;
  height: 8px;
  overflow: hidden;
  background: var(--surface-3);
  border-radius: var(--radius-pill);
}

.meter > span,
.bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width var(--dur) var(--ease);
}

.bar.warn > span {
  background: var(--warn);
}

.bar.danger > span {
  background: var(--danger);
}

/* ---- share rows --------------------------------------------------------- */

.share-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.share-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 10px var(--s3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.share-row .icon {
  width: 16px;
  height: 16px;
  color: var(--faint);
}

.share-form {
  display: flex;
  align-items: flex-end;
  gap: var(--s2);
  flex-wrap: wrap;
}

.share-form > div {
  flex: 1 1 180px;
}

/* ---- dialogs ------------------------------------------------------------ */

dialog {
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: min(760px, calc(100vw - 32px));
  width: 100%;
}

dialog::backdrop {
  background: rgba(6, 15, 25, .55);
  backdrop-filter: blur(3px);
}

.dialog-body,
.panel-body,
.preview-body {
  padding: var(--s4) var(--s4) var(--s5);
}

.dialog-body h3,
#preview-title,
#panel-title {
  font-size: 14px;
  font-weight: 600;
}

.preview-body {
  max-height: 74vh;
  overflow: auto;
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.preview-body img,
.preview-body video {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: var(--radius-sm);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.panel .icon {
  width: 15px;
  height: 15px;
}

/* ---- flash / toast ------------------------------------------------------ */

.flash {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 10px var(--s3);
  margin: 0 0 var(--s4);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text);
  font-size: 13px;
}

.flash .icon {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.flash.error {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.flash.error .icon {
  color: var(--danger);
}

.flash.ok {
  border-left-color: var(--ok);
  background: var(--ok-soft);
}

.flash.ok .icon {
  color: var(--ok);
}

#flash.toast {
  position: fixed;
  right: var(--s5);
  bottom: var(--s5);
  z-index: 90;
  margin: 0;
  box-shadow: var(--shadow);
}

/* ---- row action menu ----------------------------------------------------
 * Markup: <details class="menu"><summary aria-label="Actions">…</summary>
 *           <div class="sheet">…items…</div></details>
 * No JavaScript: <details> opens natively, which keeps the CSP strict and the
 * menu usable with the keyboard alone.
 */

.menu {
  position: relative;
  display: inline-block;
  text-align: left;
}

.menu > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  list-style: none;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu > summary:hover,
.menu[open] > summary {
  color: var(--text);
  background: var(--surface-3);
}

/* The last row opens upwards: a menu that hangs below the final row would fall
   off the page. No JavaScript, no measurement — the row position is the cue. */
.filelist tbody tr:nth-last-child(-n + 2) .menu[open] > .sheet {
  top: auto;
  bottom: calc(100% + 4px);
}

.menu[open] > .sheet {
  max-height: min(70vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 224px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
}

/* Every item in the popover — the download link, the dialog triggers, the
   rename field and the delete button — is the same 32 px row on the left edge.
   `flex-direction`/`justify-content` are stated explicitly because the generic
   `.panel` block and the global `button` rule would otherwise stack the icon
   above the label and centre both. */
.menu[open] > .sheet > a,
.menu[open] > .sheet > form > button {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: var(--s2);
  width: 100%;
  height: 32px;
  margin: 0;
  padding: 0 var(--s2);
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: var(--radius-xs);
  box-shadow: none;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  text-align: left;
  text-decoration: none;
}

.menu[open] > .sheet > a:hover,
.menu[open] > .sheet > form > button:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

.menu[open] > .sheet > a .icon,
.menu[open] > .sheet > form > button .icon {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--muted);
}

.menu[open] > .sheet > .sep {
  height: 1px;
  margin: 5px 0;
  background: var(--line);
}

/* the inline rename form inside the menu */
.menu[open] > .sheet form.rename {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px var(--s2) 2px;
}

.menu[open] > .sheet form.rename label {
  margin: 0;
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.menu[open] > .sheet form.rename .row {
  display: flex;
  gap: var(--s2);
}

.menu[open] > .sheet form.rename .row input {
  height: 30px;
  min-width: 0;
  flex: 1;
}

.menu[open] > .sheet form.rename .row button {
  justify-content: center;
  width: 34px;
  height: 30px;
  padding: 0;
  color: #ffffff;
  background: var(--brand);
}

/* delete sits at the end of the same menu */
.menu[open] > .sheet > form[action="/ui/delete"] > button,
.menu[open] > .sheet button.danger {
  color: var(--danger);
}

.menu[open] > .sheet > form[action="/ui/delete"] > button .icon {
  color: currentColor;
}

.menu[open] > .sheet > form[action="/ui/delete"] > button:hover,
.menu[open] > .sheet button.danger:hover {
  color: #ffffff;
  background: var(--danger);
}

/* ---- legacy inline-block helpers used by older markup ------------------- */

.i {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s4);
}

.bubble {
  display: inline-block;
  padding: 2px 8px;
  background: var(--surface-3);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: 12px;
}

.check {
  color: var(--ok);
  font-weight: 600;
}

.hint {
  color: var(--faint);
  font-size: 12.5px;
}

/* --------------------------------------------------------------- 6. pages */

/* ---- sign-in ------------------------------------------------------------ */

.login-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  min-height: 100vh;
  background: var(--bg);
}

/* The sign-in screen is a full-bleed split view: no app bar above it. */
body.login main {
  padding: 0;
  max-width: none;
}

body.login .topbar {
  display: none;
}

.login-card .brand.logo img {
  display: block;
  width: 186px;
  height: auto;
}

.login-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--s4);
  width: min(400px, calc(100vw - 48px));
  margin: 0 auto;
  padding: var(--s7) 0;
}

.login-card .brand {
  color: var(--text);
  margin-bottom: var(--s4);
}

.login-card .brand .label {
  color: var(--text);
}

.login-card h1 {
  font-size: 24px;
  letter-spacing: -.02em;
}

.login-card .sub {
  margin: -8px 0 var(--s4);
  color: var(--muted);
  font-size: 13.5px;
  /* avoid a one-word last line in a two-line paragraph */
  text-wrap: pretty;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.login-card form button[type="submit"] {
  height: 38px;
  margin-top: var(--s1);
}

.login-card .hint {
  margin-top: var(--s4);
  color: var(--faint);
  font-size: 12.5px;
  text-align: left;
}

.login-art {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--s4);
  padding: var(--s7);
  color: #eaf2fb;
  background: linear-gradient(160deg, var(--brand-2) 0%, var(--brand) 62%, #06121f 100%);
  overflow: hidden;
}

.login-art::before {
  content: "";
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 70%;
  background:
    radial-gradient(46% 60% at 24% 18%, rgba(18, 214, 196, .30) 0%, transparent 70%),
    radial-gradient(40% 52% at 82% 8%, rgba(10, 155, 165, .34) 0%, transparent 72%);
  filter: blur(6px);
  pointer-events: none;
}

.login-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(120% 90% at 70% 20%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(120% 90% at 70% 20%, #000 0%, transparent 78%);
  pointer-events: none;
}

.login-art > * {
  position: relative;
  z-index: 1;
}

.login-art h2 {
  color: #ffffff;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -.02em;
  max-width: 22ch;
}

.login-art p {
  margin: 0;
  max-width: 42ch;
  color: #b9cbdd;
  font-size: 13.5px;
  text-wrap: pretty;
}

/* Four capability pills, arranged 2 x 2 so the block reads as a grid instead of
   a row that wraps into a lonely fourth item. */
.login-art ul {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: var(--s2);
  margin: var(--s2) 0 0;
  padding: 0;
  list-style: none;
}

.login-art li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  color: #d9e6f3;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
}

.login-art li .icon {
  width: 13px;
  height: 13px;
  color: var(--teal);
}

/* ---- settings / admin --------------------------------------------------- */

.sheet form,
.card-body form {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.dir {
  display: flex;
  align-items: center;
  gap: var(--s3);
}

/* ---- reduced motion, print --------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* below 900px: the sign-in art becomes a header band */
@media (max-width: 900px) {
  .login-wrap {
    grid-template-columns: 1fr;
  }

  .login-art {
    order: -1;
    min-height: 220px;
    padding: var(--s5);
  }

  .login-art h2 {
    font-size: 18px;
  }

  .login-art p {
    display: none;
  }
}

/* below 760px: table becomes a list of two-line rows */
@media (max-width: 760px) {
  /* Two rows: identity and the account on the first, the section links on a
     scrollable second row. Nothing is hidden behind a hamburger, so the UI is
     fully usable without JavaScript. */
  .topbar {
    flex-wrap: wrap;
    gap: 0 var(--s2);
    height: auto;
    padding: 0 var(--s3);
  }

  .topbar .brand {
    height: 48px;
  }

  .topbar nav {
    order: 3;
    flex: 1 0 100%;
    height: 44px;
    gap: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    border-top: 1px solid rgba(255, 255, 255, .08);
  }

  .topbar nav::-webkit-scrollbar {
    display: none;
  }

  .topbar nav a {
    flex: 0 0 auto;
    padding: 0 var(--s2);
    white-space: nowrap;
  }

  .topbar .spacer {
    display: none;
  }

  .topbar .who {
    margin-left: auto;
    max-width: none;
  }

  /* the avatar stands in for the name — it carries the initial and the tooltip */
  .topbar .who .name {
    display: none;
  }

  .topbar .hide-sm,
  .hide-sm {
    display: none;
  }

  main {
    padding: var(--s4) var(--s3) var(--s6);
  }

  .toolbar input[type="search"] {
    width: 100%;
  }

  .filelist thead {
    display: none;
  }

  .filelist,
  .filelist tbody,
  .filelist tr,
  .filelist td {
    display: block;
    width: auto;
  }

  .filelist tbody tr {
    position: relative;
    padding: var(--s3);
    border-bottom: 1px solid var(--line);
  }

  .filelist tbody td {
    padding: 0;
    border: 0;
  }

  .filelist .size,
  .filelist .time {
    display: inline;
    width: auto;
    margin-top: 4px;
    font-size: 12px;
  }

  .filelist .size::after {
    content: " · ";
    color: var(--faint);
  }

  .filelist .actions,
  .filelist .row-actions {
    position: absolute;
    top: var(--s2);
    right: var(--s2);
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .kv .k,
  .kv dt {
    margin-top: var(--s2);
  }

  .page-head .actions {
    margin-left: 0;
    width: 100%;
  }

  dialog {
    max-width: calc(100vw - 16px);
    margin: 8px auto;
  }
}

@media print {

  .topbar,
  .toolbar,
  .actions,
  .dropzone,
  dialog {
    display: none !important;
  }

  body {
    background: #ffffff;
    color: #000000;
    font-size: 11pt;
  }

  .card {
    border-color: #999999;
    box-shadow: none;
  }
}
