:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2a3a4f;
  --text: #e7eef7;
  --muted: #8aa0b8;
  --accent: #3b82f6;
  --danger: #ef4444;
  --ok: #22c55e;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
}
.panel { max-width: 420px; margin: 10vh auto; background: var(--panel); padding: 2rem; border-radius: 12px; border: 1px solid var(--border); }
.center { text-align: center; }
.panel form { display: flex; flex-direction: column; gap: .75rem; text-align: left; }
/* Author display rules (e.g. .panel form) must not override the hidden attribute. */
[hidden] { display: none !important; }
label { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; color: var(--muted); }
input, button, .btn {
  font: inherit; border-radius: 8px; border: 1px solid var(--border); padding: .55rem .75rem;
  background: #0b1220; color: var(--text);
}
button, .btn { background: var(--accent); border-color: transparent; cursor: pointer; color: white; }
button.ghost, .ghost { background: transparent; border-color: var(--border); color: var(--text); }
.error { color: var(--danger); }
.muted { color: var(--muted); font-size: .9rem; }
.signup-status { color: var(--ok); font-size: 1rem; margin: 1rem 0 0; }
.topbar {
  display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem;
  border-bottom: 1px solid var(--border); background: var(--panel);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  min-width: 0;
}
.brand-logo {
  display: block;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}
.brand-lockup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
}
.brand-lockup-lg {
  flex-direction: column;
  gap: .75rem;
  margin: 0 0 .15rem;
}
.brand-lockup-lg .brand-logo {
  width: 64px;
  height: 64px;
}
.brand-lockup h1 { margin: 0; }
.spacer { flex: 1; }
.sidebar-toggle, .sidebar-drawer-bar, .sidebar-backdrop { display: none; }
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 56px); }
aside {
  border-right: 1px solid var(--border);
  padding: 1rem;
  background: #121a26;
  min-width: 0;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}
.sidebar-main { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
aside ul { list-style: none; padding: 0; margin: 0; }
.sidebar-bmc {
  flex: 0 0 auto;
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}
.bmc-button-sidebar {
  width: 100%;
  box-sizing: border-box;
  margin-top: 0;
  padding: .5rem .55rem;
  font-size: .82rem;
  white-space: nowrap;
}
.bmc-button-sidebar .bmc-cup {
  width: 18px;
  height: 18px;
}

main { padding: 1rem; min-width: 0; overflow-x: hidden; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; flex-wrap: wrap; }
.actions {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}
.actions > *,
.actions .sort-controls,
.actions .view-toggle,
.actions .file-btn,
.actions button {
  flex-shrink: 0;
}
.file-btn { display: inline-flex; align-items: center; margin: 0; cursor: pointer; }
#btn-mkdir[hidden],
.actions .file-btn[hidden] { display: none !important; }

.file-search {
  flex: 1 1 160px;
  min-width: 140px;
  max-width: 280px;
}
.file-search input {
  width: 100%;
  box-sizing: border-box;
  padding: .4rem .65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b1220;
  color: var(--text);
}
.trash-actions {
  display: flex;
  gap: .4rem;
  flex-shrink: 0;
  align-items: center;
}
.trash-actions[hidden] {
  display: none;
}
.search-source { font-size: .8rem; }


/* File list: fixed columns so Name/Size/Modified/actions stay aligned */
.files-wrap { width: 100%; overflow-x: hidden; position: relative; min-height: 12rem; border-radius: 10px; transition: outline-color .12s, background .12s; }
.files {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate; /* collapse + overflow:hidden on tds breaks the row line */
  border-spacing: 0;
}
.files col.col-icon { width: 2.25rem; }
.files col.col-name { width: auto; }
.files col.col-size { width: 5.25rem; }
.files col.col-mod { width: 9.5rem; }
.files col.col-actions { width: 10.75rem; }
.files th, .files td {
  text-align: left;
  padding: .5rem .35rem;
  border-bottom: 1px solid var(--border);
  font-size: .92rem;
  vertical-align: middle;
}
.files tr:hover td { background: #152033; }
.files th.icon-h, .files td.icon,
.files th.size-h, .files td.size-cell,
.files th.mod-h, .files td.mod-cell {
  overflow: hidden;
}
.files td.icon, .files th.icon-h {
  width: 2.25rem;
  text-align: center;
  white-space: nowrap;
}
.files .name-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
}
.files .name-btn {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: .25rem .45rem;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
}
.files .name-btn:hover, .files .name-btn:focus-visible {
  border-color: var(--border);
  background: #152033;
}
.files td.size-cell, .files td.mod-cell,
.files th.size-h, .files th.mod-h {
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.files th.size-h, .files th.mod-h { color: var(--text); }
.files td.row-actions, .files th.actions-h {
  display: table-cell; /* do not use flex on the td — it breaks the bottom border */
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
}
.files td.row-actions > * {
  display: inline-flex;
  vertical-align: middle;
  margin: 0 0 0 .25rem;
}
.files td.row-actions > *:first-child { margin-left: 0; }
div.row-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .25rem;
  flex-wrap: nowrap;
}
.row-actions button {
  flex: 0 0 auto;
  padding: .25rem .4rem;
  font-size: .85rem;
  line-height: 1.2;
  min-width: 1.85rem;
  margin: 0;
}
.row-actions button.danger {
  border-color: #7f1d1d;
  color: #fca5a5;
}
.row-actions button.danger:hover {
  background: #7f1d1d33;
}

#breadcrumbs {
  display: flex; flex-wrap: nowrap; align-items: center; gap: .15rem;
  min-width: 0; max-width: 100%; overflow: hidden;
}
#breadcrumbs button {
  background: transparent; border: none; color: var(--accent); padding: 0 .2rem;
  max-width: 10rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#whoami {
  max-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

