:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-alt: #1c202a;      /* folder tiles, dropzone, quota bar track's outer context */
  --input-bg: #0d0f14;       /* text inputs, quota track, mini-link boxes */
  --btn-bg: #232735;
  --btn-bg-hover: #2a2f3f;
  --border: #262b36;
  --text: #e8eaf0;
  --muted: #8b93a5;
  --accent: #5b8cff;
  --accent-hover: #4577ff;
  --accent-wash: rgba(91,140,255,0.12);   /* accent tinted backgrounds (success alert, dropzone hover) */
  --accent-wash-border: rgba(91,140,255,0.3);
  --danger: #ff6b6b;
  --danger-wash: rgba(255,107,107,0.12);  /* danger tinted backgrounds (error alert, danger btn hover) */
  --danger-wash-border: rgba(255,107,107,0.3);
  --radius: 10px;
}

/* Light theme — applied when the person toggles it (see partials/header.ejs). Every color
   above is a variable specifically so this override block is the only place that needs to
   define an alternate palette; nothing else in this file references a raw hex/rgba value. */
[data-theme="light"] {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-alt: #eef0f4;
  --input-bg: #ffffff;
  --btn-bg: #eef0f4;
  --btn-bg-hover: #e2e5ec;
  --border: #dde1e8;
  --text: #1a1d24;
  --muted: #5c6470;
  --accent: #3b6fe0;
  --accent-hover: #2f5cc4;
  --accent-wash: rgba(59,111,224,0.08);
  --accent-wash-border: rgba(59,111,224,0.25);
  --danger: #d64545;
  --danger-wash: rgba(214,69,69,0.08);
  --danger-wash-border: rgba(214,69,69,0.25);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
}
.brand { color: var(--text); font-weight: 700; font-size: 18px; text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 18px; }
.nav-links a { color: var(--muted); text-decoration: none; font-size: 14px; }
.nav-links a:hover { color: var(--text); }
.inline-form { display: inline; }
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 6px 9px;
}
.theme-toggle:hover { background: var(--btn-bg); }

.site-footer {
  text-align: center;
  padding: 20px 28px;
  border-top: 1px solid var(--border);
}
.site-footer a { color: var(--muted); font-size: 13px; text-decoration: none; }
.site-footer a:hover { color: var(--text); text-decoration: underline; }

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 48px 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 520px;
  margin: 0 auto;
}
.card.wide { max-width: 820px; }
.card.narrow { max-width: 400px; }

h1 { margin-top: 0; font-size: 24px; }
.card h2 { font-size: 18px; margin: 28px 0 10px; }
.card h2:first-of-type { margin-top: 20px; }
.card ul { margin: 8px 0; padding-left: 22px; }
.card li { margin: 4px 0; }
.file-detail-title { display: flex; align-items: center; gap: 12px; word-break: break-word; }
.file-detail-title-image { margin-bottom: 14px; }
.file-detail-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--panel-alt);
}
.file-detail-thumb-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
}
/* --- file-detail page: big inline image preview, so most images don't need downloading
   just to be viewed. Capped well below typical camera-original resolution/size (see
   lib/thumbnails.js "xl" — 1600px long edge) — big enough to actually view comfortably,
   far lighter than the real original. --- */
.file-preview-wrap {
  display: block;
  text-align: center;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 18px;
}
.file-preview-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 70vh;
  margin: 0 auto;
  border-radius: 6px;
  object-fit: contain;
}
.muted { color: var(--muted); font-size: 14px; }
.muted.small { font-size: 13px; margin-top: 20px; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert-error { background: var(--danger-wash); color: var(--danger); border: 1px solid var(--danger-wash-border); }
.alert-success { background: var(--accent-wash); color: var(--accent); border: 1px solid var(--accent-wash-border); }

.compress-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 12px;
  cursor: pointer;
}
.compress-toggle-locked { cursor: default; }
.compress-toggle input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}
.compress-toggle input:disabled { cursor: default; }

.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 260px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  margin: 20px 0;
  text-align: center;
  padding: 16px;
  transition: border-color .15s, background .15s;
}
.dropzone.dragover { border-color: var(--accent); background: var(--accent-wash); }
.dropzone input { display: none; }
.dropzone-inner { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.choose-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
#dropzoneLabel { color: var(--muted); font-size: 16px; }

/* Full-page drag-and-drop overlay — shown whenever a drag is over the document, so it's
   obvious files can be dropped anywhere on the upload page, not just inside .dropzone. */
.page-drop-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  background: var(--accent-wash);
  border: 4px dashed var(--accent);
  pointer-events: none; /* let the drop event pass through to the document listener */
}
.page-drop-overlay.active { display: flex; }
.page-drop-overlay-msg {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 28px;
  font-size: 18px;
  font-weight: 600;
}

.file-size-label { margin: -10px 0 14px; }
.file-list-names { font-size: 12.5px; word-break: break-word; }

