/* Download Status Bar Styles */
#download-status-bar {
  transition: all 0.3s ease;
}

#download-status-bar button {
  transition: all 0.2s ease;
}

#download-status-bar button:hover {
  transform: translateY(-1px);
}

/* Footer adjustments when status bar is visible */
footer {
  transition: bottom 0.3s ease;
}

body.has-status-bar footer {
  bottom: 45px; /* Height of status bar */
}

/* Split.js styles */
.split {
  display: flex;
  flex-direction: row;
}

.gutter {
  background-color: var(--border-weak-base);
  background-repeat: no-repeat;
  background-position: 50%;
  cursor: col-resize;
  border-left: 1px solid var(--border-base);
  border-right: 1px solid var(--border-base);
}

.gutter:hover {
  background-color: var(--border-base);
}

.gutter.gutter-horizontal {
  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==');
  cursor: col-resize;
  width: 8px;
}

/* Panel sizing */
.tree-panel {
  min-width: 200px;
  flex: 0 0 250px;
}

.files-panel {
  min-width: 300px;
  flex: 1;
}

.preview-panel {
  min-width: 250px;
  flex: 0 0 300px;
}

/* Custom scrollbars */
.tree-content::-webkit-scrollbar,
.files-content::-webkit-scrollbar,
.preview-content::-webkit-scrollbar {
  width: 8px;
}

.preview-content {
   display: flex;
   flex-direction: column;
   height: 100%;
}

.preview-body {
   flex-grow: 1;
   display: flex;
   flex-direction: column;
   padding: 1px;
}

.text-preview {
   flex-grow: 1;
   display: flex;
   flex-direction: column;
   overflow: auto;
}

.preview-text {
   flex-grow: 1;
   white-space: pre-wrap;
   word-break: break-all;
}

.tree-content::-webkit-scrollbar-track,
.files-content::-webkit-scrollbar-track,
.preview-content::-webkit-scrollbar-track {
  background: var(--background-base);
}

.tree-content::-webkit-scrollbar-thumb,
.files-content::-webkit-scrollbar-thumb,
.preview-content::-webkit-scrollbar-thumb {
  background: var(--border-base);
  border-radius: 4px;
}

.tree-content::-webkit-scrollbar-thumb:hover,
.files-content::-webkit-scrollbar-thumb:hover,
.preview-content::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* Tree view styles */
.tree-item {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  margin: 1px 0;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s;
}

.tree-item:hover {
  background-color: var(--surface-base-hover);
  color: var(--text-strong);
}

.tree-item:hover .tree-icon,
.tree-item:hover .tree-toggle {
  color: var(--text-strong);
}

.tree-item.selected {
  background-color: var(--surface-base-hover);
  color: var(--text-strong);
  font-weight: 500;
}

.tree-item.selected .tree-icon,
.tree-item.selected .tree-toggle {
  color: var(--text-strong);
}

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

.tree-toggle {
  width: 16px;
  height: 16px;
  margin-right: 4px;
  transition: transform 0.15s;
  cursor: pointer;
}

.tree-children {
  margin-left: 8px;
  display: none;
}

.tree-children.expanded {
  display: block;
}

.tree-icon {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  flex-shrink: 0;
}

.tree-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* File list styles */
.files-table tbody tr {
  transition: background-color 0.15s;
}

.files-table tbody tr:hover {
  background-color: var(--surface-base-hover);
  color: var(--text-strong);
}

.files-table tbody tr:hover .file-name-text {
  color: var(--text-strong);
}

.files-table tbody tr:hover .file-actions {
  color: var(--text-strong);
}

.files-table tbody tr:hover .file-actions i,
.files-table tbody tr:hover .file-actions svg {
  color: var(--text-strong);
}

/* Ensure file actions don't create white overlay */
.file-actions {
  background: transparent !important;
}

.file-actions::before,
.file-actions::after {
  display: none !important;
}