@media (max-width: 960px) {
  .files col.col-mod, .files th.mod-h, .files td.mod-cell { display: none; }
  .files col.col-actions { width: 6.5rem; }
}
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  #main-view > .topbar { position: relative; z-index: 81; }
  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: .35rem .65rem;
    font-weight: 600;
  }
  .sidebar-toggle[aria-expanded="true"] { background: #243247; }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: var(--main-topbar-height, 56px);
    border: 0;
    padding: 0;
    margin: 0;
    border-radius: 0;
    background: rgba(0,0,0,.55);
    z-index: 70;
    cursor: pointer;
  }
  body.sidebar-open .sidebar-backdrop { display: block; }
  body.sidebar-open { overflow: hidden; }
  #sidebar {
    display: none;
    position: fixed;
    top: var(--main-topbar-height, 56px);
    left: 0;
    bottom: 0;
    width: min(18.5rem, 88vw);
    z-index: 80;
    border-right: 1px solid var(--border);
    border-bottom: none;
    box-shadow: 8px 0 28px rgba(0,0,0,.45);
    overflow: hidden;
  }
  body.sidebar-open #sidebar { display: flex; }
  .sidebar-drawer-bar {
    display: flex;
    justify-content: flex-end;
    flex: 0 0 auto;
    margin: -0.35rem -0.15rem .35rem;
  }
  .sidebar-close { padding: .3rem .6rem; }
  .files col.col-size, .files th.size-h, .files td.size-cell { display: none; }
  .files col.col-actions { width: 6.25rem; }
  #breadcrumbs button { max-width: 6rem; }
  .toolbar {
    align-items: stretch;
    gap: .65rem;
  }
  #breadcrumbs {
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
  }
  .file-search {
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
  }
  .trash-actions {
    flex: 1 1 100%;
  }
  .trash-actions[hidden] {
    display: none;
  }
  .actions {
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
  }
}
@media (max-width: 420px) {
  .files col.col-actions { width: 5.75rem; }
  .row-actions button { padding: .2rem .3rem; min-width: 1.7rem; }
  .actions { gap: .4rem; }
  .view-btn { padding: .28rem .45rem !important; font-size: .78rem; }
  .brand-logo { width: 28px; height: 28px; }
  .brand-lockup-lg .brand-logo { width: 48px; height: 48px; }
}

.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; padding: 1rem; }
.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); }
#preview { border: none; border-radius: 12px; padding: 0; max-width: min(96vw, 1100px); max-height: 92vh; background: #000; color: white; }
#preview::backdrop { background: rgba(0,0,0,.65); }
#preview .close { position: absolute; right: .5rem; top: .5rem; z-index: 2; }
#preview-body { padding: 1rem; display: flex; justify-content: center; align-items: center; min-width: 280px; min-height: 200px; }
#preview-body img, #preview-body video { max-width: 90vw; max-height: 85vh; }
#preview-body.pdf-mode { padding: 0; width: min(96vw, 1100px); height: min(90vh, 900px); min-height: 60vh; display: block; }
#preview-body .pdf-frame, .public-single-preview .pdf-frame {
  width: 100%; height: 100%; min-height: 60vh; border: 0; border-radius: 10px; background: #0b1220;
}
.public-single-preview.pdf-mode { text-align: left; }
.public-single-preview.pdf-mode .pdf-frame { min-height: min(70vh, 720px); height: min(70vh, 720px); }

