:root {
  --bg: #f2f4f7;
  --panel: #ffffff;
  --border: #e2e6ec;
  --text: #22242a;
  --muted: #7a828e;
  --accent: #0082c9;
  --accent-dark: #006ba3;
  --danger: #d93b3b;
  --row-hover: #f6f9fc;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* ---------- Top navigation ---------- */
.topbar {
  /* Height is auto with a 56px floor and the row may wrap: with a fixed
     height and no wrap, viewports too narrow for all five items pushed
     the last one - the user menu, the only way to Settings and Sign out -
     past the right edge, unreachable until the phone was rotated. Desktop
     fits one line and looks exactly as before. */
  height: auto;
  min-height: 56px;
  flex-wrap: wrap;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
}
.topbar .brand {
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.3px;
}
.topbar .brand span { opacity: 0.85; font-weight: 400; }
.topbar .brand .brand-version {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.55;
  margin-left: 7px;
}
.topbar .spacer { flex: 1; }

/* Topbar user menu: the name is the button, the items live in a dropdown
   below it (settings + sign out). */
.user-menu { position: relative; }
.user-btn {
  display: flex;
  align-items: center;
  gap: 6px;
}
.user-btn .caret { font-size: 10px; opacity: 0.8; }
.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  display: flex;
  flex-direction: column;
  min-width: 160px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.18);
}
/* The dropdown sits inside the blue topbar DOM-wise (via .user-menu), so
   these selectors have to out-specify `.topbar button` - same specificity,
   and that rule comes later in the file. Without the extra .topbar prefix
   the dropdown items would paint white text onto the white panel and be
   invisible in light mode. */
.topbar .user-dropdown button {
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 8px 11px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}
.topbar .user-dropdown button:hover { background: var(--row-hover); }
.topbar .storage {
  font-size: 13px;
  opacity: 0.75;
  margin-right: 14px;
}
.topbar button {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}
.topbar button:hover { background: rgba(255, 255, 255, 0.28); }

/* ---------- Layout ---------- */
.container {
  max-width: 1000px;
  margin: 28px auto;
  padding: 0 20px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar .grow { flex: 1; }
/* View toggles in the toolbar ("Show hidden"): accent-filled while on, the
   same treatment the editor toolbar gives its active buttons. */
.toolbar .btn.secondary.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}
.btn:hover { background: var(--accent-dark); }
/* Toolbar buttons split icon and label: the label hides on phones
   (icon-only row), the icon keeps its place - an inline SVG at text
   height, currentColor so it follows the button's state colors. */
.btn-ico { margin-right: 5px; display: inline-flex; align-items: center; }
.btn-ico svg { width: 17px; height: 17px; display: block; }
.btn.secondary {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.secondary:hover { background: var(--row-hover); }
.editor-toolbar .btn.secondary.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #bf3131; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:disabled:hover { background: var(--accent); }
.btn.secondary:disabled:hover { background: var(--panel); }
.btn.danger:disabled:hover { background: var(--danger); }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--muted); }
.breadcrumb .current { color: var(--text); font-weight: 600; }

/* ---------- File list ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
/* Sortable columns: the whole header cell toggles the sort direction. The
   indicator is a triangle drawn with borders rather than a glyph, so the
   source stays ASCII; it is invisible until the column is the active sort
   and flips to point down for descending. */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text); }
th.sortable .arrow {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 6px;
  vertical-align: middle;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 5px solid currentColor;
  opacity: 0;
  transition: transform 0.15s, opacity 0.15s;
}
th.sortable.active .arrow { opacity: 1; }
th.sortable.desc .arrow { transform: rotate(180deg); }
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--row-hover); }
tbody tr { cursor: pointer; }

.name-cell { display: flex; align-items: center; gap: 12px; }
/* A long file name must wrap inside its cell instead of stretching the
   table past .panel (whose overflow: hidden would then clip it): the
   inner column may shrink, and unbreakable strings break anywhere. */
