/* FileManager — styles */

/* Palette taken from the Jat Gate (regimental red, black, gold) and the badge (gold, royal purple). */
:root {
  --bg: #f4efe4;             /* parchment */
  --surface: #fffcf5;
  --surface-2: #f1eadb;
  --hover: #e9e0cc;
  --border: #e0d5bd;
  --text: #1d1a15;
  --muted: #6b6150;
  --primary: #b3121b;        /* regimental red */
  --primary-hover: #8e0d14;
  --primary-soft: #f7dfdc;
  --fill: #b3121b;           /* filled buttons: true regimental red in both themes */
  --fill-hover: #8e0d14;
  --on-primary: #ffffff;
  --gold: #c9a13b;
  --gold-bright: #e2bc55;
  --gold-deep: #8a6a1c;
  --gold-soft: #f3e7c6;
  --purple: #3b2a8c;
  --ink: #121110;            /* the black band of the gate */
  --ink-2: #1f1d1a;
  --danger: #b3121b;
  --danger-soft: #f9e2df;
  --success: #2f7d32;
  --success-soft: #e4f1dd;
  --warning: #8a5a00;
  --warning-soft: #f8ecd0;
  --shadow: 0 1px 2px rgba(40, 28, 10, .07), 0 1px 3px rgba(40, 28, 10, .12);
  --shadow-lg: 0 16px 40px rgba(40, 28, 10, .25);
  --radius: 10px;
  --font-display: "Cinzel", "Trajan Pro", Georgia, "Times New Roman", serif;
  --k-folder: #8a6a1c; --k-image: #b3121b; --k-video: #9c1d5c; --k-audio: #3b2a8c; --k-pdf: #b3121b;
  --k-doc: #1f4f9c; --k-sheet: #2f7d32; --k-slide: #c26a00; --k-archive: #6d6252; --k-code: #0f766e;
  --k-text: #57503f; --k-other: #6d6252;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0e0c;
    --surface: #1a1815;
    --surface-2: #23201b;
    --hover: #2d2923;
    --border: #3a342a;
    --text: #efe8da;
    --muted: #a99f8c;
    --primary: #e2454c;
    --primary-hover: #f0676d;
    --primary-soft: #3b1a1a;
    --fill: #b3121b;
    --fill-hover: #cc1f28;
    --on-primary: #ffffff;
    --gold: #d9b45a;
    --gold-bright: #ecc96b;
    --gold-deep: #e2c070;
    --gold-soft: #33291a;
    --purple: #a99cf0;
    --danger: #f06a70;
    --danger-soft: #3b1a1a;
    --success: #7cc47f;
    --success-soft: #1c2e1c;
    --warning: #e8b84f;
    --warning-soft: #3a2e12;
    --shadow: 0 1px 2px rgba(0, 0, 0, .45);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .6);
    --k-folder: #d9b45a; --k-image: #f06a70; --k-video: #e879b0; --k-audio: #a99cf0; --k-pdf: #f06a70;
    --k-doc: #7fa8ea; --k-sheet: #7cc47f; --k-slide: #f0a54a; --k-archive: #b3a893; --k-code: #4fd1c5;
    --k-text: #b8ad97; --k-other: #b3a893;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { line-height: 1.25; }
hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.icon { flex: none; display: block; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Form controls ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[readonly] { background: var(--surface-2); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; }
label { display: block; font-weight: 500; font-size: 14px; }
label > input, label > select { margin-top: 6px; font-weight: 400; }
.hint { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; min-height: 38px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn.active { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.btn-primary { background: var(--fill); border-color: var(--fill); color: #fff; }
.btn-primary:hover { background: var(--fill-hover); border-color: var(--fill-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); background: var(--danger); }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 12px; min-height: 32px; font-size: 14px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; flex: none;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.icon-btn.active { background: var(--primary-soft); color: var(--primary); }

/* ---------- Flash messages ---------- */
.flashes { display: grid; gap: 8px; margin-bottom: 16px; }
.flash {
  display: flex; align-items: flex-start; gap: 8px; justify-content: space-between;
  padding: 10px 12px 10px 16px; border-radius: 10px; font-size: 14px;
  background: var(--gold-soft); color: var(--text); border: 1px solid transparent;
}
.flash > span, .flash > div { padding-top: 6px; padding-bottom: 6px; }
.flash-success { background: var(--success-soft); }
.flash-error { background: var(--danger-soft); }
.flash-error div { padding: 2px 0; }
.flash-close { width: 32px; height: 32px; }

/* ---------- Display type ---------- */
.page-title, .auth-card h1, .card h2, .empty h2, .dlg-head h2, .stat-value, .crumbs, .brand-name,
.auth-hero-name, .auth-hero-tagline, .sidebar-motto {
  font-family: var(--font-display);
  letter-spacing: .02em;
}

/* ---------- Auth pages: gate photograph + sign-in card ---------- */
.auth-split { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(400px, 1fr); }
.auth-hero {
  position: relative; display: flex; align-items: flex-end;
  background: var(--ink) url("img/jat-gate.jpg") center 40% / cover no-repeat; color: #fff;
  border-right: 4px solid var(--gold);
}
.auth-hero::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(18, 17, 16, .15) 0%, rgba(18, 17, 16, .5) 50%, rgba(18, 17, 16, .94) 100%);
}
.auth-hero-inner { position: relative; padding: 48px 56px; display: grid; justify-items: start; }
.auth-badge { width: 76px; height: auto; margin-bottom: 18px; filter: drop-shadow(0 6px 16px rgba(0, 0, 0, .55)); }
.auth-hero-name {
  margin: 0; font-size: clamp(30px, 3.4vw, 46px); font-weight: 700; line-height: 1.1;
  color: #e2bc55; text-shadow: 0 2px 12px rgba(0, 0, 0, .6);
}
.auth-hero-sub { margin: 8px 0 0; font-size: 13px; letter-spacing: .32em; text-transform: uppercase; color: #efe8da; }
.auth-hero-tagline {
  margin: 22px 0 0; padding-top: 14px; border-top: 2px solid #c9a13b;
  font-size: 18px; font-weight: 600; color: #fff;
}
.auth-wrap { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-top: 4px solid var(--primary);
  border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow-lg);
}
.auth-card h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; }
.auth-card h1::after { content: ""; display: block; width: 48px; height: 3px; background: var(--gold); margin-top: 10px; }
.auth-card > p { margin: 10px 0 20px; }
.auth-card .flash { margin-bottom: 16px; }
.form { display: grid; gap: 16px; margin-top: 20px; }
.form-narrow { max-width: 420px; }

/* ---------- App shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  height: 64px; padding: 0 16px;
  background: var(--ink); color: #efe8da;
  border-bottom: 3px solid var(--gold);          /* gold over regimental red, like the gate */
  box-shadow: inset 0 -3px 0 #b3121b;
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; }
.brand:hover { text-decoration: none; }
.topbar .brand { width: 240px; flex: none; }
.brand-badge { width: 32px; height: auto; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }
.brand-text { display: grid; line-height: 1.15; min-width: 0; }
.brand-name { font-size: 16px; font-weight: 700; color: #e2bc55; white-space: nowrap; }
.brand-sub { font-size: 10.5px; letter-spacing: .24em; text-transform: uppercase; color: #b9ad95; white-space: nowrap; }
.search {
  flex: 1; max-width: 720px; position: relative; display: flex; align-items: center;
}
.search .icon { position: absolute; left: 16px; color: #a99f8c; pointer-events: none; }
.topbar .search input[type="search"] {
  padding-left: 46px; border-radius: 999px; min-height: 42px;
  background: #2a2722; border-color: #3a352d; color: #efe8da;
}
.topbar .search input[type="search"]::placeholder { color: #a99f8c; }
.topbar .search input[type="search"]:focus { border-color: #c9a13b; box-shadow: 0 0 0 3px rgba(201, 161, 59, .3); }
.topbar .icon-btn { color: #d8cfbd; }
.topbar .icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.user-chip { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.user-chip form { margin: 0; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: #c9a13b; color: #121110; font-family: var(--font-display); font-weight: 700; font-size: 15px;
  box-shadow: 0 0 0 2px #121110, 0 0 0 3px #c9a13b;
}
.avatar:hover { text-decoration: none; filter: brightness(1.08); }

.shell { display: flex; min-height: calc(100vh - 64px); }
.sidebar { width: 256px; flex: none; padding: 18px 16px 16px; display: flex; flex-direction: column; gap: 16px; }
.new-wrap { position: relative; }
.btn-new {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 13px 24px 13px 16px; border-radius: 12px; border: 0;
  background: var(--fill); color: #fff; box-shadow: var(--shadow);
  font-weight: 600; font-size: 15px; cursor: pointer;
}
.btn-new:hover { background: var(--fill-hover); text-decoration: none; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 14px; padding: 8px 16px; border-radius: 999px;
  color: var(--text); font-weight: 500; font-size: 14px;
}
.nav a:hover { background: var(--hover); text-decoration: none; }
.nav a.active { background: var(--gold-soft); font-weight: 600; }
.nav a.active .icon { color: var(--primary); }
.usage { padding: 0 16px; }
.usage-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-bottom: 6px; }
.usage-bar span { display: block; height: 100%; background: var(--gold); }
.sidebar-motto {
  margin-top: auto; padding: 14px 8px 0; text-align: center;
  font-size: 13px; font-weight: 600; color: var(--gold-deep);
  border-top: 1px solid var(--border);
}

.main {
  flex: 1; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-bottom: 0;
  border-radius: 14px 14px 0 0;
  margin: 16px 16px 0 0; padding: 20px 24px 48px;
}
.page-title { font-size: 24px; font-weight: 700; margin: 4px 0 20px; }
.page-title::after { content: ""; display: block; width: 48px; height: 3px; background: var(--gold); margin-top: 8px; }
.only-mobile { display: none; }
.sidebar-scrim { display: none; }

/* ---------- Menus ---------- */
.menu {
  position: absolute; z-index: 50; min-width: 220px; padding: 6px 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
}
.new-wrap .menu { top: calc(100% + 6px); left: 0; }
.menu button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 16px; border: 0; background: none; text-align: left; cursor: pointer; font-size: 14px;
}
.menu button:hover, .menu button:focus-visible { background: var(--hover); outline: none; }
.menu button .icon { color: var(--muted); }
.menu button.danger, .menu button.danger .icon { color: var(--danger); }
.ctx-menu { position: fixed; }

/* ---------- Drive header / toolbar ---------- */
.drive-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.crumbs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; font-size: 21px; font-weight: 600; margin: 0; flex: 1; min-width: 0; }
.crumbs a { color: var(--muted); padding: 2px 10px; border-radius: 999px; }
.crumbs a:hover { background: var(--hover); text-decoration: none; }
.crumbs a.current, .crumbs span { color: var(--text); }
.crumbs .icon { color: var(--muted); }
.toolbar { display: flex; align-items: center; gap: 6px; }
.sort-form { margin: 0; }
.select-sm { min-height: 34px !important; padding: 4px 30px 4px 12px !important; border-radius: 999px !important; width: auto !important; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; }
.seg .icon-btn { width: 34px; height: 30px; border-radius: 999px; }

.filters {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px;
  padding: 14px 16px; margin-bottom: 16px; background: var(--surface-2); border-radius: var(--radius);
}
.filters label { font-size: 13px; }
.filters select, .filters input { min-width: 150px; }

.bulk-bar {
  position: sticky; top: 64px; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px; margin-bottom: 12px;
  background: var(--primary-soft); border-radius: 999px; font-weight: 500;
}
.bulk-bar .spacer { flex: 1; }
.bulk-bar .btn { background: var(--surface); }

/* ---------- Items: shared ---------- */
.section-title { font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-deep); margin: 20px 0 12px; }
.items .item { position: relative; cursor: pointer; user-select: none; }
.item .name { display: flex; align-items: center; gap: 12px; min-width: 0; font-weight: 500; font-size: 14px; }
.item .name a { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .name a:hover { text-decoration: none; }
.item .meta { color: var(--muted); font-size: 13px; }
.item .col-loc { display: none; }
.items.searching .item .col-loc { display: inline; }
.kind-folder { color: var(--k-folder); } .kind-image { color: var(--k-image); } .kind-video { color: var(--k-video); }
.kind-audio { color: var(--k-audio); } .kind-pdf { color: var(--k-pdf); } .kind-doc { color: var(--k-doc); }
.kind-sheet { color: var(--k-sheet); } .kind-slide { color: var(--k-slide); } .kind-archive { color: var(--k-archive); }
.kind-code { color: var(--k-code); } .kind-text { color: var(--k-text); } .kind-other { color: var(--k-other); }
.item .sel { flex: none; }
.list-head { display: none; }

/* ---------- Grid view ---------- */
.items.grid .folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.items.grid .files { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.items.grid .item {
  background: var(--surface-2); border-radius: var(--radius); border: 1px solid transparent;
  transition: background-color .12s;
}
.items.grid .item:hover { background: var(--hover); }
.items.grid .item.selected { background: var(--primary-soft); border-color: var(--primary); }
.items.grid .item .sel {
  position: absolute; top: 12px; left: 12px; z-index: 2; width: 18px; height: 18px;
  opacity: 0; transition: opacity .12s;
}
.items.grid .item:hover .sel, .items.grid .item .sel:checked, .items.grid.selecting .item .sel, .items.grid .item .sel:focus-visible { opacity: 1; }
.items.grid .item.folder { display: flex; align-items: center; padding: 4px 4px 4px 16px; min-height: 52px; }
.items.grid .item.folder .thumb, .items.grid .item.folder .meta { display: none; }
.items.grid .item.folder .name { flex: 1; }
.items.grid .item.folder:hover .sel, .items.grid .item.folder .sel:checked, .items.grid.selecting .item.folder .sel { top: 17px; left: 17px; }
.items.grid .item.folder:hover .kind-icon, .items.grid .item.folder.selected .kind-icon, .items.grid.selecting .item.folder .kind-icon { visibility: hidden; }
.items.grid .item.file {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "thumb thumb" "name more" "meta meta";
  padding: 0 4px 10px 0;
}
.items.grid .item.file .thumb {
  grid-area: thumb; margin: 8px 8px 8px 8px; aspect-ratio: 4 / 3; border-radius: 8px;
  background: var(--surface); display: grid; place-items: center; overflow: hidden;
}
.items.grid .item.file .thumb { position: relative; }
.items.grid .item.file .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }  /* never crop an artefact */
.items.grid .item.file .name { grid-area: name; padding-left: 12px; }
.items.grid .item.file .more { grid-area: more; }
.items.grid .item.file .meta {
  grid-area: meta; padding: 0 12px; display: flex; gap: 6px; flex-wrap: wrap;
  overflow: hidden; white-space: nowrap;
}
.items.grid .item.file .meta .col-size::before { content: "·"; margin-right: 6px; }
.items.grid.searching .item.file .meta .col-loc { flex-basis: 100%; overflow: hidden; text-overflow: ellipsis; }

/* ---------- List view ---------- */
.items.list .section-title { display: none; }
.items.list {
  --cols: 36px minmax(0, 1fr) 170px 110px 44px;
}
.items.list.searching { --cols: 36px minmax(0, 1fr) minmax(0, 200px) 170px 110px 44px; }
.items.list .list-head, .items.list .item {
  display: grid; grid-template-columns: var(--cols); align-items: center; gap: 8px;
  padding: 0 8px; border-bottom: 1px solid var(--border);
}
.items.list .list-head {
  position: sticky; top: 64px; z-index: 5; background: var(--surface);
  height: 44px; font-size: 13px; font-weight: 500; color: var(--muted);
}
.items.list .list-head .col-loc { display: none; }
.items.list.searching .list-head .col-loc { display: block; }
.items.list .item { min-height: 48px; }
.items.list .item:hover { background: var(--hover); }
.items.list .item.selected { background: var(--primary-soft); }
.items.list .item .thumb { display: none; }
.items.list .item .meta { display: contents; }
.items.list .item .meta > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.items.list .item .sel, .items.list .list-head > span:first-child { justify-self: center; display: flex; }

.result-count { margin-top: 20px; }

.empty { text-align: center; padding: 72px 16px; color: var(--muted); }
.empty > .icon { margin: 0 auto 16px; color: var(--gold-deep); opacity: .8; }
.empty-badge { display: block; width: 88px; height: auto; margin: 0 auto 18px; }
.empty h2 { color: var(--text); font-size: 20px; font-weight: 500; margin: 0 0 6px; }
.empty p { margin: 0 0 20px; }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.pick-folder { justify-self: center; }
.up-list .up-dir { color: var(--muted); }

/* ---------- Dialogs ---------- */
dialog { color: var(--text); }
.dlg {
  width: min(440px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow-lg);
}
.dlg-wide { width: min(600px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(18, 17, 16, .55); }
.dlg-body { display: grid; gap: 14px; padding: 20px 24px 20px; margin: 0; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -4px -8px 0 0; }
.dlg-head h2 { font-size: 19px; font-weight: 500; margin: 0; overflow: hidden; text-overflow: ellipsis; }
.dlg-body p { margin: 0; }
.dlg-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 4px; }
.dlg-foot .muted { margin-right: auto; }
.dlg-filename { word-break: break-all; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.folder-picker { margin-top: 6px; padding: 4px !important; }
.folder-picker option { padding: 6px 8px; border-radius: 6px; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 28px 16px; border: 2px dashed var(--border); border-radius: var(--radius);
  color: var(--muted); font-weight: 400; cursor: pointer; text-align: center;
  transition: border-color .12s, background-color .12s;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone strong { color: var(--primary); }
.up-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; display: grid; gap: 6px; }
.up-list:empty { display: none; }
.up-list li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px 10px;
  padding: 8px 6px 8px 12px; background: var(--surface-2); border-radius: 8px; font-size: 14px;
}
.up-list .up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-list .up-size { color: var(--muted); font-size: 12px; }
.up-list .icon-btn { width: 28px; height: 28px; }
.up-list .up-progress { grid-column: 1 / -1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.up-list .up-progress span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .15s; }
.up-list li.ok .up-progress span { background: var(--success); }
.up-list li.err .up-progress span { background: var(--danger); width: 100% !important; }
.up-list .up-error { grid-column: 1 / -1; color: var(--danger); font-size: 12px; }
.date-mode { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px 12px; margin: 0; display: grid; gap: 8px; }
.date-mode legend { font-weight: 500; font-size: 14px; padding: 0 6px; }
.radio { display: flex; align-items: center; gap: 10px; font-weight: 400; flex-wrap: wrap; }
.radio input[type="datetime-local"] { width: auto; flex: 1; min-width: 200px; }

/* Preview (lightbox) */
.dlg-preview {
  width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh; margin: 0; padding: 0; border: 0;
  background: rgba(10, 12, 16, .94); color: #fff;
}
.dlg-preview[open] { display: grid; grid-template-rows: auto 1fr; grid-template-columns: 64px minmax(0, 1fr) 64px; }
.dlg-preview::backdrop { background: rgba(0, 0, 0, .6); }
.preview-bar { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 20px; }
.preview-bar .icon-btn { color: #e5e7eb; }
.preview-bar .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.preview-title { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-body { display: grid; place-items: center; min-height: 0; padding: 8px 0 24px; }
.preview-body img, .preview-body video { max-width: 100%; max-height: calc(100vh - 100px); border-radius: 6px; }
.preview-body audio { width: min(520px, 90%); }
.preview-body iframe { width: 100%; height: calc(100vh - 100px); border: 0; border-radius: 6px; background: #fff; }
.preview-nav {
  align-self: center; justify-self: center; width: 48px; height: 48px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, .1); color: #fff; cursor: pointer;
  display: grid; place-items: center;
}
.preview-nav:hover { background: rgba(255, 255, 255, .2); }
.preview-nav:disabled { visibility: hidden; }

/* Drag & drop overlay */
.drop-overlay {
  position: fixed; inset: 0; z-index: 100; display: none; place-items: center;
  background: rgba(179, 18, 27, .1); border: 3px dashed var(--primary); pointer-events: none;
}
.drop-overlay > div { background: var(--fill); color: #fff; padding: 24px 36px; border-radius: 16px; text-align: center; box-shadow: var(--shadow-lg); }
.drop-overlay .icon { margin: 0 auto 8px; }
.drop-overlay p { margin: 0; font-weight: 500; }
body.dragging .drop-overlay { display: grid; }

/* ---------- Admin / cards / tables ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface-2); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 2px; border-left: 3px solid var(--gold); }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 26px; font-weight: 600; }
.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; }
.card h2 { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 600; margin: 0 0 8px; }
.card h2 .icon { color: var(--gold-deep); }
.card > p { margin: 0 0 16px; }
.invite-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.invite-result { background: var(--success-soft); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px; display: grid; gap: 10px; }
.invite-result > strong { display: flex; align-items: center; gap: 8px; color: var(--success); }
.invite-result p { margin: 0; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions form { display: inline-flex; gap: 6px; margin: 0; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--muted); }
.badge-active { background: var(--success-soft); color: var(--success); }
.badge-used { background: var(--surface-2); color: var(--muted); }
.badge-expired { background: var(--warning-soft); color: var(--warning); }
.badge-revoked { background: var(--danger-soft); color: var(--danger); }
.badge-admin { background: rgba(59, 42, 140, .12); color: var(--purple); }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 8px 0 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .topbar { gap: 8px; padding: 0 8px; }
  .topbar .brand { width: auto; }
  .topbar .brand-sub { display: none; }
  .only-mobile { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; background: var(--bg);
    padding-top: 20px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .4); }
  .main { margin: 0; border-radius: 16px 16px 0 0; padding: 16px 16px 40px; }
  .crumbs { font-size: 18px; flex-basis: 100%; }
  .toolbar { flex-wrap: wrap; }
  .items.list, .items.list.searching { --cols: 32px minmax(0, 1fr) 90px 40px; }
  .items.list .list-head span:nth-child(3), .items.list .list-head span:nth-child(4),
  .items.list .item .col-loc, .items.list .item .col-date { display: none !important; }
  .items.grid .files { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .items.grid .folders { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .dlg-preview[open] { grid-template-columns: 0 minmax(0, 1fr) 0; }
  .preview-nav { display: none; }
}
@media (max-width: 480px) {
  .auth-card { padding: 24px 20px; }
  .user-chip .avatar { display: none; }
  .copy-row { flex-direction: column; }
}
@media (max-width: 860px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-hero { min-height: 260px; border-right: 0; border-bottom: 4px solid var(--gold); }
  .auth-hero-inner { padding: 24px; }
  .auth-badge { width: 52px; margin-bottom: 10px; }
  .auth-hero-tagline { display: none; }
  .auth-wrap { padding: 24px 16px 40px; align-items: start; }
}
@media (max-width: 560px) {
  .topbar .brand-text { display: none; }
}

/* ---------- Collections: sidebar submenu ---------- */
.nav-group {
  margin: 14px 16px 4px; font-size: 11px; font-weight: 700; letter-spacing: .16em;
  text-transform: uppercase; color: var(--gold-deep);
}
.nav a.sub { padding-left: 28px; }
.nav-sep { height: 1px; background: var(--border); margin: 10px 16px; }

/* ---------- Shared page bits ---------- */
.page-title-inline { margin: 0; flex: 1; display: flex; align-items: center; gap: 12px; }
.page-title-inline::after { display: none; }
.count {
  font-family: system-ui, sans-serif; font-size: 13px; font-weight: 600; letter-spacing: 0;
  padding: 2px 10px; border-radius: 999px; background: var(--gold-soft); color: var(--gold-deep);
}
.toolbar form { margin: 0; }
.inline-search { position: relative; display: flex; align-items: center; }
.inline-search .icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.toolbar .inline-search input[type="search"] { min-height: 34px; padding: 4px 12px 4px 34px; border-radius: 999px; width: 240px; }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.nowrap { white-space: nowrap; }
.form-tight { gap: 14px; margin-top: 0; }
textarea { resize: vertical; font: inherit; }
.remove-book-form { border-top: 1px solid var(--border); padding-top: 12px; margin: 0; }
.xhr-progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.xhr-progress span { display: block; height: 100%; width: 0; background: var(--gold); transition: width .15s; }
.xhr-error { margin: 0; color: var(--danger); font-size: 14px; }

/* ---------- Books ---------- */
.books-table td { vertical-align: middle; }
.books-table .col-icon { width: 44px; padding-right: 0; }
.book-spine {
  display: grid; place-items: center; width: 34px; height: 42px; border-radius: 3px 6px 6px 3px;
  background: linear-gradient(90deg, var(--fill) 0 5px, var(--gold-soft) 5px); color: var(--gold-deep);
  box-shadow: var(--shadow);
}
.book-title { color: var(--text); font-weight: 600; font-size: 15px; }
.book-notes { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.row-actions form { margin: 0; }

/* ---------- Albums ---------- */
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.album-card {
  display: flex; flex-direction: column; color: var(--text); background: var(--surface-2);
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border);
  transition: transform .12s, box-shadow .12s;
}
.album-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.album-cover {
  aspect-ratio: 4 / 3; background: var(--ink); display: grid; place-items: center; color: var(--gold);
  border-bottom: 3px solid var(--gold); position: relative; overflow: hidden;
}
.album-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.album-info { padding: 12px 16px 16px; }
.album-info h2 { font-family: var(--font-display); font-size: 17px; margin: 0 0 4px; }
.album-info p { margin: 8px 0 0; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.album-meta { display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--muted); font-size: 14px; margin: -4px 0 8px; }
.album-meta > * { display: inline-flex; align-items: center; gap: 6px; }
.album-meta a { color: var(--muted); }
.album-description { max-width: 760px; margin: 0 0 12px; }
.album-day .muted { font-weight: 500; letter-spacing: 0; margin-left: 6px; }
.items.grid.album .files { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.items.grid.album .item.file .thumb { aspect-ratio: 1; background: var(--ink); }
.items.grid.album .item.file .thumb img { object-fit: cover; }

@media (max-width: 900px) {
  .toolbar .inline-search input[type="search"] { width: 160px; }
  .hide-sm { display: none; }
  .album-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
}
