:root {
  --bg: #000000;
  --card: #0d0d0d;
  --card-hover: #131313;
  --border: #2a2a2a;
  --text: #ffffff;
  --text-muted: #999999;
  --accent: #cbff33;
  --accent-hover: #b8ea23;
  --accent-text: #000000;
  --danger: #ff4d4d;
  --danger-bg: #2a1414;
  --ok: #cbff33;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

h1, h2, .btn-primary, .btn-secondary {
  font-family: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
}

header {
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.crumbs {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.crumbs a { color: var(--text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs span { margin: 0 6px; }
.crumbs-current { color: var(--text); font-weight: 600; }

header h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
header h1::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 2px;
  margin-right: 10px;
}
.subtitle { margin: 4px 0 0 20px; color: var(--text-muted); font-size: 13px; }

.brand-tag {
  margin: 6px 0 0 20px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

main {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 24px;
}

.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 18px;
  /* stretch makes the shorter column visually match the taller one --
     NOT the same thing as clipping either one to a fixed height. Since
     neither the row nor any ancestor (main/body) is height-locked to the
     viewport anymore, the row itself sizes to whichever column actually
     needs more room (normal CSS Grid auto-sizing), so .left-col's full
     content (API key, dropzone, ECU info, all 3 checkboxes, both
     buttons, the hint text) always renders in full -- it can only grow
     the row, never get clipped by it. An earlier version locked
     body/main/.layout to the viewport height specifically so #rows
     below could scroll internally instead of growing the page -- but
     that same lock also capped .left-col to that height, and once its
     content grew past it (adding the ECU card + extra checkboxes over
     time), the overflow spilled out past the card's own background/
     border instead of the card growing. #rows gets its own bounded
     max-height instead (below), decoupled from .left-col entirely, so
     both goals hold: .left-col always shows everything, #rows still
     caps and scrolls once there are many map rows. */
  align-items: stretch;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.left-col, .right-col {
  display: flex;
  flex-direction: column;
}

.left-col .spacer { flex: 1 1 auto; }

/* used to be scoped ".right-col #rows.rows-scroll" -- #rows now lives in
   the Relocate Maps modal instead of the right column (see the console
   panel below), so this is unscoped to just the id+class */
#rows.rows-scroll {
  max-height: 560px;
  overflow-y: auto;
  padding-right: 4px;
}

.console-log {
  flex: 1 1 auto;
  min-height: 200px;
  max-height: 720px;
  overflow-y: auto;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: "Consolas", "Space Grotesk", monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--accent);
  white-space: pre-wrap;
  word-break: break-word;
}
.console-log:empty::before {
  content: "Nothing yet -- output from Process runs (and any relocated map details) will appear here.";
  color: var(--text-muted);
  font-style: italic;
}
.console-log .log-error { color: var(--danger); }
.console-log .log-muted { color: var(--text-muted); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.header-btns { display: flex; gap: 8px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 16px;
}

.field span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="file"] {
  background: #000;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
}
.field input[type="text"]:focus,
.field input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}
.checkbox-field input { accent-color: var(--accent); flex: 0 0 auto; }

.ecu-info {
  background: var(--accent);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 20px;
}
.ecu-info.hidden { display: none; }
.ecu-info-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent-text);
  margin-bottom: 12px;
}
.ecu-info-rows {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 16px;
}
.ecu-info-rows dt {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-text);
  grid-column: 1;
}
.ecu-info-rows dd {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.7);
  margin: 0;
  grid-column: 2;
  font-family: "Space Grotesk", monospace;
}
.ecu-info-rows dd.not-found {
  color: rgba(0, 0, 0, 0.4);
  font-style: italic;
  font-family: inherit;
}

