: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: 56px;
  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 { font-size: 14px; opacity: 0.95; }
.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; }

.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); }
.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;
}
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; }
.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;
}

.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; }
}

/* ---------- 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;
}
.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 {
  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;
}
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;
  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); }

/* ---------- 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);
}
