: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-meta { font-size: var(--fs); color: var(--muted); white-space: nowrap; }
/* the share URL, sat ~50px to the right of the folder-manager title
   (38px here + the appbar's own 12px flex gap) */
.appbar-url {
  margin-left: 38px; min-width: 0; flex: 0 1 auto;
  font-size: var(--fs); font-weight: 400; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.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);
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); background: none; border: none;
  padding: 5px 8px; cursor: pointer; white-space: nowrap;
}
.appbar .ghost:hover { color: var(--text); }
.appbar .ghost svg { display: none; width: 20px; height: 20px; flex-shrink: 0; } /* text-only on desktop; icon shows alongside the label on mobile */

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

/* the URL copy button - always shows its icon (unlike the account
   ghost buttons, which are text-only on desktop); the copy/check svgs
   swap via [hidden] */
.appbar #copy-url-btn { padding: 5px 7px; margin-left: 2px; }
.appbar #copy-url-btn svg:not([hidden]) { display: block; }
.appbar #copy-url-btn .copy-ok { color: var(--ok); }
.appbar #copy-url-btn .copy-msg { color: var(--ok); font-size: var(--fs-label); font-weight: 600; }

/* filter field, moved into the top bar left of the flags */
/* it's a <label>, so kill the global label bottom-margin that was
   nudging it above centre */
.appbar .search { height: 42px; width: 190px; margin: 0; }

/* 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"], textarea {
  font: inherit;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #626c77; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }

/* Flatpickr (date fields) - its own popup, so make it bigger and blend
   it into the app's palette */
.flatpickr-calendar {
  transform: scale(1.3); transform-origin: top left;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.flatpickr-months { background: var(--surface); color: var(--muted); }
/* weekday row picks up the top-bar's faint-accent tint so it reads as a header */
.flatpickr-weekdays, span.flatpickr-weekday { background: var(--appbar-bg); color: var(--muted); }
.flatpickr-month, .flatpickr-current-month input.cur-year, .flatpickr-monthDropdown-months { color: var(--text); fill: var(--text); }
.flatpickr-day { color: var(--text); border-radius: 6px; }
.flatpickr-day.today { border-color: var(--accent); }
.flatpickr-day.selected, .flatpickr-day.selected:hover { background: var(--accent); border-color: var(--accent); }
.flatpickr-day:hover { background: var(--surface-2); border-color: var(--surface-2); }
.flatpickr-day.flatpickr-disabled, .flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay { color: var(--faint); }
.flatpickr-prev-month:hover svg, .flatpickr-next-month:hover svg { fill: var(--accent); }
/* weekends (Sat/Sun) - tagged by staff.js onDayCreate / onReady */
.flatpickr-day.weekend:not(.selected), span.flatpickr-weekday.weekend { color: var(--danger); }
.flatpickr-day.weekend.prevMonthDay, .flatpickr-day.weekend.nextMonthDay,
.flatpickr-day.weekend.flatpickr-disabled { color: color-mix(in srgb, var(--danger) 55%, var(--faint)); }

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; }
.gate-card #gate-sub:empty { margin: 0; }

.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 .fi { width: 17px; height: 17px; color: var(--accent); flex-shrink: 0; }
.t-row .fi svg { width: 17px; height: 17px; }
/* folder icons run larger than the file-type icons (row height is fixed,
   so this doesn't change line spacing) */
.t-row:not(.file) .fi:not(.trash),
.t-row:not(.file) .fi:not(.trash) svg { width: 24px; height: 24px; }
.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: minmax(57px, auto) 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; box-shadow: 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; flex-wrap: wrap;
  gap: 8px 9px; padding: 8px 18px;
  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; }

/* read-only share (guest password): hide every write affordance, keep the
   download ones */
