﻿:root {
  --fa-header-h: 56px;
  --fa-sidebar-w: 260px;
  --fa-status-h: 38px;
  --fa-bg: #f5f7fa;
  --fa-panel: #ffffff;
  --fa-border: #e4e8ee;
  --fa-border-strong: #cfd6e0;
  --fa-text: #1f2937;
  --fa-muted: #6b7280;
  --fa-primary: #2563eb;
  --fa-primary-soft: #eff6ff;
  --fa-hover: #f1f4f8;
  --fa-radius: 8px;
  --bs-body-bg: var(--fa-panel);
  --bs-body-color: var(--fa-text);
  --bs-border-color: var(--fa-border);
  --bs-secondary-color: var(--fa-muted);
  --bs-secondary-bg: var(--fa-hover);
  --bs-tertiary-bg: var(--fa-hover);
  --bs-emphasis-color: var(--fa-text);
  --bs-primary: var(--fa-primary);
  --bs-primary-rgb: 37, 99, 235;
  color-scheme: light;
}

[data-theme="dark"] {
  --fa-bg: #0f1115;
  --fa-panel: #171a21;
  --fa-border: #262b35;
  --fa-border-strong: #394150;
  --fa-text: #e5e7eb;
  --fa-muted: #98a2b3;
  --fa-primary: #60a5fa;
  --fa-primary-soft: #1e293b;
  --fa-hover: #222836;
  --bs-primary-rgb: 96, 165, 250;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--fa-bg);
  color: var(--fa-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    "PingFang SC", "Noto Sans SC", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--fa-primary);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--fa-sidebar-w) 6px minmax(0, 1fr);
  grid-template-rows: var(--fa-header-h) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  transition: grid-template-columns 0.18s ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 0 0 minmax(0, 1fr);
}

.app-shell.sidebar-collapsed .app-sidebar {
  visibility: hidden;
  border-right: 0;
}

.app-shell.sidebar-collapsed .sidebar-resizer {
  display: none;
}

/* Header */

.app-header {
  grid-column: 1 / -1;
  grid-row: 1;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: var(--fa-panel);
  border-bottom: 1px solid var(--fa-border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--fa-text);
  text-decoration: none;
  white-space: nowrap;
}

.brand-name {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.version-badge {
  font-size: 10px;
  font-weight: 500;
  color: var(--fa-muted) !important;
  background: var(--fa-bg) !important;
}

.header-search {
  position: relative;
  flex: 1;
  max-width: 520px;
  margin-left: 6px;
}

.header-search .form-control {
  height: 34px;
  padding-left: 34px;
  background: var(--fa-bg);
  border-color: var(--fa-border);
  color: var(--fa-text);
}

.header-search .form-control:disabled {
  background: var(--fa-bg);
  opacity: 1;
  cursor: not-allowed;
}

.header-search .form-control::placeholder {
  color: var(--fa-muted);
  opacity: 0.8;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 11px;
  z-index: 2;
  width: 16px;
  height: 16px;
  color: var(--fa-muted);
  pointer-events: none;
  transform: translateY(-50%);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.user-menu {
  position: relative;
}

.user-menu[hidden],
.user-menu-dropdown[hidden] {
  display: none;
}

.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 190px;
  padding: 6px 9px;
  color: var(--fa-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
}

.user-menu-trigger:hover,
.user-menu-trigger[aria-expanded="true"] {
  background: var(--fa-bg);
  border-color: var(--fa-border);
}

.user-menu-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-trigger .icon {
  flex: 0 0 auto;
  color: var(--fa-muted);
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 120;
  min-width: 160px;
  padding: 6px;
  background: var(--fa-panel);
  border: 1px solid var(--fa-border);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
}

.user-menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  color: var(--fa-text);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 5px;
  font-size: 12px;
}

.user-menu-item:hover {
  background: var(--fa-bg);
}

.user-menu-item[hidden],
.mobile-only {
  display: none;
}

.user-menu-danger {
  color: var(--bs-danger, #dc3545);
}

.auth-state {
  color: var(--fa-muted);
  font-size: 12px;
}

.sidebar-toggle {
  display: inline-flex;
}

/* Sidebar */

.app-sidebar {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--fa-panel);
  border-right: 1px solid var(--fa-border);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  flex: 0 0 48px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--fa-border);
}

.sidebar-title {
  color: var(--fa-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tree {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.tree-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 46px 14px;
  color: var(--fa-muted);
  text-align: center;
}

.tree-empty .icon-xl {
  color: var(--fa-border-strong);
}

.tree-empty p {
  margin: 12px 0 4px;
  color: var(--fa-text);
  font-size: 13px;
  font-weight: 600;
}

.tree-empty small {
  max-width: 180px;
  font-size: 11px;
  line-height: 1.6;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  flex: 0 0 38px;
  padding: 0 16px;
  color: var(--fa-muted);
  font-size: 11px;
  border-top: 1px solid var(--fa-border);
}

.dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--fa-muted);
  opacity: 0.6;
}

.sidebar-resizer {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  z-index: 10;
  cursor: col-resize;
}

.sidebar-resizer::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 1px;
  background: transparent;
  content: "";
}

.sidebar-resizer:hover::after,
.sidebar-resizer:focus-visible::after {
  background: var(--fa-primary);
}

body.resizing {
  cursor: col-resize;
  user-select: none;
}

.sidebar-backdrop {
  display: none;
}

/* Main */

.app-main {
  grid-column: 3;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--fa-bg);
}

.main-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 52px;
  flex: 0 0 52px;
  padding: 0 18px;
  background: var(--fa-panel);
  border-bottom: 1px solid var(--fa-border);
}

.breadcrumb {
  margin: 0;
  font-size: 13px;
}