.name-cell > div { min-width: 0; overflow-wrap: anywhere; }
.icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #eaf4fb;
  font-size: 18px;
  flex-shrink: 0;
}
.icon.folder { background: #fff3d6; }
.name-cell .meta-mobile { display: none; }

/* Three-dot row menu */
.kebab {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 2px 9px;
  cursor: pointer;
  font-size: 19px;
  line-height: 1.4;
  color: var(--muted);
}
.kebab:hover { color: var(--text); background: var(--bg); }

.row-menu {
  position: fixed;
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-width: 155px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.18);
}
.row-menu-item {
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 7px 11px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}
.row-menu-item:hover { background: var(--row-hover); }
.row-menu-item.danger { color: var(--danger); }
.row-menu-item.danger:hover { background: var(--danger); color: #fff; }

.size-col { width: 110px; color: var(--muted); font-size: 14px; }
.date-col { width: 170px; color: var(--muted); font-size: 14px; }
.actions-col { width: 60px; text-align: right; }

/* ---------- Multi-selection (bulk operations) ---------- */
.check-col { width: 36px; text-align: center; padding-right: 0 !important; }
.check-col input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
}
tbody tr.selected,
tbody tr.selected:hover { background: rgba(0, 130, 201, 0.10); }

.bulkbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.bulkbar .grow { flex: 1; }
.bulkbar .btn { padding: 7px 13px; font-size: 13.5px; }
.bulk-count { font-size: 14px; font-weight: 600; }

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0082c9 0%, #006ba3 100%);
  padding: 20px;
}
.auth-card {
  background: var(--panel);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  padding: 36px;
  width: 100%;
  max-width: 380px;
}
.auth-card .logo {
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}
.auth-card .tagline {
  text-align: center;
  color: var(--muted);
  margin-bottom: 26px;
  font-size: 14px;
}
.auth-tabs {
  display: flex;
  margin-bottom: 22px;
  border-bottom: 2px solid var(--border);
}
.auth-tabs button {
  flex: 1;
  background: none;
  border: none;
  padding: 10px;
  cursor: pointer;
  font-size: 15px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.auth-tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
/* Shown only when JavaScript is off - the one visitor who cannot run the
   i18n dictionaries, so the text is bilingual and static (login page and
   app both carry it). Theme-aware: it appears in the dark theme too. */
.noscript-warn {
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: rgba(217, 59, 59, 0.1);
  color: var(--danger);
  font-size: 14px;
  line-height: 1.45;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text);
  font-weight: 500;
}
.field input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 15px;
  transition: border 0.15s, box-shadow 0.15s;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 130, 201, 0.12);
}

.auth-card .btn { width: 100%; padding: 12px; font-size: 15px; margin-top: 6px; }

