/* ---- Template Selector ---- */
.template-selector-section {
  margin-bottom: 1.75rem;
}
.template-section-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.55rem;
}
.template-selector-row {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}
.template-selector-row .setup-select { flex: 1; }
.btn-template-action {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  padding: 0.38rem 0.8rem;
  cursor: pointer;
  font-size: 0.78rem;
  font-family: var(--font-main);
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-template-action:hover { border-color: var(--cyan); color: var(--cyan); }
.btn-template-delete {
  background: none;
  border: 1px solid rgba(255, 90, 90, 0.3);
  border-radius: 6px;
  color: rgba(255, 90, 90, 0.6);
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.btn-template-delete:hover { border-color: #ff5a5a; color: #ff5a5a; background: rgba(255,90,90,0.06); }

/* ---- Launch Panel ---- */
.tool-launch-panel { max-width: 460px; margin: 0 auto; padding: 1rem 0 2rem; }
.tool-launch-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2.5rem;
}
.tool-launch-icon { font-size: 2.2rem; }
.tool-launch-name {
  font-family: var(--font-head);
  font-size: 1.1rem;
  color: var(--text);
}
.tool-launch-meta {
  color: var(--text-dim);
  font-size: 0.78rem;
  font-family: var(--font-mono);
  margin-top: 0.2rem;
}
.tool-launch-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 480px) { .tool-launch-actions { grid-template-columns: 1fr; } }
.tool-launch-btn {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.4rem 1.1rem;
  cursor: pointer;
  transition: all 0.25s;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  text-align: left;
  position: relative;
  overflow: hidden;
}
.tool-launch-btn::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  opacity: 0;
  transition: opacity 0.25s;
}
.tool-launch-btn:hover { border-color: var(--cyan); box-shadow: 0 0 20px rgba(255,107,0,0.12); transform: translateY(-3px); }
.tool-launch-btn:hover::before { opacity: 1; }
.launch-btn-icon {
  font-size: 1.4rem;
  color: var(--cyan);
  font-family: var(--font-head);
  flex-shrink: 0;
  width: 1.8rem;
  text-align: center;
}
.launch-btn-title {
  font-family: var(--font-head);
  font-size: 0.82rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}
.launch-btn-desc { font-size: 0.72rem; color: var(--text-dim); line-height: 1.4; }

/* ---- Setup Name Input ---- */
.setup-name-input {
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--cyan);
  font-family: var(--font-head);
  font-size: 1.2rem;
  font-weight: 700;
  outline: none;
  padding: 0.1rem 0 0.25rem;
  width: 100%;
  max-width: 420px;
  transition: border-color 0.2s;
  display: block;
  margin-bottom: 0.35rem;
}
.setup-name-input:focus { border-bottom-color: var(--cyan); }
.setup-name-input::placeholder { color: var(--text-dim); opacity: 0.45; font-weight: 400; }
.setup-header-inputs {
  display: flex;
  gap: 1.25rem;
  align-items: flex-end;
  flex-wrap: wrap;
}
.setup-track-input {
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  outline: none;
  padding: 0.1rem 0 0.25rem;
  width: 180px;
  transition: border-color 0.2s, color 0.2s;
  display: block;
  margin-bottom: 0.35rem;
}
.setup-track-input:focus { border-bottom-color: var(--cyan); color: var(--text); }
.setup-track-input::placeholder { color: var(--text-dim); opacity: 0.35; }
@media (max-width: 520px) {
  .setup-header-inputs { flex-direction: column; gap: 0.5rem; }
  .setup-track-input { width: 100%; }
}


