/* =========================================================
   RESET & CUSTOM PROPERTIES
   ========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #21242f;
  --border: #2e3247;
  --accent: #5b7fff;
  --accent-hover: #7b9fff;
  --text: #e8eaf0;
  --text-muted: #7880a0;
  --danger: #e05c6e;
  --success: #3fcf8e;
  --radius: 10px;
  --topbar-h: 56px;
  --sidebar-w: 300px;
  --transition: 0.18s ease;
}

html,
body {
  height: 100%;
  font-family: system-ui, -apple-system, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-muted);
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.3rem;
}

/* =========================================================
   AUTH OVERLAY
   ========================================================= */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: min(420px, 92vw);
}

.auth-card h1 {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}

.auth-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1.2rem;
}

#auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

#auth-form input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition);
}

#auth-form input:focus {
  border-color: var(--accent);
}

/* =========================================================
   BUTTONS
   ========================================================= */
button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: background var(--transition), color var(--transition);
}

.icon-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  color: var(--text-muted);
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  position: relative;
}

.icon-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.topbar-badge {
  position: absolute;
  top: -0.25rem;
  right: -0.3rem;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: #d33131;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.1rem;
  text-align: center;
  border: 1px solid var(--surface);
}

button[type="submit"],
.primary {
  background: var(--accent);
  color: #fff;
  padding: 0.55rem 1.2rem;
  font-weight: 600;
  width: 100%;
  margin-top: 0.5rem;
}

button[type="submit"]:hover,
.primary:hover {
  background: var(--accent-hover);
}

button.danger {
  background: var(--surface2);
  color: var(--danger);
  padding: 0.55rem 1.2rem;
  width: 100%;
  margin-top: 0.5rem;
}

button.danger:hover {
  background: var(--border);
}

button:disabled,
input:disabled,
select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.danger.admin-update-highlight {
  animation: admin-update-pulse 0.9s ease-in-out 2;
}

@keyframes admin-update-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(211, 49, 49, 0.55);
    transform: scale(1);
  }

  50% {
    box-shadow: 0 0 0 10px rgba(211, 49, 49, 0);
    transform: scale(1.02);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(211, 49, 49, 0);
    transform: scale(1);
  }
}

/* =========================================================
   TOP BAR
   ========================================================= */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 0.5rem;
  flex-shrink: 0;
}

#topbar>#btn-refresh {
  flex: 0 0 auto;
}

#breadcrumb-wrap {
  flex: 1;
  min-width: 0;
}

#breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.1rem;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
}

#breadcrumb .crumb {
  color: var(--text-muted);
  background: none;
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
}

#breadcrumb .crumb:hover {
  color: var(--text);
  background: var(--surface2);
}

#breadcrumb .crumb.active {
  color: var(--text);
  cursor: default;
}

#breadcrumb .sep {
  color: var(--border);
  user-select: none;
}

#topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
  position: relative;
}

.topbar-dropdown {
  position: relative;
}

.topbar-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.28);
  padding: 0.35rem;
  z-index: 140;
  display: none;
}

.topbar-dropdown-menu--right {
  left: auto;
  right: 0;
}

.topbar-dropdown.open .topbar-dropdown-menu {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.topbar-menu-item {
  display: flex;
  align-items: center;
  gap: 0.48rem;
  width: 100%;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
  text-align: left;
  position: relative;
}

.topbar-menu-item svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.topbar-menu-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.topbar-menu-item .topbar-badge {
  top: -0.24rem;
  right: -0.22rem;
}

.top-search {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: 0.2rem;
}

.top-search input {
  width: min(34vw, 300px);
  min-width: 150px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.88rem;
  padding: 0.42rem 0.6rem;
  outline: none;
}

.top-search input:focus {
  border-color: var(--accent);
}

#btn-search {
  padding: 0.36rem 0.62rem;
}

.global-favicon-preview {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  overflow: hidden;
  color: #fff;
}

.global-favicon-preview svg,
.global-favicon-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.icon-btn.icon-only {
  width: 2rem;
  height: 2rem;
  padding: 0;
  justify-content: center;
}