.error-msg {
  background: #fdecec;
  color: var(--danger);
  border: 1px solid #f5c2c2;
  border-radius: 7px;
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

/* Neutral/good-news notice (e.g. "account created, awaiting activation"). */
.error-msg.success {
  background: #e8f6ee;
  color: #1e7e46;
  border-color: #b9e3cb;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Upload drop zone ---------- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  color: var(--muted);
  margin-bottom: 16px;
  transition: all 0.15s;
  cursor: pointer;
}
.dropzone.dragover {
  border-color: var(--accent);
  background: #eaf4fb;
  color: var(--accent);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .date-col, .size-col { display: none; }
  .name-cell .meta-mobile {
    display: block;
    font-size: 12px;
    color: var(--muted);
  }
  .actions-col { width: auto; }

  /* Toolbar: icon-only for EVERY button - the eight symbols are distinct
     (page/folder x plus/arrow, trash, trash+X, eye), so a row of squares
     needs no labels; the button's title is the tooltip - a long press on
     touch, a hover with a mouse. */
  .toolbar .btn .btn-label { display: none; }
  .toolbar .btn .btn-ico { margin-right: 0; }
  .toolbar .btn .btn-ico svg { width: 20px; height: 20px; }
  .toolbar .btn { min-height: 44px; }

  /* The topbar holds five items in one row; a phone cannot. The quota
     lives in Settings > Storage and the version in Settings too, so both
     drop here (the row itself may wrap - see the base rule), and a long
     display name ellipsizes instead of widening the row. The spacer is
     retired on phones: it only exists to push the right cluster along,
     and with margin-left on the menu the user menu stays pinned right -
     on one line or on its own wrapped line. */
  .topbar { padding: 6px 12px; gap: 8px; }
  .topbar .spacer { display: none; }
  .topbar .user-menu { margin-left: auto; }
  .topbar .storage { display: none; }
  .topbar .brand { font-size: 17px; }
  .topbar .brand .brand-version { display: none; }
  #user-label {
    display: inline-block;
    max-width: 40vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ---------- Sharing ---------- */
.shared-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: #eaf4fb;
  border-radius: 8px;
  padding: 1px 7px;
  vertical-align: middle;
  white-space: nowrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 32, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}
.modal {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  width: min(440px, calc(100vw - 32px));
  padding: 20px;
  /* A dialog whose content outgrows the screen must scroll *inside* rather
     than push its footer (the close button) below the fold - the share and
     user-admin dialogs both stack enough rows to need it. */
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.modal h3 { margin: 0 0 12px; font-size: 17px; }
.modal-footer { margin-top: 14px; display: flex; justify-content: flex-end; }

/* ---------- file preview (lightbox) ---------- */
.preview-modal {
  position: relative; /* the gallery arrows anchor to the panel */
  width: min(920px, calc(100vw - 32px));
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
}
.preview-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.preview-head .grow { flex: 1; }
.preview-head a { font-size: 13px; font-weight: 400; }
.preview-body {
  padding: 14px;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
}
.preview-body img,
.preview-body video { max-width: 100%; max-height: calc(100vh - 190px); }
.preview-body audio { width: min(480px, 100%); }
.preview-body iframe {
  width: 100%;
  height: calc(100vh - 190px);
  border: 0;
  background: #fff;
}
/* Android's Chromium cannot render PDFs inside a frame (app.js
   pdfNeedsNewTab): the lightbox explains that and offers the open
   button instead of showing a blank frame. */
.preview-body .pdf-open {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 420px;
  text-align: center;
}
.preview-body .pdf-open .empty-small { padding-top: 0; }
/* Gallery arrows: dark discs over the panel edges, one step per click.
   app.js hides them at the ends of the gallery (`hidden` attribute). */
.preview-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  cursor: pointer;
}
.preview-nav:hover { background: rgba(0, 0, 0, 0.7); }
.preview-nav[hidden] { display: none; }
.preview-nav.preview-prev { left: 10px; }
.preview-nav.preview-next { right: 10px; }
.preview-nav svg { width: 22px; height: 22px; display: block; }
tr.previewable { cursor: pointer; }

/* ---------- text editor (lightbox) ---------- */
.editor {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.editor-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap; /* status + meta + buttons share a phone-width row */
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.editor-status { color: var(--muted); min-width: 90px; }
.editor-status.unsaved { color: var(--danger); }
.editor-meta { color: var(--muted); }
.editor-toolbar .btn { padding: 4px 12px; font-size: 13px; }
.editor-main { display: flex; flex: 1; min-height: 0; }
.editor-main textarea {
  flex: 1;
  border: 0;
  resize: none;
  padding: 12px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  background: var(--panel);
  color: var(--text);
  outline: none;
  min-height: calc(100vh - 230px);
}
.editor-md {
  flex: 1;
  overflow: auto;
  padding: 12px 20px;
  border-left: 1px solid var(--border);
  background: #ffffff;
  color: #1c2128;
  font-size: 14px;
  line-height: 1.6;
}
.editor-md h1, .editor-md h2 {
  border-bottom: 1px solid #e2e5ea;
  padding-bottom: 4px;
}
.editor-md h1 { font-size: 1.5em; }
.editor-md h2 { font-size: 1.25em; }
.editor-md h3 { font-size: 1.1em; }
.editor-md pre {
  background: #f4f5f7;
  padding: 10px 12px;
  border-radius: 6px;
  overflow: auto;
  font-size: 13px;
}
.editor-md code {
  background: #f4f5f7;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 0.92em;
}
.editor-md pre code { background: none; padding: 0; }
.editor-md blockquote {
  margin: 0;
  padding-left: 12px;
  border-left: 3px solid #d4d9e0;
  color: #55606d;
}
.editor-md img { max-width: 100%; }
.editor-md table { border-collapse: collapse; }
.editor-md td, .editor-md th { border: 1px solid #d4d9e0; padding: 3px 8px; }

.empty-small { color: var(--muted); font-size: 13px; padding: 6px 0 10px; }

.share-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.share-info { display: flex; flex-direction: column; }
.share-user { font-weight: 600; }
.share-perms { font-size: 12px; color: var(--muted); }

.share-form { margin-top: 14px; display: flex; flex-direction: column; gap: 9px; }
.share-form input[type="text"],
.share-form select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.perm-checks { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.perm-checks label { display: flex; align-items: center; gap: 5px; cursor: pointer; }

/* The grantee's key fingerprint (5.5, DECISION 6): shown while picking, in
   a face that can be read aloud digit by digit; a *changed* key turns it
   into the warning it is. */
.share-fp { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); }
.share-fp.fp-warn { color: var(--danger); }

/* ---------- Public links (concepts/public_links.md section 7) ---------- */
.share-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.share-section h4 {
  margin: 0 0 3px;
  font-size: 14px;
}
.share-section .share-sub {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}
.public-form { display: flex; flex-direction: column; gap: 9px; }
.public-form select,
.public-form input[type="text"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.public-form .public-actions { display: flex; gap: 8px; align-items: center; }
.public-warn { color: var(--danger); font-size: 12px; }
.public-hidden-note { color: var(--muted); font-size: 12px; }

/* The one-time token box: shown the moment a link is minted, and it is the
   only place the raw token ever appears (the server stores only its hash). */
.public-created {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  padding: 9px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.public-created input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
.public-once {
  color: var(--danger);
  font-size: 12px;
  margin-top: 6px;
}

/* ---------- Public-link visitor page ---------- */
.visitor-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}
.visitor-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.visitor-head h1 {
  font-size: 20px;
  margin: 0;
  word-break: break-word;
}
.visitor-label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}
.visitor-crumb {
  font-size: 13px;
  margin-bottom: 12px;
  color: var(--muted);
}
.visitor-crumb a { color: var(--accent); cursor: pointer; text-decoration: none; }
.visitor-crumb a:hover { text-decoration: underline; }
.visitor-crumb .sep { margin: 0 6px; }
.visitor-crumb .current { color: var(--text); font-weight: 600; }
.visitor-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.visitor-toolbar .grow { flex: 1; }
.visitor-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.visitor-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.visitor-row:last-child { border-bottom: none; }
.visitor-row .v-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.visitor-row .v-name:hover { text-decoration: underline; }
.visitor-row .v-size {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.visitor-row .v-icon { flex-shrink: 0; }
.visitor-status {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 14px;
}
.visitor-status.error { color: var(--danger); }
.visitor-hidden { display: none; }
.visitor-foot {
  margin-top: 22px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* ---------- Move/Copy destination picker ---------- */
.pick-modal { width: min(500px, calc(100vw - 32px)); }
.pick-crumb {
  font-size: 13px;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  overflow-x: auto;
  white-space: nowrap;
}
.pick-crumb a { color: var(--accent); text-decoration: none; cursor: pointer; }
.pick-crumb a:hover { text-decoration: underline; }
.pick-crumb .sep { color: var(--muted); margin: 0 6px; }
.pick-crumb .current { font-weight: 600; }

.pick-list {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
}
.pick-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.pick-row:hover { background: var(--row-hover); }
.pick-name { flex: 1; }

/* ---------- Upload progress ---------- */
.upload-status {
  margin-top: 9px;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Client-side encryption (ENCRYPTION.md section 7) ---------- */

/* Header switch: reads as a state, not as an action, until it is clicked. */
.topbar .enc-badge {
  font-size: 12.5px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  white-space: nowrap;
}
.topbar .enc-badge.setup { background: rgba(255, 255, 255, 0.12); opacity: 0.9; }
.topbar .enc-badge.locked { background: rgba(0, 0, 0, 0.22); }
.topbar .enc-badge.unlocked { background: rgba(46, 160, 67, 0.55); }

/* A row whose bytes the server cannot read. */
.enc-mark {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #1a6b34;
  background: #e6f5ea;
  border-radius: 8px;
  padding: 1px 6px;
  margin-left: 4px;
  vertical-align: middle;
  white-space: nowrap;
}

.enc-modal { width: min(520px, calc(100vw - 32px)); }
.enc-pane { display: block; }

/* DECISION 3: the two storage-secret choices, login pre-selected. */
.enc-choice { margin-bottom: 16px; }
.enc-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.enc-option + .enc-option { margin-top: 8px; }
.enc-option input { margin: 0; accent-color: var(--accent); }
.enc-option.is-on {
  border-color: var(--accent);
  background: rgba(0, 130, 201, 0.07);
}
.enc-lead {
  margin: 0 0 12px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
}
.enc-lead strong { color: var(--text); }

/* Explicit, small, and never a colour that carries meaning on its own. */
.enc-status {
  min-height: 18px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}
.enc-status.error {
  color: var(--danger);
  background: #fdecec;
  border-radius: 7px;
  padding: 8px 10px;
}

/* The recovery key: monospaced, selectable, unambiguous about grouping. */
.enc-recovery {
  margin: 0;
  padding: 12px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: 1.5px;
  user-select: all;
  white-space: pre-wrap;
  word-break: break-all;
}
.enc-ack {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 12px;
  font-size: 13.5px;
  cursor: pointer;
}
.enc-ack input { margin-top: 3px; }

.hint {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.enc-fingerprint {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  letter-spacing: 1px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  user-select: all;
}

/* A secondary footer row inside the same pane (the recovery-key step). */
.enc-pane .modal-footer + .enc-ack + .hint + .modal-footer { margin-top: 10px; }
textarea#enc-rcv-key {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  resize: vertical;
}
textarea#enc-rcv-key:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 130, 201, 0.12);
}

/* ---------- user settings (topbar menu) ---------- */
/* The dialog never outgrows the viewport: its pane list is capped and the
   content column scrolls, so a long session list can no longer push the
   footer off-screen (the 0.0.33 complaint the nav layout answers). */
.settings-modal {
  width: min(640px, calc(100vw - 32px));
  max-height: min(86vh, 660px);
  display: flex;
  flex-direction: column;
}
.settings-layout {
  display: flex;
  gap: 18px;
  flex: 1;
  min-height: 0;
}
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 168px;
  flex: 0 0 auto;
  border-right: 1px solid var(--border);
  padding-right: 12px;
}
.settings-nav-btn {
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.settings-nav-btn:hover { background: var(--row-hover); }
.settings-nav-btn.active {
  background: var(--row-hover);
  color: var(--accent);
  font-weight: 600;
}
.settings-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding-right: 4px;
}
.settings-panel { margin-bottom: 18px; }
.settings-panel h4 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}
@media (max-width: 560px) {
  .settings-layout { flex-direction: column; gap: 12px; }
  .settings-nav {
    flex-direction: row;
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 0 0 8px;
    overflow-x: auto;
  }
}
.settings-info { display: flex; flex-direction: column; gap: 5px; font-size: 14px; }
.settings-info .label {
  display: inline-block;
  min-width: 110px;
  color: var(--muted);
}
.settings-form { display: flex; gap: 8px; }
.settings-form input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--panel);
  color: var(--text);
}
.settings-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 130, 201, 0.12);
}
#set-pass-form { flex-direction: column; }
.theme-picker { display: flex; gap: 8px; }
.theme-picker button {
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.theme-picker button:hover { border-color: var(--accent); }
.theme-picker button.active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.settings-status { min-height: 18px; margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.settings-status.error { color: var(--danger); }

/* ---- language switcher (i18n.js draws the dropdown into .lang-switch) ----
   Three hosts: the topbar, the settings dialog and the login card. A
   button shows the current flag and opens a menu with every language, so
   the row stays one button wide however many flags exist. The buttons are
   line-height 0 so the SVG flags sit on a stable baseline. */
.lang-switch { position: relative; display: inline-flex; align-items: center; }
.lang-current {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  line-height: 0;
  transition: border-color 0.15s, background 0.15s;
}
.lang-current:hover { border-color: var(--accent); }
.lang-current[aria-expanded="true"] {
  border-color: var(--accent);
  background: rgba(127, 127, 127, 0.14);
}
.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 70;
  min-width: 150px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
}
/* [hidden] must win over the flex below, so the base rule stays display-less. */
.lang-menu:not([hidden]) { display: flex; flex-direction: column; gap: 2px; }
.lang-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}
.lang-btn:hover { background: rgba(127, 127, 127, 0.16); }
.lang-btn.active { background: rgba(127, 127, 127, 0.22); font-weight: 600; }
.topbar .lang-current:hover { border-color: rgba(255, 255, 255, 0.7); }
.topbar .lang-current[aria-expanded="true"] {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.22);
}
/* The menu opens inside the blue topbar DOM-wise, so it walks into the
   same failure class the comment above .user-dropdown documents:
   `.topbar button` is more specific than the unprefixed .lang-btn and
   painted the language names white onto the menu's white panel - the
   light theme got white-on-white, unreadable - while also forcing the
   topbar's padding and sizing onto every row. Same remedy: the
   .topbar prefix, with hover and active restated as the dropdown does
   (an equally specific unprefixed hover would lose to this block). */
