@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Inter:wght@400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #060a0e;
  --surface:   #0b1017;
  --panel:     #0f1620;
  --raised:    #141e2a;
  --border:    #1e2f42;
  --border2:   #2d4459;
  --text:      #edf2f7;
  --text-2:    #a8bfd4;
  --text-3:    #6b8aaa;
  --ghost:     #1a2a3a;
  --cyan:      #2dd4e8;
  --cyan-dim:  rgba(45,212,232,0.10);
  --green:     #4ade80;
  --green-dim: rgba(74,222,128,0.10);
  --gold:      #f5c842;
  --gold-dim:  rgba(245,200,66,0.10);
  --red:       #f87171;
  --red-dim:   rgba(248,113,113,0.10);
  --blue:      #60a5fa;
  --mono:      'JetBrains Mono', 'Fira Code', monospace;
  --sans:      'Inter', system-ui, sans-serif;
  --radius:    5px;
}

html { font-size: 14px; }
body { font-family: var(--sans); background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.55; }

/* ── Chrome ───────────────────────────────────────────────────────────────── */
.topbar { height: 2px; background: linear-gradient(90deg, var(--cyan), var(--blue) 50%, var(--gold)); }

header { display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.logo { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--cyan); letter-spacing: 0.06em; }
.logo em { color: var(--text-3); font-style: normal; }
.header-status { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--text-3); display: flex; align-items: center; gap: 7px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ghost); flex-shrink: 0; }
.dot.ok { background: var(--green); box-shadow: 0 0 6px rgba(74,222,128,0.5); }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.layout { display: grid; grid-template-columns: 256px 1fr; height: calc(100vh - 34px); }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; overflow: hidden; }
.sidebar-section { padding: 14px 14px 12px; border-bottom: 1px solid var(--border); }
.label { font-family: var(--mono); font-size: 9px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 8px; display: block; }

/* ── Bundle Finder sidebar link (opens standalone page) ──────────────────── */
.sidebar-bf-link {
  padding: 8px 8px 4px;
}
.btn-bf-link {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: var(--radius);
  border: 1px solid rgba(45,212,232,0.25);
  background: var(--cyan-dim);
  color: var(--cyan); text-decoration: none;
  transition: all 0.12s;
}
.btn-bf-link:hover {
  border-color: var(--cyan); background: rgba(45,212,232,0.18);
}
.btn-bf-icon { font-size: 15px; flex-shrink: 0; width: 18px; text-align: center; }
.btn-bf-text { flex: 1; min-width: 0; }
.btn-bf-name { display: block; font-size: 13px; font-weight: 500; }
.btn-bf-hint { display: block; font-size: 10px; font-family: var(--mono); margin-top: 1px; opacity: 0.7; }

/* ── Nav tabs ─────────────────────────────────────────────────────────────── */
.nav-tabs { display: flex; flex-direction: column; gap: 1px; padding: 10px 8px; flex: 1; overflow-y: auto; }
.tab-btn { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: var(--radius); border: none; background: transparent; color: var(--text-2); font-family: var(--sans); font-size: 13px; cursor: pointer; text-align: left; transition: all 0.1s; width: 100%; position: relative; }
.tab-btn:hover { background: var(--panel); color: var(--text); }
.tab-btn.active { background: var(--panel); color: var(--text); font-weight: 500; }
.tab-btn.active::before { content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 2px; border-radius: 1px; background: var(--cyan); }
.tab-icon { font-size: 14px; flex-shrink: 0; width: 18px; text-align: center; }
.tab-info { flex: 1; min-width: 0; }
.tab-name { display: block; font-size: 13px; }
.tab-hint { font-size: 10px; color: var(--text-3); font-family: var(--mono); display: block; margin-top: 1px; }

.tab-state { font-family: var(--mono); font-size: 9px; font-weight: 600; padding: 2px 6px; border-radius: 10px; flex-shrink: 0; }
.tab-state.loaded  { background: var(--green-dim); color: var(--green); }
.tab-state.error   { background: var(--red-dim);   color: var(--red); }
.tab-state.loading { background: var(--cyan-dim);  color: var(--cyan); animation: tab-pulse 1.2s ease-in-out infinite; }
.tab-state.absent  { background: var(--panel); color: var(--text-3); }