.breadcrumb-item.active {
  color: var(--fa-text);
}

.breadcrumb-item + .breadcrumb-item::before {
  color: var(--fa-muted);
  content: "鈥?;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.main-content {
  display: flex;
  flex: 1;
  min-height: 0;
  padding: 28px;
  overflow: auto;
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--fa-status-h);
  flex: 0 0 var(--fa-status-h);
  padding: 0 18px;
  color: var(--fa-muted);
  font-size: 11px;
  background: var(--fa-panel);
  border-top: 1px solid var(--fa-border);
}

.status-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.footer-brand-link {
  color: inherit;
  text-decoration: none;
}

.footer-brand-link:hover {
  color: var(--fa-primary);
  text-decoration: underline;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fa-muted);
}

.status-dot.ok {
  background: #16a34a;
}

.status-dot.err {
  background: #dc2626;
}

.status-sep {
  width: 1px;
  height: 10px;
  margin: 0 4px;
  background: var(--fa-border);
}

/* Empty state */

.empty-state {
  width: 100%;
  max-width: 640px;
  margin: auto;
  padding: 34px;
  text-align: center;
  background: var(--fa-panel);
  border: 1px dashed var(--fa-border-strong);
  border-radius: 14px;
}

.empty-state-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  color: var(--fa-primary);
  background: var(--fa-primary-soft);
  border-radius: 14px;
}

.empty-state h1 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.empty-lead {
  margin: 0 auto;
  max-width: 440px;
  color: var(--fa-muted);
  font-size: 13px;
  line-height: 1.7;
}

.next-steps {
  display: grid;
  gap: 10px;
  margin-top: 24px;
  text-align: left;
}

.next-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  background: var(--fa-bg);
  border: 1px solid var(--fa-border);
  border-radius: 10px;
}

.step-no {
  flex: 0 0 auto;
  padding: 2px 7px;
  color: var(--fa-primary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--fa-primary-soft);
  border-radius: 5px;
}

.next-step strong {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
  font-weight: 650;
}

.next-step p {
  margin: 0;
  color: var(--fa-muted);
  font-size: 11px;
  line-height: 1.5;
}

/* Controls */

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--fa-muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
}

.btn-icon:hover:not(:disabled) {
  color: var(--fa-text);
  background: var(--fa-hover);
}

.btn-icon:disabled {
  opacity: 0.45;
}

.btn .icon {
  width: 15px;
  height: 15px;
  margin-right: 5px;
}

.btn-icon .icon {
  margin-right: 0;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.icon-xl {
  width: 36px;
  height: 36px;
}

.icon-2xl {
  width: 28px;
  height: 28px;
}

/* Bootstrap tweaks */

.btn-primary {
  --bs-btn-bg: var(--fa-primary);
  --bs-btn-border-color: var(--fa-primary);
  --bs-btn-hover-bg: var(--fa-primary);
  --bs-btn-hover-border-color: var(--fa-primary);
}

.form-control:disabled {
  background: var(--fa-bg);
  color: var(--fa-muted);
}

.form-control,
.form-select {
  color: var(--fa-text);
  background-color: var(--fa-panel);
  border-color: var(--fa-border-strong);
}

.form-control::placeholder {
  color: var(--fa-muted);
  opacity: 0.85;
}

.form-control:focus,
.form-select:focus {
  color: var(--fa-text);
  background-color: var(--fa-panel);
  border-color: var(--fa-primary);
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.18);
}

.form-check-input {
  background-color: var(--fa-panel);
  border-color: var(--fa-border-strong);
}

.form-check-input:checked {
  background-color: var(--fa-primary);
  border-color: var(--fa-primary);
}

.btn-outline-secondary {
  --bs-btn-color: var(--fa-text);
  --bs-btn-border-color: var(--fa-border-strong);
  --bs-btn-hover-color: var(--fa-text);
  --bs-btn-hover-bg: var(--fa-hover);
  --bs-btn-hover-border-color: var(--fa-border-strong);
  --bs-btn-active-color: var(--fa-text);
  --bs-btn-active-bg: var(--fa-hover);
  --bs-btn-active-border-color: var(--fa-border-strong);
  --bs-btn-disabled-color: var(--fa-muted);
}

[data-theme="dark"] .text-bg-light {
  color: var(--fa-text) !important;
  background-color: var(--fa-hover) !important;
}

/* Responsive */

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-main {
    grid-column: 1;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .app-sidebar {
    position: fixed;
    top: var(--fa-header-h);
    bottom: 0;
    left: 0;
    z-index: 30;
    width: min(84vw, 320px);
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: 0 12px 32px rgb(15 23 42 / 18%);
  }

  .app-shell.sidebar-open .app-sidebar {
    transform: none;
  }

  .sidebar-resizer {
    display: none;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: var(--fa-header-h) 0 0;
    z-index: 25;
    display: block;
    pointer-events: none;
    background: rgb(15 23 42 / 45%);
    opacity: 0;
    transition: opacity 0.18s ease;
  }

  .app-shell.sidebar-open .sidebar-backdrop {
    pointer-events: auto;
    opacity: 1;
  }
}

@media (max-width: 520px) {
  .toolbar-actions > .btn span {
    display: none;
  }

  .toolbar-actions > .btn {
    gap: 0;
    padding-inline: 9px;
  }
}

