/*
  Design tokens
  -------------
  Palette (named):
    --ink        #12141c   base background, deep graphite-blue (not pure black)
    --panel      #1a1d29   card / panel surface
    --panel-2    #20242f   nested surface (table rows, inputs)
    --line       #2a2f3f   hairline borders
    --text       #d9dce6   primary text
    --dim        #7c8296   secondary / caption text
    --amber      #e8a33d   primary accent (terminal-phosphor signal)
    --amber-dim  #8a6a34   amber at low emphasis (borders, idle glyphs)
    --teal       #5fb3b3   info severity
    --red        #e0525f   high severity
    --green      #6fbf73   good / pass state
  Type:
    display/utility/data face: 'JetBrains Mono' — this is a byte-level
    inspection tool, so monospace is the *correct* register for the data,
    not a stylistic default.
    UI chrome face: 'Inter' — for nav, buttons, prose, so dense hex/mono
    text doesn't fight for attention with interface labels.
*/

:root {
  --ink: #12141c;
  --panel: #1a1d29;
  --panel-2: #20242f;
  --line: #2a2f3f;
  --text: #d9dce6;
  --dim: #7c8296;
  --amber: #e8a33d;
  --amber-dim: #8a6a34;
  --teal: #5fb3b3;
  --red: #e0525f;
  --green: #6fbf73;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

::selection { background: var(--amber); color: var(--ink); }

button, a { font-family: inherit; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(18, 20, 28, 0.92);
  backdrop-filter: blur(6px);
  z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark {
  font-family: var(--mono);
  color: var(--amber);
  font-weight: 700;
  font-size: 13px;
  border: 1px solid var(--amber-dim);
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.02em;
}
.brand-name {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.brand-sub { color: var(--dim); font-size: 12.5px; }
.topbar-actions { display: flex; gap: 8px; }

.btn {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.btn:hover { border-color: var(--amber-dim); background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn-primary { background: var(--amber); color: #241a06; border-color: var(--amber); }
.btn-primary:hover { background: #f0b054; }
.btn-block { width: 100%; justify-content: center; }
.btn-ghost {}

/* ---------- hero hex strip (signature element) ---------- */
.hexhero {
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(232,163,61,0.04), transparent 60%),
    var(--ink);
  padding: 18px 24px 12px;
}
.hexhero-inner {
  font-family: var(--mono);
  font-size: 12.5px;
  overflow-x: auto;
  white-space: nowrap;
  padding-bottom: 2px;
}
.hexhero-row { display: flex; gap: 3px; margin-bottom: 2px; }
.hexhero-row .cell {
  display: inline-block;
  width: 22px;
  text-align: center;
  color: var(--dim);
}
#hexRowOffsets .cell { color: var(--amber-dim); font-size: 10.5px; }
#hexRowBytes .cell { color: var(--text); }
#hexRowBytes .cell.sig { color: var(--amber); font-weight: 700; }
#hexRowBytes .cell.zero { color: #3a3f4f; }
#hexRowAscii .cell { color: var(--dim); }
#hexRowAscii .cell.sig { color: var(--amber); }
.hexhero-caption { color: var(--dim); font-size: 12px; margin-top: 6px; }

/* idle animation before a file is loaded */
.hexhero.idle #hexRowBytes .cell { animation: flicker 3.2s ease-in-out infinite; }
.hexhero.idle #hexRowBytes .cell:nth-child(3n) { animation-delay: 0.4s; }
.hexhero.idle #hexRowBytes .cell:nth-child(5n) { animation-delay: 0.9s; }
@keyframes flicker { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.7; } }

/* ---------- layout shell ---------- */
#app { max-width: 1320px; margin: 0 auto; padding: 28px 24px 60px; }

.hidden { display: none !important; }

/* ---------- dropzone (empty state) ---------- */
.dropzone {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 72px 24px;
  text-align: center;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.dropzone.dragover { border-color: var(--amber); background: rgba(232,163,61,0.05); }
.dropzone-glyph {
  font-family: var(--mono);
  font-size: 42px;
  font-weight: 700;
  color: var(--amber-dim);
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.dropzone-title { font-size: 17px; font-weight: 600; margin: 0 0 6px; }
.dropzone-sub { color: var(--dim); font-size: 13.5px; margin: 0 0 22px; max-width: 460px; margin-left: auto; margin-right: auto; }

/* ---------- workspace ---------- */
.workspace { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }

.rail { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 88px; }
.rail-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}
.rail-card-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); margin-bottom: 10px; font-weight: 600; }
.rail-filename { font-family: var(--mono); font-weight: 600; font-size: 13.5px; word-break: break-all; margin-bottom: 6px; }
.rail-meta { color: var(--dim); font-size: 12px; margin-bottom: 12px; }
.rail-hashes { display: flex; flex-direction: column; gap: 6px; }
.hash-row { display: flex; flex-direction: column; gap: 2px; }
.hash-label { font-size: 10.5px; text-transform: uppercase; color: var(--dim); letter-spacing: 0.05em; }
.hash-value {
  font-family: var(--mono);
  font-size: 11px;
  word-break: break-all;
  background: var(--panel-2);
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
}
.hash-value:hover { border-color: var(--amber-dim); }

.severity-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 100px;
  font-weight: 600;
  border: 1px solid transparent;
}
.chip-high { background: rgba(224,82,95,0.15); color: var(--red); border-color: rgba(224,82,95,0.35); }
.chip-warn { background: rgba(232,163,61,0.15); color: var(--amber); border-color: rgba(232,163,61,0.35); }
.chip-info { background: rgba(95,179,179,0.15); color: var(--teal); border-color: rgba(95,179,179,0.35); }

.entropy-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 11px; }
.entropy-bar-label { font-family: var(--mono); width: 62px; flex-shrink: 0; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entropy-bar-track { flex: 1; height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.entropy-bar-fill { height: 100%; background: var(--teal); }
.entropy-bar-fill.hot { background: var(--red); }
.entropy-bar-val { font-family: var(--mono); width: 32px; text-align: right; color: var(--dim); flex-shrink: 0; }

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
}
.tab {
  background: none;
  border: none;
  color: var(--dim);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 13px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--amber); border-bottom-color: var(--amber); }
.tab:focus-visible { outline: 2px solid var(--amber); outline-offset: -2px; }

.pane { display: none; }
.pane.active { display: block; animation: fadein 0.15s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ---------- data display primitives ---------- */
.grid-kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 20px; }
.kv-item { background: var(--panel); padding: 12px 14px; }
.kv-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dim); margin-bottom: 4px; }
.kv-value { font-family: var(--mono); font-size: 13px; word-break: break-word; }
.kv-value.good { color: var(--green); }
.kv-value.bad { color: var(--red); }