@keyframes tab-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Main panel ───────────────────────────────────────────────────────────── */
.main { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.panel-header { display: flex; align-items: center; gap: 10px; padding: 11px 18px; border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.panel-title { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); }
.panel-meta  { font-size: 11px; color: var(--text-3); }
.panel-actions { margin-left: auto; display: flex; gap: 7px; align-items: center; }

.btn { padding: 5px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: transparent; color: var(--text-2); font-family: var(--mono); font-size: 11px; cursor: pointer; transition: all 0.12s; white-space: nowrap; line-height: 1.4; }
.btn:hover:not(:disabled) { border-color: var(--border2); color: var(--text); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-fetch { color: #000; background: var(--cyan); border-color: var(--cyan); font-weight: 600; }
.btn-fetch:hover:not(:disabled) { background: #52e0f0; border-color: #52e0f0; }
.btn-dl { color: var(--green); border-color: rgba(74,222,128,0.30); }
.btn-dl:hover:not(:disabled) { background: var(--green-dim); border-color: var(--green); }

.search-input { padding: 5px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-family: var(--mono); font-size: 11px; width: 200px; outline: none; transition: border-color 0.15s; }
.search-input:focus { border-color: var(--cyan); }
.search-input::placeholder { color: var(--text-3); }

.panel-body { flex: 1; overflow: auto; display: flex; flex-direction: column; }

/* ── State messages (idle / single-file loading / error) ─────────────────── */
.state-msg { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 40px; text-align: center; }
.state-icon  { font-size: 36px; }
.state-title { font-size: 15px; font-weight: 600; color: var(--text); }
.state-body  { font-size: 12px; font-family: var(--mono); color: var(--text-2); line-height: 1.9; max-width: 300px; white-space: pre-line; }
.state-msg.error .state-title { color: var(--red); }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner    { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--cyan); animation: spin 0.75s linear infinite; }
.spinner-sm { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--cyan); animation: spin 0.75s linear infinite; flex-shrink: 0; }

/* ── Fetch-all progress panel ────────────────────────────────────────────── */
.fetch-all-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.fetch-all-inner { width: 100%; max-width: 480px; }

.fetch-all-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.fetch-all-title { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); }
.fetch-all-count { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--text-3); }

.fetch-file-rows { display: flex; flex-direction: column; gap: 6px; }

.fetch-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius);
  background: var(--raised);
  border: 1px solid var(--border);
  transition: border-color 0.25s;
}
.fetch-file-row.loading { border-color: rgba(45,212,232,0.30); }
.fetch-file-row.loaded  { border-color: rgba(74,222,128,0.30); }
.fetch-file-row.error   { border-color: rgba(248,113,113,0.30); }

.fetch-file-icon   { font-size: 16px; flex-shrink: 0; }
.fetch-file-name   { font-family: var(--mono); font-size: 12px; color: var(--text); flex: 1; }
.fetch-file-detail { font-family: var(--mono); font-size: 10px; color: var(--text-3); }

.fetch-file-badge {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 10px;
  min-width: 64px;
  text-align: center;
  flex-shrink: 0;
}
.fetch-file-badge.idle    { background: var(--ghost);     color: var(--text-3); }
.fetch-file-badge.loading { background: var(--cyan-dim);  color: var(--cyan);   animation: tab-pulse 1.2s ease-in-out infinite; }
.fetch-file-badge.loaded  { background: var(--green-dim); color: var(--green);  }
.fetch-file-badge.error   { background: var(--red-dim);   color: var(--red);    }

.fetch-file-dl {
  padding: 3px 9px; border-radius: var(--radius);
  border: 1px solid rgba(74,222,128,0.30); background: transparent;
  color: var(--green); font-family: var(--mono); font-size: 10px;
  cursor: pointer; transition: all 0.12s; flex-shrink: 0;
}
.fetch-file-dl:hover { background: var(--green-dim); border-color: var(--green); }