body.readonly #upload-btn,
body.readonly #newfolder-btn,
body.readonly #sel-move,
body.readonly #sel-trash,
body.readonly .actionbar .vdiv,
body.readonly .side-foot { 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;
  /* checkbox · icon · name (sized to the longest name, JS sets --name-col) ·
     size · uploaded · [spacer] · ⋯ */
  grid-template-columns: 44px 38px var(--name-col, minmax(0, 1fr)) 92px 168px 1fr 34px;
  column-gap: 20px;
  align-items: center;
}
/* the 12px left inset is folded into the checkbox column above (0 + 44 =
   12 + 32) so the checkbox is centred between the table edge and the
   divider, and every other column stays where it was */
.thead { height: 42px; padding: 0 12px 0 0; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.thead .col {
  display: inline-flex; align-items: center; gap: 3px; min-width: 0;
  padding: 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;
}
/* line the NAME header up with the row name text (.namecell has 4px left padding) */
.thead .col[data-sort="name"] { padding-left: 4px; }
/* Size / Added centre over their (centred) row cells */
.thead .col[data-sort="size"],
.thead .col[data-sort="uploaded"] { justify-content: center; }
.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;
  /* divider between the selection column and the file rows */
  align-self: stretch;
  border-right: 1px solid var(--border-soft);
}
.check {
  width: 16px; height: 16px; margin: 0; cursor: pointer; accent-color: var(--accent);
}
.tbody { flex: 1; overflow: auto; }
.tr {
  height: 50px; padding: 0 12px 0 0;
  border-bottom: 1px solid var(--border-soft, #3a434e);
  cursor: pointer; user-select: 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.folder, .tr .ic.folder svg { width: 35px; height: 35px; }
.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 0 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(--text); font-size: var(--fs); text-align: center; white-space: nowrap; }
.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); }
/* big, quiet back-arrow above the "folder is empty" message (subfolders only) */
.empty-up {
  display: block; margin: 0 auto 1.1rem;
  border: none; background: none; padding: 0;
  color: var(--faint); cursor: pointer;
}
.empty-up svg { width: 84px; height: 84px; display: block; }
.empty-up:hover { 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) {
  /* top bar wraps onto two rows so every label shows in full - no
     truncation: logo + title + language flags on row 1, the account
     buttons on row 2 */
  .appbar {
    flex: 0 0 auto; flex-wrap: wrap; height: auto;
    padding: 7px 12px; gap: 5px 9px;
  }
  .appbar .vdiv, body.authed .appbar .vdiv,
  body.staff #dash-sep, body.authed #whoami,
  body.authed #share-url, body.authed #copy-url-btn,
  body.authed #filesearch { display: none; }
  .appbar-logo { width: 38px; height: 38px; padding: 4px; order: 1; }
  .appbar-title { flex: 1 1 auto; font-size: var(--fs); order: 2; }
  .appbar .lang-switch { order: 3; }
  .appbar .spacer { flex: 0 0 100%; height: 0; order: 4; }
  .appbar-back, #empty-trash-btn, #changepw-btn { order: 5; }
  #logout-btn { order: 6; }
  .appbar .ghost { padding: 4px; }
  .appbar .ghost span { display: inline; }
  .appbar .ghost svg { display: block; }
  /* the enlarged Flatpickr popup would overflow a phone - use its natural size */
  .flatpickr-calendar { transform: 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: 40px 38px minmax(0, 1fr) 34px; column-gap: 6px; }
  .tr { height: 56px; }
  .tr .sz, .tr .dt, .rowspacer { display: none; }
  .namecell .sub { display: block; }
}

/* honour the explicit line break in the FI drop-zone hint
   ("Pudota tiedostot tähän" / "tai valitse tiedostot") */
.uppy-Dashboard-AddFiles-title { white-space: pre-line; }

/* 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 ----
   One spacing rhythm for the whole page: every direct child of .wrap
   (cards, section headings) carries the same bottom gap, so nothing
   needs a one-off inline margin. */