/* ---- Tool Workspace ---- */
.tool-workspace-header {
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.tool-workspace-title {
  font-family: var(--font-head);
  font-size: 1.3rem;
  color: var(--cyan);
}
.tool-workspace-meta {
  color: var(--text-dim);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  margin-top: 0.2rem;
}

/* ---- Category Tabs ---- */
.category-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--cyan) transparent;
}
.cat-tab {
  flex-shrink: 0;
  padding: 0.45rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.cat-tab:hover { border-color: var(--cyan); color: var(--cyan); }
.cat-tab.active {
  background: rgba(255, 107, 0, 0.1);
  border-color: var(--cyan);
  color: var(--cyan);
}

/* ---- Category Panels ---- */
.cat-panel { display: none; }
.cat-panel.active { display: block; }

/* ---- Subcategory ---- */
.subcat-block { margin-bottom: 2rem; }
.subcat-title {
  font-family: var(--font-head);
  font-size: 0.7rem;
  color: var(--cyan);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 2.5rem;
}
@media (max-width: 640px) {
  .fields-grid { grid-template-columns: 1fr; }
}

/* ---- Field Row ---- */
.field-row { display: flex; flex-direction: column; gap: 0.3rem; }
.field-header { display: flex; justify-content: space-between; align-items: baseline; }
.field-label {
  font-size: 0.76rem;
  color: var(--text-dim);
  font-family: var(--font-main);
  font-weight: 500;
}
.field-value {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--cyan);
  min-width: 4.5rem;
  text-align: right;
}

/* ---- Slider ---- */
input[type="range"].setup-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
input[type="range"].setup-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 6px rgba(255, 107, 0, 0.7);
  cursor: pointer;
  transition: transform 0.15s;
}
input[type="range"].setup-slider::-webkit-slider-thumb:hover { transform: scale(1.35); }
input[type="range"].setup-slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 6px rgba(255, 107, 0, 0.7);
  cursor: pointer;
  border: none;
}
.field-row.field-fixed input[type="range"] { opacity: 0.35; pointer-events: none; }
.field-row.field-fixed .field-label::after { content: ' (fixo)'; font-size: 0.65rem; opacity: 0.5; }

/* ---- Select ---- */
select.setup-select {
  width: 100%;
  padding: 0.38rem 0.75rem;
  background: var(--dark2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}
select.setup-select:focus { border-color: var(--cyan); }

/* ---- Sides (L/R independent sliders) ---- */
.sides-row { display: flex; align-items: center; gap: 0.5rem; }
.side-col { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; min-width: 0; }
.side-top { display: flex; align-items: baseline; gap: 0.3rem; }
.side-label {
  font-size: 0.62rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  width: 1.6rem;
  flex-shrink: 0;
  opacity: 0.6;
}
.field-link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0.1rem 0.15rem;
  border-radius: 3px;
  opacity: 0.35;
  transition: color 0.2s, opacity 0.2s;
  line-height: 1;
  flex-shrink: 0;
  align-self: center;
}
.field-link-btn:hover { opacity: 1; }
.field-link-btn.linked { color: var(--cyan); opacity: 0.85; }