.admin-form { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .75rem; }
.admin-form input[type="text"], .admin-form input:not([type]), .admin-form input[type="password"] { width: 100%; }
.badge { display: inline-block; font-size: .72rem; padding: .1rem .4rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.badge.admin { color: #93c5fd; border-color: #3b82f6; }
.badge.disabled { color: #fca5a5; border-color: var(--danger); }
.badge.current { color: #86efac; border-color: #22c55e; }
#user-edit-dialog, #share-grant-dialog {
  border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; background: var(--panel); color: var(--text);
  max-width: min(96vw, 420px); width: 100%;
  position: relative;
}
#user-edit-dialog::backdrop, #share-grant-dialog::backdrop { background: rgba(0,0,0,.55); }
#user-edit-dialog .dialog-close, #share-grant-dialog .dialog-close { position: absolute; right: .5rem; top: .5rem; margin: 0; }
#share-grant-form.admin-form { margin-bottom: .5rem; }
#share-grant-error[hidden], #share-grant-empty[hidden] { display: none !important; }
#share-grant-current { margin-top: .35rem; }
.sep { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

.upload-status {
  padding: .75rem .85rem; border: 1px solid var(--border);
  border-radius: 12px; background: var(--panel);
  display: flex; flex-direction: column; min-height: 0;
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
}
.upload-status[hidden] { display: none !important; }
.upload-status.upload-float {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 90;
  width: min(380px, calc(100vw - 2rem));
  max-height: min(46vh, 360px);
}
.upload-status-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; flex: 0 0 auto; }
.upload-progress-label { font-weight: 500; color: var(--muted); font-size: .9rem; }
.upload-status ul,
#upload-list {
  list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .55rem;
  max-height: min(34vh, 280px);
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
}
.login-links { margin: .65rem 0 0; text-align: center; display: flex; flex-wrap: wrap; justify-content: center; gap: .75rem 1.25rem; }
.login-links a, button.linkish {
  background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-decoration: underline;
}
.upload-item { display: flex; flex-direction: column; gap: .3rem; }
.upload-item .row { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; font-size: .9rem; }
.upload-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.upload-item .meta { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.upload-item .bar {
  height: 8px; background: #0b1220; border-radius: 999px; overflow: hidden; border: 1px solid var(--border);
}
.upload-item .bar > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .12s ease-out; }
.upload-item.done .bar > span { background: var(--ok); }
.upload-item.err .bar > span { background: var(--danger); width: 100% !important; }
.upload-item.done .meta { color: var(--ok); }
.upload-item.err .meta { color: var(--danger); }

/* Sidebar folder tree */
#root-list, #root-list ul { list-style: none; padding: 0; margin: 0; }
.tree-node { margin: 0; }
.tree-row {
  display: flex; align-items: center; gap: .15rem;
  border-radius: 6px; margin-bottom: .15rem;
  padding-left: calc(var(--depth, 0) * 0.85rem);
}
.tree-row:hover { background: #243247; }
.tree-row.active { background: #243247; outline: 1px solid var(--border); }
.tree-twisty {
  flex: 0 0 1.4rem; width: 1.4rem; height: 1.6rem; padding: 0;
  border: none; background: transparent; color: var(--muted);
  font-size: .75rem; line-height: 1; cursor: pointer;
}
.tree-label {
  flex: 1 1 auto; min-width: 0; text-align: left;
  background: transparent; border: none; color: var(--text);
  padding: .4rem .35rem; border-radius: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tree-count-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.15rem;
  margin: 0 .35rem 0 .15rem;
  padding: 0 .35rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #243247;
  color: var(--text);
  font-size: .68rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
.tree-children { margin: 0; padding: 0; }

/* Sidebar albums */
.sidebar-albums { margin-top: 1.25rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.sidebar-albums h3 { margin: 0 0 .4rem; font-size: .85rem; color: var(--muted); font-weight: 600; }
.sidebar-albums .sidebar-empty { margin: .25rem 0 0; font-size: .82rem; }
#album-list { list-style: none; padding: 0; margin: 0; }
#album-list li { margin: 0; }
.album-nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: .35rem .4rem;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.album-nav-item:hover { background: #1a2433; }
.album-nav-item.active { background: #1e3a5f; color: #fff; }

/* Sidebar storage quota */
.sidebar-quota { margin-top: 1.25rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.sidebar-quota h3 { margin: 0 0 .4rem; font-size: .85rem; color: var(--muted); font-weight: 600; }
.sidebar-quota .meta { font-size: .82rem; color: var(--muted); margin-bottom: .35rem; }
.sidebar-quota .quota-bar,
.settings-card .quota-bar,
.admin-table .quota-bar {
  height: 6px; background: #0b1220; border-radius: 4px; overflow: hidden; border: 1px solid var(--border);
}
.sidebar-quota .quota-bar > span,
.settings-card .quota-bar > span,
.admin-table .quota-bar > span { display: block; height: 100%; background: var(--accent); }
.sidebar-quota .quota-bar.over > span,
.settings-card .quota-bar.over > span,
.admin-table .quota-bar.over > span { background: var(--danger); }

/* Settings: left vertical nav + right content panel */
#settings-view { display: flex; flex-direction: column; min-height: 100vh; }
#settings-view[hidden] { display: none; }
.settings-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  flex: 1;
  min-height: 0;
}
.settings-nav {
  display: flex; flex-direction: column; gap: .25rem;
  padding: 1rem .75rem;
  border-right: 1px solid var(--border);
  background: var(--panel);
}
.settings-nav-item {
  text-align: left;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  border-radius: 8px; padding: .55rem .75rem;
}
.settings-nav-item:hover { color: var(--text); background: #152033; }
.settings-nav-item.active {
  color: var(--text); border-color: var(--border); background: var(--bg);
}
.settings-nav-item:disabled,
.settings-nav-item[aria-disabled="true"] {
  opacity: .4; pointer-events: none;
}
.settings-content { padding: 1rem 1.25rem; overflow: auto; }
.settings-panel { display: none; max-width: 960px; }
.settings-panel.active { display: block; }
.settings-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.1rem;
}
.settings-card h3 { margin: 0 0 .75rem; }
.about-card p { margin: 0 0 .75rem; line-height: 1.5; }
.about-card a:not(.bmc-button) { color: var(--accent); }
.about-card a:not(.bmc-button):hover { text-decoration: underline; }
.bmc-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  margin-top: .15rem;
  padding: .65rem 1.15rem;
  background: #FFDD00;
  color: #0D0C22 !important;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-decoration: none !important;
  border-radius: 8px;
  border: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.bmc-button:hover { background: #ffe34d; }
.bmc-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.bmc-cup {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.settings-account { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .65rem; }
.settings-account .meta { font-size: .85rem; color: var(--muted); }
#change-password-msg.error,
#password-policy-msg.error { color: var(--danger); }
.settings-gate-banner {
  margin: 0; color: #fbbf24; font-size: .9rem; max-width: 50vw;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.policy-form { max-width: 420px; }
.policy-form label.check { display: flex; flex-direction: row; align-items: center; gap: .5rem; }
@media (max-width: 800px) {
  .settings-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    align-content: start;
  }
  .settings-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    align-self: start;
    width: 100%;
    box-sizing: border-box;
    gap: .35rem;
    padding: .5rem .75rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .settings-content { padding: .75rem .9rem; }
  .settings-nav-item {
    flex: 0 0 auto;
    align-self: center;
    white-space: nowrap;
    padding: .4rem .75rem;
    font-size: .85rem;
    line-height: 1.2;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #0b1220;
  }
  .settings-nav-item.active {
    color: #fff;
    border-color: transparent;
    background: var(--accent);
  }
  .settings-gate-banner { max-width: none; white-space: normal; }
}
.admin-section { padding: 1rem; max-width: 1100px; }
.admin-section h3 { margin-top: 0; }
.admin-section .admin-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .5rem .65rem;
  align-items: end;
  margin-bottom: 1rem;
  padding: .85rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.admin-section .admin-form .check { grid-column: span 1; }
.admin-section .admin-form button[type="submit"] { justify-self: start; }

.admin-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}
.admin-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}
.admin-table col.col-user { width: 9.5rem; }
.admin-table col.col-home { width: auto; }
.admin-table col.col-quota { width: 11rem; }
.admin-table col.col-status { width: 7.5rem; }
.admin-table col.col-share-name { width: 9.5rem; }
.admin-table col.col-share-path { width: auto; }
.admin-table col.col-share-grants { width: 16rem; }
.admin-table col.col-link-label { width: 8.5rem; }
.admin-table col.col-link-target { width: 18%; }
.admin-table col.col-link-url { width: auto; }
.admin-table col.col-link-status { width: 9.5rem; }
.admin-table col.col-actions { width: 14rem; }
.admin-table.links-table col.col-actions { width: 9.5rem; }
.admin-table .link-label-cell,
.admin-table .link-target-cell,
.admin-table .link-url-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-table .link-url-cell a,
.admin-table .path-cell code {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.admin-table .link-url-cell a {
  color: var(--accent, #6cb6ff);
  text-decoration: none;
}
.admin-table .link-url-cell a:hover { text-decoration: underline; }
.admin-table th, .admin-table td {
  text-align: left;
  padding: .55rem .55rem;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
  vertical-align: middle;
}
.admin-table thead th {
  color: var(--muted);
  font-weight: 600;
  background: #121a26;
  position: sticky;
  top: 0;
}
.admin-table tbody tr:hover td { background: #152033; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table .user-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-table .meta { font-size: .78rem; color: var(--muted); margin-top: .1rem; }
.admin-table .home-cell code {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .85rem;
  color: var(--muted);
}
.admin-table td.grants-cell {
  overflow: hidden;
  white-space: normal;
  vertical-align: middle;
}
.grant-list {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
}
.grant-row {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem .4rem;
  max-width: 100%;
  padding: .15rem .4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b1220;
}
.grant-row .grant-name {
  font-size: .85rem;
  color: var(--text);
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.grant-row .grant-perm {
  width: auto;
  min-width: 5.5rem;
  padding: .2rem .35rem;
  font-size: .82rem;
}
.grant-row .grant-revoke {
  padding: .2rem .4rem;
  font-size: .78rem;
}
.grant-row .grant-summary {
  font-size: .78rem;
  color: var(--muted);
  white-space: nowrap;
}
.grant-row .grant-delete-flag {
  flex-direction: row;
  align-items: center;
  gap: .3rem;
  margin: 0;
  font-size: .82rem;
  color: var(--text);
  white-space: nowrap;
}
.grant-row .grant-delete-flag input { margin: 0; }
#btn-bulk-delete[hidden],
#btn-bulk-move[hidden],
#btn-bulk-copy[hidden],
#btn-bulk-share[hidden] { display: none !important; }
.admin-table td.quota-cell {
  overflow: hidden;
  max-width: 0;
}
.admin-table .quota-cell .meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-table .quota-cell .quota-bar {
  margin-top: .3rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.admin-table .status-cell { white-space: nowrap; }
.admin-table td.row-actions,
.admin-table th.actions-h {
  text-align: right;
  white-space: nowrap;
  overflow: visible;
}
/* Keep the Actions td as a real table-cell. display:grid/flex on the td
   takes it out of table layout (storage bars overflow later columns;
   link-share Label/Target/URL previously stacked). */
.admin-table td.row-actions {
  display: table-cell;
  vertical-align: middle;
}
/* Keep Edit / Approve / Reject / Del on one row; column width is sized for three buttons. */
.admin-table .row-actions-inner {
  display: inline-flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: .25rem;
  vertical-align: middle;
}
.admin-table .row-actions button {
  flex: 0 0 auto;
  padding: .25rem .45rem;
  font-size: .82rem;
  line-height: 1.2;
  min-width: 2rem;
  margin: 0;
}
.admin-table .empty-row { text-align: center; padding: 1rem; }
.grant-chip {
  display: inline-block;
  font-size: .72rem;
  padding: .1rem .4rem;
  margin: .1rem .15rem .1rem 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  background: #0b1220;
  white-space: nowrap;
}
.system-notes { padding-left: 1.1rem; margin: .5rem 0 0; list-style: disc; }
.system-notes li { margin: .35rem 0; background: transparent; border: none; padding: 0; }
.system-status { margin: 0 0 1.15rem; }
.system-status h4 { margin: 0 0 .75rem; font-size: 1rem; }
.status-metric { margin: 0 0 .85rem; }
.status-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; margin-bottom: .3rem; flex-wrap: wrap; }
.status-label { font-weight: 600; color: var(--text); }
.status-value { color: var(--muted); font-size: .9rem; text-align: right; min-width: 0; word-break: break-word; }
#system-quota-note, #system-disk-path, #system-gpu-flags, #system-gpu-note, #system-status-updated { margin: .3rem 0 0; }
.system-gpu-list { margin: .35rem 0 0; padding-left: 1.1rem; list-style: disc; }
.system-gpu-list:empty { display: none; }
.system-gpu-list li { margin: .25rem 0; background: transparent; border: none; padding: 0; color: var(--muted); font-size: .9rem; word-break: break-word; }
#system-status-error[hidden], #system-cpu-bar[hidden], #system-ram-bar[hidden], #system-quota-bar[hidden], #system-disk-bar[hidden] { display: none !important; }
#global-quota-form { margin-top: .75rem; }
.admin-form-note { grid-column: 1 / -1; margin: 0; }
#create-user-quota-note[hidden], #edit-user-quota-note[hidden], #global-quota-msg[hidden] { display: none !important; }
@media (max-width: 900px) {
  .admin-table col.col-home,
  .admin-table col.col-share-path,
  .admin-table col.col-link-target,
  .admin-table td.home-cell,
  .admin-table td.link-target-cell { display: none; }
  .admin-table thead th.home-h,
  .admin-table thead th.path-h { display: none; }
}
/* Link shares: keep Actions as a real table-cell so Copy/Revoke stay under the header
   (display:grid on td takes the cell out of table layout and stacks content). */
.admin-table.links-table td.row-actions {
  display: table-cell;
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
  overflow: visible;
}
.admin-table.links-table td.row-actions button {
  display: inline-block;
  vertical-align: middle;
  margin-left: .2rem;
}
.links-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .75rem;
  margin: 0 0 .65rem;
}
#links-bulk-msg { margin: 0; }
#links-bulk-msg[hidden] { display: none !important; }
.admin-table.links-table col.col-check { width: 2.25rem; }
.admin-table.links-table th.check-h,
.admin-table.links-table td.check-cell {
  text-align: center;
  width: 2.25rem;
  padding-left: .4rem;
  padding-right: .35rem;
  overflow: hidden;
  vertical-align: middle;
}
.admin-table.links-table td.check-cell input,
.admin-table.links-table th.check-h input {
  margin: 0;
  vertical-align: middle;
}

@media (max-width: 800px) {
  .admin-grid { grid-template-columns: 1fr; }
  .admin-table col.col-status,
  .admin-table col.col-link-status,
  .admin-table td.status-cell,
  .admin-table thead th.status-h { display: none; }
  .admin-table col.col-actions { width: 6.5rem; }
  .admin-table.links-table col.col-check { width: 2.15rem; }
  .admin-table.links-table col.col-link-label { width: 28%; }
  .admin-table.links-table col.col-link-url { width: auto; }
  .admin-table.links-table col.col-actions { width: 8.75rem; }
}
@media (max-width: 420px) {
  .admin-table.links-table col.col-check { width: 2.1rem; }
  .admin-table.links-table col.col-link-label { width: 30%; }
  .admin-table.links-table col.col-actions { width: 7.25rem; }
  .admin-table.links-table .row-actions button {
    padding: .2rem .35rem;
    font-size: .75rem;
    min-width: 0;
  }
}


/* Sort controls — one horizontal row (override global label { flex-direction: column }) */
.sort-controls {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: .35rem;
  align-items: center;
  white-space: nowrap;
}
.sort-label {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: .35rem;
  align-items: center;
  font-size: .82rem;
  color: var(--muted);
  white-space: nowrap;
  margin: 0;
}
.sort-label select {
  background: #0b1220;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .3rem .45rem;
  font: inherit;
  flex: 0 0 auto;
}
#btn-sort-dir {
  flex: 0 0 auto;
  white-space: nowrap;
}
.th-sort {
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
  text-align: inherit;
}
.th-sort:hover { color: var(--accent); }
.th-sort.active { color: var(--accent); }

/* View toggle */
.view-toggle { display: inline-flex; gap: .2rem; border: 1px solid var(--border); border-radius: 8px; padding: .15rem; background: #0b1220; }
.view-btn { padding: .3rem .55rem !important; font-size: .82rem; border: none !important; border-radius: 6px !important; color: var(--muted) !important; }
.view-btn.active { background: var(--accent) !important; color: #fff !important; }

/* Drop zone */
.files-wrap.drop-active {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  background: #15203388;
}
.drop-hint {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--accent);
  background: #0b1220aa;
  border-radius: 10px;
  text-align: center;
  padding: 1rem;
}
.files-wrap.drop-active .drop-hint {
  display: flex;
}
tr.drop-folder-target td,
.file-card.drop-folder-target {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: #1e3a5f !important;
}

/* Icon / grid view */
.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: .75rem;
  padding: .35rem 0 .75rem;
}
.file-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .35rem;
  padding: .55rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
  min-width: 0;
  position: relative;
}
.file-card:hover { border-color: var(--accent); background: #152033; }
.file-card .thumb {
  aspect-ratio: 1;
  width: 100%;
  border-radius: 8px;
  background: #0b1220;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  font-size: 2rem;
}
.file-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.file-card .thumb .play-badge {
  position: absolute;
  right: .35rem;
  bottom: .35rem;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: .7rem;
  padding: .15rem .35rem;
  border-radius: 4px;
}
.file-card .card-name {
  font-size: .82rem;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.file-card .card-actions {
  display: flex;
  justify-content: center;
  gap: .2rem;
  opacity: .85;
}
.file-card .card-actions button {
  padding: .15rem .35rem;
  font-size: .75rem;
  min-width: 1.6rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.file-card .card-actions button.danger {
  border-color: #7f1d1d;
  color: #fca5a5;
}
.files-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 10px;
  margin: .5rem 0;
}

.totp-qr {
  display: block;
  width: 180px;
  height: 180px;
  margin: .75rem 0;
  background: #fff;
  border-radius: 8px;
  padding: .5rem;
}
.backup-codes {
  list-style: none;
  padding: 0;
  margin: .5rem 0 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .35rem .75rem;
  font-family: ui-monospace, monospace;
}
.totp-actions {
  display: flex;
  gap: .5rem;
  margin-top: .75rem;
  flex-wrap: wrap;
}
#totp-enroll-login, #totp-form {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  text-align: left;
  margin-top: 1rem;
}
#totp-enroll-login[hidden], #totp-form[hidden] { display: none !important; }


/* Multi-select + bulk bar */
.files col.col-check { width: 2rem; }
.files th.check-h, .files td.check-cell {
  width: 2rem;
  text-align: center;
  vertical-align: middle;
}
.files col.col-actions { width: 10.75rem; }
.files tr.selected td { background: #1e3a5f; }
.bulk-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  margin: 0 0 .75rem; padding: .5rem .75rem;
  background: #152033; border: 1px solid var(--border); border-radius: 10px;
}
.bulk-bar[hidden] { display: none !important; }
.bulk-bar .danger { border-color: #7f1d1d; color: #fca5a5; }
.file-card { position: relative; }
.file-card.selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-check {
  position: absolute; top: .35rem; left: .35rem; z-index: 2;
  background: rgba(0,0,0,.45); border-radius: 6px; padding: .15rem .2rem;
}
#share-url {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: .5rem 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
#share-result, #share-existing, #share-form { min-width: 0; }
#share-result { text-align: left; margin-top: .35rem; }
#share-result h4 { margin: 0 0 .35rem; font-size: 1.05rem; }
#share-dialog #share-target { margin: 0 0 .75rem; }
#share-form[hidden],
#share-result[hidden],
#share-error[hidden],
#share-link-options[hidden],
#share-perm-wrap[hidden],
#share-existing[hidden],
#share-user-empty[hidden],
#share-user-hint[hidden],
#share-user-filter[hidden],
#share-url[hidden],
#btn-copy-share-url[hidden] {
  display: none !important;
}
.share-fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem .75rem .75rem;
  margin: 0 0 .75rem;
  min-width: 0;
}
.share-fieldset legend { padding: 0 .35rem; font-weight: 600; }
.share-user-hint { margin: .35rem 0 0; font-size: .85rem; }
#share-user-filter { width: 100%; margin: .45rem 0 0; }
.share-user-list {
  max-height: min(40vh, 16rem);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: .45rem 0 .35rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b1220;
  min-height: 0;
}
.share-user-list:empty { display: none; }
label.share-user-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: .6rem;
  margin: 0;
  padding: .65rem .7rem;
  min-height: 2.75rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
label.share-user-row:last-child { border-bottom: none; }
label.share-user-row:hover { background: #152033; }
label.share-user-row:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
label.share-user-row input { flex-shrink: 0; margin: 0; accent-color: var(--accent); }
.share-user-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .95rem;
  color: var(--text);
}
.share-user-badge {
  flex-shrink: 0;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .1rem .45rem;
}
.share-existing { text-align: left; margin: .5rem 0; min-width: 0; }
.share-existing h4 { margin: 0 0 .35rem; font-size: 1rem; }
.share-existing-list { list-style: none; padding: 0; margin: 0 0 .5rem; min-width: 0; }
.share-existing-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .4rem .5rem;
  padding: .4rem 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.share-existing-list .meta { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-existing-list li.share-existing-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "label actions"
    "url url";
  align-items: center;
  column-gap: .5rem;
  row-gap: .25rem;
}
.share-existing-list .share-link-label {
  grid-area: label;
  min-width: 0;
}
.share-existing-list .share-link-url {
  grid-area: url;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .85rem;
  color: var(--muted);
}
.share-existing-list .share-link-actions {
  grid-area: actions;
  display: flex;
  gap: .35rem;
  flex-shrink: 0;
  justify-self: end;
}

.share-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .25rem;
}
.share-result-actions #btn-copy-share-url { flex: 1 1 auto; }
#btn-create-share:disabled { opacity: .65; cursor: wait; }
.public-file-list { list-style: none; padding: 0; margin: 1rem 0 0; text-align: left; }
.public-file-list li {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .45rem .25rem; border-bottom: 1px solid var(--border);
}
.public-file-list .name-btn { text-align: left; flex: 1; min-width: 0; }
.public-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem; margin-top: .75rem; }
#public-share-view { max-width: min(920px, 96vw); }
.public-single-preview { margin-top: 1rem; text-align: center; }
.public-single-preview img, .public-single-preview video {
  max-width: 100%; max-height: min(70vh, 640px); border-radius: 10px; background: #0b1220;
}
.public-single-preview.pdf-mode .public-actions { margin-top: .75rem; }
.public-single-preview .public-actions { margin-top: .75rem; display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }
#transfer-dialog, #share-dialog {
  border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem;
  background: var(--panel); color: var(--text); max-width: min(96vw, 420px); width: 100%;
}
#share-dialog {
  max-height: min(90vh, 720px);
  overflow-x: hidden;
  overflow-y: auto;
}
#transfer-dialog {
  max-width: min(96vw, 440px);
  max-height: min(90vh, 640px);
  overflow-x: hidden;
  overflow-y: auto;
}
#transfer-dialog::backdrop, #share-dialog::backdrop { background: rgba(0,0,0,.65); }
#transfer-form.admin-form {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  min-width: 0;
}
#transfer-form.admin-form > * { min-width: 0; }
#transfer-form #transfer-root { width: 100%; }
#transfer-dest-hint { margin: 0; word-break: break-word; color: var(--muted); font-size: .85rem; }
#transfer-error[hidden] { display: none !important; }
.transfer-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .15rem .25rem;
  min-width: 0;
}
.transfer-crumb, .transfer-crumb-sep {
  font-size: .85rem;
  color: var(--muted);
}
button.ghost.transfer-crumb {
  padding: .2rem .4rem;
  border-radius: 6px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
button.ghost.transfer-crumb[aria-current="location"] {
  color: var(--text);
  font-weight: 600;
  cursor: default;
}
.transfer-folders {
  max-height: min(40vh, 260px);
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b1220;
  min-height: 6.5rem;
}
.transfer-folders-empty {
  margin: 0;
  padding: .75rem .7rem;
  color: var(--muted);
  font-size: .9rem;
}
.transfer-folder-current,
button.ghost.transfer-folder-btn {
  display: flex;
  align-items: center;
  gap: .45rem;
  width: 100%;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: .6rem .7rem;
  min-width: 0;
}
.transfer-folder-current {
  background: #152033;
  font-weight: 600;
  margin: 0;
}
button.ghost.transfer-folder-btn:hover { background: #243247; }
button.ghost.transfer-folder-btn:last-child,
.transfer-folder-current:last-child { border-bottom: none; }
.transfer-folder-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Album view */
.album-view { padding: .25rem 0 1rem; }
.album-folders,
.album-media {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .85rem;
}
.album-media { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .65rem; }
.album-section-title {
  margin: 1rem 0 .55rem;
  font-size: .85rem;
  color: var(--muted);
  font-weight: 600;
}
.album-section-title:first-child { margin-top: .15rem; }
.album-tile,
.album-media-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
  overflow: hidden;
  position: relative;
}
.album-tile:hover,
.album-media-card:hover { border-color: var(--accent); background: #152033; }
.album-tile .thumb,
.album-media-card .thumb {
  aspect-ratio: 4 / 3;
  width: 100%;
  background: #0b1220;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  font-size: 2rem;
}
.album-tile .thumb { aspect-ratio: 16 / 11; }
.album-tile .thumb img,
.album-media-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.album-tile .thumb .play-badge,
.album-media-card .thumb .play-badge {
  position: absolute;
  right: .4rem;
  bottom: .4rem;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: .7rem;
  padding: .15rem .35rem;
  border-radius: 4px;
}
.album-tile .tile-name,
.album-media-card .tile-name {
  padding: .45rem .55rem .5rem;
  font-size: .85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.album-tile .tile-actions,
.album-media-card .tile-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .2rem;
  padding: 0 .4rem .4rem;
}
.album-tile .tile-actions button,
.album-media-card .tile-actions button {
  padding: .15rem .35rem;
  font-size: .75rem;
  min-width: 1.6rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.album-hint { margin: .75rem 0 0; font-size: .82rem; }
.album-empty { padding: 1.5rem .5rem; text-align: center; }
.album-badge {
  display: inline-block;
  margin-left: .4rem;
  padding: .05rem .35rem;
  border-radius: 4px;
  font-size: .7rem;
  border: 1px solid var(--border);
  color: var(--muted);
  vertical-align: middle;
}

@media (max-width: 800px) {
  .album-folders,
  .album-media {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .6rem;
  }
  .album-tile .tile-name,
  .album-media-card .tile-name { font-size: .8rem; }
}

@media (max-width: 960px) {
  .files col.col-actions { width: 7.5rem; }
}
@media (max-width: 800px) {
  .files col.col-actions { width: 7rem; }
}

/* Upload name-conflict dialog */
#upload-conflict-dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  background: var(--panel);
  color: var(--text);
  max-width: min(96vw, 560px);
  width: 100%;
  max-height: min(90vh, 680px);
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
}
#upload-conflict-dialog::backdrop { background: rgba(0,0,0,.65); }
#upload-conflict-dialog .dialog-close { position: absolute; right: .5rem; top: .5rem; margin: 0; }
#upload-conflict-dialog h3 { margin: 0 2rem .5rem 0; }
#upload-conflict-intro { margin: 0 0 1rem; }
.conflict-apply {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin: 0 0 .75rem;
  font-size: .9rem;
  color: var(--muted);
}
.conflict-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
button.conflict-choice {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: .35rem .65rem;
  font-size: .85rem;
}
button.conflict-choice:hover { background: #243247; }
button.conflict-choice.active {
  background: var(--accent);
  border-color: transparent;
  color: white;
}
button.conflict-choice:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.conflict-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  max-height: min(45vh, 360px);
  overflow-y: auto;
}
.conflict-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem .75rem;
  padding: .65rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b1220;
}
.conflict-row-info {
  min-width: 0;
  flex: 1 1 160px;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.conflict-row-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conflict-row-hint { font-size: .8rem; color: var(--muted); }
.conflict-footer {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  flex-wrap: wrap;
}
.upload-item.skipped .bar > span { background: var(--muted); width: 100% !important; }
.upload-item.skipped .meta { color: var(--muted); }

.login-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: .85rem 0 .15rem;
  color: var(--muted);
  font-size: .85rem;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}
#oidc-login { margin: .25rem 0 .15rem; }
#oidc-start.btn {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
}
#oidc-form input[readonly] {
  color: var(--muted);
  background: #0b1220;
}

#oo-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
body.oo-editor-open { overflow: hidden; }
#oo-editor-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
}
#oo-editor-bar .title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
#oo-editor-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #0f1419;
  min-height: 0;
}