.topbar .lang-btn {
  padding: 6px 8px;
  border-radius: 5px;
  font-size: inherit;
  background: transparent;
  color: var(--text);
}
.topbar .lang-btn:hover { background: rgba(127, 127, 127, 0.16); }
.topbar .lang-btn.active { background: rgba(127, 127, 127, 0.22); }
.settings-lang { display: flex; }
.auth-lang { display: flex; justify-content: center; margin: 10px 0 2px; }

/* ---- passkeys (WebAuthn): login tab hint + settings device list ---- */
.auth-hint {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}
.settings-hint {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}
.passkey-list,
.session-list,
.version-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.passkey-empty { margin: 0; font-size: 13px; color: var(--muted); }
.passkey-row,
.session-row,
.version-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}
.passkey-meta,
.session-meta,
.version-meta { flex: 1; min-width: 0; }
.passkey-label,
.session-label,
.version-time {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.passkey-sub,
.session-sub,
.version-sub { display: block; font-size: 12px; color: var(--muted); }
.passkey-actions,
.session-actions,
.version-actions { display: flex; gap: 6px; }
.passkey-actions button,
.session-actions button,
.version-actions button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  font-size: 12px;
  padding: 4px 9px;
  cursor: pointer;
}
.passkey-actions button:hover,
.session-actions button:hover,
.version-actions button:hover { background: var(--row-hover); }
.passkey-actions button.danger,
.session-actions button.danger,
.version-actions button.danger { color: var(--danger); border-color: var(--danger); }

