/* File Magic. Dark, dense, one amber accent. Fonts fall back to system faces; nothing is fetched from a CDN. */
:root {
  color-scheme: dark; /* dark scrollbars and form controls */
  --ground: #0e1116;
  --panel: #161b22;
  --raised: #1d242d;
  --line: #2a323d;
  --line-soft: #222a34;
  --line-strong: #4a5666;
  --text: #e6eaf0;
  --muted: #9aa6b5;
  --accent: #f0b429;
  --accent-ink: #1a1300;
  --link: #7db3ff;
  --selected: #22364d;
  --danger: #ff9b8a;
  --sans: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  --display: "Space Grotesk", "Segoe UI Semibold", var(--sans);
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--link); }
a:hover { color: #a9cdff; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.5; }

:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

h1 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 20px; }
p { margin: 0; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

.boot { min-height: 100vh; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.eyebrow {
  margin: 0;
  font-family: var(--display);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: #ffc94d; }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--text); font-weight: 500; }
.btn-ghost:hover:not(:disabled) { background: var(--raised); }
.btn-icon { width: 44px; padding: 0; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-align: left; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link:hover { text-decoration-thickness: 2px; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.segmented button { min-height: 44px; padding: 0 16px; border: 0; background: transparent; color: var(--muted); }
.segmented button:hover:not(:disabled) { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--line); color: var(--text); font-weight: 600; }

/* Top bar */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
}
.brand-icon { display: inline-flex; color: var(--accent); }

.stack { flex: 1 1 320px; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-family: var(--mono); font-size: 13px; }
.stack-item { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; max-width: 100%; padding: 0; border: 0; background: transparent; }
.stack-link { color: var(--link); }
.stack-link:hover { color: #a9cdff; }
.stack-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 32ch; }
.stack-sep { color: var(--muted); }
.stack-ahead { opacity: 0.55; }
.stack-ahead:hover { opacity: 1; }
.nav-buttons { display: inline-flex; gap: 6px; }

.tag { padding: 3px 8px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--text); white-space: nowrap; }
.tag-current { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }

.file-button { position: relative; cursor: pointer; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-button:focus-within { outline: 2px solid var(--link); outline-offset: 2px; }

/* Landing */
.landing { width: 100%; max-width: 1120px; margin: 0 auto; padding: 48px 24px; display: flex; flex-direction: column; gap: 20px; }
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 56px 24px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
}
.dropzone:hover, .dropzone:focus-within { border-color: var(--accent); }
.dropzone h1 { font-size: 34px; letter-spacing: -0.01em; color: var(--text); }
.dropzone .lead { max-width: 520px; font-size: 15px; }
.dropzone-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

/* Covers the page while files are dragged over it (filemagic.js sets "dragging"); its input takes the drop. */
.drop-overlay { display: none; position: fixed; inset: 0; z-index: 900; align-items: center; justify-content: center; padding: 24px; background: rgb(14 17 22 / 0.85); }
.dragging .drop-overlay { display: flex; }
.drop-overlay-card { display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(560px, 100%); padding: 56px 24px; border: 2px dashed var(--accent); border-radius: 16px; background: var(--panel); color: var(--accent); pointer-events: none; }
.drop-overlay-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }

.cards { display: flex; flex-wrap: wrap; gap: 16px; }
/* Type cards keep one width, so a short last row does not stretch. */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card { flex: 1 1 220px; display: flex; flex-direction: column; gap: 8px; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.card-types { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.card-title { font-family: var(--display); font-weight: 600; font-size: 18px; }

.progress-card { display: flex; flex-direction: column; gap: 12px; padding: 28px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
progress { width: 100%; height: 8px; accent-color: var(--accent); }

.alert { padding: 10px 14px; border: 1px solid #7a3b32; border-radius: 6px; background: #2a1815; color: var(--danger); }
.alert-bar { margin: 12px 20px 0; }
.note { padding: 10px 14px; border: 1px solid #5c4a1a; border-radius: 6px; background: #231c0c; color: #f3d48a; font-size: 13px; }

/* Split layout: panes side by side, stacking on narrow screens */
.split { flex: 1; display: flex; flex-wrap: wrap; align-items: stretch; min-height: 0; }
.pane { box-sizing: border-box; max-width: 100%; padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.pane-left { flex: 1 1 280px; border-right: 1px solid var(--line); }
.pane-tree { flex: 1 1 240px; border-right: 1px solid var(--line); gap: 10px; }
.pane-right { flex: 1 1 280px; border-left: 1px solid var(--line); background: var(--panel); }
.pane-main { flex: 999 1 520px; min-width: 0; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.pane-title { font-family: var(--display); font-weight: 600; font-size: 22px; overflow-wrap: anywhere; }
.selected-name { font-family: var(--mono); font-size: 15px; overflow-wrap: anywhere; }

.fields { display: flex; flex-direction: column; gap: 8px; }
dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; font-size: 13px; }
dt { color: var(--muted); }
dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }

.empty { margin: auto; max-width: 520px; padding: 48px 24px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

/* Preview */
.preview-head, .list-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.preview-head h1, .list-head h1 { flex: 1 1 auto; min-width: 0; }
.preview {
  flex: 1;
  min-height: 420px;
  max-height: calc(100vh - 170px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}
.preview-dark { background: #05070a; }
.checker {
  background-color: var(--raised);
  background-image: conic-gradient(#252e39 25%, transparent 0 50%, #252e39 0 75%, transparent 0);
  background-size: 24px 24px;
}
.img-fit { max-width: 100%; max-height: 100%; object-fit: contain; }
.img-actual { max-width: none; margin: auto; image-rendering: pixelated; }
.preview video { max-width: 100%; max-height: 100%; }
.preview audio { width: min(100%, 520px); }

/* Text preview: shown as text, never rendered */
.text-view {
  flex: 1;
  min-height: 420px;
  max-height: calc(100vh - 210px);
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  tab-size: 4;
}
.text-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Tables: virtualised rows of fixed height */
.path { font-family: var(--mono); font-weight: 500; font-size: 15px; overflow-wrap: anywhere; }
.filter { display: inline-flex; align-items: center; gap: 8px; }
.filter input, .filter select { min-height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--ground); }

/* The table is the one scroller, both ways, so the header and the rows scroll sideways together; the header stays on top. */
.table { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow: auto; max-height: calc(100vh - 252px); }
.table-head, .row { display: grid; gap: 12px; align-items: center; min-width: 560px; padding: 0 16px; }
.table-head { position: sticky; top: 0; z-index: 1; background: var(--panel); min-height: 38px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
.table-body { min-height: 200px; min-width: 560px; }
.row { width: 100%; height: 40px; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; text-align: left; font-size: 13px; }
.row:hover { background: var(--raised); }
.row[aria-pressed="true"] { background: var(--selected); }
.row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cols-container { grid-template-columns: minmax(0, 1fr) 110px 90px 90px 130px; }
.cols-files { grid-template-columns: minmax(0, 1fr) 160px 90px 130px; }
.cols-scan { grid-template-columns: 120px minmax(0, 1.4fr) minmax(0, 1fr) 190px; }
.num { text-align: right; font-family: var(--mono); color: var(--muted); }
.cell-name { font-family: var(--mono); }
.cell-folder { color: var(--link); }
.cell-info { color: var(--muted); }
.cell-detected { color: var(--accent); font-weight: 500; }

/* Folder tree */
.tree { overflow: auto; max-height: calc(100vh - 160px); }
.tree-row { display: flex; align-items: center; }
.tree-toggle { flex: none; width: 28px; height: 36px; border: 0; background: transparent; color: var(--muted); }
.tree-name { flex: 1; min-width: 0; height: 36px; padding: 0 8px; border: 0; border-radius: 4px; background: transparent; text-align: left; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-name:hover { background: var(--raised); }
.tree-name[aria-current="true"] { background: var(--selected); font-weight: 600; }
.tree-note { color: var(--danger); font-size: 12px; }

/* Scan map */
.map { position: relative; height: 56px; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow: hidden; }
.map-mark { position: absolute; top: 6px; bottom: 6px; width: 6px; margin-left: -3px; padding: 0; border: 0; border-radius: 3px; background: #8a6a1f; }
.map-mark:hover { background: #b88a22; }
.map-mark[aria-pressed="true"] { background: var(--accent); outline: 2px solid var(--text); z-index: 1; }
.map-scale { display: flex; justify-content: space-between; margin-top: 6px; }

/* Database */
.db-list { max-height: 40vh; }
.db-details { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 10px 14px; font-size: 13px; }
.db-details summary { cursor: pointer; color: var(--muted); }
.db-details[open] summary { margin-bottom: 10px; }
.db-actions { justify-content: flex-start; align-items: center; }
.sql { margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--ground); font-family: var(--mono); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.cell-null { color: var(--muted); font-style: italic; }
.db-value { white-space: pre-wrap; max-height: 40vh; overflow-y: auto; }

/* Hex */
.hex { margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-family: var(--mono); font-size: 13px; line-height: 1.6; overflow-x: auto; }

/* Blazor's unhandled-error bar */
#blazor-error-ui { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; padding: 12px 20px; background: #2a1815; border-top: 1px solid #7a3b32; color: var(--danger); }
#blazor-error-ui .dismiss { position: absolute; right: 16px; top: 10px; cursor: pointer; }