.oo-create-hint {
  font-size: .8rem;
  max-width: 16rem;
  line-height: 1.25;
}
#oo-new-wrap[hidden],
#oo-create-hint[hidden] {
  display: none !important;
}
.oo-new-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}
.oo-new-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 40;
  min-width: 10rem;
  padding: .25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #121a26;
  box-shadow: 0 8px 24px #0008;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.oo-new-menu[hidden] { display: none !important; }
.oo-new-menu button {
  width: 100%;
  text-align: left;
  margin: 0;
  padding: .4rem .65rem;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
}
.oo-new-menu button:hover,
.oo-new-menu button:focus-visible {
  background: #1a2740;
}
#oo-editor-coedit-hint {
  font-size: .8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(40vw, 22rem);
}
@media (max-width: 900px) {
  #oo-editor-coedit-hint,
  .oo-create-hint { display: none; }
  .files col.col-actions { width: 9.5rem; }
}

.perm-badge {
  display: inline-block;
  margin-left: .4rem;
  font-size: .75rem;
  padding: .05rem .4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
  vertical-align: middle;
}
.name-wrap .perm-badge { margin-top: .15rem; margin-left: .45rem; }

.share-existing-user-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.share-existing-user-row .share-existing-user { flex: 1 1 auto; min-width: 6rem; }
.share-existing-perm { max-width: 10rem; }