/* Remove all transitions */
.files-table tbody tr,
.files-table tbody tr *,
.tree-item,
.tree-item *,
.action-btn,
.action-btn * {
  transition: none !important;
}

.files-table tbody tr.selected {
  background-color: var(--surface-base-hover);
  color: var(--text-strong);
}

.files-table tbody tr.selected .file-name-text {
  color: var(--text-strong);
}

.files-table tbody tr.selected .file-actions {
  color: var(--text-strong);
}

.files-table tbody tr.selected .file-actions i,
.files-table tbody tr.selected .file-actions svg {
  color: var(--text-strong);
}

.files-table tbody tr.selected .file-icon {
  color: var(--text-strong) !important;
}

.files-table tbody tr:hover .file-icon {
  color: var(--text-strong) !important;
}

.file-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.file-name {
  display: flex;
  align-items: center;
  min-width: 0;
}

.file-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-left: 8px;
}

.file-actions {
  opacity: 0;
  transition: opacity 0.15s;
}

.files-table tbody tr:hover .file-actions {
  opacity: 1;
}

.action-btn {
  padding: 4px;
  border-radius: 4px;
  transition: background-color 0.15s;
  cursor: pointer;
}

.action-btn:hover {
  background-color: var(--surface-base-hover);
}

.action-btn.danger:hover {
  background-color: var(--surface-critical-base);
  color: var(--icon-critical-base);
}

/* Drag and drop styles */
.drag-over {
  background-color: var(--background-base) !important;
  border: 2px dashed var(--border-interactive-base) !important;
}

.dragging {
  opacity: 0.5;
}

.drop-zone {
  position: relative;
}

.drop-zone::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--surface-interactive-base);
  border: 2px dashed var(--border-interactive-base);
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  z-index: 10;
}

.drop-zone.drag-over::before {
  opacity: 1;
}

/* Upload progress styles */
.upload-item {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-weak-base);
}

.upload-icon {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  flex-shrink: 0;
}

.upload-info {
  flex: 1;
  min-width: 0;
}

.upload-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-progress {
  margin-top: 4px;
}

.upload-progress-bar {
  width: 100%;
  height: 4px;
  background-color: var(--border-weak-base);
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background-color: var(--text-interactive-base);
  transition: width 0.3s;
}

.upload-status {
  display: flex;
  align-items: center;
  margin-left: 12px;
  font-size: 12px;
  color: var(--text-weak);
}

.upload-retry {
  margin-left: 8px;
  padding: 2px 6px;
  background-color: var(--background-base);
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.upload-retry:hover {
  background-color: var(--surface-base-hover);
}

/* Preview styles */
.preview-image {
  max-width: 100%;
  max-height: 400px;
  object-fit: contain;
}

.preview-text {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 12px;
  line-height: 1.5;
}

.preview-video,
.preview-audio {
  max-width: 100%;
}

.preview-pdf {
  height: 400px;
}

/* Context menu styles */
#context-menu,
#tree-context-menu {
  box-shadow: 0 4px 6px -1px color-mix(in srgb, var(--black) 10%, transparent), 0 2px 4px -1px color-mix(in srgb, var(--black) 6%, transparent);
  min-width: 160px;
}

/* Context menu buttons */
#context-menu button {
  white-space: nowrap;
  display: flex;
  align-items: center;
  width: 100%;
}

#context-menu button i {
  flex-shrink: 0;
}

/* Sort indicator styles */
.sort-icon {
  transition: transform 0.15s ease;
  opacity: 0.6;
}

/* Sortable column headers */
.sortable {
  position: relative;
  transition: background-color 0.15s ease;
}

.sortable:hover {
  background-color: var(--surface-base-hover) !important;
}

.sortable:active {
  background-color: var(--surface-base-active) !important;
}

/* Sort direction indicators */
.sortable.sort-asc .sort-icon {
  opacity: 1;
  transform: rotate(0deg);
  color: var(--text-strong) !important;
}

