:root {
  /* "almost dark" — dark bg, but panels sit clearly above it */
  --bg: #1c2128;
  --surface: #2c333d;
  --surface-2: #39424e;
  --surface-3: #434d5a;
  --border: #48525f;
  --border-soft: #3a434e;
  --text: #ffffff;
  --muted: #9aa4af;
  --faint: #7b8591;
  --accent: #4d90d6;
  --accent-hover: #5b9ee0;
  --accent-weak: #26364a;
  --accent-text: #ffffff;
  --danger: #e0655f;
  --danger-border: #6b4141;
  --danger-bg: #322525;
  --ok: #5fb36c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 32px rgba(0, 0, 0, 0.32);
  --focus: 0 0 0 2px rgba(77, 144, 214, 0.5);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* ===== ONE font size for the whole app =====
     --fs is every piece of body text: forms, buttons, the folder
     tree, the file list, breadcrumbs, menus, meta. Change this one
     number and it all moves together. The two below are the only
     exceptions and they do NOT follow --fs. */
  --fs: 18px;          /* THE baseline — used everywhere        */
  --fs-heading: 22px;  /* headings only (h1 / h2 / h3)          */
  --fs-label: 13px;    /* UPPERCASE mini-labels: table column headers, status bar */

  --appbar-h: 65px;    /* the one top bar, shared by every page   */
  --appbar-bg: color-mix(in srgb, var(--surface) 86%, var(--accent)); /* faint accent tint so the bar reads as chrome */

  font-size: var(--fs);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs);
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ============ the top bar (same on every page; left slot is
   per-page and only shows once someone is signed in) ============ */
