/* NoVault — sci-fi tech console */

:root,
html[data-theme="light"] {
  --bg: #e8f4f2;
  --bg-elev: #f4fbf9;
  --bg-panel: rgba(255, 255, 255, 0.72);
  --bg-panel-solid: #f7fcfb;
  --surface: #ffffff;
  --text: #0c1f24;
  --text-muted: #4a6b72;
  --border: rgba(14, 90, 98, 0.18);
  --border-strong: rgba(14, 120, 130, 0.35);
  --accent: #0d9b9b;
  --accent-2: #14b8a6;
  --accent-dim: rgba(13, 155, 155, 0.12);
  --accent-glow: rgba(13, 155, 155, 0.35);
  --danger: #c43c3c;
  --danger-dim: rgba(196, 60, 60, 0.12);
  --ok: #1a8a5c;
  --ok-dim: rgba(26, 138, 92, 0.12);
  --warn: #b87a12;
  --shadow: 0 12px 40px rgba(8, 40, 48, 0.08);
  --grid-line: rgba(13, 120, 130, 0.07);
  --scan: rgba(13, 155, 155, 0.04);
  --sidebar-w: 260px;
  --topbar-h: 56px;
  --radius: 6px;
  --radius-lg: 10px;
  --font-display: "Orbitron", sans-serif;
  --font-body: "Space Grotesk", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #060d10;
  --bg-elev: #0a1519;
  --bg-panel: rgba(10, 24, 28, 0.82);
  --bg-panel-solid: #0c181c;
  --surface: #0f1e24;
  --text: #e6f7f5;
  --text-muted: #7a9aa3;
  --border: rgba(45, 180, 190, 0.16);
  --border-strong: rgba(45, 200, 210, 0.32);
  --accent: #2dd4bf;
  --accent-2: #22d3ee;
  --accent-dim: rgba(45, 212, 191, 0.12);
  --accent-glow: rgba(45, 212, 191, 0.4);
  --danger: #f07178;
  --danger-dim: rgba(240, 113, 120, 0.14);
  --ok: #4ade80;
  --ok-dim: rgba(74, 222, 128, 0.12);
  --warn: #fbbf24;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  --grid-line: rgba(45, 200, 210, 0.06);
  --scan: rgba(45, 212, 191, 0.035);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-muted);
  font-size: 0.92em;
}

/* —— Background —— */
.bg-grid,
.bg-scan {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.bg-grid {
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, #000 20%, transparent 75%);
}

.bg-scan {
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    var(--scan) 2px,
    var(--scan) 3px
  );
  animation: scan-drift 12s linear infinite;
  opacity: 0.85;
}

@keyframes scan-drift {
  from { background-position: 0 0; }
  to { background-position: 0 48px; }
}

/* —— Impersonation —— */
.impersonate-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.45rem 1rem;
  background: linear-gradient(90deg, var(--warn), #e8a020);
  color: #1a1200;
  font-size: 0.85rem;
  font-weight: 600;
}

/* —— Views —— */
.view {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
}

.view-login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem 3rem;
}