.row-overflow { position: relative; display: inline-flex; flex-shrink: 0; }
.row-overflow-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 40;
  min-width: 8rem;
  padding: .25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #121a26;
  box-shadow: 0 8px 24px #0008;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.row-overflow-menu[hidden] { display: none !important; }
.row-overflow-menu button {
  width: 100%;
  text-align: left;
  margin: 0;
}

@media (max-width: 720px) {
  .files col.col-actions { width: 6.25rem; }
  .files td.row-actions, .files th.actions-h { width: 6.25rem; max-width: 6.25rem; }
}
#onlyoffice-ds-health.error { color: #fca5a5; }

#preview.preview-has-edit #preview-body img { max-height: calc(85vh - 3.5rem); }
#preview-toolbar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .5rem;
  padding: .55rem 2.75rem .7rem;
  border-top: 1px solid #222;
  background: #111;
}
#preview-toolbar[hidden] { display: none !important; }
#btn-preview-edit { padding: .4rem .85rem; }

#photo-editor {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
  width: min(96vw, 1100px);
  max-width: 96vw;
  max-height: 94vh;
  max-height: 94dvh;
}
#photo-editor::backdrop { background: rgba(0,0,0,.72); }
#photo-editor-inner {
  display: flex;
  flex-direction: column;
  height: min(94vh, 900px);
  height: min(94dvh, 900px);
  max-height: 94vh;
  max-height: 94dvh;
  min-height: 0;
}
.photo-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  padding: .85rem 1rem .65rem;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.photo-editor-heading { min-width: 0; }
#photo-editor-title { margin: 0 2rem 0 0; font-size: 1.05rem; }
#photo-editor-filename { margin: .25rem 2rem 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#photo-editor .dialog-close { position: absolute; right: .5rem; top: .5rem; margin: 0; }
#photo-editor-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 220px;
  background: #0b1220;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#photo-editor-canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
  background: #000;
}
#photo-editor-crop {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(0,0,0,.45);
  cursor: move;
  touch-action: none;
}
#photo-editor-crop[hidden] { display: none !important; }
.crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border: 1px solid #fff;
  border-radius: 1px;
  box-sizing: border-box;
  touch-action: none;
}
.crop-handle.nw { top: -6px; left: -6px; cursor: nwse-resize; }
.crop-handle.n { top: -6px; left: 50%; margin-left: -6px; cursor: ns-resize; }
.crop-handle.ne { top: -6px; right: -6px; cursor: nesw-resize; }
.crop-handle.w { top: 50%; left: -6px; margin-top: -6px; cursor: ew-resize; }
.crop-handle.e { top: 50%; right: -6px; margin-top: -6px; cursor: ew-resize; }
.crop-handle.sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.crop-handle.s { bottom: -6px; left: 50%; margin-left: -6px; cursor: ns-resize; }
.crop-handle.se { bottom: -6px; right: -6px; cursor: nwse-resize; }
#photo-editor-tools {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: .65rem;
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
}
.photo-editor-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.photo-editor-buttons button { padding: .4rem .7rem; }
.photo-editor-sliders {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .65rem 1rem;
}
.photo-editor-sliders label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .5rem;
  color: var(--muted);
  font-size: .85rem;
}
.photo-editor-sliders input[type="range"] { width: 100%; padding: 0; accent-color: var(--accent); }
#photo-editor-error, #photo-editor-status { margin: 0 1rem .5rem; }
#photo-editor-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .5rem;
  padding: .65rem 1rem 1rem;
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
  background: var(--panel);
}
@media (max-width: 720px) {
  /* Pin the editor to the visible viewport so iOS Safari's bottom chrome
     cannot cover Save / Overwrite / Cancel. 100vh is the large viewport
     and is taller than the visible area when the toolbar is showing. */
  #photo-editor {
    width: 100%;
    max-width: 100%;
    margin: 0;
    border: none;
    border-radius: 0;
    position: fixed;
    left: 0;
    right: 0;
    top: var(--photo-editor-vp-top, 0px);
    height: 100vh;
    max-height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    height: 100svh;
    max-height: 100svh;
    height: var(--photo-editor-vp-height, 100svh);
    max-height: var(--photo-editor-vp-height, 100svh);
  }
  #photo-editor-inner {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
    padding-top: env(safe-area-inset-top, 0px);
  }
  #photo-editor .dialog-close {
    top: calc(.5rem + env(safe-area-inset-top, 0px));
  }
  #photo-editor-stage {
    min-height: 80px;
    overflow: auto;
  }
  #photo-editor-tools {
    overflow-y: auto;
    min-height: 0;
  }
  .photo-editor-sliders { grid-template-columns: 1fr; }
  #photo-editor-actions {
    justify-content: stretch;
    position: sticky;
    bottom: 0;
    z-index: 3;
    padding: .65rem 1rem calc(.85rem + env(safe-area-inset-bottom, 0px));
  }
  #photo-editor-actions button { flex: 1 1 auto; }
}

.album-tile.selected,
.album-media-card.selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.album-tile .card-check,
.album-media-card .card-check {
  position: absolute; top: .35rem; left: .35rem; z-index: 3;
  width: 2.25rem; height: 2.25rem;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.45); border-radius: 6px; padding: 0;
}
.album-tile .card-check input,
.album-media-card .card-check input {
  width: 1.15rem; height: 1.15rem; margin: 0;
}
.album-select-bar {
  display: flex; align-items: center; gap: .5rem;
  margin: 0 0 .6rem; font-size: .9rem;
}
.album-select-bar input { width: 1.1rem; height: 1.1rem; }
.cover-badge {
  display: inline-block;
  margin-left: .35rem;
  padding: .05rem .35rem;
  border-radius: 4px;
  font-size: .68rem;
  background: var(--accent);
  color: #fff;
  vertical-align: middle;
}
.photo-editor-exif {
  display: flex; align-items: center; gap: .4rem;
  margin: .15rem 1rem .15rem;
  font-size: .9rem;
}
#photo-editor-exif-hint { margin: 0 1rem .5rem; font-size: .82rem; }
#photo-editor-exif-hint[hidden] { display: none !important; }
