/* ==========================================================================
   CivNode — Files App (Phase 5, Mockup B — Portfolio Hybrid)
   ========================================================================== */

/* ── Screen shell ────────────────────────────────────────────────────────── */

.files-screen {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-height, 48px));
  overflow: hidden;
  background: var(--bg-primary);
}

/* ── Pill strip row ──────────────────────────────────────────────────────── */

.files-pill-strip-row {
  background: var(--bg-secondary, var(--bg-surface));
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  height: 54px;
  padding: 0 1.25rem;
  gap: 0;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 20;
}

.files-drawers-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  margin-right: 0.75rem;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  position: relative;
}

.files-drawers-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: color-mix(in srgb, var(--text-muted) 30%, var(--border));
}

.files-drawers-btn.open {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent-border, color-mix(in srgb, var(--accent) 22%, transparent));
}

.files-drawers-btn svg {
  width: 15px;
  height: 15px;
}

/* Pill list */

.files-pills {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  height: 100%;
}

.files-pills::-webkit-scrollbar {
  display: none;
}

.files-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 1rem;
  height: 100%;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  flex-shrink: 0;
  position: relative;
  user-select: none;
}

.files-pill:hover {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--bg-elevated) 50%, transparent);
}

.files-pill.active {
  color: var(--accent);
  font-weight: 700;
  border-bottom-color: var(--accent);
  background: color-mix(in srgb, var(--accent-subtle, rgba(201,168,76,0.08)) 80%, transparent);
}

.files-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.files-pill-dot.user {
  background: var(--accent);
  opacity: 0.6;
}

.files-pill-dot.warn {
  background: var(--error, #cc4444);
  opacity: 0.9;
}

.files-pill.active .files-pill-dot.user {
  opacity: 1;
}

.files-pill-ent-icon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-elevated));
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.files-pill-ent-icon svg {
  width: 9px;
  height: 9px;
  color: var(--accent);
  opacity: 0.65;
}

.files-pill-badge {
  font-size: 0.66rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 0.07em 0.4em;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}

.files-pill.active .files-pill-badge {
  background: var(--accent-subtle, rgba(201,168,76,0.08));
  color: var(--accent);
  border-color: var(--accent-border, color-mix(in srgb, var(--accent) 22%, transparent));
}

.files-pill-strip-div {
  width: 1px;
  height: 22px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 0.35rem;
}

/* Quota widget in strip */

.files-strip-quota {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0 0.75rem;
  height: 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-left: 0.75rem;
  flex-shrink: 0;
}

.files-strip-quota-text {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.files-strip-quota-text strong {
  color: var(--text-primary);
}

.files-strip-quota-bar {
  width: 52px;
  height: 3px;
  background: var(--bg-primary);
  border-radius: 2px;
  overflow: hidden;
}

.files-strip-quota-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover, var(--accent)) 100%);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.files-strip-quota-fill.near-full {
  background: linear-gradient(90deg, var(--error, #cc4444) 0%, color-mix(in srgb, var(--error, #cc4444) 80%, var(--accent)) 100%);
}

.files-strip-quota-link {
  font-size: 0.67rem;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  border-left: 1px solid var(--border);
  padding-left: 0.55rem;
  transition: color var(--transition);
}

.files-strip-quota-link:hover {
  color: var(--accent-hover, var(--accent));
}

/* Upload button in strip */

.files-upload-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 1rem;
  height: 34px;
  background: var(--accent);
  color: var(--bg-primary);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  margin-left: 0.75rem;
  flex-shrink: 0;
  font-family: var(--font-sans);
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
  box-shadow: 0 1px 6px color-mix(in srgb, var(--accent) 22%, transparent);
}

.files-upload-btn:hover {
  background: var(--accent-hover, var(--accent));
  border-color: var(--accent-hover, var(--accent));
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 32%, transparent);
}

.files-upload-btn svg {
  width: 13px;
  height: 13px;
}

/* Icons sitting on an accent background must use the on-accent tint
   (same treatment as .btn-primary), otherwise the default light-on-dark
   --icon-filter inverts them against the gold and they vanish. */
.files-upload-btn .civ-icon {
  filter: var(--icon-filter-on-accent);
}

/* ── Main body ───────────────────────────────────────────────────────────── */

.files-main-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

/* ── Gallery area ────────────────────────────────────────────────────────── */

.files-gallery-area {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-elevated) transparent;
  position: relative;
}

/* Sticky drawer title bar */