@media (max-width: 640px) {
  .app-header {
    gap: 8px;
    padding: 0 12px;
  }

  .header-search,
  .auth-state {
    display: none;
  }

  .main-content {
    padding: 16px;
  }

  .empty-state {
    padding: 24px 18px;
  }

  .main-toolbar {
    padding: 0 12px;
  }

  .status-bar {
    padding: 0 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* Tree */

.sidebar-admin-link {
  margin-left: auto;
  color: var(--fa-primary);
  font-size: 11px;
  text-decoration: none;
}

.sidebar-admin-link:hover {
  text-decoration: underline;
}

.sidebar-admin-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-left: auto;
  color: var(--fa-muted);
  text-decoration: none;
}

.sidebar-admin-icon .icon {
  width: 16px;
  height: 16px;
}

.sidebar-admin-icon:hover {
  color: var(--fa-primary);
  text-decoration: none;
}

.sidebar-admin-icon + .sidebar-admin-link {
  margin-left: 0;
}

@media (max-width: 640px) {
  #shares-btn {
    display: none !important;
  }

  .mobile-only {
    display: block;
  }
}

.tree-root,
.tree-children {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tree-node {
  user-select: none;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 30px;
  padding: 2px 6px;
  color: var(--fa-text);
  border-radius: 6px;
  cursor: pointer;
}

.tree-row:hover {
  background: var(--fa-hover);
}

.tree-row.active {
  color: var(--fa-primary);
  background: var(--fa-primary-soft);
}

.tree-toggle {
  display: grid;
  flex: 0 0 20px;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  color: var(--fa-muted);
  background: transparent;
  border: 0;
  border-radius: 4px;
}

.tree-toggle .icon {
  width: 14px;
  height: 14px;
  transition: transform 0.12s ease;
}

.tree-toggle.expanded .icon {
  transform: rotate(90deg);
}

.tree-toggle.leaf {
  visibility: hidden;
}

.tree-label {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 6px;
  min-width: 0;
  padding: 2px 0;
  color: inherit;
  font-size: 13px;
  text-align: left;
  background: transparent;
  border: 0;
}

.tree-label .icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  color: var(--fa-primary);
}

.tree-label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-label .tree-badge {
  flex: 0 0 auto;
  padding: 0 5px;
  overflow: visible;
  color: var(--fa-muted);
  font-size: 9px;
  font-weight: 600;
  line-height: 15px;
  text-overflow: clip;
  border: 1px solid var(--fa-border-strong);
  border-radius: 999px;
}

.tree-label .tree-lock {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  color: var(--fa-muted);
}

.tree-children {
  margin-left: 12px;
  padding-left: 8px;
  border-left: 1px solid var(--fa-border);
}

.tree-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 42px 14px;
  color: var(--fa-muted);
  text-align: center;
}

.tree-empty .icon-xl {
  color: var(--fa-border-strong);
}

.tree-empty p {
  margin: 12px 0 4px;
  color: var(--fa-text);
  font-size: 13px;
  font-weight: 600;
}

.tree-empty small {
  max-width: 190px;
  font-size: 11px;
  line-height: 1.6;
}

.tree-empty a {
  margin-top: 10px;
  font-size: 11px;
  color: var(--fa-primary);
}

/* Breadcrumb */

.breadcrumb-item a {
  color: var(--fa-muted);
  text-decoration: none;
}

.breadcrumb-item a:hover {
  color: var(--fa-primary);
}

/* File table */

.main-content.has-table {
  display: block;
  padding: 16px 18px;
}

.file-table-wrap {
  width: 100%;
  overflow: hidden;
  background: var(--fa-panel);
  border: 1px solid var(--fa-border);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgb(15 23 42 / 4%);
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.file-table th,
.file-table td {
  padding: 0 12px;
  text-align: left;
  vertical-align: middle;
}

.file-table thead th {
  height: 42px;
  color: var(--fa-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--fa-bg);
  border-bottom: 1px solid var(--fa-border);
}

.file-table tbody tr {
  height: 46px;
  border-bottom: 1px solid var(--fa-border);
}

.file-table tbody tr:last-child {
  border-bottom: 0;
}

.file-table tbody tr:hover {
  background: var(--fa-hover);
}

.file-table tbody tr.selected {
  background: var(--fa-primary-soft);
}

.file-table .col-check {
  width: 48px;
  padding-right: 8px;
  cursor: pointer;
}

.file-table .row-check {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.file-table .col-size {
  width: 110px;
}

.file-table .col-time {
  width: 190px;
}

.file-table .col-actions {
  width: 100px;
  text-align: right;
}

.file-name {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-width: 0;
  padding: 4px 0;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
}

.file-name .icon {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  color: var(--fa-muted);
}

.file-name.is-dir .icon {
  color: var(--fa-primary);
}

.file-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name:hover span {
  text-decoration: underline;
}

.file-muted {
  color: var(--fa-muted);
  font-size: 12px;
}

.file-actions {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.file-table tr:hover .file-actions,
.file-table tr:focus-within .file-actions {
  opacity: 1;
}

.btn-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--fa-muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.btn-row:hover {
  color: var(--fa-text);
  background: var(--fa-hover);
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  color: inherit;
  font: inherit;
  background: transparent;
  border: 0;
}

.sort-button .sort-mark {
  color: var(--fa-primary);
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 4px 0;
  color: var(--fa-muted);
  font-size: 11px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
}

.batch-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 0;
}

.batch-actions[hidden] {
  display: none;
}

.batch-count {
  color: var(--fa-muted);
  font-size: 12px;
  white-space: nowrap;
}

.file-info-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  transition: opacity 160ms ease;
}

.file-info-backdrop.is-open {
  opacity: 1;
}

.file-info-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1041;
  display: flex;
  width: min(380px, 100vw);
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  overflow-y: auto;
  background: var(--fa-panel);
  border-left: 1px solid var(--fa-border);
  box-shadow: -12px 0 32px rgba(15, 23, 42, 0.18);
  transform: translateX(100%);
  transition: transform 180ms ease;
}

.file-info-panel.is-open {
  transform: translateX(0);
}

body.file-info-open {
  overflow: hidden;
}