.sortable.sort-desc .sort-icon {
  opacity: 1;
  transform: rotate(180deg);
  color: var(--text-strong) !important;
}

/* Active sorting column styling */
.sortable.sort-asc,
.sortable.sort-desc {
  background-color: var(--background-stronger) !important;
  font-weight: 600;
  color: var(--text-strong) !important;
}

/* Ensure sort icons are visible when sorting is active */
.sortable.sort-asc .sort-icon,
.sortable.sort-desc .sort-icon {
  display: inline-block !important;
}

/* View controls */
.view-controls button.active {
  background-color: var(--button-primary-base);
  color: var(--icon-invert-base);
}

/* Grid view styles */
.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 16px;
  padding: 16px;
}

.file-grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s;
  text-align: center;
}

.file-grid-item:hover {
  background-color: var(--surface-base-hover);
  color: var(--text-strong);
}

.file-grid-item:hover .file-grid-name {
  color: var(--text-strong);
}

.file-grid-item.selected {
  background-color: var(--surface-base-hover);
  color: var(--text-strong);
}

.file-grid-item.selected .file-grid-name {
  color: var(--text-strong);
}

.file-grid-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
}

.file-grid-name {
  font-size: 12px;
  word-break: break-word;
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.file-grid-size {
  font-size: 10px;
  color: var(--text-weak);
  margin-top: 4px;
}

/* Thumbnail styles */
.file-thumbnail {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  background-color: var(--background-base);
}

.file-thumbnail-small {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border-weak-base);
  display: inline-block;
}

/* Editor styles */
.editor {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  line-height: 1.5;
  tab-size: 2;
}

.editor:focus {
  outline: none;
}

/* Monaco Editor container styles */
.editor-container {
  width: 100%;
  height: 100%;
  min-height: 400px;
}

#monaco-editor-container {
  width: 100%;
  height: 100%;
  border: 1px solid var(--border-weak-base);
  border-radius: 4px;
  overflow: hidden;
}