.login-shell {
  width: min(100%, 400px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.login-brand {
  text-align: center;
}

.logo-mark {
  display: inline-flex;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 0 12px var(--accent-glow));
}

.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.75rem, 6vw, 2.25rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

.byline {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.byline span,
.byline-sm {
  color: var(--accent);
  font-weight: 600;
}

.panel {
  position: relative;
  width: 100%;
  padding: 1.5rem 1.35rem 1.35rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.panel-edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(90deg, var(--accent), transparent 40%) top / 100% 1px no-repeat,
    linear-gradient(90deg, transparent 60%, var(--accent-2)) bottom / 100% 1px no-repeat;
  opacity: 0.55;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field > span {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field input,
.field select,
.modal-body input,
.modal-body select,
.admin-form input,
.admin-form select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus,
.field select:focus,
.modal-body input:focus,
.modal-body select:focus,
.admin-form input:focus,
.admin-form select:focus,
.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-error {
  margin: 0;
  padding: 0.5rem 0.65rem;
  font-size: 0.88rem;
  color: var(--danger);
  background: var(--danger-dim);
  border-radius: var(--radius);
  border: 1px solid rgba(196, 60, 60, 0.25);
}

.form-ok {
  margin: 0;
  padding: 0.5rem 0.65rem;
  font-size: 0.88rem;
  color: var(--ok);
  background: var(--ok-dim);
  border-radius: var(--radius);
}

.link-toggle {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.5rem;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.88rem;
  cursor: pointer;
  text-align: center;
}

.link-toggle:hover {
  text-decoration: underline;
}

.invite-form {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* —— Clearance pulse —— */
.clearance {
  text-align: center;
  padding: 1rem 0.5rem;
}

.clearance h2 {
  margin: 1rem 0 0.4rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.clearance-ring {
  position: relative;
  width: 88px;
  height: 88px;
  margin: 0.5rem auto;
}

.clearance-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: clearance-pulse 2s var(--ease) infinite;
}

.clearance-core {
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-2), var(--accent));
  box-shadow: 0 0 24px var(--accent-glow);
  animation: clearance-core 2s ease-in-out infinite;
}

@keyframes clearance-pulse {
  0% { transform: scale(0.75); opacity: 0.9; }
  70% { transform: scale(1.15); opacity: 0; }
  100% { transform: scale(1.15); opacity: 0; }
}

@keyframes clearance-core {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.88); opacity: 0.75; }
}

.clearance-status {
  margin: 0.75rem 0 1rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  background: var(--surface);
  color: var(--text);
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #041012;
  border-color: transparent;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 22px var(--accent-glow);
}

.btn-secondary {
  background: var(--accent-dim);
  border-color: var(--border-strong);
  color: var(--accent);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: var(--danger-dim);
  border-color: rgba(196, 60, 60, 0.35);
  color: var(--danger);
}

.btn-sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.btn-icon:hover,
.btn-icon.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: var(--border);
}

.upload-label {
  cursor: pointer;
  margin: 0;
}

/* —— App shell —— */
.view-app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--topbar-h);
  padding: 0.4rem 0.75rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--accent);
  text-decoration: none;
  flex-shrink: 0;
}

.topbar-brand:hover {
  text-decoration: none;
  filter: brightness(1.1);
}

.wordmark-sm {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-toggle {
  flex-shrink: 0;
}

@media (min-width: 900px) {
  .sidebar-toggle {
    display: none;
  }
}

.breadcrumbs {
  display: none;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 0.25rem;
  overflow-x: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
  scrollbar-width: none;
}

.breadcrumbs::-webkit-scrollbar {
  display: none;
}

@media (min-width: 700px) {
  .breadcrumbs {
    display: flex;
  }
}

.breadcrumbs button,
.crumb {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
  white-space: nowrap;
  font-size: inherit;
}

.breadcrumbs button:hover,
.crumb:hover {
  color: var(--accent);
  background: var(--accent-dim);
}

.crumb-sep {
  opacity: 0.4;
  user-select: none;
}

.crumb.current {
  color: var(--text);
  font-weight: 600;
  cursor: default;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  flex-shrink: 0;
}

.search-wrap {
  display: none;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
}

.search-wrap input {
  width: 140px;
  border: none;
  background: transparent;
  outline: none;
  color: var(--text);
  padding: 0;
  box-shadow: none !important;
}

@media (min-width: 640px) {
  .search-wrap {
    display: inline-flex;
  }
}

@media (min-width: 900px) {
  .search-wrap input {
    width: 200px;
  }
}

html[data-theme="light"] .icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: none; }

.user-menu-wrap {
  position: relative;
}

.btn-user {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.55rem;
  background: var(--accent-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 140px;
}

.btn-user span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  padding: 0.35rem;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 50;
}

.dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.7rem;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.88rem;
}

.dropdown button:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.dropdown button.danger {
  color: var(--danger);
}

.dropdown button.danger:hover {
  background: var(--danger-dim);
}