/* ---------- user administration ---------- */
.admin-modal {
  width: min(760px, 94vw);
  /* Same column flex the settings dialog has: the nav-plus-panes layout
     fills the space and the footer (Close) stays pinned at the bottom. */
  display: flex;
  flex-direction: column;
}
.admin-table-wrap { max-height: 55vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.admin-table th, .admin-table td { padding: 10px 12px; font-size: 13.5px; }
/* Rows here are not clickable (unlike the file list), so the generic
   `tbody tr { cursor: pointer }` is undone. */
.admin-table tbody tr { cursor: default; }
.admin-table .admin-actions-col { width: 1%; white-space: nowrap; }
.admin-user-name { display: flex; flex-direction: column; gap: 2px; }
.admin-user-name .uname { font-weight: 600; }
.admin-user-name .udisplay { color: var(--muted); font-size: 12.5px; }
.admin-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}
.admin-badge.on  { background: #e6f4ea; color: #1e7e34; }
.admin-badge.off { background: #fdecea; color: #c0392b; }
.admin-badge.admin { background: #e8f0fe; color: #1a56c4; }
.admin-badge.member { background: #eef0f2; color: var(--muted); }
.admin-quota-cell { white-space: nowrap; }
.admin-quota-cell .used { color: var(--muted); font-size: 12.5px; }
.admin-row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.admin-row-actions .btn { padding: 5px 10px; font-size: 12.5px; }
.admin-quota-input {
  width: 90px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}
.admin-quota-input:focus { outline: none; border-color: var(--accent); }

/* ---------- Group folders (admin dialog + key distribution) ---------- */
/* The badge in the root listing tells a group folder apart from a personal
   one of the same name; purple, to stay clear of the share blue. */
.group-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #6b3fb5;
  background: #f1ecfb;
  border-radius: 8px;
  padding: 1px 7px;
  vertical-align: middle;
  white-space: nowrap;
}
.group-list {
  max-height: 40vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}
.group-list:empty { display: none; }
.group-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 11px;
  font-size: 13px;
}
.group-head { display: flex; align-items: center; gap: 10px; }
.group-head .gname { font-weight: 600; }
.group-head .gused { color: var(--muted); font-size: 12.5px; }
.group-head .grow { flex: 1; }
.group-head .btn { padding: 4px 9px; font-size: 12.5px; }
.group-members { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.group-member { display: flex; align-items: center; gap: 8px; }
.group-member .gwho { flex: 1; }
.group-member .btn { padding: 3px 8px; font-size: 12px; }
.group-add { display: flex; gap: 6px; margin-top: 8px; }
.group-add input {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}
.group-add input:focus { outline: none; border-color: var(--accent); }
.group-new { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.group-new input[type="text"] {
  flex: 1;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}
.group-new input:focus { outline: none; border-color: var(--accent); }
.group-empty { color: var(--muted); font-size: 13px; margin: 2px; }

/* Bootstrap + distribution dialogs (both reuse the compact modal width). */
#gfolder-group {
  width: 100%;
  margin: 6px 0 12px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  background: var(--bg);
  color: var(--text);
}
.gfolder-label { display: block; margin-top: 10px; font-size: 13px; color: var(--muted); }
#gfolder-name {
  width: 100%;
  margin-top: 6px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  background: var(--bg);
  color: var(--text);
}
#gfolder-name:focus, #gfolder-group:focus { outline: none; border-color: var(--accent); }
.distrib-rows { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 4px; }
.distrib-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}
.distrib-row .distrib-user { flex: 1; }
.distrib-row .btn { padding: 4px 9px; font-size: 12.5px; }
.distrib-empty { color: var(--muted); font-size: 13px; margin: 10px 0; }

/* Temporary-password dialog (result of an admin password reset) */
.reset-modal { width: min(460px, 92vw); }
.reset-user { margin: 6px 0 0; font-size: 14px; }
.reset-hint { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.reset-pass-box {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.reset-pass-box code {
  flex: 1;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1.5px;
  word-break: break-all;
  user-select: all;
}

/* ---------- dark theme ----------
   Only the palette flips; every component below reads the same variables,
   so one block repaints the whole app. Applied via data-theme on <html>,
   stored per account (migration 009_user_theme). */
[data-theme="dark"] {
  --bg: #14161b;
  --panel: #1c1f26;
  --border: #2a2e37;
  --text: #e6e9ee;
  --muted: #8b93a1;
  --row-hover: #22262e;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] body { background: var(--bg); color: var(--text); }
/* The preview iframe and the editor's markdown pane sit on paper-white on
   purpose in light mode; in dark mode they follow the panel so a full-page
   white flash does not burn the eyes. */
[data-theme="dark"] .preview-body iframe { background: var(--panel); }
[data-theme="dark"] .editor-md { background: var(--panel); color: var(--text); }
[data-theme="dark"] .icon.folder { background: #4a3d13; }

/* ---------- office editor overlay (concepts/office.md) ----------
   Full-bleed frame under a thin toolbar: the engine owns the viewport, the
   chrome above it is fxcloud's. Theme variables keep the toolbar in step
   with light/dark; the frame itself is always paper-white (an office
   document is paper, same call the preview pane makes in reverse). */
.office-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--panel);
  display: flex;
  flex-direction: column;
}
.office-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.office-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.office-frame {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  background: #fff;
}

/* ---------- Touch ---------- */
/* A finger is not a pointer. Two rules live here, both gated on the
   primary input device so a mouse-driven desktop keeps the current
   compact look: (1) tap targets grow towards the platform guidelines
   (Apple 44px, Material 48px) - row menu, kebab, checkboxes, buttons;
   (2) iOS Safari zooms the viewport into any focused field below 16px,
   the classic mobile bug, so every field gets its 16px on touch
   devices. No em-based sizing exists below, so the override is safe. */
@media (pointer: coarse) {
  .btn { padding: 13px 16px; }
  .bulkbar .btn { padding: 11px 14px; }
  .editor-toolbar .btn { padding: 9px 14px; }
  .topbar button { padding: 10px 14px; }
  .kebab { padding: 10px 12px; }
  .row-menu-item { padding: 11px 12px; }
  .check-col input { width: 22px; height: 22px; }
  input, textarea, select { font-size: 16px !important; }
}