/* Editor content wrapper */
.editor-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Ensure proper sizing for full-height editor */
.editor-page {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

/* Split.js gutter styling */
.gutter {
  background-color: var(--border-weak-base) !important;
  border: none !important;
  background-image: none !important;
  opacity: 1 !important;
  cursor: col-resize !important;
}

.gutter:hover {
  background-color: var(--border-base) !important;
}

.gutter.gutter-horizontal {
  width: 4px !important;
  cursor: col-resize !important;
}

.gutter.gutter-vertical {
  height: 4px !important;
  cursor: row-resize !important;
}

/* MOBILE-FIRST COMPLETE REDESIGN */
@media (max-width: 768px) {
  /* Hide desktop layout completely */
  .split-container {
    display: none !important;
  }
  
  /* Show mobile layout */
  .mobile-layout {
    display: flex !important;
    flex-direction: column;
    height: 100vh;
    background: var(--surface-raised-stronger);
    position: relative; /* For context menu positioning */
  }

  /* Mobile header with hamburger menu */
  .mobile-header {
    background: var(--surface-raised-stronger);
    border-bottom: 1px solid var(--border-weak-base);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    position: relative;
    z-index: 100;
  }
  
  .mobile-nav-toggle {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 8px;
    color: var(--text-strong);
  }

  .mobile-nav-toggle:active {
    background: var(--surface-base-hover);
  }

  .mobile-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-strong);
    flex: 1;
    text-align: center;
    margin: 0 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .mobile-actions {
    display: flex;
    gap: 8px;
  }
  
  .mobile-search-btn,
  .mobile-upload-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 8px;
    color: var(--text-strong);
  }

  .mobile-search-btn:active,
  .mobile-upload-btn:active {
    background: var(--surface-base-hover);
  }
  
  /* Mobile navigation drawer */
  .mobile-nav-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    height: 100vh;
    background: var(--surface-raised-stronger);
    border-right: 1px solid var(--border-weak-base);
    transform: translateX(-100%);
    transition: transform 0.3s ease-out;
    z-index: 1000;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .mobile-nav-drawer.open {
    transform: translateX(0);
  }
  
  .mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: color-mix(in srgb, var(--black) 50%, transparent);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-out;
    z-index: 999;
  }
  
  .mobile-nav-overlay.open {
    opacity: 1;
    visibility: visible;
  }
  
  /* Mobile drawer header */
  .mobile-drawer-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-weak-base);
    background: var(--background-stronger);
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .mobile-drawer-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-strong);
    margin: 0;
  }

  .mobile-drawer-subtitle {
    font-size: 14px;
    color: var(--text-weak);
    margin: 4px 0 0 0;
  }
  
  /* Mobile tree navigation */
  .mobile-tree {
    padding: 16px 0;
  }
  
  .mobile-tree-item {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-strong);
    border-bottom: 1px solid var(--border-weak-base);
    min-height: 60px;
  }

  .mobile-tree-item:active {
    background: var(--surface-base-hover);
  }

  .mobile-tree-item.selected {
    background: var(--surface-base-active);
    font-weight: 500;
    color: var(--text-strong);
  }

  .mobile-tree-icon {
    width: 24px;
    height: 24px;
    margin-right: 16px;
    color: var(--text-weak);
    flex-shrink: 0;
  }
  
  .mobile-tree-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .mobile-tree-chevron {
    width: 20px;
    height: 20px;
    color: var(--text-weaker);
    margin-left: 8px;
    flex-shrink: 0;
  }

  /* Mobile content area */
  .mobile-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--surface-raised-stronger);
  }

  /* Mobile breadcrumb */
  .mobile-breadcrumb {
    padding: 12px 16px;
    background: var(--background-stronger);
    border-bottom: 1px solid var(--border-weak-base);
    font-size: 14px;
    color: var(--text-weak);
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  
  .mobile-breadcrumb::-webkit-scrollbar {
    display: none;
  }
  
  /* Mobile search overlay */
  .mobile-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--surface-raised-stronger);
    z-index: 2000;
    transform: translateY(-100%);
    transition: transform 0.3s ease-out;
  }

  .mobile-search-overlay.open {
    transform: translateY(0);
  }

  .mobile-search-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-weak-base);
    display: flex;
    align-items: center;
    gap: 16px;
  }
  
  .mobile-search-close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 8px;
    color: var(--text-strong);
  }

  .mobile-search-input {
    flex: 1;
    height: 44px;
    padding: 0 16px;
    border: 1px solid var(--border-base);
    border-radius: 8px;
    font-size: 16px;
    background: var(--input-base);
  }

  .mobile-search-input:focus {
    outline: none;
    border-color: var(--input-focus);
  }
  
  /* Mobile file list */
  .mobile-files {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .mobile-file-item {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-weak-base);
    min-height: 72px;
    cursor: pointer;
    position: relative;
  }

  .mobile-file-item:active {
    background: var(--surface-base-hover);
  }

  .mobile-file-item.selected {
    background: var(--surface-base-active);
  }
  
  .mobile-file-icon {
    width: 44px;
    height: 44px;
    margin-right: 16px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background-base);
    border-radius: 8px;
    color: var(--text-weak);
  }

  .mobile-file-info {
    flex: 1;
    min-width: 0;
  }
  
  .mobile-file-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-strong);
    margin-bottom: 4px;
    word-break: break-word;
    line-height: 1.3;
  }

  .mobile-file-meta {
    font-size: 14px;
    color: var(--text-weak);
    display: flex;
    gap: 12px;
  }
  
  .mobile-file-actions {
    display: flex;
    gap: 8px;
    margin-left: 16px;
    opacity: 0.7;
  }
  
  .mobile-action-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--background-base);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-weak);
  }

  .mobile-action-btn:active {
    background: var(--surface-base-active);
    color: var(--text-strong);
  }

  .mobile-action-btn.danger {
    color: var(--icon-critical-base);
  }

  .mobile-action-btn.danger:active {
    background: var(--surface-critical-base);
  }
  
  /* Mobile bottom action bar */
  .mobile-bottom-bar {
    background: var(--surface-raised-stronger);
    border-top: 1px solid var(--border-weak-base);
    padding: 16px;
    display: flex;
    gap: 12px;
    min-height: 84px;
    align-items: center;
    position: sticky;
    bottom: 0;
    z-index: 50;
  }
  
  .mobile-bottom-btn {
    flex: 1;
    height: 52px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }
  
  .mobile-bottom-btn.primary {
    background: var(--button-primary-base);
    color: var(--icon-invert-base);
  }

  .mobile-bottom-btn.primary:active {
    background: var(--button-primary-base);
  }

  .mobile-bottom-btn.secondary {
    background: var(--button-secondary-base);
    color: var(--text-strong);
    border: 1px solid var(--border-weak-base);
  }

  .mobile-bottom-btn.secondary:active {
    background: var(--button-secondary-hover);
  }
  
  /* Mobile empty state */
  .mobile-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
  }
  
  .mobile-empty-icon {
    width: 64px;
    height: 64px;
    color: var(--text-weaker);
    margin-bottom: 16px;
  }

  .mobile-empty-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-strong);
    margin-bottom: 8px;
  }

  .mobile-empty-text {
    font-size: 14px;
    color: var(--text-weak);
    line-height: 1.5;
  }
  
  /* Hide desktop elements completely on mobile */
  header,
  .files-table,
  .tree-panel,
  .files-panel,
  .preview-panel,
  .view-controls,
  .layout-controls,
  #context-menu {
    display: none !important;
  }
}