.files-drawer-title-bar {
  padding: 1rem 1.5rem 0.75rem;
  display: flex;
  align-items: baseline;
  gap: 0.875rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  background: color-mix(in srgb, var(--bg-surface) 80%, transparent);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(6px);
}

.files-drawer-title-name {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.files-drawer-title-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.files-drawer-title-spacer {
  flex: 1;
}

.files-drawer-search {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.32em 0.7em;
  font-size: 0.8rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  width: 195px;
  transition: border-color var(--transition), width var(--transition);
}

.files-drawer-search::placeholder {
  color: var(--text-muted);
}

.files-drawer-search:focus {
  outline: none;
  border-color: var(--accent);
  width: 230px;
}

/* Gallery grid */

.files-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.125rem;
  padding: 1.25rem 1.5rem 5rem;
}

/* Empty state */

.files-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 4rem 2rem;
  color: var(--text-muted);
  text-align: center;
}

.files-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.files-empty-icon svg {
  width: 24px;
  height: 24px;
  color: var(--text-muted);
}

.files-empty-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.files-empty-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ── Gallery tiles ───────────────────────────────────────────────────────── */

.files-tile {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    transform 200ms ease;
  position: relative;
}

.files-tile:hover {
  border-color: color-mix(in srgb, var(--text-muted) 50%, var(--border));
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.files-tile.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent), var(--shadow-md);
}

/* Thumbnail */

.files-tile-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--bg-elevated);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.files-tile-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.files-tile-type-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  height: 100%;
}

.files-tile-type-lbl {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: var(--font-mono);
  opacity: 0.25;
  user-select: none;
  letter-spacing: 0.04em;
}

/* Format badge top-left */

.files-tile-badge {
  position: absolute;
  top: 7px;
  left: 7px;
  font-size: 0.58rem;
  font-weight: 700;
  font-family: var(--font-mono);
  background: color-mix(in srgb, var(--bg-primary) 80%, transparent);
  color: var(--text-secondary);
  padding: 0.12em 0.38em;
  border-radius: 3px;
  letter-spacing: 0.03em;
  backdrop-filter: blur(2px);
}

/* Hover quick-actions overlay */

.files-tile-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}

.files-tile:hover .files-tile-actions {
  opacity: 1;
}

.files-tile-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: color-mix(in srgb, var(--bg-primary) 80%, transparent);
  border: 1px solid color-mix(in srgb, var(--text-primary) 10%, transparent);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  flex-shrink: 0;
  backdrop-filter: blur(2px);
}

.files-tile-action-btn:hover {
  background: color-mix(in srgb, var(--accent) 25%, transparent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--accent);
}

.files-tile-action-btn.danger:hover {
  background: color-mix(in srgb, var(--error, #cc4444) 25%, transparent);
  border-color: color-mix(in srgb, var(--error, #cc4444) 40%, transparent);
  color: var(--error, #cc4444);
}

.files-tile-action-btn svg {
  width: 11px;
  height: 11px;
}

/* Tile info footer */

.files-tile-info {
  padding: 0.6rem 0.75rem 0.7rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}

.files-tile-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  margin-bottom: 0.1rem;
}

.files-tile.selected .files-tile-name {
  color: var(--accent);
}

.files-tile-meta {
  font-size: 0.67rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Inline rename input */

.files-tile-rename-input {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.35em;
  width: 100%;
  font-family: var(--font-sans);
  outline: none;
  box-sizing: border-box;
}

/* Upload progress tile */

.files-tile.uploading .files-tile-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--bg-primary) 55%, transparent);
}

.files-tile-progress-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  width: 44px;
  height: 44px;
}

.files-tile-progress-ring circle {
  transition: stroke-dashoffset 0.2s linear;
}

/* Error state */

.files-tile.upload-error {
  border-color: var(--error, #cc4444);
}

.files-tile-error-overlay {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--error, #cc4444) 10%, var(--bg-elevated));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem;
  text-align: center;
}

.files-tile-error-msg {
  font-size: 0.7rem;
  color: var(--error, #cc4444);
  font-weight: 600;
  line-height: 1.3;
}

.files-tile-error-retry {
  font-size: 0.67rem;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-sans);
}

.files-tile-error-dismiss {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
}

.files-tile-error-dismiss:hover {
  color: var(--text-secondary);
}

/* Skeleton tiles */

.files-tile-skeleton .files-tile-thumb {
  background: color-mix(in srgb, var(--bg-elevated) 70%, var(--bg-surface));
  animation: files-shimmer 1.4s ease-in-out infinite;
}

.files-tile-skeleton .files-tile-name {
  height: 12px;
  background: color-mix(in srgb, var(--bg-elevated) 70%, var(--bg-surface));
  border-radius: var(--radius-sm);
  width: 70%;
  animation: files-shimmer 1.4s ease-in-out infinite;
}

.files-tile-skeleton .files-tile-meta {
  height: 10px;
  background: color-mix(in srgb, var(--bg-elevated) 70%, var(--bg-surface));
  border-radius: var(--radius-sm);
  width: 45%;
  animation: files-shimmer 1.4s ease-in-out infinite;
  margin-top: 4px;
}

@keyframes files-shimmer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Drag-over overlay ───────────────────────────────────────────────────── */

.files-drag-overlay {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--accent) 4%, transparent);
  border: 2px dashed color-mix(in srgb, var(--accent) 50%, transparent);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s ease;
}