.file-info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.file-info-head h2 {
  margin: 0;
  font-size: 16px;
}

.file-info-summary {
  display: flex;
  align-items: center;
  gap: 14px;
}

.file-info-icon {
  display: flex;
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  color: var(--fa-primary);
  background: var(--fa-bg);
  border: 1px solid var(--fa-border);
  border-radius: 14px;
}

.file-info-name {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.file-info-name strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info-details {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
  font-size: 12px;
}

.file-info-details dt {
  color: var(--fa-muted);
  font-weight: 500;
}

.file-info-details dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.file-info-qr-section {
  padding-top: 14px;
  border-top: 1px solid var(--fa-border);
}

.file-info-qr-section h3 {
  margin: 0 0 12px;
  font-size: 14px;
}

.file-info-qr-tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 10px;
}

.file-info-qr-tabs .btn.active {
  color: #fff;
  background: var(--fa-primary, #2563eb);
  border-color: var(--fa-primary, #2563eb);
}

.file-info-qr {
  display: flex;
  min-height: 120px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}

.file-info-qr-image {
  display: block;
  width: 180px;
  max-width: 100%;
  height: auto;
  padding: 0;
  background: transparent;
  border-radius: 8px;
}

.file-info-qr p {
  margin: 0;
  font-size: 11px;
}

@media (max-width: 640px) {
  .file-info-panel {
    width: 100vw;
    padding: 16px;
  }
}

.search-path {
  display: block;
  margin: 2px 0 0 26px;
  overflow: hidden;
  color: var(--fa-muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-copy-text {
  min-height: 52px;
  margin-top: 8px;
  font-size: 12px;
  resize: vertical;
}

.share-toolbar {
  padding: 10px 0 4px;
  border-bottom: 0;
}

.share-toolbar .form-check {
  margin: 0;
}

.share-check {
  flex: 0 0 auto;
  margin-right: 4px;
}

.pager-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--fa-muted);
  background: var(--fa-panel);
  border: 1px solid var(--fa-border);
  border-radius: 8px;
}

.pager-btn:hover:not(:disabled) {
  color: var(--fa-text);
  border-color: var(--fa-primary);
}

.pager-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Content states */

.content-state {
  max-width: 520px;
  margin: 64px auto;
  color: var(--fa-muted);
  text-align: center;
}

.content-state .state-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  color: var(--fa-muted);
  background: var(--fa-panel);
  border: 1px solid var(--fa-border);
  border-radius: 12px;
}

.content-state h2 {
  margin: 0 0 6px;
  color: var(--fa-text);
  font-size: 16px;
  font-weight: 650;
}

.content-state p {
  margin: 0 0 14px;
  font-size: 12px;
  line-height: 1.7;
}

.content-state .btn {
  margin: 0 3px;
}

.skeleton-list {
  width: 100%;
  overflow: hidden;
  background: var(--fa-panel);
  border: 1px solid var(--fa-border);
  border-radius: 12px;
}

.skeleton-row {
  display: flex;
  gap: 14px;
  align-items: center;
  height: 46px;
  padding: 0 12px;
  border-bottom: 1px solid var(--fa-border);
}

.skeleton-row:last-child {
  border-bottom: 0;
}

.skeleton-block {
  height: 10px;
  background: var(--fa-border);
  border-radius: 4px;
  animation: fa-pulse 1.2s ease-in-out infinite;
}

.skeleton-block.name {
  width: 38%;
}

.skeleton-block.size {
  width: 8%;
}

.skeleton-block.time {
  width: 18%;
  margin-left: auto;
}

@keyframes fa-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

/* Preview */

.preview-dialog {
  width: min(92vw, 1100px);
  max-width: 1100px;
  max-height: 90vh;
  padding: 0;
  overflow: hidden;
  color: var(--fa-text);
  background: var(--fa-panel);
  border: 0;
  border-radius: 14px;
  box-shadow: 0 24px 80px rgb(15 23 42 / 35%);
}

.preview-dialog::backdrop {
  background: rgb(15 23 42 / 55%);
}

.preview-head {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 54px;
  padding: 0 16px;
  border-bottom: 1px solid var(--fa-border);
}

.preview-title {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.preview-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  max-height: calc(90vh - 54px);
  overflow: auto;
  color: #e5e7eb;
  background: #0b0d10;
}

.preview-body img,
.preview-body video {
  max-width: 100%;
  max-height: calc(90vh - 54px);
  object-fit: contain;
}

.preview-body audio {
  width: min(680px, 90%);
}

.preview-body iframe {
  width: 100%;
  height: 78vh;
  background: #fff;
  border: 0;
}

.preview-body pre {
  width: 100%;
  max-height: calc(90vh - 54px);
  margin: 0;
  padding: 20px;
  overflow: auto;
  color: #dbeafe;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-empty {
  padding: 40px;
  color: #98a2b3;
  font-size: 13px;
  text-align: center;
}

.markdown-body {
  align-self: stretch;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 28px clamp(18px, 4vw, 48px);
  color: #e5e7eb;
  font-size: 14px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 1.4em 0 0.55em;
  color: #f8fafc;
  line-height: 1.35;
}

.markdown-body h1 {
  padding-bottom: 0.35em;
  border-bottom: 1px solid #2a3038;
  font-size: 24px;
}

.markdown-body h2 {
  font-size: 20px;
}

.markdown-body h3 {
  font-size: 17px;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote {
  margin: 0.75em 0;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.6em;
}

.markdown-body li + li {
  margin-top: 0.25em;
}

.markdown-body a {
  color: #7dd3fc;
}

.markdown-body code {
  padding: 0.12em 0.35em;
  color: #fbcfe8;
  background: #1a1f27;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.markdown-body pre {
  background: #11151b;
  border: 1px solid #252c36;
  border-radius: 8px;
}

.markdown-body pre code {
  padding: 0;
  color: #dbeafe;
  background: transparent;
}

.markdown-body blockquote {
  padding: 0.2em 0 0.2em 1em;
  color: #b9c2d0;
  border-left: 3px solid #3b82f6;
}

.markdown-body hr {
  margin: 1.5em 0;
  border: 0;
  border-top: 1px solid #2a3038;
}

.readme-section {
  margin-top: 18px;
  overflow: hidden;
  background: var(--fa-panel);
  border: 1px solid var(--fa-border);
  border-radius: 12px;
}

.readme-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  color: var(--fa-muted);
  font-size: 12px;
  border-bottom: 1px solid var(--fa-border);
}

.readme-head strong {
  color: var(--fa-text);
  font-size: 13px;
}

.readme-head .btn-row {
  margin-left: auto;
}

.readme-content {
  min-height: 40px;
}

.readme-loading {
  padding: 20px 16px;
  color: var(--fa-muted);
  font-size: 12px;
}

.readme-body {
  max-width: none;
  margin: 0;
  padding: 20px clamp(16px, 3vw, 32px);
  color: var(--fa-text);
  background: transparent;
}

.readme-body h1,
.readme-body h2,
.readme-body h3,
.readme-body h4,
.readme-body h5,
.readme-body h6 {
  color: var(--fa-text);
}

.readme-body h1 {
  border-bottom-color: var(--fa-border);
}

.readme-body a {
  color: var(--fa-primary);
}

.readme-body code {
  color: var(--fa-text);
  background: var(--fa-bg);
}

.readme-body pre {
  background: var(--fa-bg);
  border-color: var(--fa-border);
}

.readme-body pre code {
  color: var(--fa-text);
}

.readme-body blockquote {
  color: var(--fa-muted);
  border-left-color: var(--fa-primary);
}

.readme-body hr {
  border-top-color: var(--fa-border);
}

/* Admin */

.admin-page {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

.admin-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.admin-head h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.admin-head p {
  margin: 4px 0 0;
  color: var(--fa-muted);
  font-size: 12px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.admin-panel {
  overflow: hidden;
  background: var(--fa-panel);
  border: 1px solid var(--fa-border);
  border-radius: 12px;
}

.admin-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 46px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--fa-border);
}

.root-list,
.user-list,
.permission-list {
  display: grid;
  gap: 0;
  max-height: 560px;
  overflow: auto;
  background: transparent;
}

.root-item,
.user-item,
.permission-item {
  padding: 12px 14px;
  background: var(--fa-panel);
  border-bottom: 1px solid var(--fa-border);
}

.root-item:last-child,
.user-item:last-child,
.permission-item:last-child {
  border-bottom: 0;
}

.root-item.active {
  background: var(--fa-primary-soft);
}

.user-item.active {
  background: var(--fa-primary-soft);
}

.root-item-head,
.user-item-head,
.permission-item-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.root-item-name,
.user-item-name,
.permission-item-title {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.root-item-path {
  margin-top: 4px;
  overflow: hidden;
  color: var(--fa-muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.root-item-actions,
.user-item-actions,
.permission-item-buttons {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.root-form,
.admin-form {
  padding: 16px;
}

.root-form h2,
.admin-form h2,
.admin-panel > h2,
.admin-wide > h2 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 650;
}

.admin-wide > h2 {
  margin: 0;
  padding: 16px 16px 12px;
}

.form-row {
  margin-bottom: 12px;
}

.form-row label {
  display: block;
  margin-bottom: 4px;
  color: var(--fa-muted);
  font-size: 11px;
  font-weight: 600;
}

.form-row .form-control {
  font-size: 13px;
}

.form-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 4px 0 14px;
}

.form-checks label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--fa-text);
  font-size: 12px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--fa-border);
}