/* Extra small mobile optimizations */
@media (max-width: 480px) {
  .mobile-nav-drawer {
    width: 280px;
  }
  
  .mobile-file-item {
    padding: 12px;
    min-height: 64px;
  }
  
  .mobile-file-icon {
    width: 40px;
    height: 40px;
    margin-right: 12px;
  }
  
  .mobile-file-name {
    font-size: 15px;
  }
  
  .mobile-file-meta {
    font-size: 13px;
  }
  
  .mobile-file-actions {
    margin-left: 8px;
  }
  
  .mobile-action-btn {
    width: 40px;
    height: 40px;
  }
  
  .mobile-bottom-bar {
    padding: 12px;
    min-height: 76px;
  }
  
  .mobile-bottom-btn {
    height: 48px;
    font-size: 15px;
  }
  
  .mobile-tree-item {
    padding: 12px 20px;
    min-height: 56px;
    font-size: 15px;
  }
}

/* Loading states */
.loading {
  pointer-events: none;
  opacity: 0.6;
}

/* Responsive design */
@media (max-width: 1024px) {
  .preview-panel {
    display: none;
  }
  
  .tree-panel {
    min-width: 150px;
    flex: 0 0 200px;
  }
}

@media (max-width: 768px) {
  .tree-panel {
    min-width: 120px;
    flex: 0 0 150px;
  }
  
  .upload-controls {
    flex-direction: column;
    gap: 4px;
  }
  
  .file-actions {
    opacity: 1;
  }
}

