:root {
  --bg-outer: #0e0905;
  --bg-panel: #1a120a;
  --bg-inset: #221710;
  --bg-input: #150e08;
  --border-frame-dark: #3d2810;
  --border-frame-light: #5a3a18;
  --hairline: #3a2a18;
  --hairline-strong: #5a4a30;
  --accent: #c9a050;
  --fg-primary: #e8c068;
  --fg-secondary: #a08850;
  --fg-muted: #7a6840;
  --fg-dim: #5a4a30;

  --sev-error: #c25450;
  --sev-warning: #d49a3a;
  --sev-display: #9aa478;
  --sev-verbose: #6a5a40;
  --sev-fatal: #a03028;
  --sev-log: #9aa478;
  --sev-very-verbose: #5a4a30;

  --hover-tint: rgba(201, 160, 80, 0.06);
  --active-tint: rgba(201, 160, 80, 0.14);
  --focus-ring: rgba(201, 160, 80, 0.25);

  --font-head: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;

  --radius: 4px;
  --row-h: 24px;
  --row-h-expanded: 110px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-outer);
  color: var(--fg-primary);
  font-family: var(--font-mono);
  font-size: 13px;
}

body {
  min-height: 100vh;
  background-image: radial-gradient(circle at 50% 0%, rgba(201,160,80,0.04), transparent 60%);
  padding: 32px 24px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.panel {
  max-width: 1400px;
  margin: 0 auto;
  background: var(--bg-panel);
  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(0,0,0,0) 0px,
      rgba(0,0,0,0) 2px,
      rgba(0,0,0,0.04) 2px,
      rgba(0,0,0,0.04) 3px
    );
  border: 1px solid var(--border-frame-light);
  outline: 1px solid var(--border-frame-dark);
  outline-offset: 4px;
  box-shadow:
    inset 0 0 0 1px rgba(201,160,80,0.05),
    0 0 60px rgba(201,160,80,0.05);
  border-radius: 6px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--hairline);
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.18em;
  color: var(--fg-primary);
  text-transform: uppercase;
}

.brand h1 em {
  color: var(--fg-secondary);
  font-style: normal;
  font-weight: 500;
}

.compass {
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
}

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

.file-meta .file-name {
  color: var(--fg-primary);
}

input[type='datetime-local'],
input[type='search'],
.search-field {
  background: var(--bg-input);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--fg-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  height: 32px;
  padding: 0 12px;
  box-shadow: inset 0 1px 0 rgba(0,0,0,0.4);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input::placeholder { color: var(--fg-dim); }

input[type='datetime-local']:focus,
input[type='search']:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(0,0,0,0.4),
    inset 0 0 0 1px var(--focus-ring);
}

.search-field {
  flex: 1 1 220px;
  display: inline-flex;
  align-items: center;
  padding: 0;
}
.search-field input { border: none; box-shadow: none; background: transparent; flex: 1; }
.search-field input:focus { box-shadow: none; }
.search-field:focus-within {
  border-color: var(--accent);
  box-shadow:
    inset 0 1px 0 rgba(0,0,0,0.4),
    inset 0 0 0 1px var(--focus-ring);
}

.search-spinner {
  width: 12px;
  height: 12px;
  margin: 0 10px 0 6px;
  border: 2px solid var(--hairline);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: search-spin 700ms linear infinite;
  flex-shrink: 0;
}
.search-spinner[hidden] { display: none; }
@keyframes search-spin {
  to { transform: rotate(360deg); }
}

.btn-pill {
  height: 32px;
  padding: 0 16px;
  background: var(--bg-input);
  color: var(--fg-primary);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-family: var(--font-head);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 120ms ease;
}
.btn-pill:hover { background: var(--hover-tint); }
.btn-pill:active { background: var(--active-tint); }

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check-box {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--bg-input);
  position: relative;
  transition: border-color 120ms ease, background 120ms ease;
}
.check-box::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transition: opacity 120ms ease;
}
.check input:checked + .check-box::after { opacity: 1; }
.check input:checked + .check-box { border-color: var(--accent); }
.check:hover .check-box { background: var(--hover-tint); }
.check-label {
  font-family: var(--font-head);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-secondary);
}

.log-pane {
  position: relative;
  background: var(--bg-panel);
  min-height: 60vh;
  max-height: calc(100vh - 320px);
  overflow: hidden;
}

.log-empty,
.histogram-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  color: var(--fg-secondary);
  font-style: italic;
  font-size: 12px;
  padding: 12px;
  text-align: center;
}
.log-empty[hidden],
.histogram-empty[hidden] { display: none; }

