.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.toolbar button {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
}

.toolbar button:hover:not(:disabled) {
  background: var(--bg-surface-hover);
}

.toolbar button svg { width: 14px; height: 14px; }
.toolbar .spacer { flex: 1; }

.toolbar #fileSearch {
  width: 180px;
  font-size: 12px;
  padding: 5px 8px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  overflow-x: auto;
  white-space: nowrap;
}

.crumb {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-weight: 500;
}

.crumb:hover { background: var(--accent-soft); }
.crumb:last-child { color: var(--text); cursor: default; }
.crumb:last-child:hover { background: none; }
.crumb-sep { color: var(--text-tertiary); margin: 0 1px; }

.file-list-header {
  display: grid;
  grid-template-columns: 32px 1fr 100px 160px;
  gap: 8px;
  padding: 6px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg);
  flex-shrink: 0;
  user-select: none;
}

.file-list-header span { cursor: pointer; }
.file-list-header span:hover { color: var(--text-secondary); }

.file-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.file-row {
  display: grid;
  grid-template-columns: 32px 1fr 100px 160px;
  gap: 8px;
  padding: 8px 16px;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}

.file-row:hover { background: var(--bg-surface-hover); }
.file-row.selected { background: var(--accent-soft); }

.file-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-icon svg {
  width: 20px;
  height: 20px;
  color: var(--text-tertiary);
}

.file-row[data-type="d"] .file-icon svg { color: var(--accent); }
.file-row.selected .file-icon svg { color: var(--accent); }

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

.file-size {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
  font-family: var(--font-mono);
}

.file-date {
  font-size: 12px;
  color: var(--text-tertiary);
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text-tertiary);
  font-size: 14px;
  padding: 40px;
}

.empty-state[hidden] { display: none; }

/* Grid view */
.file-list.grid-view {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  align-content: flex-start;
}

.grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}

.grid-item:hover {
  background: var(--bg-hover);
}

.grid-item.selected {
  background: var(--bg-selected);
}

.grid-icon {
  width: 40px;
  height: 40px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.grid-icon svg {
  width: 100%;
  height: 100%;
}

.grid-name {
  font-size: 11px;
  line-height: 1.3;
  color: var(--text-primary);
  word-break: break-all;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-width: 100%;
}

/* Folder size loading animation */
.size-loading {
  animation: pulse-opacity 1.2s ease-in-out infinite;
}

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

/* File viewer overlay */
.page[data-page="files"] {
  position: relative;
}

.file-viewer {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.file-viewer[hidden] { display: none; }

.viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.viewer-toolbar button {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
}

.viewer-toolbar button svg { width: 14px; height: 14px; }
.viewer-toolbar .spacer { flex: 1; }

.viewer-zoom-label {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  min-width: 36px;
  text-align: center;
  flex-shrink: 0;
}

.viewer-zoom-label[hidden] { display: none; }

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

.viewer-content {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.viewer-loading,
.viewer-error {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text-tertiary);
  font-size: 14px;
}

.viewer-error { color: var(--error); }

.viewer-text {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  tab-size: 4;
  color: var(--text);
  overflow: auto;
}

.viewer-text-edit {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  tab-size: 4;
  padding: 0;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text);
  resize: none;
  outline: none;
  min-height: 200px;
}

.viewer-media {
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  border-radius: var(--radius-sm);
}

img.viewer-media {
  object-fit: contain;
  transition: transform 0.15s ease;
  cursor: zoom-in;
}

/* Fullscreen media fills the screen */
.viewer-media:fullscreen,
.viewer-pdf:fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  object-fit: contain;
  background: #000;
  border-radius: 0;
}

audio.viewer-media {
  width: 100%;
  max-width: 500px;
  margin: auto;
}

.viewer-pdf {
  flex: 1;
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  min-height: 400px;
}

/* Hex editor */
.hex-editor {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.hex-info-bar {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 4px 0 8px;
  font-family: var(--font-mono);
}

.hex-table {
  flex: 1;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
}

.hex-row {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.hex-row:hover {
  background: var(--bg-hover);
}

.hex-offset {
  color: var(--text-tertiary);
  user-select: none;
  min-width: 72px;
}

.hex-cells {
  display: inline-flex;
  gap: 2px;
}

.hex-gap {
  width: 6px;
}

.hex-cell {
  width: 22px;
  text-align: center;
  cursor: pointer;
  border-radius: 2px;
  color: var(--text-secondary);
  outline: none;
}

.hex-cell:hover {
  background: var(--bg-hover);
}

.hex-cell.hex-active {
  background: var(--accent);
  color: var(--text-on-accent, #fff);
}

.hex-cell.hex-modified {
  color: var(--warning, #f0a030);
  font-weight: 600;
}

.hex-cell.hex-empty {
  cursor: default;
}

.hex-ascii {
  border-left: 1px solid var(--border);
  padding-left: 8px;
  color: var(--text-tertiary);
}

.hex-ascii-char {
  cursor: default;
}

.hex-ascii-char.hex-active {
  background: var(--accent);
  color: var(--text-on-accent, #fff);
  border-radius: 2px;
}

.hex-ascii-char.hex-modified {
  color: var(--warning, #f0a030);
  font-weight: 600;
}

/* Entropy bar */
.viewer-entropy {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.entropy-ok { background: var(--bg-surface); color: var(--text-secondary); }
.entropy-info { background: #2a3040; color: #7eb8f0; }
.entropy-warning { background: #3a2a1a; color: #f0a030; }

/* EXIF metadata */
.viewer-exif {
  font-size: 12px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.viewer-exif summary {
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 0;
  font-weight: 500;
}

.exif-table {
  width: 100%;
  max-width: 500px;
  border-collapse: collapse;
  margin-top: 4px;
}

.exif-table td {
  padding: 2px 8px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
}

.exif-table td:first-child {
  color: var(--text-secondary);
  white-space: nowrap;
  width: 140px;
}

@media (max-width: 768px) {
  .file-list-header,
  .file-row {
    grid-template-columns: 28px 1fr 80px;
  }
  .file-date { display: none; }
  .toolbar #fileSearch { width: 120px; }
}