/* =========================================================
   MAIN + SIDEBAR LAYOUT
   ========================================================= */
#main-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  position: relative;
}

#folder-stats {
  margin-bottom: 0.8rem;
  font-size: 0.85rem;
}

/* Drop overlay */
#drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(91, 127, 255, 0.12);
  border: 3px dashed var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  font-size: 1.4rem;
  color: var(--accent);
  pointer-events: none;
}

/* When sidebar is open, shrink main content */
#app.sidebar-open #main-content {
  margin-right: var(--sidebar-w);
}

/* =========================================================
   FILE GRID
   ========================================================= */
#file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
}

.file-group-separator {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.1rem;
  margin-bottom: 0.1rem;
  color: var(--text-muted);
  font-size: 0.76rem;
  letter-spacing: 0.02em;
}

.file-group-separator::before,
.file-group-separator::after {
  content: '';
  height: 1px;
  background: var(--border);
  flex: 1;
}

.file-group-separator span {
  padding: 0.12rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}

.file-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.9rem 0.5rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition), border-color var(--transition);
  text-align: center;
  gap: 0.4rem;
  position: relative;
  touch-action: manipulation;
}

.file-item:hover {
  background: var(--surface);
  border-color: var(--border);
}

.file-item.file-item--preview-placeholder {
  visibility: hidden;
  pointer-events: none;
}

.file-item.selected {
  background: var(--surface2);
  border-color: var(--accent);
}

.file-item .icon {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.file-item .icon.thumb-pending::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 50%;
  top: 50%;
  border: 2px solid rgba(232, 234, 240, 0.35);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: icon-thumb-spin 0.75s linear infinite;
  background: rgba(15, 17, 23, 0.85);
}

@keyframes icon-thumb-spin {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }

  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.file-item .icon svg {
  width: 100%;
  height: 100%;
}

.file-item .icon .watched-overlay {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  border-radius: 50%;
  background: rgba(15, 17, 23, 0.45);
}

.file-item .icon .watched-overlay--partway {
  width: 16.8px;
  height: 16.8px;
}

.file-item .icon .watched-overlay--partway path {
  fill: #8f98a5;
}

.file-item .icon .watched-overlay-svg {
  width: 100%;
  height: 100%;
}

.file-item .name {
  font-size: 0.8rem;
  word-break: normal;
  overflow-wrap: anywhere;
  max-width: 100%;
  line-height: 1.3;
  color: var(--text);
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: calc(1.3em * 4);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
}

/* =========================================================
   SIDEBAR
   ========================================================= */
#sidebar {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 1.25rem;
  overflow-y: auto;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#sidebar-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
}

#sidebar-close:hover {
  background: var(--surface2);
  color: var(--text);
}

#sidebar-icon {
  display: flex;
  justify-content: center;
}

#sidebar-icon svg {
  width: 64px;
  height: 64px;
}

#sidebar-name {
  font-size: 1rem;
  word-break: break-all;
  text-align: center;
}

#sidebar-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 0.75rem;
}

#sidebar-meta dt {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

#sidebar-meta dd {
  font-size: 0.8rem;
  word-break: break-all;
}

#sidebar-meta .root-access-list {
  margin: 0;
  padding-left: 1rem;
}

#sidebar-meta .root-access-list li {
  margin: 0.12rem 0;
}

#sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

#sidebar-actions button {
  background: var(--surface2);
  color: var(--text);
  padding: 0.5rem 0.8rem;
  text-align: left;
}

#sidebar-actions button:hover {
  background: var(--border);
}

#sidebar-actions button.danger {
  color: var(--danger);
}

.sidebar-view-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
  padding-top: 0.7rem;
  margin-top: 0.2rem;
}

.sidebar-view-options h3 {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar-view-option-label {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sidebar-view-option-control {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.42rem 0.5rem;
}

.sidebar-view-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--text);
}

.custom-context-menu {
  position: fixed;
  min-width: 220px;
  max-width: min(320px, calc(100vw - 12px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35);
  padding: 0.35rem;
  z-index: 12000;
}

.custom-context-menu button,
.custom-context-menu .custom-context-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  color: var(--text);
  padding: 0.45rem 0.55rem;
  text-align: left;
  border-radius: 6px;
}