.form-hint {
  margin-top: 7px;
  color: var(--fa-muted);
  font-size: 11px;
  line-height: 1.5;
}

.probe-result {
  margin-top: 10px;
  padding: 8px 10px;
  color: var(--fa-muted);
  font-size: 11px;
  background: var(--fa-bg);
  border: 1px solid var(--fa-border);
  border-radius: 6px;
}

.probe-result.ok {
  color: #15803d;
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.probe-result.bad {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}

/* Toast */

.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: grid;
  gap: 8px;
  max-width: min(360px, calc(100vw - 40px));
}

.toast-message {
  padding: 10px 14px;
  color: var(--fa-text);
  font-size: 12px;
  background: var(--fa-panel);
  border: 1px solid var(--fa-border);
  border-left: 3px solid var(--fa-primary);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgb(15 23 42 / 16%);
  animation: fa-toast-in 0.18s ease;
}

.toast-message.error {
  border-left-color: #dc2626;
}

.toast-message.success {
  border-left-color: #16a34a;
}

@keyframes fa-toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 900px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .file-table .col-time,
  .file-table .col-size {
    display: none;
  }

  .file-table .col-actions {
    width: 56px;
  }

  .file-actions {
    opacity: 1;
  }

  .main-toolbar {
    height: auto;
    min-height: 52px;
    flex: 0 0 auto;
    flex-wrap: wrap;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .toolbar-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .batch-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    margin-bottom: 2px;
  }

  .batch-actions .btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .batch-count {
    flex: 0 0 auto;
  }

  .main-content.has-table {
    padding: 12px;
  }

  .table-footer {
    flex-wrap: wrap;
  }
}

.file-empty {
  padding: 40px 12px;
  color: var(--fa-muted);
  font-size: 12px;
  text-align: center;
}