.dropzone {
  position: relative;
  overflow: hidden; /* clips the flare sweep to the box */
  width: 100%;
  aspect-ratio: 1 / 1; /* height == width */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  background: #000;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover { border-color: #4d4d4d; }
.dropzone.dragover { border-color: var(--accent); background: #0f1400; }
.dropzone.has-file { border-style: solid; border-color: var(--accent); }

.dropzone.disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.dropzone.disabled:hover { border-color: var(--border); }
.dropzone.disabled::after,
.dropzone.disabled .dropzone-icon-idle {
  animation: none; /* nothing to draw attention to until it's actually usable */
}

/* periodic light flare -- a soft diagonal highlight that sweeps across
   the box once every 10s. The sweep itself only occupies the first ~9%
   of the animation's timeline; the rest holds it off-screen, so a single
   linear/infinite keyframe animation produces a "flash every 10 seconds"
   effect with no JS timer needed. */
.dropzone::after {
  content: "";
  position: absolute;
  top: -60%;
  left: 0;
  width: 35%;
  height: 220%;
  background: linear-gradient(100deg, transparent, rgba(203, 255, 51, 0.35), transparent);
  transform: translateX(-250%) skewX(-20deg);
  animation: dz-flare 10s linear infinite;
  pointer-events: none;
}
@keyframes dz-flare {
  0%   { transform: translateX(-250%) skewX(-20deg); }
  9%   { transform: translateX(350%) skewX(-20deg); }
  100% { transform: translateX(350%) skewX(-20deg); }
}

.dropzone-icon {
  width: 30%;
  max-width: 64px;
  color: var(--text-muted);
  transition: color 0.2s;
}
.dropzone-icon-loaded { display: none; }
.dropzone.has-file .dropzone-icon-idle { display: none; }
.dropzone.has-file .dropzone-icon-loaded { display: block; color: var(--accent); }
.dropzone:hover .dropzone-icon-idle,
.dropzone.dragover .dropzone-icon-idle { color: var(--accent); }

/* gentle idle breathing so the box doesn't feel static before a file is
   picked -- stops once has-file swaps in the checkmark icon, since a
   "done" state shouldn't keep pulsing */
.dropzone-icon-idle { animation: dz-icon-pulse 2.6s ease-in-out infinite; }
@keyframes dz-icon-pulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

.dropzone-text { font-size: 13px; color: var(--text-muted); }
.dropzone-text strong { color: var(--text); }

.dropzone-file {
  font-size: 13px;
  color: var(--accent);
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .dropzone::after { animation: none; display: none; }
  .dropzone-icon-idle { animation: none; }
}

.row-wrap { margin-bottom: 16px; }

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: #050505;
}

.row > div {
  flex: 1 1 130px;
  min-width: 110px;
}

.row > div:first-child { flex-basis: 160px; }

.row input, .row select {
  background: #000;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
}
.row input:focus, .row select:focus { outline: none; border-color: var(--accent); }

.row .btn-remove { flex: 0 0 auto; }

.row-status {
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 4px 0;
  min-height: 16px;
}
.row-status.ok { color: var(--ok); font-weight: 600; }
.row-status.error { color: var(--danger); }

.row .col-label {
  font-size: 10px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  padding: 10px 16px;
  font-weight: 700;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  width: 100%;
  padding: 14px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-size: 15px;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-download { margin-top: 8px; }
.btn-download:disabled { background: var(--border); color: var(--text-muted); opacity: 1; }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-remove {
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 11px;
  padding: 6px 10px;
  text-transform: uppercase;
}
.btn-remove:hover { background: #3a1a1a; }

.hint {
  color: var(--text-muted);
  font-size: 12px;
  margin: 8px 0 0;
}

#status {
  margin-top: 10px;
  font-size: 13px;
  white-space: pre-wrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

#status.ok { color: var(--ok); font-weight: 600; }
#status.error { color: var(--danger); }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
}
.overlay.hidden { display: none; }

.big-spinner {
  width: 100px;
  height: 100px;
  position: relative;
}

.ring {
  position: absolute;
  border-radius: 50%;
  border: 3px solid transparent;
}

.ring-outer {
  inset: 0;
  border-top-color: var(--accent);
  border-right-color: var(--accent);
  filter: drop-shadow(0 0 12px rgba(203, 255, 51, 0.65));
  animation: spin-cw 1.1s cubic-bezier(0.6, 0, 0.4, 1) infinite;
}

.ring-inner {
  inset: 24px;
  border-bottom-color: var(--text);
  border-left-color: var(--text);
  opacity: 0.5;
  animation: spin-ccw 0.7s linear infinite;
}

@keyframes spin-cw {
  to { transform: rotate(360deg); }
}
@keyframes spin-ccw {
  to { transform: rotate(-360deg); }
}

.overlay-text {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text);
}

/* Antilag settings modal -- a real interactive dialog (unlike .overlay,
   which is just a busy-spinner backdrop), so it needs its own click-
   through backdrop + a scrollable, fixed-width box rather than centered
   free-floating content. */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 380px;
  max-width: 100%;
  max-height: 100%;
  overflow-y: auto;
}

/* Relocate Maps holds an open-ended, actively-edited list of rows rather
   than a handful of settings fields -- needs real width, not Antilag's
   compact 380px. */
.modal-box-wide {
  width: 760px;
}

.modal-title {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.tab-3way {
  display: flex;
  gap: 4px;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 18px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 4px;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--accent);
  color: var(--accent-text);
}
.tab-btn:disabled {
  color: #4a4a4a;
  cursor: not-allowed;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