/* —— Body / sidebar —— */
.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(var(--sidebar-w), 88vw);
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel-solid);
  border-right: 1px solid var(--border);
  transform: translateX(-105%);
  transition: transform 0.28s var(--ease);
  padding-top: env(safe-area-inset-top);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(4, 12, 16, 0.45);
  backdrop-filter: blur(2px);
  border: none;
  padding: 0;
  cursor: pointer;
}

.sidebar-backdrop[hidden] {
  display: none !important;
}

@media (min-width: 900px) {
  .sidebar {
    position: sticky;
    top: var(--topbar-h);
    height: calc(100dvh - var(--topbar-h));
    transform: none;
    flex-shrink: 0;
  }

  .sidebar-close,
  .sidebar-backdrop {
    display: none !important;
  }
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-label {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.65rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 0.9rem;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.nav-item:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.nav-item.active {
  background: var(--accent-dim);
  border-color: var(--border-strong);
  color: var(--accent);
  font-weight: 600;
}

.nav-item .nav-ico {
  flex-shrink: 0;
  opacity: 0.85;
}

.sidebar-foot {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}

.byline-sm {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 1rem 0.85rem 2.5rem;
}

@media (min-width: 900px) {
  .main {
    padding: 1.25rem 1.5rem 2.5rem;
  }
}

/* —— Drive —— */
.drive-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.view-toggle {
  display: inline-flex;
  gap: 0.15rem;
  padding: 0.15rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-right: auto;
}

/* Dropzone / upload glow */
.dropzone {
  display: none;
  margin-bottom: 1rem;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--accent-dim);
  transition: border-color 0.2s, box-shadow 0.3s, background 0.2s;
}

.dropzone.active,
body.dragging .dropzone {
  display: block;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim), 0 0 32px var(--accent-glow);
  animation: upload-glow 1.4s ease-in-out infinite;
  color: var(--accent);
}

@keyframes upload-glow {
  0%, 100% { box-shadow: 0 0 0 3px var(--accent-dim), 0 0 18px var(--accent-glow); }
  50% { box-shadow: 0 0 0 5px var(--accent-dim), 0 0 36px var(--accent-glow); }
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.dropzone-inner p {
  margin: 0;
  font-weight: 600;
}

.upload-queue {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  animation: upload-glow 1.6s ease-in-out infinite;
}

.upload-item.done {
  animation: none;
  border-color: rgba(26, 138, 92, 0.35);
}

.upload-item.err {
  animation: none;
  border-color: rgba(196, 60, 60, 0.35);
}

.upload-item .bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.upload-item .bar > span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s;
}

.upload-item .name {
  flex: 0 1 40%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* File stage */
.file-stage {
  min-height: 120px;
}

.file-stage.layout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 0.75rem;
}

.file-stage.layout-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.file-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

/* Folder fade motion */
.file-card,
.file-row {
  animation: folder-fade 0.35s var(--ease) both;
}

@keyframes folder-fade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.file-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0.85rem 0.7rem 0.7rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  text-align: left;
  color: inherit;
  font: inherit;
  position: relative;
}

.file-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 1px var(--accent-dim), var(--shadow);
  transform: translateY(-2px);
}

.file-card .fico {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  margin-bottom: 0.55rem;
  color: var(--accent);
}

.file-card .fico.has-thumb {
  height: 140px;
  margin: -0.85rem -0.7rem 0.65rem;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
  background: var(--bg-elev);
}

.file-card .fthumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #111;
}

.file-row .fico.has-thumb {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
}

.file-row .fthumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  display: block;
}