/* ---- Field Controls (value + cfg button) ---- */
.field-controls { display: flex; align-items: center; gap: 0.35rem; }
.field-cfg-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.72rem;
  padding: 0.05rem 0.15rem;
  border-radius: 3px;
  opacity: 0.4;
  transition: color 0.2s, opacity 0.2s;
  line-height: 1;
}
.field-cfg-btn:hover { color: var(--cyan); opacity: 1; }
.field-row.cfg-open .field-cfg-btn { color: var(--cyan); opacity: 1; }
.field-info-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.72rem;
  padding: 0.05rem 0.15rem;
  border-radius: 3px;
  opacity: 0.4;
  transition: color 0.2s, opacity 0.2s;
  line-height: 1;
  font-style: italic;
  font-weight: 700;
}
.field-info-btn:hover { color: #ffc03d; opacity: 1; }
.field-row.info-open .field-info-btn { color: #ffc03d; opacity: 1; }

/* ---- Field Info Panel ---- */
.field-info {
  display: none;
  margin-top: 0.45rem;
  padding: 0.5rem 0.7rem;
  background: rgba(255, 192, 61, 0.04);
  border: 1px solid rgba(255, 192, 61, 0.18);
  border-radius: 6px;
}
.field-row.info-open .field-info { display: block; }
.field-info-desc {
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0 0 0.4rem;
}
.field-info-tags { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-bottom: 0.1rem; }
.field-info-effects { margin-top: 0.5rem; }
.field-info-fx-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.field-info-fx-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.field-info-fx-default {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  margin-left: auto;
  opacity: 0.65;
}
.field-info-fx-list {
  margin: 0;
  padding-left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}
.field-info-fx-list li { font-size: 0.75rem; color: var(--text); line-height: 1.4; }
.field-info-tag {
  font-size: 0.6rem;
  padding: 0.08rem 0.38rem;
  background: rgba(255, 192, 61, 0.08);
  border: 1px solid rgba(255, 192, 61, 0.2);
  border-radius: 3px;
  color: #ffc03d;
  font-family: var(--font-mono);
  opacity: 0.8;
}

/* ---- Field Config Panel ---- */
.field-config {
  display: none;
  margin-top: 0.5rem;
  padding: 0.55rem 0.7rem;
  background: rgba(255, 107, 0, 0.04);
  border: 1px solid rgba(255, 107, 0, 0.12);
  border-radius: 6px;
}
.field-row.cfg-open .field-config { display: block; }

.cfg-inputs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}
.cfg-inputs-select { grid-template-columns: 1fr; max-width: 130px; }
@media (max-width: 480px) { .cfg-inputs { grid-template-columns: repeat(2, 1fr); } }

.cfg-label-input { display: flex; flex-direction: column; gap: 0.2rem; }
.cfg-label {
  font-size: 0.62rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}
.cfg-input {
  width: 100%;
  padding: 0.22rem 0.4rem;
  background: var(--dark);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  outline: none;
  transition: border-color 0.2s;
  -moz-appearance: textfield;
}
.cfg-input:focus { border-color: var(--cyan); }
.cfg-input::-webkit-outer-spin-button,
.cfg-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
select.cfg-input { background: var(--dark); cursor: pointer; }

/* ---- Adjustable toggle ---- */
.cfg-adjustable-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.55rem;
  cursor: pointer;
  user-select: none;
}
.cfg-adjustable-check { display: none; }
.cfg-toggle-track {
  width: 28px;
  height: 15px;
  background: var(--border);
  border-radius: 8px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}
.cfg-toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.2s, background 0.2s;
}
.cfg-adjustable-check:checked + .cfg-toggle-track { background: rgba(255, 107, 0, 0.35); }
.cfg-adjustable-check:checked + .cfg-toggle-track .cfg-toggle-thumb {
  transform: translateX(13px);
  background: var(--cyan);
}

/* ---- Locked (non-adjustable) field ---- */
.field-row.field-locked .setup-slider { opacity: 0.2; pointer-events: none; }
.field-row.field-locked .field-label  { opacity: 0.45; }
.field-row.field-locked .field-value  { opacity: 0.45; }
.field-row.field-locked .field-value::after { content: ' 🔒'; font-size: 0.65em; }

/* ---- Action Bar ---- */
.setup-action-bar {
  display: flex;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.btn-toggle-fixed {
  margin-left: auto;
  opacity: 0.6;
}
.btn-toggle-fixed:hover { opacity: 1; }

/* ---- Action Group Dropdowns ---- */
.action-group {
  position: relative;
}
.action-group-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.45rem 1.1rem;
  border-radius: 6px;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}
.action-group-toggle:hover { border-color: var(--cyan); color: var(--cyan); }
.action-group.open .action-group-toggle { border-color: var(--cyan); color: var(--cyan); }
.action-group-arrow {
  font-size: 0.72rem;
  transition: transform 0.2s;
  display: inline-block;
}
.action-group.open .action-group-arrow { transform: rotate(180deg); }
.action-dropdown {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem;
  z-index: 100;
  flex-direction: column;
  gap: 0.15rem;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.4);
}
.action-group.open .action-dropdown { display: flex; }
.action-dropdown button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 0.85rem;
  border-radius: 5px;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.action-dropdown button:hover { background: rgba(255,107,0,0.08); color: var(--cyan); }