.confirm-dialog {
  width: min(92vw, 420px);
  max-width: 420px;
  padding: 0;
  overflow: hidden;
  color: var(--fa-text);
  background: var(--fa-panel);
  border: 0;
  border-radius: 12px;
  box-shadow: 0 24px 80px rgb(15 23 42 / 30%);
}

.confirm-dialog::backdrop {
  background: rgb(15 23 42 / 45%);
}

.editor-dialog {
  width: min(92vw, 900px);
  max-width: 900px;
  padding: 0;
  overflow: hidden;
  color: var(--fa-text);
  background: var(--fa-panel);
  border: 0;
  border-radius: 14px;
  box-shadow: 0 24px 80px rgb(15 23 42 / 35%);
}

.editor-dialog::backdrop {
  background: rgb(15 23 42 / 55%);
}

.editor-body {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.editor-body h2 {
  margin: 0;
  font-size: 18px;
}

.editor-name-row {
  display: grid;
  gap: 6px;
  color: var(--fa-muted);
  font-size: 12px;
}

.editor-textarea {
  width: 100%;
  min-height: 45vh;
  padding: 14px;
  color: var(--fa-text);
  background: var(--fa-bg);
  border: 1px solid var(--fa-border);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}

.editor-textarea:disabled {
  opacity: 0.65;
}

.editor-meta {
  margin-right: auto;
  color: var(--fa-muted);
  font-size: 11px;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.editor-error {
  color: var(--bs-danger, #dc3545);
  font-size: 12px;
}

.confirm-body {
  padding: 18px;
}

.confirm-body h2 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 650;
}

.confirm-body p {
  margin: 0;
  color: var(--fa-muted);
  font-size: 12px;
  line-height: 1.65;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.context-menu {
  position: fixed;
  z-index: 120;
  min-width: 160px;
  padding: 4px;
  background: var(--fa-panel);
  border: 1px solid var(--fa-border);
  border-radius: 8px;
  box-shadow: 0 12px 36px rgb(15 23 42 / 18%);
}

.context-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  color: var(--fa-text);
  font-size: 12px;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 5px;
}

.context-item:hover:not(:disabled) {
  background: var(--fa-hover);
}

.context-item.danger {
  color: #dc2626;
}

.context-item:disabled {
  opacity: 0.4;
}

.context-item .icon {
  width: 15px;
  height: 15px;
  color: var(--fa-muted);
}

.login-content {
  display: grid;
  flex: 1;
  place-items: center;
  min-height: 0;
  padding: 32px;
  overflow: auto;
}

.login-page {
  width: 100%;
  max-width: 420px;
}

.login-card {
  padding: 28px;
  background: var(--fa-panel);
  border: 1px solid var(--fa-border);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgb(15 23 42 / 8%);
}

.login-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 16px;
  color: #fff;
  background: var(--fa-accent);
  border-radius: 10px;
}

.login-mark .icon {
  width: 20px;
  height: 20px;
}

.login-form h1 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 680;
}

.login-subtitle {
  margin: 0 0 20px;
  color: var(--fa-muted);
  font-size: 12px;
  line-height: 1.65;
}

.login-field {
  margin-bottom: 14px;
}

.login-field label {
  display: block;
  margin-bottom: 6px;
  color: var(--fa-muted);
  font-size: 11px;
}

.login-field .form-control {
  font-size: 13px;
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 14px;
  color: var(--fa-muted);
  font-size: 12px;
}

.login-submit {
  width: 100%;
}

.login-error {
  margin-bottom: 12px;
  padding: 8px 10px;
  color: #b91c1c;
  font-size: 12px;
  background: rgb(220 38 38 / 8%);
  border-radius: 6px;
}

.admin-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--fa-border);
}

.admin-tabs a {
  padding: 8px 12px;
  color: var(--fa-muted);
  font-size: 12px;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.admin-tabs a:hover {
  color: var(--fa-text);
}

.admin-tabs a.active {
  color: var(--fa-accent);
  border-bottom-color: var(--fa-accent);
}

.admin-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
  font-size: 12px;
  background: rgb(37 99 235 / 7%);
  border: 1px solid rgb(37 99 235 / 20%);
  border-radius: 8px;
}

.admin-notice code {
  padding: 3px 7px;
  color: var(--fa-text);
  background: var(--fa-hover);
  border-radius: 4px;
  user-select: all;
}

.user-item-meta,
.permission-item-path,
.permission-item-actions {
  margin-top: 4px;
  color: var(--fa-muted);
  font-size: 11px;
  word-break: break-all;
}

.audit-item .permission-item-title {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.audit-json {
  max-height: 120px;
  margin-top: 4px;
  overflow: auto;
  color: var(--fa-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  word-break: break-all;
}

.settings-grid {
  grid-template-columns: minmax(0, 1fr);
}

.share-public {
  max-width: 560px;
  padding: 28px;
  margin: 40px auto;
}

.share-public h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.share-public input {
  margin: 12px 0;
}

.share-public .btn {
  margin-top: 12px;
}

.share-dialog .confirm-body {
  display: grid;
  gap: 4px;
}

.share-dialog .confirm-actions {
  margin-top: 14px;
}

.input-with-button {
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-with-button .form-control {
  flex: 1 1 auto;
  min-width: 0;
}

.input-with-button-btn {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
}

.share-code {
  padding: 1px 6px;
  color: var(--fa-primary);
  background: var(--fa-bg);
  border: 1px solid var(--fa-border);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
}

.user-role {
  padding: 1px 6px;
  color: var(--fa-muted);
  font-size: 10px;
  background: var(--fa-hover);
  border-radius: 999px;
}

.user-role.is-admin {
  color: var(--fa-accent);
  background: rgb(37 99 235 / 10%);
}

.user-item-role {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--fa-muted);
  font-size: 11px;
}

.user-role-select {
  width: auto;
  min-width: 110px;
}

.group-members {
  border-top: 1px solid var(--fa-border);
}

.group-member-list {
  max-height: 300px;
  overflow: auto;
}

.group-member {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 12px;
  border-bottom: 1px solid var(--fa-border);
}

.group-member:last-child {
  border-bottom: 0;
}

.group-member .btn {
  margin-left: auto;
}

.group-add-member {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--fa-border);
}

.group-add-member .form-select {
  flex: 1;
}

.permission-item-title {
  font-weight: 600;
}

.admin-wide {
  margin-top: 16px;
}

.action-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 4px 0 12px;
}