.appbar {
  flex: 0 0 var(--appbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  background: var(--appbar-bg);
  border-bottom: 1px solid var(--accent-weak);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.appbar .spacer { flex: 1; }
.appbar-logo {
  width: 56px; height: 56px; flex-shrink: 0;
  border-radius: 50%; object-fit: contain;
  background: #fff; padding: 5px;
}
.appbar-title {
  margin: 0; min-width: 0; flex: 0 1 auto;
  font-size: var(--fs-heading); font-weight: 650; letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.appbar-user, .appbar-label { font-size: var(--fs); color: var(--muted); white-space: nowrap; }
.appbar-label { margin-right: -4px; }
.appbar-back {
  display: none; align-items: center; gap: 3px; flex-shrink: 0;
  font-size: var(--fs); color: var(--muted); text-decoration: none; white-space: nowrap;
}
.appbar-back:hover { color: var(--text); }
#dash-sep { display: none; }
body.staff .appbar-back { display: flex; }
body.staff #dash-sep { display: block; }
.appbar .vdiv { width: 1px; height: 24px; background: var(--border); flex-shrink: 0; }
.appbar .ghost {
  font: inherit; font-size: var(--fs);
  color: var(--muted); background: none; border: none;
  padding: 5px 8px; cursor: pointer; white-space: nowrap;
}
.appbar .ghost:hover { color: var(--text); }

/* left slot + account controls appear only once someone is signed in */
#share-name, #logout-btn, #changepw-btn, #whoami, .appbar .vdiv { display: none; }
body.authed #share-name { display: block; }
body.authed .appbar .vdiv { display: block; }
body.authed #logout-btn,
body.authed #changepw-btn { display: inline-flex; }
body.authed #whoami { display: inline-block; }

/* the page body below the bar */
#gate.center-stage,
#app { flex: 1 1 auto; min-height: 0; }
#app { overflow-y: auto; }
#app.explorer { overflow: hidden; }

a { color: var(--accent); }

button, .btn {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
button:hover, .btn:hover { background: var(--surface-2); border-color: #454e59; }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, a:focus-visible { outline: none; box-shadow: var(--focus); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-sm { padding: 0.32rem 0.6rem; font-size: var(--fs); }

input[type="text"], input[type="password"], input[type="email"] {
  font: inherit;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
input::placeholder { color: #626c77; }
input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }

label { display: block; font-size: var(--fs); color: var(--muted); margin-bottom: 0.3rem; }
.field { margin-bottom: 0.9rem; }

.wrap { max-width: 960px; margin: 0 auto; padding: 1.5rem 1.2rem 4rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem;
}

.center-stage {
  position: relative;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 1.5rem;
}
.center-stage .card { width: 100%; max-width: 380px; }
.center-stage h2 { margin-top: 0; font-size: var(--fs-heading); }
.gate-card { text-align: left; }
.gate-glyph {
  width: 42px; height: 42px; border-radius: 10px; background: var(--surface-2);
  display: grid; place-items: center; color: var(--accent); margin-bottom: 14px;
}
.gate-card h2 { font-size: var(--fs-heading); }
.gate-card #gate-sub { margin: 0.3rem 0 1.3rem; font-size: var(--fs); line-height: 1.5; }

.msg { font-size: var(--fs); margin-top: 0.6rem; min-height: 1.2em; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--ok); }

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

/* ============ file explorer ============ */
.explorer {
  display: grid;
  grid-template-columns: var(--sidebar-w, 244px) 1fr;
  overflow: hidden;
}
.explorer svg { display: block; }

/* ---- sidebar ---- */
.sidebar {
  position: relative;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
}
/* drag the right edge to resize; double-click to reset */
.resizer {
  position: absolute; top: 0; right: 0; bottom: 0; width: 7px;
  cursor: col-resize; z-index: 5;
}
.resizer:hover, .resizer.dragging { box-shadow: inset -2px 0 0 var(--accent); }
.tree { flex: 1; overflow: auto; padding: 12px 8px; display: flex; flex-direction: column; gap: 1px; }
.side-foot { padding: 8px; border-top: 1px solid var(--border); }
.t-row {
  display: flex; align-items: center; gap: 7px;
  width: 100%; height: 34px; padding: 0 8px;
  border: none; background: none; border-radius: 7px;
  color: var(--text); font: inherit; text-align: left;
  white-space: nowrap; cursor: pointer;
}
.t-row:hover { background: var(--surface-2); }
.t-row.current { background: var(--accent-weak, #26364a); color: #eaf1f8; }
.t-row.drop-target { outline: 2px solid var(--accent); outline-offset: -2px; }
.t-row .caret {
  width: 20px; height: 30px; margin-left: -4px; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 5px;
  color: var(--faint, #7b8591); cursor: pointer;
}
.t-row:not(.leaf) .caret:hover { color: var(--text); background: var(--surface-3, #434d5a); }
.t-row .caret svg { width: 13px; height: 13px; }
.t-row.leaf .caret { cursor: default; pointer-events: none; }
.t-row.leaf .caret svg { display: none; }
.t-row .fi { width: 17px; height: 17px; color: var(--accent); flex-shrink: 0; }
.t-row .fi svg { width: 17px; height: 17px; }
.t-row.current .fi { color: #8fbdec; }
.t-row .fi.trash { color: var(--faint, #7b8591); }
.t-row .fi.pdf { color: var(--danger); }
.t-row .fi.img { color: var(--ok); }
.t-row .fi.vid { color: #a583d6; }
.t-row .fi.zip { color: #d8a24a; }
.t-row .fi.doc { color: #6ea8e0; }
.t-row .fi.file { color: var(--muted); }
.t-row.file .nm { color: var(--muted); }
.t-row.file:hover .nm, .t-row.file.current .nm { color: var(--text); }
.t-row .nm { overflow: hidden; text-overflow: ellipsis; }

/* ---- main column: action bar / path bar / table / status ---- */
.main {
  display: grid;
  grid-template-rows: 57px 40px minmax(0, 1fr) 37px;
  min-width: 0; background: var(--bg); overflow: hidden;
}

/* the path bar just shows where you are: EventName \ Sub \ Sub… */
.pathbar {
  display: flex; align-items: center;
  padding: 0 18px;
}
.crumbs {
  display: flex; align-items: center; gap: 6px;
  flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: thin;
}
.crumbs a { color: var(--text); text-decoration: none; white-space: nowrap; padding: 1px 3px; border-radius: 4px; }
.crumbs a:hover { background: var(--surface-3, #434d5a); }
.crumbs a.drop-target { background: var(--accent); color: #fff; }
.crumbs .sep { color: var(--text); flex-shrink: 0; }
.crumbs .cur { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.search {
  display: flex; align-items: center; gap: 7px;
  width: 214px; flex-shrink: 0; height: 32px; padding: 0 10px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
.search:focus-within { border-color: var(--accent); }
.search svg { color: var(--faint, #7b8591); flex-shrink: 0; }
.search input { flex: 1; min-width: 0; width: auto; background: none; border: none; padding: 0;
  color: var(--text); font: inherit; outline: none; }
.search input::placeholder { color: var(--faint, #7b8591); }

/* ---- action bar: Upload / New folder / Download all / search |
   Download / Move / Send to Trash (last three disabled until a
   selection exists) ---- */
.actionbar {
  display: flex; align-items: center; gap: 9px; padding: 0 18px;
  overflow-x: auto; scrollbar-width: thin;
  border-bottom: 1px solid var(--border-soft, #3a434e);
}
.actionbar > * { flex-shrink: 0; }
.actionbar .vdiv { width: 1px; height: 22px; background: var(--border); margin: 0 2px; }
.actionbar .btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer; white-space: nowrap;
}
.actionbar .btn:hover:not(:disabled) { background: var(--surface-2); }
.actionbar .btn:disabled { opacity: 0.4; cursor: default; }
.actionbar .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; padding: 0 15px; }
.actionbar .btn.primary:hover { background: var(--accent-hover); }
.actionbar .btn.danger { color: var(--danger); border-color: var(--danger-border); }
.actionbar .btn.danger:hover:not(:disabled) { background: var(--danger-bg); }
.actionbar .btn svg { flex-shrink: 0; }
.actionbar .search { height: 34px; width: 200px; }
/* the selection buttons are icon-only (labels only surface via title) */
.actionbar .sel-btn { padding: 0 9px; }
.actionbar .sel-btn span { display: none; }

/* ---- table ---- */
.table {
  margin: 4px 18px 0; display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
}
.grid {
  display: grid;
  /* icon · name (sized to the longest name, JS sets --name-col) · size ·
     uploaded · [spacer] · checkbox · ⋯ — the checkbox rides the right edge */
  grid-template-columns: 38px var(--name-col, minmax(0, 1fr)) 92px 116px 1fr 32px 34px;
  align-items: center;
}
.thead { height: 42px; padding: 0 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
/* up-one-level button — sits in the icon column, left of NAME; hidden at root */
.thead-up {
  justify-self: center;
  width: 32px; height: 32px; padding: 0; margin: 0;
  display: grid; place-items: center;
  border: none; background: none; border-radius: 6px;
  color: var(--muted); cursor: pointer;
}
.thead-up:hover { background: var(--surface-3, #434d5a); color: var(--text); }
.thead-up svg { width: 28px; height: 28px; display: block; }
/* keep the grid cell so header columns don't shift when at root */
.thead-up.off { visibility: hidden; pointer-events: none; }
.thead .col {
  display: inline-flex; align-items: center; gap: 3px; min-width: 0;
  background: none; border: none; cursor: pointer;
  font: inherit; font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted); overflow: hidden;
}
.thead .col span:first-child { overflow: hidden; text-overflow: ellipsis; }
.thead .col:hover { color: var(--text); }
.thead .col.on { color: var(--text); }
.thead .sortarrow { color: var(--accent); font-size: 0.72em; }
.ckcell { display: flex; align-items: center; justify-content: center; }
.check {
  width: 16px; height: 16px; margin: 0; cursor: pointer; accent-color: var(--accent);
}
.tbody { flex: 1; overflow: auto; }
.tr {
  height: 50px; padding: 0 12px;
  border-bottom: 1px solid var(--border-soft, #3a434e);
  cursor: pointer; user-select: none;
}
.tr:last-child { border-bottom: none; }
.tr:hover { background: var(--surface-2); }
.tr.sel { background: var(--accent-weak, #26364a); }
.tr.drop-target { outline: 2px solid var(--accent); outline-offset: -2px; }
.tr .ic { width: 19px; height: 19px; color: var(--muted); justify-self: center; }
.tr .ic svg { width: 19px; height: 19px; }
.tr .ic.folder { color: var(--accent); }
.tr .ic.pdf { color: var(--danger); }
.tr .ic.img { color: var(--ok); }
.tr .ic.vid { color: #a583d6; }
.tr .ic.zip { color: #d8a24a; }
.tr .ic.doc { color: #6ea8e0; }
.tr .thumb {
  width: 28px; height: 28px; object-fit: cover; border-radius: 5px;
  border: 1px solid var(--border); background: var(--surface-2);
  justify-self: center;
}
.namecell { min-width: 0; padding: 0 12px 0 4px; display: flex; flex-direction: column; justify-content: center; }
.tr .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr.folder .nm { font-weight: 550; }

/* ".." parent-directory row — first entry whenever below the share root */
.namecell .sub { display: none; font-size: var(--fs); color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr .sz, .tr .dt { color: var(--muted); font-size: var(--fs); }
.tr .more {
  width: 26px; height: 26px; display: grid; place-items: center;
  border: none; background: none; border-radius: 6px;
  color: var(--faint, #7b8591); cursor: pointer; opacity: 0; transition: opacity 0.1s;
}
.tr:hover .more { opacity: 1; }
.tr .more:hover { background: var(--surface-3, #434d5a); color: var(--text); }

@media (hover: none) { .tr .more { opacity: 1; } }

.statusbar {
  display: flex; align-items: center;
  padding: 0 22px; font-size: var(--fs-label); color: var(--faint, #7b8591);
}

.empty { padding: 3rem 1rem; text-align: center; color: var(--muted); }

/* ---- context menu ---- */
.ctxmenu {
  position: fixed; z-index: 70; min-width: 168px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow); padding: 4px;
  display: flex; flex-direction: column;
}
.ctxmenu button {
  border: none; background: none; color: inherit; text-align: left;
  padding: 7px 10px; border-radius: 6px; font: inherit; font-size: var(--fs); cursor: pointer;
}
.ctxmenu button:hover { background: var(--surface-2); }
.ctxmenu button.danger { color: var(--danger); }

/* ---- move picker ---- */
.mv-tree { max-height: 52vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 5px; }
.mv-row {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 6px 8px; border: none; background: none; border-radius: 6px;
  color: var(--text); font: inherit; font-size: var(--fs); text-align: left; cursor: pointer;
}
.mv-row:hover { background: var(--surface-2); }
.mv-row.disabled { opacity: 0.4; cursor: default; }
.mv-row.disabled:hover { background: none; }
.mv-row .fi { width: 17px; height: 17px; color: var(--accent); flex-shrink: 0; }
.mv-row .fi svg { width: 17px; height: 17px; }

/* ---- trash modal rows ---- */
.trash-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--border-soft, #3a434e); }
.trash-row:last-child { border-bottom: none; }
.trash-row .ic { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.trash-row .ic svg { width: 18px; height: 18px; }
.trash-row .ic.folder { color: var(--accent); }
.trash-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-row .meta { color: var(--muted); font-size: var(--fs); white-space: nowrap; }
.trash-row .acts { display: flex; gap: 0.35rem; flex-shrink: 0; }
.list.plain { border: none; background: none; }

/* the folder sidebar is always visible — it never collapses at any width */
@media (max-width: 560px) {
  .appbar { padding: 0 12px; gap: 8px; }
  .appbar-label, .appbar .vdiv, body.authed .appbar .vdiv, body.staff #dash-sep { display: none; }
  .appbar-back span { display: none; }
  body.authed #whoami { display: none; }
  .search { display: none; }
  .actionbar .btn span { display: none; }
  .actionbar .btn { padding: 0 11px; }
  .actionbar .btn.primary span { display: inline; }
  .table { margin: 4px 10px 0; }
  .thead { display: none; }
  .grid { grid-template-columns: 38px minmax(0, 1fr) 32px 34px; }
  .tr { height: 56px; }
  .tr .sz, .tr .dt, .rowspacer { display: none; }
  .namecell .sub { display: block; }
}

/* the whole window is a drop target (Uppy DropTarget) */
body.uppy-is-drag-over::after {
  content: attr(data-drop);
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  font-size: var(--fs-heading); color: var(--text);
  background: rgba(28, 33, 40, 0.78);
  outline: 3px dashed var(--accent); outline-offset: -14px;
  pointer-events: none;
}

/* ---- staff dashboard ---- */
.wrap h2 { font-size: var(--fs-heading); }

.share-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem 1.1rem;
  margin-bottom: 0.8rem;
}
.share-card.trashed { opacity: 0.7; }
.share-card .name-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 0.25rem -8px; }
.share-card .name-input {
  flex: 0 1 340px; min-width: 0; width: auto;
  font-size: var(--fs-heading); font-weight: 650; color: var(--text);
  padding: 3px 8px;
  background: none; border: 1px solid transparent; border-radius: 6px;
}
.share-card .name-input[readonly] { cursor: default; }
.share-card .name-input.editing { border-color: var(--accent); background: var(--bg); }
.share-card .name-input.editing:focus { outline: none; box-shadow: var(--focus); }
.share-card .name-msg { margin: 0; font-size: var(--fs); }
.share-card h3 { margin: 0 0 0.25rem; font-size: var(--fs-heading); }
.share-card .sub { color: var(--muted); font-size: var(--fs); margin-bottom: 0.7rem; word-break: break-all; }
.share-card .row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.pw-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.pw-row label { margin: 0; font-size: var(--fs); color: var(--muted); }
.pw-row .pw-input {
  width: auto; flex: 0 1 220px;
  padding: 0.32rem 0.55rem; font-size: var(--fs);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.pw-row .pw-msg { margin: 0; font-size: var(--fs); min-height: 0; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 13, 18, 0.6);
  display: grid; place-items: center; padding: 1.5rem; z-index: 50;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.4rem; width: 100%; max-width: 380px;
  box-shadow: var(--shadow);
}
.modal h3 { margin-top: 0; font-size: var(--fs-heading); }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

.hidden { display: none !important; }


/* ---- disk meter + trash (staff) ---- */
.disk-card { padding: 0.9rem 1.1rem; display: flex; gap: 1.5rem; align-items: center; }
.disk-left { flex: 0 0 50%; min-width: 0; }
.disk-right {
  flex: 1 1 auto; display: flex; flex-direction: column; align-items: flex-end;
  gap: 0.4rem; text-align: right;
}
.disk-right #trash-info { font-size: var(--fs); }
@media (max-width: 560px) {
  .disk-card { flex-direction: column; align-items: stretch; gap: 0.9rem; }
  .disk-left, .disk-right { flex: none; }
  .disk-right { align-items: flex-start; text-align: left; }
}
.disk-row { display: flex; justify-content: space-between; gap: 1rem; font-size: var(--fs); margin-bottom: 0.5rem; }
.meter { height: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.disk-card.low .meter-fill { background: var(--danger); }
.disk-card.low #disk-label { color: var(--danger); }

/* ---- language switch ---- */
.lang-switch { display: inline-flex; gap: 0.3rem; align-items: center; }
.lang-flag {
  width: 32px; height: 23px; padding: 2px;
  border: 1px solid var(--border); border-radius: 5px;
  background: var(--surface); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0.45; transition: opacity 0.12s, border-color 0.12s;
}
.lang-flag svg { width: 100%; height: 100%; border-radius: 2px; display: block; }
.lang-flag:hover { opacity: 0.8; background: var(--surface); }
.lang-flag.active { opacity: 1; border-color: var(--accent); }