/* ---- Tag filter bar ---- */
.tag-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.tag-filter-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  opacity: 0.6;
  white-space: nowrap;
  margin-right: 0.1rem;
}
.tag-filter-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.62rem;
  font-family: var(--font-mono);
  padding: 0.12rem 0.5rem;
  border-radius: 2rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.tag-filter-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.tag-filter-btn.active {
  background: var(--cyan);
  color: var(--dark);
  border-color: var(--cyan);
  font-weight: 600;
}
.tag-filter-clear {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.62rem;
  font-family: var(--font-mono);
  cursor: pointer;
  opacity: 0.55;
  margin-left: auto;
  padding: 0.12rem 0.4rem;
}
.tag-filter-clear:hover { opacity: 1; color: #ff6b6b; }


/* ---- SVM button ---- */
.btn-svm {
  border-color: rgba(255, 107, 0, 0.4);
  color: var(--cyan);
}
.btn-svm:hover { border-color: var(--cyan); background: rgba(255,107,0,0.08); }
.tool-launch-btn--svm { grid-column: 1 / -1; }

/* ---- Label wrap + symmetric warning ---- */
.field-label-wrap { display: flex; align-items: baseline; gap: 0.3rem; }
.field-sym-warn {
  display: none;
  font-size: 0.7rem;
  color: #ffc03d;
  cursor: default;
}
.field-sym-warn.visible { display: inline; }

/* ---- Analyze Button ---- */
.btn-analyze {
  background: transparent;
  border: 1px solid rgba(255, 107, 0, 0.35);
  color: var(--cyan);
  padding: 0.45rem 1.1rem;
  border-radius: 6px;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.btn-analyze:hover { background: rgba(255, 107, 0, 0.08); border-color: var(--cyan); }
.analyze-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.2rem;
  height: 1.2rem;
  padding: 0 0.3rem;
  background: var(--cyan);
  color: var(--dark);
  border-radius: 10px;
  font-size: 0.62rem;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
}

/* ---- Field Diff Badge ---- */
.field-diff-badge {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
  line-height: 1.5;
  flex-shrink: 0;
}
.field-diff-badge.up   { color: var(--cyan);  background: rgba(255, 107, 0, 0.1); }
.field-diff-badge.down { color: #ffc03d;       background: rgba(255, 192, 61, 0.1); }

/* ---- Analysis Overlay ---- */
.analysis-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 15, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.analysis-overlay.open { opacity: 1; pointer-events: all; }
.analysis-panel {
  width: min(460px, 100vw);
  height: 100vh;
  background: var(--dark2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow: hidden;
}
.analysis-overlay.open .analysis-panel { transform: translateX(0); }
.analysis-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.analysis-title {
  font-family: var(--font-head);
  font-size: 0.85rem;
  color: var(--cyan);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.analysis-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.analysis-close:hover { border-color: var(--cyan); color: var(--cyan); }
.analysis-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--cyan) transparent;
}
.analysis-empty {
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 2rem;
}
.analysis-card {
  background: rgba(255, 107, 0, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.analysis-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.analysis-field-name {
  font-family: var(--font-head);
  font-size: 0.82rem;
  color: var(--text);
}
.analysis-dir {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  flex-shrink: 0;
}
.analysis-dir.up   { color: var(--cyan); background: rgba(255, 107, 0, 0.1); border: 1px solid rgba(255, 107, 0, 0.2); }
.analysis-dir.down { color: #ffc03d;      background: rgba(255, 192, 61, 0.1); border: 1px solid rgba(255, 192, 61, 0.2); }
.analysis-values {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}
.analysis-current { color: var(--cyan); }
.analysis-sep { color: var(--text-dim); }
.analysis-default { color: var(--text-dim); }
.analysis-desc { font-size: 0.78rem; color: var(--text-dim); line-height: 1.5; margin: 0; }
.analysis-effects {
  margin: 0.1rem 0 0 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.analysis-effects li { font-size: 0.78rem; color: var(--text); line-height: 1.4; }
.analysis-tags { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.analysis-tag {
  font-size: 0.6rem;
  padding: 0.1rem 0.4rem;
  background: rgba(255, 107, 0, 0.06);
  border: 1px solid rgba(255, 107, 0, 0.15);
  border-radius: 3px;
  color: var(--cyan);
  font-family: var(--font-mono);
  opacity: 0.7;
}

/* ---- Save / History buttons ---- */
.btn-save {
  background: rgba(255, 107, 0, 0.1);
  border: 1px solid rgba(255, 107, 0, 0.4);
  color: var(--cyan);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-save:hover { background: rgba(255, 107, 0, 0.18); border-color: var(--cyan); }
.btn-save.saved {
  background: rgba(255, 107, 0, 0.25);
  border-color: var(--cyan);
  color: var(--cyan);
}
.btn-history {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-main);
  font-size: 0.78rem;
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-history:hover { border-color: var(--cyan); color: var(--cyan); }

/* ---- Generic Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 15, 0.75);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  transform: translateY(12px) scale(0.97);
  transition: transform 0.2s;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.modal-overlay.open .modal-box { transform: translateY(0) scale(1); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }
.modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.modal-label {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
}
.modal-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-main);
  font-size: 0.92rem;
  padding: 0.55rem 0.85rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}
.modal-input:focus { border-color: var(--cyan); }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 0.75rem 1.25rem 1rem;
  border-top: 1px solid var(--border);
}
.modal-btn {
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 1.2rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid var(--border);
}
.modal-btn-cancel { background: transparent; color: var(--text-dim); }
.modal-btn-cancel:hover { border-color: var(--text-dim); color: var(--text); }
.modal-btn-confirm { background: var(--cyan); border-color: var(--cyan); color: var(--dark); }
.modal-btn-confirm:hover { filter: brightness(1.1); }

/* ---- History Overlay ---- */
.history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 15, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.history-overlay.open { opacity: 1; pointer-events: all; }
.history-panel {
  width: min(420px, 100vw);
  height: 100vh;
  background: var(--dark2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow: hidden;
}
.history-overlay.open .history-panel { transform: translateX(0); }
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.history-title {
  font-family: var(--font-head);
  font-size: 0.85rem;
  color: var(--cyan);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.history-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.history-close:hover { border-color: var(--cyan); color: var(--cyan); }
.history-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  scrollbar-width: thin;
  scrollbar-color: var(--cyan) transparent;
}
.history-empty {
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 2rem;
}
.history-entry {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  transition: border-color 0.2s;
}
.history-entry:hover { border-color: rgba(255, 107, 0, 0.3); }
.history-entry-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.history-entry-name {
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-track {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-entry-date {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  opacity: 0.6;
}
.history-entry-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}
.btn-history-load {
  background: rgba(255, 107, 0, 0.08);
  border: 1px solid rgba(255, 107, 0, 0.3);
  color: var(--cyan);
  font-size: 0.72rem;
  font-family: var(--font-main);
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-history-load:hover { background: rgba(255, 107, 0, 0.18); border-color: var(--cyan); }
.btn-history-delete {
  background: none;
  border: 1px solid rgba(255, 90, 90, 0.25);
  color: rgba(255, 90, 90, 0.5);
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.btn-history-delete:hover { border-color: #ff5a5a; color: #ff5a5a; background: rgba(255,90,90,0.06); }
.btn-history-load-disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ---- History filters ---- */
.history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
}
.history-filter-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.72rem;
  font-family: var(--font-mono);
  padding: 0.18rem 0.65rem;
  border-radius: 2rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.history-filter-chip:hover { border-color: var(--cyan); color: var(--cyan); }
.history-filter-chip.active { background: var(--cyan); color: var(--dark); border-color: var(--cyan); font-weight: 700; }

/* ---- History entry car label ---- */
.history-entry-car {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--cyan);
  opacity: 0.65;
  background: rgba(255,107,0,0.06);
  border: 1px solid rgba(255,107,0,0.15);
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
}
.history-hidden { display: none !important; }

.history-entry-default {
  border-color: rgba(255, 107, 0, 0.12);
  background: rgba(255, 107, 0, 0.03);
  margin-top: 0.25rem;
}
.history-entry-default .history-entry-name { color: var(--cyan); opacity: 0.7; }
.history-entry-default .history-entry-date { opacity: 0.45; }
.btn-history-load-default {
  border-color: rgba(255, 107, 0, 0.2);
  color: var(--text-dim);
  background: none;
}
.btn-history-load-default:hover { background: rgba(255, 107, 0, 0.1); border-color: var(--cyan); color: var(--cyan); }

/* ============================================
   CIRCUIT SELECTOR ROW
   ============================================ */
.circuit-select-row {
  display: flex;
  margin-top: 0.6rem;
}
.circuit-select {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 107, 0, 0.25);
  border-radius: 3px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  outline: none;
  max-width: 340px;
  width: 100%;
}
.circuit-select:focus { border-color: var(--cyan); }
.circuit-select option, .circuit-select optgroup {
  background: #0a0f1a;
  color: var(--text-primary);
}
@media (max-width: 520px) {
  .circuit-select { max-width: 100%; }
}

/* ============================================
   CIRCUIT INFO ROW
   ============================================ */
.circuit-info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 0.6rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 107, 0, 0.03);
  border: 1px solid rgba(255, 107, 0, 0.1);
  border-radius: 4px;
}
.circuit-info-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.circuit-info-select {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 107, 0, 0.25);
  border-radius: 3px;
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.15rem 0.4rem;
  cursor: pointer;
  outline: none;
}
.circuit-info-select:focus { border-color: var(--cyan); }
@media (max-width: 520px) {
  .circuit-info-row { flex-direction: column; gap: 0.5rem; }
}

/* ============================================
   DIAGNOSIS BUTTON
   ============================================ */
.btn-diagnosis {
  background: rgba(255, 165, 0, 0.08);
  border: 1px solid rgba(255, 165, 0, 0.35);
  border-radius: 4px;
  color: #ffa500;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-diagnosis:hover { background: rgba(255, 165, 0, 0.16); border-color: #ffa500; }

/* ============================================
   DIAGNOSIS PANEL
   ============================================ */
.diagnosis-panel {
  width: min(520px, 100vw);
}
.diagnosis-banner {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 107, 0, 0.08);
}
.diagnosis-tip {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  background: rgba(255, 107, 0, 0.04);
  border: 1px solid rgba(255, 107, 0, 0.1);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  line-height: 1.45;
}
.diagnosis-tip-warn {
  background: rgba(255, 165, 0, 0.06);
  border-color: rgba(255, 165, 0, 0.2);
  color: rgba(255, 165, 0, 0.85);
}
.diagnosis-tip-icon { font-size: 1rem; flex-shrink: 0; margin-top: 0.05rem; }

.diagnosis-body { padding: 0.5rem 0; }

.diagnosis-category { margin-bottom: 0.25rem; }
.diagnosis-category-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cyan);
  opacity: 0.55;
  padding: 0.6rem 1rem 0.25rem;
}

.diagnosis-card { border-bottom: 1px solid rgba(255, 107, 0, 0.06); }
.diagnosis-card-header {
  width: 100%;
  display: grid;
  grid-template-columns: 1.6rem 1fr auto 1.1rem;
  align-items: start;
  gap: 0.4rem;
  padding: 0.65rem 1rem;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.diagnosis-card-header:hover { background: rgba(255, 107, 0, 0.04); }
.diagnosis-card-icon { font-size: 1rem; }
.diagnosis-card-title {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
}
.diagnosis-card-desc {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.4;
  grid-column: 2;
  margin-top: 0.1rem;
}
.diagnosis-card-arrow {
  font-size: 0.75rem;
  color: var(--text-dim);
  transition: transform 0.2s;
  align-self: center;
}
.diagnosis-card.open .diagnosis-card-arrow { transform: rotate(180deg); }
.diagnosis-card.open .diagnosis-card-title { color: var(--cyan); }

.diagnosis-card-body {
  display: none;
  padding: 0 1rem 0.75rem 1rem;
  flex-direction: column;
  gap: 0.35rem;
}
.diagnosis-card.open .diagnosis-card-body { display: flex; }

.diagnosis-adjustment {
  display: grid;
  grid-template-columns: 1.2rem 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.15rem 0.5rem;
  padding: 0.45rem 0.5rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 107, 0, 0.06);