.file-card .fname {
  font-size: 0.82rem;
  font-weight: 600;
  word-break: break-word;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.file-card .fmeta {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.file-card .factions,
.file-row .factions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-top: 0.5rem;
  opacity: 0.85;
}

.file-card .factions .btn-icon,
.file-row .factions .btn-icon {
  width: 30px;
  height: 30px;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.2s, background 0.15s;
  text-align: left;
  color: inherit;
  font: inherit;
  width: 100%;
}

.file-row:hover {
  border-color: var(--border-strong);
  background: var(--accent-dim);
}

.file-row .fico {
  flex-shrink: 0;
  color: var(--accent);
  display: flex;
}

.file-row .fname {
  flex: 1;
  min-width: 0;
  font-weight: 560;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row .fmeta {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  display: none;
}

@media (min-width: 640px) {
  .file-row .fmeta {
    display: block;
  }
}

.file-row .factions {
  margin-top: 0;
  flex-shrink: 0;
}

.is-folder .fico {
  color: var(--accent-2);
}

/* —— Admin —— */
.admin-head {
  margin-bottom: 1rem;
}

.admin-head h2 {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.06em;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.65rem;
}

.admin-tab {
  padding: 0.45rem 0.8rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}

.admin-tab:hover {
  color: var(--accent);
  background: var(--accent-dim);
}

.admin-tab.active {
  color: var(--accent);
  border-color: var(--border-strong);
  background: var(--accent-dim);
}

.admin-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.admin-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  padding: 0.85rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.admin-form .field {
  flex: 1 1 140px;
  min-width: 120px;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin-table th,
.admin-table td {
  padding: 0.55rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-table th {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-elev);
  font-weight: 600;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.acl-smart {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}

.acl-smart .acl-grant-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.picker-col {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.75rem;
  background: var(--bg-panel);
  min-height: 180px;
}

.picker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.85rem;
}

.picker-search {
  flex: 1;
  max-width: 180px;
  font-size: 0.8rem;
  padding: 0.3rem 0.5rem;
}

.picker-toolbar {
  margin-bottom: 0.45rem;
}

.picker-list {
  max-height: 260px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.picker-item {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  padding: 0.35rem 0.4rem;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

.picker-item:hover {
  background: var(--accent-dim);
}

.check-line {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.check-line.tight {
  margin-top: 0;
  font-weight: 500;
}

@media (max-width: 720px) {
  .acl-smart {
    grid-template-columns: 1fr;
  }
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--accent-dim);
  color: var(--accent);
}

.badge.warn {
  background: rgba(184, 122, 18, 0.15);
  color: var(--warn);
}

.badge.danger {
  background: var(--danger-dim);
  color: var(--danger);
}

.invite-code-display {
  font-family: ui-monospace, monospace;
  font-size: 0.9rem;
  padding: 0.5rem 0.7rem;
  background: var(--accent-dim);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  word-break: break-all;
}

/* —— Modal —— */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 560px) {
  .modal-root {
    align-items: center;
    padding: 1.5rem;
  }
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 12, 16, 0.55);
  backdrop-filter: blur(3px);
  cursor: pointer;
}

.modal {
  position: relative;
  z-index: 1;
  width: min(100%, 480px);
  max-height: min(90dvh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow);
  animation: modal-in 0.28s var(--ease);
}

@media (min-width: 560px) {
  .modal {
    border-radius: var(--radius-lg);
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal.modal-wide {
  width: min(100%, 720px);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.modal-body {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
}

.modal-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}

.preview-frame {
  width: 100%;
  min-height: 280px;
  max-height: 60dvh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.preview-frame img,
.preview-frame video {
  display: block;
  max-width: 100%;
  max-height: 60dvh;
  margin: 0 auto;
}

.preview-frame iframe {
  width: 100%;
  height: 60dvh;
  border: none;
}

/* —— Toasts —— */
.toasts {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  left: 1rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  pointer-events: none;
  align-items: stretch;
}

@media (min-width: 560px) {
  .toasts {
    left: auto;
    width: min(360px, calc(100vw - 2rem));
    align-items: flex-end;
  }
}

.toast {
  pointer-events: auto;
  padding: 0.7rem 0.9rem;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  animation: toast-in 0.3s var(--ease);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.ok {
  border-left-color: var(--ok);
}

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

/* —— Utilities —— */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

code.mono {
  font-family: ui-monospace, monospace;
  font-size: 0.85em;
}