.custom-context-menu button:hover,
.custom-context-menu .custom-context-menu-item:hover {
  background: var(--surface2);
}

.custom-context-menu button.danger,
.custom-context-menu .custom-context-menu-item.danger {
  color: var(--danger);
}

.custom-context-menu-separator {
  height: 1px;
  background: var(--border);
  margin: 0.32rem 0;
}

.custom-context-menu-row {
  position: relative;
}

.custom-context-submenu {
  position: absolute;
  top: 0;
  left: calc(100% + 0.3rem);
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35);
  padding: 0.35rem;
  display: none;
}

.custom-context-menu-row:hover>.custom-context-submenu,
.custom-context-menu-row:focus-within>.custom-context-submenu {
  display: block;
}

/* ─── Duplicates panel ─────────────────────────────────── */
#sidebar-duplicates {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.sidebar-duplicates-heading {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #888);
  margin: 0 0 0.4rem;
}

.sidebar-duplicates-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-duplicate-entry {
  display: block;
  width: 100%;
  background: var(--surface2);
  color: var(--text);
  padding: 0.35rem 0.6rem;
  text-align: left;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: var(--radius);
  cursor: pointer;
}

.sidebar-duplicate-entry:hover {
  background: var(--border);
}

.admin-size-feedback {
  font-size: 0.82rem;
  margin: 0.25rem 0 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
}

.admin-size-feedback.ok {
  color: var(--accent);
}

.admin-size-feedback.err {
  color: #e55;
}

/* =========================================================
   MODALS
   ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 11000;
}

#file-conflict-modal,
#overwrite-modal {
  z-index: 11150;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: min(560px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal.small {
  width: min(340px, 94vw);
}

#confirm-modal .modal.confirm-modal-wide {
  width: min(760px, 94vw);
}

.modal h2 {
  font-size: 1.3rem;
  margin-bottom: 1.25rem;
}

.modal h3 {
  font-size: 1rem;
  color: var(--text-muted);
  margin: 1rem 0 0.5rem;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 0.25rem 0.5rem;
}

.modal-close:hover {
  color: var(--text);
}

.update-commit-list {
  max-height: min(48vh, 420px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  padding: 0.6rem 0.8rem;
}

.update-commit-item+.update-commit-item {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.update-commit-item h3 {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 700;
  color: var(--text);
}

.update-commit-hash {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.update-commit-subject {
  color: var(--text);
}

.update-commit-body {
  margin: 0.45rem 0 0;
  font-size: 0.94rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* =========================================================
   FOLDER ICON PICKER
   ========================================================= */
.folder-icon-modal {
  width: min(680px, 94vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
}

.folder-icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.5rem;
  max-height: 50vh;
  overflow-y: auto;
  padding: 0.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.folder-icon-filter {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.48rem 0.68rem;
  outline: none;
}

.folder-icon-filter:focus {
  border-color: var(--accent);
}

.debug-modal {
  width: min(980px, 96vw);
  max-height: 92vh;
}

.debug-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  margin: 0.75rem 0 1rem;
}

.debug-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.debug-copy-btn {
  padding: 0.3rem 0.55rem;
  border-radius: 7px;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
}

.debug-copy-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.debug-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.debug-summary-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}

.debug-summary-item .k {
  display: block;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.debug-summary-item .v {
  display: block;
  color: var(--text);
  font-weight: 650;
  margin-top: 0.12rem;
}

.debug-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.debug-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
  background: var(--bg);
  font-size: 0.82rem;
}

.debug-table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  background: var(--bg);
}

.debug-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.debug-table th,
.debug-table td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  padding: 0.45rem 0.55rem;
}

.debug-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}

.debug-table tr:last-child td {
  border-bottom: 0;
}

.debug-path {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-word;
}

.folder-icon-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.folder-icon-cell:hover {
  background: var(--surface2);
}

.folder-icon-cell.selected {
  border-color: var(--accent);
  background: rgba(91, 127, 255, 0.12);
}

.folder-icon-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--surface2);
}