.files-drag-overlay.visible {
  opacity: 1;
}

.files-drag-overlay-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-elevated));
  border: 1px solid var(--accent-border, color-mix(in srgb, var(--accent) 22%, transparent));
  display: flex;
  align-items: center;
  justify-content: center;
}

.files-drag-overlay-icon svg {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.files-drag-overlay-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
}

.files-drag-overlay-sub {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ── Floating drawers overlay ────────────────────────────────────────────── */

.files-drawers-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 272px;
  max-height: calc(100vh - 108px);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  box-shadow: var(--shadow-float, 0 16px 48px rgba(0,0,0,0.55), 0 4px 12px rgba(0,0,0,0.3));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 40;
  transform: translateX(-100%);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.files-drawers-overlay.open {
  transform: translateX(0);
}

.files-drawers-overlay-head {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.files-drawers-overlay-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.files-overlay-new-btn {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.18em 0.38em;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  transition: background var(--transition);
}

.files-overlay-new-btn:hover {
  background: var(--accent-subtle, rgba(201,168,76,0.08));
}

.files-overlay-new-btn svg {
  width: 10px;
  height: 10px;
}

/* Inline new-drawer form */

.files-overlay-new-form {
  padding: 0.5rem 0.875rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.files-overlay-new-form input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.28em 0.6em;
  font-size: 0.78rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  outline: none;
}

.files-overlay-new-form button {
  padding: 0.28em 0.65em;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background var(--transition);
}

.files-overlay-new-form button.confirm {
  background: var(--accent);
  color: var(--bg-primary);
}

.files-overlay-new-form button.confirm:hover {
  background: var(--accent-hover, var(--accent));
}

.files-overlay-new-form button.cancel {
  background: none;
  color: var(--text-muted);
  border-color: var(--border);
}

.files-overlay-new-form button.cancel:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.files-overlay-search {
  padding: 0.45rem 0.875rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  flex-shrink: 0;
}

.files-overlay-search input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.27em 0.6em;
  font-size: 0.78rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
}

.files-overlay-search input::placeholder {
  color: var(--text-muted);
}

.files-overlay-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.files-overlay-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

.files-overlay-section {
  padding: 0.55rem 0.875rem 0.2rem;
  font-size: 0.61rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.files-overlay-section::after {
  content: '';
  flex: 1;
  height: 1px;
  background: color-mix(in srgb, var(--border) 60%, transparent);
}

.files-overlay-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.38em 0.875rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.files-overlay-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.files-overlay-item.active {
  background: var(--accent-subtle, rgba(201,168,76,0.08));
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.files-overlay-item.over-quota {
  border-left-color: var(--error, #cc4444);
}

.files-overlay-item-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.55;
}

.files-overlay-item.active .files-overlay-item-icon {
  opacity: 0.9;
  color: var(--accent);
}

.files-overlay-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.files-overlay-item-count {
  font-size: 0.67rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.files-overlay-item.over-quota .files-overlay-item-count {
  color: var(--error, #cc4444);
}

.files-overlay-auto-badge {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-elevated));
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.files-overlay-auto-badge svg {
  width: 8px;
  height: 8px;
  color: var(--accent);
  opacity: 0.75;
}

.files-overlay-warn-icon {
  width: 12px;
  height: 12px;
  color: var(--error, #cc4444);
  flex-shrink: 0;
  opacity: 0.85;
}

/* Overlay quota footer */

.files-overlay-quota {
  border-top: 1px solid var(--border);
  padding: 0.7rem 0.875rem;
  flex-shrink: 0;
}

.files-overlay-quota-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.files-overlay-quota-text {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.files-overlay-quota-text strong {
  color: var(--text-primary);
}

.files-overlay-quota-link {
  font-size: 0.67rem;
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

.files-overlay-quota-link:hover {
  color: var(--accent-hover, var(--accent));
}

.files-overlay-quota-bar {
  height: 3px;
  background: var(--bg-primary);
  border-radius: 2px;
  overflow: hidden;
}

.files-overlay-quota-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ── Preview panel ───────────────────────────────────────────────────────── */

.files-preview-panel {
  width: 300px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: -2px 0 8px color-mix(in srgb, var(--bg-primary) 50%, transparent);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.files-pp-head {
  height: 50px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 0.5rem;
  flex-shrink: 0;
}

.files-pp-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  flex: 1;
}

.files-pp-pin-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2em 0.5em;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.files-pp-pin-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.files-pp-pin-btn.pinned {
  color: var(--accent);
  border-color: var(--accent-border, color-mix(in srgb, var(--accent) 22%, transparent));
  background: var(--accent-subtle, rgba(201,168,76,0.08));
}

.files-pp-pin-btn svg {
  width: 10px;
  height: 10px;
}

.files-pp-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
  padding: 0;
}

.files-pp-close:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.files-pp-close svg {
  width: 12px;
  height: 12px;
}

.files-pp-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  scrollbar-width: thin;
}

/* Preview thumbnail */

.files-pp-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-elevated);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.files-pp-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.files-pp-thumb-doc {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  height: 100%;
}

.files-pp-thumb-doc svg {
  width: 40px;
  height: 40px;
  opacity: 0.3;
}

.files-pp-thumb-ext {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.files-pp-filename {
  font-family: var(--font-serif);
  font-size: 0.975rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  word-break: break-word;
}

/* Rename input in preview */

.files-pp-rename-input {
  font-family: var(--font-serif);
  font-size: 0.975rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.2em 0.45em;
  width: 100%;
  outline: none;
  box-sizing: border-box;
}

/* Meta rows */

.files-pp-meta {
  display: flex;
  flex-direction: column;
}

.files-pp-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0.3em 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  gap: 0.5rem;
}

.files-pp-row:last-child {
  border-bottom: none;
}

.files-pp-k {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  flex-shrink: 0;
}

.files-pp-v {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-align: right;
}

.files-pp-v.hash {
  font-size: 0.63rem;
  word-break: break-all;
  white-space: normal;
  max-width: 148px;
  text-align: right;
  cursor: default;
}

/* Actions in preview panel */

.files-pp-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
}

.files-pp-action-row {
  display: flex;
  gap: 0.32rem;
}

.files-pp-action-row .files-pp-action-btn {
  flex: 1;
  justify-content: center;
}

.files-pp-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.32rem;
  padding: 0.4em 0.85em;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.files-pp-action-btn svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.files-pp-action-btn.primary {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
}

.files-pp-action-btn.primary:hover {
  background: var(--accent-hover, var(--accent));
}

.files-pp-action-btn.secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: var(--border);
}

.files-pp-action-btn.secondary:hover {
  background: color-mix(in srgb, var(--bg-elevated) 60%, var(--bg-surface));
  color: var(--text-primary);
}

.files-pp-action-btn.danger {
  background: transparent;
  color: color-mix(in srgb, var(--error, #cc4444) 65%, var(--text-secondary));
  border-color: color-mix(in srgb, var(--error, #cc4444) 30%, var(--border));
}

.files-pp-action-btn.danger:hover {
  background: color-mix(in srgb, var(--error, #cc4444) 10%, transparent);
  color: var(--error, #cc4444);
  border-color: color-mix(in srgb, var(--error, #cc4444) 55%, var(--border));
}

/* Move dropdown in preview */

.files-move-dropdown {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem 0;
  box-shadow: var(--shadow-md);
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.files-move-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.38em 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.files-move-dropdown-item:hover {
  background: color-mix(in srgb, var(--bg-elevated) 50%, var(--bg-surface));
  color: var(--text-primary);
}

.files-move-dropdown-item svg {
  width: 12px;
  height: 12px;
  opacity: 0.55;
  flex-shrink: 0;
}

/* No-drawer state */

.files-no-drawer {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

.files-no-drawer-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.files-no-drawer-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.5;
}