.action-checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--fa-muted);
  font-size: 11px;
}

.preview-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 16px 16px;
}

.preview-result {
  margin: 0 16px 16px;
  padding: 10px 12px;
  color: var(--fa-muted);
  font-size: 11px;
  background: var(--fa-hover);
  border-radius: 6px;
}

.preview-result.ok {
  color: var(--fa-text);
}

.preview-result.bad {
  color: #b91c1c;
}

.preview-title {
  margin-bottom: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}

.preview-sources {
  display: grid;
  gap: 4px;
  max-height: 180px;
  margin-top: 8px;
  overflow: auto;
}

.preview-source {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.preview-source code {
  padding: 1px 4px;
  color: var(--fa-text);
  background: var(--fa-hover);
  border-radius: 3px;
}

.admin-page .btn-sm {
  padding: 4px 9px;
  font-size: 12px;
  line-height: 1.5;
}

.admin-page .form-control-sm,
.admin-page .form-select-sm,
.admin-page .form-row .form-control,
.admin-page .user-role-select {
  min-height: 30px;
  font-size: 12px;
}

.permission-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--fa-panel);
  border: 1px solid var(--fa-border);
  border-radius: 12px;
}

.permission-toolbar .form-row {
  margin: 0;
}

.permission-toolbar .form-row:first-child {
  width: 220px;
}

.permission-toolbar .form-row:nth-child(2) {
  flex: 1;
}

.permission-grid {
  grid-template-columns: 300px minmax(0, 1fr);
}

.dir-browser {
  max-height: 520px;
  padding: 10px;
  overflow: auto;
}

.dir-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--fa-border);
}

.dir-crumb {
  padding: 2px 3px;
  color: var(--fa-primary);
  font-size: 11px;
  background: transparent;
  border: 0;
}

.dir-crumb:not(:last-child)::after {
  margin-left: 3px;
  color: var(--fa-muted);
  content: "/";
}

.dir-list {
  display: grid;
  gap: 2px;
}

.dir-row {
  width: 100%;
  padding: 6px 8px;
  overflow: hidden;
  color: var(--fa-text);
  font-size: 12px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: transparent;
  border: 0;
  border-radius: 5px;
}

.dir-row:hover {
  background: var(--fa-hover);
}

.dir-row.is-parent {
  color: var(--fa-muted);
}

.permission-form {
  border-top: 1px solid var(--fa-border);
}

.permission-list {
  max-height: 340px;
}

@media (max-width: 900px) {
  .admin-page {
    max-width: none;
  }

  .admin-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
  }

  .admin-head h1 {
    font-size: 18px;
  }

  .admin-head p {
    font-size: 11px;
    line-height: 1.5;
  }

  .admin-head > .btn {
    align-self: flex-start;
  }

  .admin-tabs {
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .admin-tabs::-webkit-scrollbar {
    display: none;
  }

  .admin-tabs a {
    flex: 0 0 auto;
    padding: 10px 12px;
    font-size: 12px;
    white-space: nowrap;
  }

  .admin-grid,
  .permission-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .admin-panel {
    border-radius: 10px;
  }

  .admin-panel-head {
    height: 42px;
    padding: 0 12px;
    font-size: 11px;
  }

  .root-list,
  .user-list,
  .permission-list {
    max-height: 42vh;
  }

  .root-item,
  .user-item,
  .permission-item {
    padding: 12px;
  }

  .user-item-head,
  .permission-item-head {
    align-items: flex-start;
    gap: 6px;
  }

  .user-item-actions,
  .permission-item-buttons {
    gap: 8px;
    width: 100%;
  }

  .user-item-actions .btn,
  .permission-item-buttons .btn {
    flex: 1;
    min-height: 34px;
  }

  .permission-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px;
  }

  .permission-toolbar .form-row,
  .permission-toolbar .form-row:first-child,
  .permission-toolbar .form-row:nth-child(2) {
    grid-column: 1 / -1;
    width: auto;
    flex: none;
  }

  .permission-toolbar > .btn {
    width: 100%;
    min-height: 36px;
  }

  .permission-form,
  .admin-form {
    padding: 14px;
  }

  .admin-page .form-control-sm,
  .admin-page .form-select-sm,
  .admin-page .form-row .form-control,
  .admin-page .user-role-select {
    min-height: 38px;
    font-size: 16px;
  }

  .admin-page .btn-sm {
    min-height: 34px;
    padding: 5px 9px;
    font-size: 12px;
  }

  .dir-browser {
    max-height: 34vh;
  }

  .group-add-member {
    flex-direction: column;
    align-items: stretch;
  }

  .group-add-member .btn {
    width: 100%;
  }

  .group-member {
    align-items: flex-start;
  }

  .group-member .btn {
    margin-left: 0;
  }

  .preview-form .form-row {
    margin-bottom: 8px;
  }

  .preview-source {
    align-items: flex-start;
  }

  .audit-json {
    max-height: 140px;
  }
}


/* Upload task panel */
.upload-tasks-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1080;
  width: min(360px, calc(100vw - 32px));
  overflow: hidden;
  background: var(--fa-panel, #fff);
  border: 1px solid var(--fa-border, #dbe1ea);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
}

.upload-tasks-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  font-size: 13px;
}