.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); font-weight: 700; margin: 26px 0 10px; }
.section-title:first-child { margin-top: 0; }

table.datatable { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 8px; }
table.datatable th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--dim); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--ink);
}
table.datatable td { padding: 7px 10px; border-bottom: 1px solid var(--line); font-family: var(--mono); vertical-align: top; }
table.datatable tr:hover td { background: var(--panel); }
table.datatable .mono-dim { color: var(--dim); }

.badge { font-family: var(--mono); font-size: 10.5px; padding: 2px 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--dim); display: inline-block; }
.badge-url { color: var(--teal); border-color: rgba(95,179,179,0.4); }
.badge-ip { color: var(--teal); border-color: rgba(95,179,179,0.4); }
.badge-dll { color: var(--dim); }
.badge-exe-ref { color: var(--amber); border-color: var(--amber-dim); }
.badge-registry { color: var(--amber); border-color: var(--amber-dim); }
.badge-suspicious-exec { color: var(--red); border-color: rgba(224,82,95,0.5); }

.indicator-row { display: flex; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: var(--panel); align-items: flex-start; }
.indicator-sev { font-family: var(--mono); font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 3px 7px; border-radius: 4px; flex-shrink: 0; margin-top: 1px; }
.indicator-sev.high { background: rgba(224,82,95,0.18); color: var(--red); }
.indicator-sev.warn { background: rgba(232,163,61,0.18); color: var(--amber); }
.indicator-sev.info { background: rgba(95,179,179,0.18); color: var(--teal); }
.indicator-msg { font-size: 13px; }

.search-box {
  width: 100%; max-width: 340px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  color: var(--text); font-family: var(--mono); font-size: 12.5px; padding: 8px 10px; margin-bottom: 14px;
}
.search-box:focus { outline: none; border-color: var(--amber-dim); }

.empty-note { color: var(--dim); font-size: 13px; padding: 20px 0; }

pre.rawjson {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px;
  font-family: var(--mono); font-size: 11.5px; overflow-x: auto; max-height: 70vh; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
}

.error-banner {
  margin-top: 20px; padding: 14px 16px; background: rgba(224,82,95,0.1); border: 1px solid rgba(224,82,95,0.4);
  border-radius: 8px; color: var(--red); font-family: var(--mono); font-size: 13px;
}

.footer { text-align: center; color: var(--dim); font-size: 11.5px; padding: 20px 24px 40px; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; }
  .rail { position: static; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .brand-sub { display: none; }
}