/* Animation classes */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from { transform: translateX(-10px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.fade-in {
  animation: fadeIn 0.2s ease-out;
}

.slide-in {
  animation: slideIn 0.2s ease-out;
}

/* Utility classes */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.pointer-events-none {
  pointer-events: none;
}

/* Fix long paths overflow in file table */
.files-table {
  table-layout: fixed;
  width: 100%;
}

.files-table td:nth-child(2) {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Remove the white background tooltip overlay that covers filename */
.files-table td:nth-child(2):hover {
  /* Allow text wrapping but without the white overlay */
  white-space: normal;
  word-break: break-all;
  overflow: visible;
}

/* Type column styling */
.files-table td:nth-child(3) {
  width: 80px;
  font-size: 12px;
  color: var(--text-weak);
  text-transform: uppercase;
}

/* Responsive button text - hide text under 1024px for cleaner look */
@media (max-width: 1024px) {
  .button-text {
    display: none;
  }
  
  /* Remove margin from icons when text is hidden */
  .upload-file-btn i,
  .new-folder-btn i,
  .new-file-btn i,
  .download-archive i,
  .json-view i {
    margin-right: 0 !important;
  }
  
  /* Adjust button padding for icon-only buttons */
  .upload-file-btn,
  .new-folder-btn,
  .new-file-btn,
  .download-archive,
  .json-view {
    padding: 8px !important;
    min-width: 40px;
  }
  
  /* Ensure icons are centered */
  .upload-file-btn,
  .new-folder-btn,
  .new-file-btn,
  .download-archive,
  .json-view {
    justify-content: center;
  }
}
/* Mobile context menu */
.mobile-context-menu {
  position: absolute;
  z-index: 1001;
  background-color: var(--surface-raised-stronger);
  border: 1px solid var(--border-weak-base);
  border-radius: 8px;
  box-shadow: 0 4px 6px -1px color-mix(in srgb, var(--black) 10%, transparent), 0 2px 4px -1px color-mix(in srgb, var(--black) 6%, transparent);
  padding: 8px 0;
  min-width: 200px;
}

.mobile-context-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}

.mobile-context-menu-item:hover {
  background-color: var(--surface-base-hover);
}

.mobile-context-menu-item i {
  margin-right: 12px;
  width: 20px;
  height: 20px;
}

.mobile-context-menu-item.danger {
  color: var(--icon-critical-base);
}

/* Download Manager Styles */
#download-manager {
  transition: transform 0.3s ease-out;
}

#download-manager.minimized {
  transform: translateY(calc(100% - 48px));
}

.download-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-weak-base);
}

.download-item:last-child {
  border-bottom: none;
}

.download-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.download-info {
  flex: 1;
  min-width: 0;
}

.download-filename {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-strong);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-url {
  font-size: 12px;
  color: var(--text-weak);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-actions {
  display: flex;
  gap: 4px;
  margin-left: 12px;
}

.download-action-btn {
  padding: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  color: var(--text-weak);
  transition: all 0.15s;
}

.download-action-btn:hover {
  background: var(--surface-base-hover);
  color: var(--text-strong);
}

.download-progress-container {
  margin-top: 8px;
}

.download-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border-weak-base);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

.download-progress-fill {
  height: 100%;
  background: var(--text-interactive-base);
  transition: width 0.3s ease;
  border-radius: 3px;
}

.download-progress-fill.completed {
  background: var(--icon-success-base);
}

.download-progress-fill.failed {
  background: var(--icon-critical-base);
}

.download-stats {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-weak);
}

.download-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  margin-top: 4px;
}

.download-status.downloading {
  color: var(--text-interactive-base);
}

.download-status.completed {
  color: var(--icon-success-base);
}

.download-status.failed {
  color: var(--icon-critical-base);
}

.download-status-icon {
  width: 14px;
  height: 14px;
  animation: spin 1s linear infinite;
}

.download-status.completed .download-status-icon,
.download-status.failed .download-status-icon {
  animation: none;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Download History Styles */
.history-group {
  margin-bottom: 24px;
}

.history-group-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-weak-base);
}

.history-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-weak-base);
}

.history-item:last-child {
  border-bottom: none;
}

.history-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.history-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-strong);
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-item-status {
  font-size: 12px;
  color: var(--text-weak);
}

.history-item-url {
  font-size: 12px;
  color: var(--text-weak);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-path {
  font-size: 12px;
  color: var(--text-weaker);
  font-family: 'Monaco', 'Menlo', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-error {
  font-size: 12px;
  color: var(--icon-critical-base);
  margin-top: 4px;
  padding: 6px;
  background: var(--surface-critical-base);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-retry-btn {
  padding: 4px 8px;
  font-size: 11px;
  background: var(--icon-critical-base);
  color: var(--icon-invert-base);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.history-retry-btn:hover {
  background: var(--icon-critical-base);
}

.history-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-weaker);
}

.history-empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--text-weaker);
}