.upload-tasks-close {
  padding: 0 4px;
  color: var(--fa-muted, #64748b);
  font-size: 20px;
  line-height: 1;
  background: transparent;
  border: 0;
}

.upload-tasks-summary {
  padding: 0 14px 10px;
  color: var(--fa-muted, #64748b);
  font-size: 11px;
}

.upload-tasks-list {
  max-height: min(45vh, 360px);
  overflow-y: auto;
  border-top: 1px solid var(--fa-border, #dbe1ea);
}

.upload-task {
  padding: 10px 14px;
  border-bottom: 1px solid var(--fa-border, #edf0f4);
}

.upload-task:last-child {
  border-bottom: 0;
}

.upload-task-head,
.upload-task-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.upload-task-name {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-task-percent {
  flex: 0 0 auto;
  color: var(--fa-muted, #64748b);
  font-size: 11px;
}

.upload-task-bar {
  height: 5px;
  margin: 7px 0 5px;
  overflow: hidden;
  background: var(--fa-border, #e5eaf0);
  border-radius: 999px;
}

.upload-task-fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--fa-primary, #2563eb);
  border-radius: inherit;
  transition: width 120ms linear;
}

.upload-task-meta {
  color: var(--fa-muted, #64748b);
  font-size: 10px;
}

.upload-task-error {
  max-width: 65%;
  overflow: hidden;
  color: var(--fa-danger, #dc2626);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-task-action {
  margin-top: 7px;
  margin-right: 6px;
}

.upload-task-failed .upload-task-fill {
  background: var(--fa-danger, #dc2626);
}

.upload-task-completed .upload-task-fill {
  background: var(--fa-success, #16a34a);
}

.upload-task-cancelled .upload-task-fill {
  background: var(--fa-muted, #94a3b8);
}

@media (max-width: 640px) {
  .upload-tasks-panel {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }
}


/* My shares */
.share-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.share-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  background: var(--fa-panel);
  border: 1px solid var(--fa-border);
  border-radius: var(--fa-radius);
}

.share-stat strong {
  font-size: 20px;
  line-height: 1.1;
}

.share-stat span {
  color: var(--fa-muted);
  font-size: 11px;
}

.share-stat-active strong { color: var(--fa-success, #16a34a); }
.share-stat-expiring strong { color: #d97706; }
.share-stat-downloads strong { color: var(--fa-primary); }

.share-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.share-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  color: var(--fa-muted);
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--fa-border);
  border-radius: 999px;
}

.share-tab.active {
  color: var(--fa-primary);
  background: var(--fa-primary-soft);
  border-color: var(--fa-primary);
}

.share-tab-count {
  min-width: 18px;
  padding: 1px 5px;
  font-size: 10px;
  text-align: center;
  background: var(--fa-hover);
  border-radius: 999px;
}

.share-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.share-search {
  flex: 1 1 220px;
  max-width: 320px;
}

.share-filter {
  width: auto;
  min-width: 120px;
}

.share-selection-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  background: var(--fa-primary-soft);
  border: 1px solid var(--fa-border);
  border-radius: var(--fa-radius);
}

.share-table {
  overflow: hidden;
  background: var(--fa-panel);
  border: 1px solid var(--fa-border);
  border-radius: var(--fa-radius);
}

.share-table-head,
.share-row {
  display: grid;
  grid-template-columns: 32px minmax(220px, 1.7fr) 100px 112px 80px 92px 48px;
  gap: 8px;
  align-items: center;
}

.share-table-head {
  padding: 9px 12px;
  color: var(--fa-muted);
  font-size: 11px;
  background: var(--fa-hover);
  border-bottom: 1px solid var(--fa-border);
}

.share-row {
  padding: 10px 12px;
  border-bottom: 1px solid var(--fa-border);
}

.share-row:last-child {
  border-bottom: 0;
}

.share-row:hover {
  background: var(--fa-hover);
}

.share-cell {
  min-width: 0;
  font-size: 12px;
}

.share-cell-check {
  display: flex;
  justify-content: center;
}

.share-cell-name {
  min-width: 0;
}

.share-name {
  display: flex;
  gap: 7px;
  align-items: center;
  min-width: 0;
  font-weight: 600;
}

.share-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-path {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--fa-muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-cell-actions {
  display: flex;
  justify-content: flex-end;
}

.share-more {
  padding: 2px 7px;
  line-height: 1.2;
}

.share-status {
  display: inline-block;
  padding: 2px 7px;
  font-size: 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.share-status-active { color: #15803d; background: #dcfce7; }
.share-status-expiring { color: #b45309; background: #fef3c7; }
.share-status-expired { color: #b91c1c; background: #fee2e2; }
.share-status-revoked { color: var(--fa-muted); background: var(--fa-hover); }
.share-status-limit { color: #7e22ce; background: #f3e8ff; }

.share-empty {
  padding: 36px 16px;
  color: var(--fa-muted);
  font-size: 13px;
  text-align: center;
}

@media (max-width: 900px) {
  .share-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .share-table-head {
    display: none;
  }

  .share-row {
    display: grid;
    grid-template-columns: 24px 1fr 1fr;
    gap: 7px 10px;
    margin: 8px;
    padding: 12px;
    border: 1px solid var(--fa-border);
    border-radius: var(--fa-radius);
  }

  .share-cell-name {
    grid-column: 2 / -1;
  }

  .share-cell-actions {
    grid-column: 3;
    grid-row: 1;
  }

  .share-cell-check {
    grid-row: 1;
  }

  .share-cell[data-label]::before {
    display: block;
    margin-bottom: 2px;
    color: var(--fa-muted);
    content: attr(data-label);
    font-size: 9px;
  }
}