.folder-icon-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  word-break: break-all;
  text-align: center;
  max-width: 72px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.vjs-text-track-cue>div {
  background: transparent !important;
  text-shadow: 2px 0 black, -2px 0 black, 0 2px black, 0 -2px black,
    1px 1px black, -1px -1px black, 1px -1px black, -1px 1px black;
}

/* Admin path list */
.path-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.path-row span {
  flex: 1;
  word-break: break-all;
}

.path-row button {
  background: none;
  color: var(--danger);
  padding: 0.2rem 0.5rem;
}

.path-add-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.path-add-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.path-add-row input:focus {
  border-color: var(--accent);
}

.path-add-row button {
  background: var(--surface2);
  color: var(--text);
  padding: 0.45rem 0.9rem;
}

.path-add-row button:hover {
  background: var(--border);
}

.admin-favicon-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0.35rem 0 0.6rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.admin-favicon-row .icon-btn {
  color: var(--text);
  background: var(--surface2);
}

.admin-favicon-row .icon-btn:hover {
  background: var(--border);
}

.admin-scheduled-restart {
  margin: 0.4rem 0 0.8rem;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.admin-scheduled-restart.admin-scheduled-restart--disabled {
  opacity: 0.7;
}

.admin-scheduled-restart-toggle {
  margin-bottom: 0.5rem;
}

.admin-scheduled-restart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.admin-scheduled-restart-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.admin-scheduled-restart-grid input,
.admin-scheduled-restart-grid select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.4rem 0.55rem;
}

/* User list */
.user-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.user-row .user-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.9rem;
}

.user-row .user-admin-badge {
  font-size: 0.72rem;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
}

.user-row button {
  background: none;
  color: var(--text-muted);
  padding: 0.2rem 0.5rem;
  font-size: 0.85rem;
}

.user-row button:hover {
  color: var(--text);
}

.user-row button.danger {
  color: var(--danger);
}

#admin-orphan-userfolders-section {
  margin-top: 1rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
}

#admin-orphan-userfolders-section h4 {
  margin: 0 0 0.35rem;
  font-size: 0.86rem;
  color: var(--text);
}

.orphan-folder-row .orphan-folder-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* User form permissions */
#user-permissions {
  margin-top: 0.75rem;
}

#user-permissions h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.perm-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}

.perm-row .perm-label {
  min-width: 130px;
  color: var(--text);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* Form labels in modals */
.modal form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
}

.modal form input[type="text"],
.modal form input[type="password"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition);
}

.modal form input:focus {
  border-color: var(--accent);
}

/* Admin user-folder controls use the same visual language as modal forms. */
#admin-userfolder-section label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
}

#admin-userfolder-section input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition);
}

#admin-userfolder-section input[type="text"]:focus {
  border-color: var(--accent);
}

/* =========================================================
  FILE PREVIEW — SHARED MEDIA STYLES
  ========================================================= */
.preview-media {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 8px;
  background: #fff;
}

.preview-audio {
  width: min(640px, 95%);
}

.preview-model-wrap {
  width: 100%;
  height: 100%;
  min-height: 240px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d111a;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
}

.preview-model-canvas {
  flex: 1 1 auto;
  width: 100%;
  min-height: 180px;
  display: block;
  cursor: grab;
}

.preview-model-canvas:active {
  cursor: grabbing;
}

.preview-model-hint {
  margin: 0;
  padding: 0.45rem 0.7rem;
  border-top: 1px solid rgba(120, 128, 160, 0.35);
  color: #b8c4e8;
  font-size: 0.78rem;
  text-align: center;
}

.preview-text {
  width: 100%;
  min-height: 100%;
  color: #dce4ff;
  background: #0d111a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem;
  font: 0.85rem/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  overflow: auto;
  white-space: pre;
  text-align: left;
}

.preview-code .tok-comment {
  color: #6f7f9a;
}

.preview-code .tok-string {
  color: #9ee37d;
}

.preview-code .tok-number {
  color: #f8c46a;
}

.preview-code .tok-keyword {
  color: #8bb4ff;
  font-weight: 600;
}

.preview-code .tok-key {
  color: #59c8ff;
}

.preview-unsupported {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 56ch;
  text-align: center;
}