.wrap h2 { font-size: var(--fs-heading); font-weight: 650; margin: 0 0 0.9rem; }
.wrap > .card,
.wrap > h2 { margin-bottom: 1.4rem; }
.wrap > #shares { margin-bottom: 0; }

#trashed-wrap { margin-top: 1.5rem; }
#trashed-wrap summary { cursor: pointer; }
#trashed-shares { margin-top: 0.7rem; }
.trashed-deleteall { display: flex; justify-content: flex-end; margin-bottom: 0.7rem; }

.btn-block { width: 100%; }

/* create-form: the visible fields + the button, all bottom-aligned;
   steps down 4 -> 2 -> 1 columns rather than an awkward flex-wrap */
.create-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.9rem;
  align-items: end;
}
.create-form .field { margin: 0; }
@media (max-width: 860px) {
  .create-form { grid-template-columns: repeat(2, 1fr); }
  .create-form button { grid-column: 1 / -1; width: 100%; }
}
@media (max-width: 520px) {
  .create-form { grid-template-columns: 1fr; }
}

/* customer name - hidden for now (feature paused, not removed; delete
   this rule + the "customer-field" classes in staff.html/staff.js to
   bring it back). */
.customer-field { display: none !important; }

/* event start/end date - hidden for now (feature paused, not removed;
   delete this rule + the "startdate-field"/"enddate-field" classes in
   staff.html to bring it back). With no dates submitted, the backend
   naturally creates no per-day folders and never auto-closes the share -
   all of that logic stays in place in src/routes/staff.js and
   src/shares.js, just unreachable while these fields are empty. */
.startdate-field, .enddate-field { display: none !important; }

.share-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 1rem;
}
.share-card.trashed { opacity: 0.7; padding: 1.1rem 1.2rem; }

/* open-request cards are <details>: the <summary> is the folder icon +
   the (editable) event-name row + a disclosure caret; everything else
   lives in the collapsible .s-body - the same native disclosure the
   Trashed section uses. Cards start collapsed. */
details.share-card > summary {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.95rem 1.1rem 0.95rem 0.85rem;
  cursor: pointer; list-style: none;
}
details.share-card > summary::-webkit-details-marker { display: none; }
details.share-card[open] > summary { padding-bottom: 0; }
/* one even vertical rhythm for every row in the body */
details.share-card > .s-body {
  padding: 0.35rem 1.2rem 1.1rem 0.85rem; min-width: 0;
  display: flex; flex-direction: column; gap: 0.8rem;
}
details.share-card > summary > .name-row { flex: 1; min-width: 0; margin: 0; }
details.share-card > summary .name-input { flex: 1; }
/* collapsed: the row is just "icon  name  caret" - hide the edit affordance
   until the card is open */
details.share-card:not([open]) > summary .name-row [data-act],
details.share-card:not([open]) > summary .name-row .name-msg { display: none; }
/* disclosure caret at the start of the row - a CSS triangle so it
   rotates reliably (inline <svg> won't take a CSS transform here) */
details.share-card > summary::before {
  content: ''; flex-shrink: 0; order: -1;
  width: 0; height: 0; margin-right: -0.35rem;
  border-left: 6px solid var(--faint);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  transition: transform 0.15s ease;
}
details.share-card[open] > summary::before { transform: rotate(90deg); }

/* leading avatar - anchors each card so a long list scans quickly */
.share-card .s-avatar {
  flex-shrink: 0; width: 48px; height: 48px; margin-top: 2px;
  border-radius: 12px; background: var(--accent-weak); color: var(--accent);
  display: grid; place-items: center;
}
.share-card .s-avatar svg { width: 30px; height: 30px; }

/* Identity block: event name + customer name are ONE visual
   construction on purpose (same size/weight/edit interaction) - normal
   body text, not a headline. A list of cards reads better this way;
   "Shared folders" above is the real headline on this page. The folder
   password field (.pw-input, further down) shares this exact locked ->
   Edit -> Save treatment. */