.log-empty .jump-link {
  display: inline-block;
  margin-top: 6px;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  color: var(--fg-primary);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-family: var(--font-head);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
}
.log-empty .jump-link:hover { background: var(--hover-tint); }

.log-viewport {
  position: relative;
  height: calc(100vh - 320px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-color: var(--hairline-strong) transparent;
}

.log-spacer { width: 1px; }

.log-rows {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.log-row {
  position: absolute;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 16px 110px 56px 1fr;
  align-items: start;
  gap: 12px;
  padding: 4px 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 16px;
  color: var(--fg-primary);
  cursor: pointer;
  pointer-events: auto;
  border-bottom: 1px solid transparent;
  outline: none;
}
.log-row:focus-visible { box-shadow: inset 0 0 0 1px var(--accent); }
.log-row:hover { background: var(--hover-tint); }
.log-row.sev-error    { background: rgba(194, 84, 80, 0.04); }
.log-row.sev-warning  { background: rgba(212, 154, 58, 0.04); }
.log-row.sev-fatal    { background: rgba(160, 48, 40, 0.06); }

.log-row .chev {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-secondary);
  transition: transform 120ms ease;
  font-size: 12px;
}
.log-row.expanded .chev { transform: rotate(90deg); }

.log-row .ts {
  color: var(--fg-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-row .sev {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--fg-secondary);
  white-space: nowrap;
}
.log-row .sev .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot, var(--fg-secondary));
}
.log-row.sev-error    .sev { color: var(--sev-error); }
.log-row.sev-warning  .sev { color: var(--sev-warning); }
.log-row.sev-display  .sev { color: var(--sev-display); }
.log-row.sev-verbose  .sev { color: var(--sev-verbose); }
.log-row.sev-fatal    .sev { color: var(--sev-fatal); }
.log-row.sev-log      .sev { color: var(--sev-log); }
.log-row.sev-veryverbose .sev { color: var(--sev-very-verbose); }

.log-row .body {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-row .cat {
  font-family: var(--font-head);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-right: 6px;
}

.log-row .extra {
  display: none;
  grid-column: 2 / -1;
  margin-top: 4px;
  font-size: 12px;
}
.log-row.expanded .extra { display: block; }
.log-row .extra .raw {
  color: var(--fg-secondary);
  opacity: 0.55;
  font-style: italic;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-row mark.match {
  background: rgba(201, 160, 80, 0.32);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.tok-guid { color: #5a8a8a; }
.tok-string { color: #dcc89a; }
.tok-number { color: #b07050; }
.tok-url { color: #9aa478; }

/* Header strip layout */
.panel-head {
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
}

.head-stats {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-head);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-secondary);
  display: inline-flex;
  flex-wrap: wrap;
  gap: 14px;
}
.head-stats .stat strong {
  font-family: var(--font-mono);
  color: var(--fg-primary);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  margin-left: 6px;
}
.head-stats .stat + .stat::before {
  content: '·';
  color: var(--fg-dim);
  margin-right: 14px;
  margin-left: -8px;
}

.head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Dropdown trigger pill */
.trigger {
  height: 32px;
  padding: 0 12px;
  background: var(--bg-input);
  color: var(--fg-primary);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  transition: background 120ms ease, border-color 120ms ease;
  max-width: 320px;
}
.trigger:hover { background: var(--hover-tint); }
.trigger[aria-expanded='true'] { border-color: var(--accent); background: var(--hover-tint); }
.trigger .trigger-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.trigger .trigger-icon { color: var(--fg-secondary); }
.trigger .caret { color: var(--fg-secondary); font-size: 10px; }

/* Manual reload icon button */
.icon-btn {
  width: 32px;
  height: 32px;
  background: var(--bg-input);
  color: var(--fg-primary);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: background 120ms ease, border-color 120ms ease;
}
.icon-btn:hover { background: var(--hover-tint); border-color: var(--accent); }

/* Auto-refresh toggle pill */
.toggle-pill {
  height: 32px;
  padding: 0 12px;
  background: var(--bg-input);
  color: var(--fg-primary);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-head);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: background 120ms ease, border-color 120ms ease;
}
.toggle-pill:hover { background: var(--hover-tint); }
.toggle-pill[aria-pressed='true'] { border-color: var(--accent); }
.toggle-pill .toggle-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: transparent;
}
.toggle-pill[aria-pressed='true'] .toggle-dot { background: var(--accent); }

/* Filter strip */
.filter-strip {
  padding: 10px 18px;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  background: var(--bg-inset);
  display: flex;
  align-items: center;
  gap: 12px;
}
.filter-strip .search-field { flex: 1 1 auto; }

/* Popover shell (used by both time + severity dropdowns) */
.popover {
  position: absolute;
  z-index: 50;
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  border-radius: var(--radius);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg-primary);
}
.popover[hidden] { display: none; }
.popover h2 {
  margin: 0 0 8px;
  font-family: var(--font-head);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-secondary);
}

/* Time-range popover */
#time-popover { width: 520px; }
.popover-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.popover-absolute .abs-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--fg-secondary);
}
.popover-absolute .abs-field input {
  background: var(--bg-input);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--fg-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  height: 32px;
  padding: 0 10px;
  box-shadow: inset 0 1px 0 rgba(0,0,0,0.4);
}
.popover-absolute .abs-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(0,0,0,0.4), inset 0 0 0 1px var(--focus-ring);
}
.popover-absolute .abs-hint {
  margin: 12px 0 0;
  font-size: 11px;
  color: var(--fg-muted);
}
.popover-presets ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.popover-presets li {
  padding: 6px 8px;
  cursor: pointer;
  border-radius: var(--radius);
  color: var(--fg-primary);
}
.popover-presets li:hover,
.popover-presets li[aria-current='true'] {
  background: var(--hover-tint);
  color: var(--fg-primary);
}