.preview-footer {
  border-top: 1px solid var(--border);
  padding: 0.8rem 1rem;
  display: flex;
  justify-content: flex-end;
}

.preview-footer .primary {
  width: auto;
  margin-top: 0;
  min-width: 8rem;
}



/* =========================================================

.toast-msg {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  animation: slideup 0.25s ease;
}

.toast-msg.err {
  border-color: var(--danger);
  color: var(--danger);
}

.toast-msg.ok {
  border-color: var(--success);
  color: var(--success);
}

@keyframes slideup {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================================
   UPLOAD PROGRESS
   ========================================================= */
.upload-bar-wrap {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.5rem 1rem;
  z-index: 80;
  font-size: 0.85rem;
}

.upload-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.upload-abort-btn {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  padding: 0.25rem 0.55rem;
  font: inherit;
  cursor: pointer;
}

.upload-abort-btn:hover:not(:disabled),
.upload-abort-btn:focus-visible:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.upload-abort-btn:disabled {
  cursor: default;
  opacity: 0.55;
}

.upload-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-top: 0.3rem;
}

.upload-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.2s linear;
}

/* =========================================================
   RESPONSIVE — narrow screens
   ========================================================= */
@media (max-width: 600px) {
  #topbar {
    height: auto;
    min-height: var(--topbar-h);
    padding: 0.5rem 0.6rem;
    align-items: flex-start;
    flex-direction: column;
  }

  #topbar>#btn-refresh {
    align-self: flex-start;
  }

  #breadcrumb-wrap {
    width: 100%;
  }

  #topbar-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.15rem;
  }

  .top-search {
    order: -1;
    width: 100%;
    margin-right: 0;
  }

  .top-search input {
    flex: 1;
    min-width: 0;
    width: auto;
  }

  .topbar-dropdown-menu {
    position: fixed;
    top: calc(var(--topbar-h) + 0.35rem);
    left: 0.6rem;
    right: 0.6rem;
    min-width: 0;
  }

  .topbar-dropdown-menu--right {
    left: 0.6rem;
    right: 0.6rem;
  }

  .icon-btn {
    padding: 0.4rem 0.55rem;
    font-size: 0.82rem;
  }

  #main-content {
    padding: 0.9rem;
  }

  #file-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  #app.sidebar-open #main-content {
    margin-right: 0;
  }

  #sidebar {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    height: auto;
    max-height: min(68vh, calc(100vh - 0.5rem));
    padding: 0.9rem 0.9rem 1rem;
    border-left: none;
    border-top: 1px solid var(--border);
    width: 100%;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -12px 26px rgba(0, 0, 0, 0.34);
    gap: 0.55rem;
  }

  #sidebar-close {
    display: inline-flex;
    position: absolute;
    top: 0.45rem;
    right: 0.45rem;
    border-color: var(--border);
    background: var(--surface2);
  }

  #sidebar-name {
    padding-right: 2rem;
  }

  #sidebar-icon svg {
    width: 54px;
    height: 54px;
  }

  #sidebar-actions {
    margin-top: 0.2rem;
  }

  .modal {
    padding: 1.25rem;
  }

  .preview-overlay {
    padding: 0.8rem;
  }

  .preview-sheet {
    width: 100%;
    height: 92vh;
  }

  .preview-fold {
    width: 54px;
    height: 54px;
  }

  .preview-close {
    top: 5px;
    right: 5px;
  }
}

/* =========================================================
   DIALOG MODALS (confirm / prompt / overwrite)
   ========================================================= */
.dialog-message {
  color: var(--text-muted);
  font-size: 0.93rem;
  margin: 0 0 1.5rem;
  line-height: 1.5;
  word-break: break-word;
}

.dialog-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.dialog-actions--overwrite {
  justify-content: space-between;
}

.dialog-actions button {
  min-width: 5rem;
  background: var(--surface2);
  color: var(--text);
  padding: 0.5rem 1rem;
}

.dialog-actions button:hover {
  background: var(--border);
}

/* Override .primary full-width inside dialog rows */
.dialog-actions button.primary {
  width: auto;
  margin-top: 0;
}