/* ── Bundle table ────────────────────────────────────────────────────────── */
.bundle-toolbar { display: flex; align-items: center; gap: 10px; padding: 9px 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.bundle-count   { font-family: var(--mono); font-size: 11px; color: var(--text-2); margin-left: auto; }
.bundle-wrap    { flex: 1; overflow: auto; }

table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; }
thead th { padding: 7px 16px; text-align: left; font-size: 9px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.1em; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1; }
tbody td { padding: 5px 16px; color: var(--text); border-bottom: 1px solid var(--ghost); vertical-align: middle; }
tbody tr:hover td { background: var(--panel); }
tbody tr:last-child td { border-bottom: none; }

.type-badge { font-size: 9px; font-weight: 600; padding: 2px 7px; border-radius: 10px; border: 1px solid var(--border2); color: var(--text-2); white-space: nowrap; text-transform: uppercase; letter-spacing: 0.04em; }
.hl { color: var(--gold); background: var(--gold-dim); border-radius: 2px; padding: 0 2px; }
.row-acts { display: flex; gap: 5px; opacity: 0; transition: opacity 0.1s; }
tr:hover .row-acts { opacity: 1; }

/* ── JSON viewer ─────────────────────────────────────────────────────────── */
.json-wrap { flex: 1; overflow: auto; padding: 14px 18px; }
.json-tree { font-family: var(--mono); font-size: 12px; line-height: 1.75; white-space: pre; color: var(--text); }
.j-key  { color: #7ec8f5; }
.j-str  { color: #b5d9ff; }
.j-num  { color: var(--gold); }
.j-bool { color: #f4896b; }
.j-null { color: var(--text-3); }

/* ── Pagination ──────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; padding: 9px 16px; border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.page-btn { padding: 3px 9px; border-radius: var(--radius); border: 1px solid var(--border); background: transparent; color: var(--text-2); font-family: var(--mono); font-size: 11px; cursor: pointer; transition: all 0.1s; }
.page-btn:hover:not(:disabled) { color: var(--text); border-color: var(--border2); }
.page-btn.active { color: var(--cyan); border-color: var(--cyan); background: var(--cyan-dim); }
.page-btn:disabled { opacity: 0.3; cursor: default; }
.page-info { font-family: var(--mono); font-size: 10px; color: var(--text-3); margin-left: auto; }

/* ── Bundle Finder layout ────────────────────────────────────────────────── */
.bundle-finder {
  display: flex; flex-direction: column; flex: 1; overflow: hidden;
}

/* Hero heading — shown in every catalog state (idle, loading, error, loaded) */
.bf-hero {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
.bf-hero-title {
  font-family: var(--sans);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.bf-hero-accent { color: var(--gold); }
.bf-hero-sub {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-3);
  max-width: 500px;
}

/* Section 1 — loaded catalog card */
.bf-section {
  padding: 13px 18px 11px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.bf-section-num {
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.1em;
  margin-bottom: 9px;
}
.bf-loaded-card {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid rgba(74,222,128,0.40); background: var(--raised);
}
.bf-loaded-icon {
  width: 28px; height: 28px; border-radius: var(--radius);
  background: var(--green-dim); border: 1px solid rgba(74,222,128,0.40);
  display: flex; align-items: center; justify-content: center;
  color: var(--green); font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.bf-loaded-info { flex: 1; min-width: 0; }
.bf-loaded-name { font-family: var(--mono); font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bf-loaded-sub  { font-family: var(--mono); font-size: 10px; color: var(--text-3); margin-top: 2px; }
.bf-loaded-badge {
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  padding: 3px 10px; border-radius: 10px; flex-shrink: 0;
  border: 1px solid rgba(74,222,128,0.40); color: var(--green); background: var(--green-dim);
}
.bf-indexed { margin-top: 7px; font-family: var(--mono); font-size: 11px; color: var(--green); }
.bf-local-btn {
  display: inline-block; margin-top: 5px; cursor: pointer;
  font-family: var(--mono); font-size: 10px; color: var(--text-3);
  border: none; background: none; padding: 0;
  text-decoration: underline; text-underline-offset: 2px;
}
.bf-local-btn:hover { color: var(--text-2); }

/* Drag-drop zone (idle / error states) */
.bf-dropzone {
  display: block; margin-top: 14px;
  border: 1px dashed var(--border2); border-radius: var(--radius);
  padding: 13px 18px; text-align: center; cursor: pointer;
  font-family: var(--mono); font-size: 11px; color: var(--text-3);
  transition: all 0.15s;
}
.bf-dropzone code { color: var(--text-2); }
.bf-dropzone:hover, .bf-dropzone.drag-over {
  border-color: var(--cyan); color: var(--cyan); background: var(--cyan-dim);
}

/* History + Favourites accordion row */
.bf-accordion-row {
  display: flex; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.bf-accordion { flex: 1; border-right: 1px solid var(--border); }
.bf-accordion:last-child { border-right: none; }
.bf-accordion-btn {
  width: 100%; display: flex; align-items: center; gap: 7px;
  padding: 9px 14px; background: var(--surface); border: none;
  color: var(--text-3); font-family: var(--mono); font-size: 10px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  cursor: pointer; transition: all 0.12s;
}
.bf-accordion-btn:hover, .bf-accordion-btn.open {
  background: var(--panel); color: var(--text-2);
}
.bf-acc-count {
  font-family: var(--mono); font-size: 9px; padding: 1px 6px;
  border-radius: 10px; background: var(--ghost); color: var(--text-3);
}
.bf-acc-arrow { margin-left: auto; font-size: 8px; color: var(--text-3); }
.bf-accordion-body {
  padding: 10px 14px 12px;
  background: var(--panel); border-top: 1px solid var(--border);
}
.bf-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.bf-chip {
  padding: 3px 10px; border-radius: 12px;
  border: 1px solid var(--border2); background: transparent;
  color: var(--text-2); font-family: var(--mono); font-size: 10px;
  cursor: pointer; transition: all 0.1s;
}
.bf-chip:hover { border-color: var(--cyan); color: var(--cyan); background: var(--cyan-dim); }
.bf-chip-fav { border-color: rgba(245,200,66,0.30); color: var(--gold); }
.bf-chip-fav:hover { border-color: var(--gold); background: var(--gold-dim); }
.bf-empty-chips {
  font-family: var(--mono); font-size: 10px; color: var(--text-3); font-style: italic;
}

/* Search section */
.bf-search-section {
  padding: 12px 18px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.bf-search-row {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
  background: var(--raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 14px;
  transition: border-color 0.15s;
}
.bf-search-row:focus-within { border-color: var(--cyan); }
.bf-search-icon { font-size: 15px; flex-shrink: 0; }
.bf-search-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-family: var(--mono); font-size: 13px;
}
.bf-search-input::placeholder { color: var(--text-3); }
.bf-try-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px;
}
.bf-try-label {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; flex-shrink: 0;
}
.bf-try-chip {
  padding: 3px 10px; border-radius: 12px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-2); font-family: var(--sans); font-size: 11px;
  cursor: pointer; transition: all 0.1s;
}
.bf-try-chip:hover { border-color: var(--cyan); color: var(--cyan); background: var(--cyan-dim); }

/* Results section */
.bf-results-section {
  display: flex; flex-direction: column; flex: 1; overflow: hidden; min-height: 0;
}
.bf-results-header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.hash-toggle {
  margin-left: auto; display: flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 10px; color: var(--text-3);
  cursor: pointer; user-select: none;
}
.hash-toggle input { accent-color: var(--cyan); cursor: pointer; }
.export-hint {
  font-family: var(--mono); font-size: 10px; color: var(--text-3);
  padding: 10px 0 4px; text-align: right;
}
.export-hint code { color: var(--cyan); }
.bf-no-results {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px; color: var(--text-3); font-family: var(--mono);
}

/* Per-bundle row action buttons */
.bundle-fav-btn {
  padding: 2px 7px; border-radius: var(--radius);
  border: 1px solid transparent; background: transparent;
  color: var(--text-3); font-size: 13px; cursor: pointer;
  line-height: 1; transition: all 0.1s;
}
.bundle-fav-btn:hover { color: var(--gold); border-color: rgba(245,200,66,0.30); }
.bundle-fav-btn.active { color: var(--gold); }
.bundle-dl-btn {
  padding: 2px 8px; border-radius: var(--radius);
  border: 1px solid rgba(74,222,128,0.30); background: transparent;
  color: var(--green); font-family: var(--mono); font-size: 10px;
  cursor: pointer; transition: all 0.12s;
}
.bundle-dl-btn:hover { background: var(--green-dim); border-color: var(--green); }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 18px; right: 18px; padding: 8px 15px; border-radius: var(--radius); background: var(--raised); border: 1px solid var(--border); font-family: var(--mono); font-size: 11px; color: var(--text); opacity: 0; transform: translateY(6px); transition: all 0.18s; pointer-events: none; z-index: 200; }
.toast.show { opacity: 1; transform: none; }
.toast.ok  { border-color: var(--green); color: var(--green); }
.toast.err { border-color: var(--red);   color: var(--red); }


/* Snapshot dashboard */
.snapshot-dashboard {
  margin: 14px 16px 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(45,212,232,0.10), rgba(96,165,250,0.06) 48%, rgba(245,200,66,0.08));
}
.snapshot-kicker { font-family: var(--mono); font-size: 10px; color: var(--cyan); text-transform: uppercase; letter-spacing: 0.14em; }
.snapshot-title {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}
.diag-bar {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px; margin-bottom: 2px;
  font-family: var(--mono); font-size: 10px; color: var(--text-3);
}
.diag-label  { color: var(--text-2); font-weight: 600; }
.diag-path   { color: var(--cyan); }
.diag-dot    { width: 5px; height: 5px; border-radius: 50%; background: var(--red); flex-shrink: 0; }
.diag-dot.ok { background: var(--green); }
.diag-status { color: var(--text-3); }

.snapshot-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 9px; margin-top: 12px; }

.snapshot-ghost-row {
  display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px;
}
.snapshot-ghost {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 4px;
  border: 1px dashed var(--border); background: transparent;
  opacity: 0.45;
}
.ghost-title { font-family: var(--mono); font-size: 10px; color: var(--text-3); }
.ghost-label { font-family: var(--mono); font-size: 9px; color: var(--text-3);
  padding: 1px 5px; border-radius: 3px; background: var(--panel); }
.snapshot-card { min-height: 82px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: rgba(6,10,14,0.58); display: flex; flex-direction: column; gap: 7px; }
.snapshot-card.ok { border-color: rgba(74,222,128,0.35); }
.snapshot-card.warning { border-color: rgba(251,191,36,0.45); }
.snapshot-card.missing { opacity: 0.62; }
.snapshot-card b { font-family: var(--mono); font-size: 11px; color: var(--text); }
.snapshot-card span, .snapshot-empty { font-size: 11px; color: var(--text-3); }
.snapshot-card .file-debug { font-family: var(--mono); word-break: break-word; }
.snapshot-card button, .snapshot-download { display: inline-block; margin-right: 6px; padding: 4px 7px; border-radius: 5px; border: 1px solid var(--border2); background: transparent; color: var(--text-2); font-family: var(--mono); font-size: 10px; text-decoration: none; cursor: pointer; }
.snapshot-card button:hover, .snapshot-download:hover { border-color: var(--cyan); color: var(--cyan); }
.viewer-meta {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  display: flex; align-items: center; gap: 10px;
}
.vm-size { color: var(--text-2); font-weight: 600; }
.vm-mode {
  font-size: 9px; color: var(--cyan); text-transform: uppercase;
  letter-spacing: 0.08em; padding: 1px 6px;
  border: 1px solid var(--cyan-dim); border-radius: 3px;
  background: var(--cyan-dim);
}
@media (max-width: 1100px) { .snapshot-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); } }

/* ── JSON collapsible tree ───────────────────────────────────────────────────── */
.json-tree-wrap { flex: 1; overflow: auto; padding: 14px 18px; }

/* <details> / <summary> reset */
.json-tree details { margin: 0; }
.j-summary {
  list-style: none;
  cursor: pointer;
  color: var(--text-3);
  font-size: 11px;
  padding: 1px 0;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.j-summary::-webkit-details-marker { display: none; }
.j-summary::marker { content: ''; display: none; }
.j-summary::before { content: '▶'; font-size: 8px; opacity: 0.55; flex-shrink: 0; }
details[open] > .j-summary::before { content: '▼'; }
.j-summary:hover { color: var(--text-2); }

/* Indented children with a left border guide */
.j-children {
  padding-left: 16px;
  border-left: 1px solid var(--border);
  margin-left: 4px;
  margin-top: 1px;
  margin-bottom: 1px;
}

/* A single key: value row inside the tree */
.j-row {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  line-height: 1.75;
  gap: 0;
}

/* Array index prefix  ( 0: , 1: … ) */
.j-idx  { color: var(--text-3); flex-shrink: 0; margin-right: 2px; }

/* Empty object/array tokens  {} / [] */
.j-brace { color: var(--text-3); }

/* "… N more items" overflow indicator */
.j-more {
  color: var(--text-3);
  font-style: italic;
  font-size: 10px;
  padding: 2px 0;
  opacity: 0.75;
}

/* ── JSON large-file search toolbar ─────────────────────────────────────────── */
.json-search-toolbar {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.json-search-input {
  padding: 5px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  width: 240px;
  outline: none;
  transition: border-color 0.15s;
}
.json-search-input:focus { border-color: var(--cyan); }
.json-search-input::placeholder { color: var(--text-3); }

/* Shown when a filter is active */
.json-filter-info {
  padding: 5px 18px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--cyan);
  background: var(--cyan-dim);
  border-bottom: 1px solid rgba(45,212,232,0.20);
  flex-shrink: 0;
}

/* Container for paginated <pre> + pagination bar */
.json-paginated { flex: 1; overflow: auto; display: flex; flex-direction: column; min-height: 0; }

/* Plain-text (startup_text.txt) should wrap instead of scrolling infinitely */
.json-tree.plain-text { white-space: pre-wrap; word-break: break-word; }

/* ── Mobile responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Stack sidebar above main content */
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    min-height: calc(100vh - 34px);
  }

  /* Sidebar becomes a horizontal scrollable tab strip */
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    height: auto;
    overflow: hidden;
  }
  .sidebar-bf-link { display: none; } /* hide the big link buttons on mobile */
  .nav-tabs {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 4px 6px;
    gap: 2px;
    /* hide scrollbar on mobile for cleanliness */
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .nav-tabs::-webkit-scrollbar { display: none; }

  /* Compact tab buttons in a row */
  .tab-btn {
    flex-direction: column;
    align-items: center;
    min-width: 72px;
    max-width: 100px;
    padding: 5px 8px;
    gap: 2px;
    flex-shrink: 0;
  }
  .tab-hint { display: none; }
  .tab-name { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Active indicator moves to bottom on horizontal tabs */
  .tab-btn.active::before {
    top: auto;
    bottom: 0;
    left: 8px;
    right: 8px;
    width: auto;
    height: 2px;
    border-radius: 1px;
  }

  /* Main panel: let it grow naturally */
  .main { height: auto; min-height: 60vh; overflow: visible; }
  .panel-body { height: auto; min-height: 50vh; overflow: auto; }

  /* Panel header wraps on small screens */
  .panel-header { flex-wrap: wrap; gap: 6px; }
  .panel-actions { margin-left: 0; flex-wrap: wrap; gap: 5px; }

  /* Snapshot grid: two columns */
  .snapshot-grid { grid-template-columns: repeat(2, minmax(110px, 1fr)); }
  .snapshot-dashboard { margin: 8px 10px 0; }

  /* JSON search input: fill available width */
  .json-search-input { width: 100%; }
  .json-search-toolbar { flex-direction: column; align-items: stretch; }
}