/* Download Modal Styles */
#download-modal .bg-white {
  max-height: 90vh;
  overflow-y: auto;
}

/* Responsive adjustments for download manager */
@media (max-width: 768px) {
  #download-manager {
    max-height: 60vh !important;
  }
  
  #download-list {
    max-height: calc(60vh - 120px) !important;
  }
  
  .download-stats {
    flex-direction: column;
    gap: 2px;
  }
}

/* ==========================================================================
   Unified theming — Phase 3.3 (font size), Phase 4.2 (embed layout control),
   Phase 5 (scrollbars / focus / selection). Appended block.
   ========================================================================== */

/* --- Phase 3.3: editor / monospace font size from --font-size-editor -------- */
.monaco-editor, code, pre, .mono { font-size: var(--font-size-editor, 14px); }

/* --- Phase 4.2: layout control via <html data-*> attributes ----------------- */
/* Page header (a bare <header> direct child of <body>) + editor toolbar.
   `> body > header` avoids hiding <header> inside rendered file previews. */
html[data-hide-header="true"] > body > header,
html[data-hide-header="true"] .editor-header { display: none !important; }
/* chromeless additionally hides the file-list toolbar (.files-header) */
html[data-chromeless="true"] .files-header { display: none !important; }
html[data-hide-sidebar="true"] .tree-panel { display: none !important; }
/* Mobile sidebar: hide drawer, overlay AND toggle (toggle alone would lock scroll) */
html[data-hide-sidebar="true"] .mobile-nav-drawer,
html[data-hide-sidebar="true"] .mobile-nav-overlay,
html[data-hide-sidebar="true"] .mobile-nav-toggle { display: none !important; }
html[data-hide-preview="true"] .preview-panel { display: none !important; }
html[data-hide-footer="true"] footer,
html[data-hide-footer="true"] #download-status-bar,
html[data-hide-footer="true"] #download-manager { display: none !important; }
html[data-hide-header="true"] .mobile-nav-toggle { display: none !important; }
html[data-chromeless="true"] .mobile-search-header { display: none !important; }
html[data-hide-header="true"] .mobile-header { display: none !important; }
html[data-hide-footer="true"] .mobile-bottom-bar { display: none !important; }

/* borderless — strip outer borders/margins/shadows for a seamless iframe */
html[data-borderless="true"] body { margin: 0; padding: 0; border: none; }
html[data-borderless="true"] header,
html[data-borderless="true"] footer,
html[data-borderless="true"] .tree-panel,
html[data-borderless="true"] .files-panel,
html[data-borderless="true"] .preview-panel,
html[data-borderless="true"] .editor-header,
html[data-borderless="true"] .files-header { border: none !important; }
html[data-borderless="true"] main,
html[data-borderless="true"] .split-container { border: none !important; outline: none !important; }
html[data-borderless="true"] header,
html[data-borderless="true"] footer,
html[data-borderless="true"] #download-status-bar,
html[data-borderless="true"] #download-manager { box-shadow: none !important; }
html[data-borderless="true"] .gutter { background-color: transparent !important; border: none !important; }

/* embedBg=transparent */
html[data-bg-transparent="true"],
html[data-bg-transparent="true"] body { background: transparent !important; }

/* --- Phase 5.3: scrollbar theming ------------------------------------------ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--background-base); }
::-webkit-scrollbar-thumb { background: var(--border-base); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* --- Phase 5.4: focus ring consistency ------------------------------------- */
*:focus-visible {
  outline: 2px solid var(--border-interactive-base);
  outline-offset: 2px;
}

/* --- Phase 5.5: selection color -------------------------------------------- */
::selection {
  background: var(--surface-interactive-base);
  color: var(--text-on-interactive-base);
}