.share-card .name-row {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  margin: 0 0 0.2rem -8px;
}
.share-card .name-input,
.share-card .customer-input,
.share-card .pw-input {
  flex: 0 1 340px; min-width: 0; width: auto;
  font-size: var(--fs); font-weight: 400; color: var(--text);
  padding: 3px 8px;
  background: none; border: 1px solid transparent; border-radius: 6px;
}
/* the event name reads as the card's title */
.share-card .name-input {
  flex-basis: 460px;
  font-size: var(--fs-heading); font-weight: 600;
}
.share-card .name-input[readonly],
.share-card .customer-input[readonly],
.share-card .pw-input[readonly] { cursor: default; }
.share-card .name-input.editing,
.share-card .customer-input.editing,
.share-card .pw-input.editing { border-color: var(--accent); background: var(--bg); }
.share-card .name-input.editing:focus,
.share-card .customer-input.editing:focus,
.share-card .pw-input.editing:focus { outline: none; box-shadow: var(--focus); }
.share-card .name-msg,
.share-card .customer-msg,
.share-card .pw-msg { margin: 0; font-size: var(--fs); }

/* the Edit / Save button on each editable row is pushed flush to the
   card's right edge; order:1 keeps it the last flex item so the (usually
   empty) status message doesn't sit between it and the edge */
.share-card .name-row > [data-act],
.share-card .dates-row > [data-act],
.share-card .pw-row > [data-act] { margin-left: auto; order: 1; }

.share-card .sub { color: var(--muted); font-size: var(--fs); margin: 0 0 1rem; word-break: break-all; }

/* the link/files/size line reads as icon-labeled chips instead of one
   run-on text string */
.share-card .s-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1rem; margin: 0; }
.share-card .s-meta-item { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs); min-width: 0; }
.share-card .s-meta-item svg { flex-shrink: 0; color: var(--faint); }
.share-card .s-meta-item .url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* event date range - display text that Edit swaps for two pickers,
   same locked -> Edit -> Save rhythm as the fields above */
.dates-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0; }
.dates-row label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: var(--fs); color: var(--muted); }
.dates-row label svg { flex-shrink: 0; color: var(--faint); }
.dates-row .dates-text { font-size: var(--fs); color: var(--muted); }
.dates-row .date-edit-field {
  flex: 0 1 150px; min-width: 0; width: auto;
  font-size: var(--fs); color: var(--text);
  padding: 3px 8px;
  background: var(--bg); border: 1px solid var(--accent); border-radius: 6px;
}
.dates-row .date-edit-field:focus { outline: none; box-shadow: var(--focus); }
.dates-row .date-sep { flex: none; border: 0; background: none; padding: 0; color: var(--faint); }
.dates-row .dates-msg { margin: 0; font-size: var(--fs); }

.share-card .row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.share-card .btn-sm { display: inline-flex; align-items: center; gap: 6px; }
.share-card .btn-sm svg { flex-shrink: 0; }

/* the copyable client message reads as its own quiet sub-panel, not
   just another loose field at the end of the card */
.share-card .message-field {
  padding: 0.8rem 0.9rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}