.thumb-preview-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: -6px 0 14px;
}
.thumb-preview-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 64px;
}
.thumb-preview-item .file-thumb { width: 48px; height: 48px; border: 1px solid var(--border); }
.thumb-preview-name {
  font-size: 11px;
  color: var(--muted);
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.progress-wrap { margin: 10px 0 16px; }
.progress-track {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}
.progress-fill { background: var(--accent); height: 100%; border-radius: 999px; transition: width .15s ease; }
.progress-text { margin: 6px 0 0; font-size: 12.5px; }

.btn {
  display: inline-block;
  background: var(--btn-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn:hover { background: var(--btn-bg-hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger-wash); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-large { padding: 14px 24px; font-size: 16px; }
.btn-oauth { display: block; width: 100%; margin-bottom: 8px; }
.btn[disabled] { opacity: .6; cursor: default; }

.field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.link-row { display: flex; gap: 8px; margin-bottom: 20px; }
.link-row input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
}
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; }

.uploaded-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.uploaded-item:last-of-type { border-bottom: none; }
.share-link-input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
}

.stack-form { display: flex; flex-direction: column; gap: 14px; }
.stack-form label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.stack-form input {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
}
.stack-form .hint { font-size: 12px; color: var(--muted); }

.text-editor-area {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  min-height: 360px;
  resize: vertical;
  white-space: pre;
}

/* --- account settings page --- */
.section-heading { margin: 28px 0 6px; font-size: 16px; }
.identity-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.identity-row:last-of-type { border-bottom: none; }

/* --- merge confirmation preview --- */
.merge-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.stat-tile {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); }
.stat-label { margin-top: 4px; font-size: 13px; color: var(--muted); }
.hint-inline { font-size: 11.5px; }

.divider { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0; position: relative; }

.link-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0; text-decoration: underline; }
.link-btn:hover { color: var(--text); }
.link-btn.danger { color: var(--danger); }

.row-between { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }

.file-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 12px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.file-table th, .file-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.file-table th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.file-table a { color: var(--text); text-decoration: none; }
.file-table a:hover { color: var(--accent); }
.file-table th:first-child, .file-table td:first-child { width: 32px; padding-right: 0; }
.mini-link { width: 100%; background: var(--input-bg); border: 1px solid var(--border); border-radius: 6px; color: var(--muted); padding: 5px 8px; font-size: 12px; }

/* --- shared-folder view switch (gallery vs list) --- */
.view-toggle { display: inline-flex; gap: 2px; background: var(--panel-alt); border: 1px solid var(--border); border-radius: 8px; padding: 3px; margin: 4px 0 4px; }
.view-toggle-btn { background: none; border: none; border-radius: 6px; color: var(--muted); font-size: 13px; padding: 6px 12px; cursor: pointer; }
.view-toggle-btn:hover { color: var(--text); }
.view-toggle-btn.active { background: var(--btn-bg); color: var(--text); }

/* --- shared-folder gallery (big-image) view — the default whenever a folder has images --- */
.gallery-grid { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin: 14px 0 6px; }
.gallery-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 220px;
  text-decoration: none;
  color: var(--text);
}
.gallery-thumb {
  width: 220px;
  height: 220px;
  object-fit: contain; /* preserves the image's real aspect ratio — a gallery preview should look like the photo, not a cropped square icon */
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  flex-shrink: 0;
}
.gallery-thumb-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  line-height: 1;
}
.gallery-item:hover .gallery-thumb { border-color: var(--accent); }
.gallery-name {
  font-size: 13px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.gallery-item:hover .gallery-name { color: var(--accent); }

.icon-cell { width: 32px; padding-right: 0; }
.icon-cell a { display: block; line-height: 0; }
.name-cell { white-space: nowrap; }
.name-link { display: inline-block; }
.file-thumb {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--panel-alt);
}
.file-thumb-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  width: 32px;
  height: 32px;
}

.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 12px;
}

.quota { margin: 4px 0 24px; }
.quota-label { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; margin-bottom: 6px; }
.quota-track { background: var(--input-bg); border: 1px solid var(--border); border-radius: 999px; height: 8px; overflow: hidden; }
.quota-fill { background: var(--accent); height: 100%; border-radius: 999px; transition: width .2s ease; }
.quota-fill-warn { background: var(--danger); }

/* --- responsive "Downloads" column label: full word on desktop, "D" on mobile --- */
.short-label { display: none; }

/* --- breadcrumb --- */
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); text-decoration: underline; }
.breadcrumb a:last-of-type { color: var(--text); }
.crumb-sep { margin: 0 6px; color: var(--border); }

/* --- folder create/rename/delete controls --- */
.folder-toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.folder-rename-form, .new-folder-form { display: flex; align-items: center; gap: 8px; }
.btn-secondary { background: transparent; }
.btn-secondary:hover { background: var(--btn-bg); }
.mini-input {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  width: 160px;
}

/* --- subfolder tiles --- */
.folder-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.folder-tile {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}
.folder-tile:hover { border-color: var(--accent); background: var(--btn-bg-hover); }

/* --- per-file "move to folder" dropdown --- */
.mini-select {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 6px;
  font-size: 12px;
  max-width: 130px;
}

/* --- mobile layout: stacked top nav + the dashboard ("My files") table --- */
@media (max-width: 700px) {
  .topnav {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
  }
  .nav-links {
    width: 100%;
    flex-wrap: wrap;
    gap: 10px 16px;
  }
  .container {
    padding: 20px 0;
  }
  .card.wide {
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: 20px 10px;
  }
  .file-preview-wrap {
    padding: 0;
    border: none;
    background: none;
    border-radius: 0;
  }
  .file-preview-img { border-radius: 0; }
  .row-between {
    padding: 0 6px;
  }
  .quota {
    padding: 0 6px;
  }
  .breadcrumb, .folder-toolbar, .folder-grid {
    padding: 0 6px;
  }
  .mini-input { width: 120px; }
  .file-table {
    font-size: 12.5px;
  }
  .file-table th,
  .file-table td {
    padding: 8px 5px;
    white-space: nowrap;
  }
  .full-label { display: none; }
  .short-label { display: inline; }
  .gallery-grid {
    gap: 10px;
    padding: 0 6px;
    justify-content: center;
  }
  .gallery-item { width: 47%; }
  .gallery-thumb { width: 100%; height: 160px; }
}

/* Honeypot: hide off-screen rather than display:none — some bots skip fields
   that are display:none but still fill in ones that are merely positioned away. */
.hp-field {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