/* Severity multiselect popover */
#severity-popover { width: 280px; }
#severity-list { list-style: none; margin: 0; padding: 0; }
#severity-list li {
  display: grid;
  grid-template-columns: 16px 12px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  cursor: pointer;
  border-radius: var(--radius);
}
#severity-list li:hover { background: var(--hover-tint); }
#severity-list .checkbox {
  width: 14px;
  height: 14px;
  border: 1px solid var(--hairline);
  background: var(--bg-input);
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#severity-list li[aria-checked='true'] .checkbox {
  border-color: var(--accent);
  background: var(--accent);
}
#severity-list li[aria-checked='true'] .checkbox::after {
  content: '';
  width: 6px; height: 6px; background: var(--bg-panel); border-radius: 1px;
}
#severity-list .sev-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--dot-color, var(--fg-secondary));
}
#severity-list .sev-name { color: var(--fg-primary); font-family: var(--font-head); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; }
#severity-list .sev-count { color: var(--fg-secondary); font-variant-numeric: tabular-nums; }

.popover-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  border-top: 1px solid var(--hairline);
  padding-top: 10px;
}
.popover-btn {
  flex: 1;
  height: 28px;
  background: var(--bg-input);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--fg-secondary);
  font-family: var(--font-head);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
}
.popover-btn:hover { background: var(--hover-tint); border-color: var(--accent); color: var(--fg-primary); }
.popover-btn.no-flex {
  flex: none;
  padding: 0 12px;
}

/* Off-screen measurement host for variable-height row heights */
.measure-host {
  position: absolute;
  left: -10000px;
  top: 0;
  width: 1200px;
  visibility: hidden;
  pointer-events: none;
}

/* Histogram pane */
.histogram-pane {
  position: relative;
  height: 96px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--hairline);
  user-select: none;
}
.histogram-svg {
  width: 100%;
  height: 100%;
  display: block;
}
.histogram-svg .bar-error    { fill: var(--sev-error); }
.histogram-svg .bar-warning  { fill: var(--sev-warning); }
.histogram-svg .bar-display  { fill: var(--sev-display); }
.histogram-svg .bar-verbose  { fill: var(--sev-verbose); }
.histogram-svg .axis-label,
.histogram-svg .y-label {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--fg-secondary);
}
.histogram-svg .selection-rect {
  fill: rgba(201, 160, 80, 0.15);
  stroke: rgba(201, 160, 80, 0.6);
  stroke-width: 1;
}

.histogram-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  padding: 6px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--fg-primary);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  border-radius: var(--radius);
  white-space: nowrap;
  z-index: 60;
}
.histogram-tooltip[hidden] { display: none; }
.histogram-tooltip .row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
.histogram-tooltip .row .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--dot-color, var(--fg-secondary));
}
.histogram-tooltip .row .name {
  flex: 1;
  text-align: left;
  color: var(--fg-secondary);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.14em;
}
.histogram-tooltip .row .count { color: var(--fg-primary); }
.histogram-tooltip .header { color: var(--fg-secondary); margin-bottom: 4px; }