.share-card .message-head {
  display: flex; align-items: center; gap: 6px; margin: 0 0 0.4rem;
  font-size: var(--fs-label); font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
.share-card .message-head svg { flex-shrink: 0; color: var(--faint); }
.message-langs { margin-left: 14px; display: flex; gap: 10px; }
.message-lang {
  border: none; background: none; padding: 0;
  font: inherit; font-size: var(--fs-label); font-weight: 600;
  letter-spacing: 0; text-transform: none;
  color: var(--accent); text-decoration: underline; cursor: pointer;
}
.message-lang:hover { color: var(--accent-hover); }
.message-lang.active {
  color: var(--muted); text-decoration: none; cursor: default; font-weight: 700;
}
.message-lang:disabled { opacity: 0.4; cursor: default; }
.share-card .message-box { margin-bottom: 0.6rem; }
.share-card .message-box[readonly] { border-color: var(--border-soft); cursor: default; }
.share-card .message-foot { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.share-card .message-copy-hint { font-size: var(--fs-label); }

/* app-wide client-message template editor - sits at the bottom of the page */
.tpl-card { margin-top: 1.5rem; }
.tpl-card > summary {
  display: flex; align-items: center; gap: 0.6rem;
  cursor: pointer; list-style: none;
}
.tpl-card > summary::-webkit-details-marker { display: none; }
/* same CSS-triangle caret as the share cards */
.tpl-card > summary::before {
  content: ''; flex-shrink: 0;
  width: 0; height: 0;
  border-left: 6px solid var(--faint);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  transition: transform 0.15s ease;
}
.tpl-card[open] > summary::before { transform: rotate(90deg); }
.tpl-card > summary .tpl-title {
  font-size: var(--fs-heading); font-weight: 700;
}
.tpl-card .tpl-body { margin-top: 1rem; }
.tpl-card .tpl-head { display: flex; margin-bottom: 0.5rem; }
.tpl-card .tpl-head .message-langs { margin-left: 0; }
.tpl-card #tpl-box {
  width: 100%; font: inherit; line-height: 1.5;
  padding: 0.7rem 0.8rem; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); color: var(--text);
  resize: vertical;
}
.tpl-card .tpl-hint { margin: 0.5rem 0 0; font-size: var(--fs-label); }
.tpl-card .tpl-actions {
  display: flex; align-items: center; gap: 0.7rem; margin-top: 0.8rem;
}
.tpl-card .tpl-actions .msg { margin: 0; }

.pw-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0; }
.pw-row label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: var(--fs); color: var(--muted); }
.pw-row label svg { flex-shrink: 0; color: var(--faint); }
/* the field itself is styled with .name-input / .customer-input above -
   the only password-specific touch is a monospace face so the credential
   is easy to read back */
.pw-row .pw-input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.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 usage + "Empty trash" live in the top bar (staff); both use
   the same type/colour as the rest of the bar - only .low adds an alert
   tint, matching how the app flags errors everywhere else ---- */
.appbar-meta.low { color: var(--danger); }
@media (max-width: 560px) {
  /* disk readout + "empty trash" are desktop-only - keeps the wrapped
     mobile bar to two rows; trash can still be emptied from a wider screen */
  .appbar-meta, .appbar #empty-trash-btn { display: none; }
  /* share cards: smaller avatar, name/customer input on its own line so
     the Edit button stays a compact left-aligned chip, not a stretched
     centered box (this block sits after the .share-card base rules on
     purpose - equal specificity, later wins) */
  details.share-card > summary { padding: 0.85rem 0.9rem; gap: 0.6rem; }
  details.share-card > .s-body { padding: 0.9rem; }
  .share-card.trashed { padding: 1rem; }
  .share-card .s-avatar { width: 40px; height: 40px; }
  .share-card .s-avatar svg { width: 24px; height: 24px; }
  .share-card .name-row { margin-left: 0; }
  .share-card .name-input,
  .share-card .customer-input,
  .share-card .pw-input { flex: 1 1 100%; }
  .share-card .name-row .btn-sm,
  .share-card .pw-row .btn-sm { white-space: nowrap; }
}

/* ---- language switch ---- */
.lang-switch { display: inline-flex; gap: 0.3rem; align-items: center; }
/* a brief double-flash to point a first-time visitor at the language flags */
@keyframes lang-hint {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
  45%      { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.75); }
}
.lang-switch.lang-hint {
  border-radius: 8px;
  animation: lang-hint 0.85s ease-in-out 0.4s 2;
}
@media (prefers-reduced-motion: reduce) {
  .lang-switch.lang-hint { animation: none; }
}
.lang-flag {
  width: 59px; height: 42px; padding: 4px;
  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); }
