.tool-header {
  margin-bottom: 1rem;
}

.kicker {
  margin: 0 0 0.35rem;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tool-header h1 {
  margin: 0;
}

.tool-link {
  margin-top: 0.8rem;
}

.lead {
  margin-top: 0.45rem;
  color: var(--muted);
  max-width: 62ch;
}

.trust-line {
  margin-bottom: 1rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 92%, var(--primary) 8%);
  font-weight: 600;
}

.mobile-only-warning {
  display: none;
}

.layout-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  align-items: stretch;
}

.panel {
  padding: 1rem;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.panel-span-2 {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.small {
  font-size: 0.86rem;
}

.kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 0.8rem;
  margin-bottom: 0.8rem;
}

.kv-grid .k {
  color: var(--muted);
  font-weight: 600;
}

.kv-grid .v {
  color: var(--text);
  word-break: break-word;
}

.row {
  display: grid;
  gap: 0.35rem;
}

.row label {
  font-weight: 600;
}

.hint {
  color: var(--muted);
  font-size: 0.86rem;
}

.button-row {
  margin-top: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.button-row .btn {
  min-width: 140px;
}

.gpu-stage {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 20% 10%, rgba(31, 199, 186, 0.22), transparent 46%),
    radial-gradient(140% 120% at 85% 90%, rgba(68, 114, 255, 0.18), transparent 52%),
    #06080a;
}

#glCanvas {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #06141a, #0a2028 58%, #0b2c2d);
  max-height: clamp(220px, 42vh, 420px);
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 0.9rem;
  margin-bottom: 0.9rem;
  align-items: start;
}

.canvas-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.6rem;
  background: var(--surface-muted);
}

.canvas-card h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
}

.canvas-card.full {
  grid-column: 1 / -1;
}

.canvas-card canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 88%, #000 12%);
}

#fpsGauge {
  height: clamp(220px, 30vh, 340px);
}

#fpsGraph {
  height: clamp(220px, 30vh, 340px);
}

#frameGraph {
  height: clamp(220px, 34vh, 360px);
}

.stats-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stat {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: var(--surface-muted);
}

.stat-label {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.2rem;
}

.stat-value {
  font-size: 1rem;
  font-weight: 700;
}

.status-row {
  margin-top: 0.8rem;
  min-height: 1.2rem;
  font-weight: 600;
}

.status-row.is-warn {
  color: #ffb94a;
}

.history-list {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
  max-height: 240px;
  overflow: auto;
}

.history-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: var(--surface-muted);
}

.history-item strong {
  display: block;
}

.history-meta {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.history-actions {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.history-actions .btn {
  min-width: 120px;
}

.compare-grid {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: 1fr;
  margin-bottom: 0.8rem;
}

.compare-grid .btn {
  width: 100%;
}

.compare-result {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 0.7rem;
  min-height: 68px;
}

.actions {
  display: flex;
  gap: 0.5rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: min(520px, 92vw);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 1rem;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.25);
}

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

  .panel-span-2 {
    grid-column: auto;
  }

  .telemetry-grid {
    grid-template-columns: 1fr;
  }

  .canvas-card.full {
    grid-column: auto;
  }

  .compare-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 0.85rem;
  }

  .panel-head {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .actions .btn {
    flex: 1 1 160px;
  }
}

@media (max-width: 768px) {
  .tool-header h1 {
    font-size: 1.45rem;
    line-height: 1.25;
  }

  .lead {
    font-size: 0.95rem;
  }

  .trust-line {
    font-size: 0.92rem;
  }

  .mobile-only-warning {
    display: block;
  }

  .kv-grid {
    grid-template-columns: 1fr;
    gap: 0.28rem 0.55rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .button-row .btn,
  .compare-grid .btn,
  .actions .btn {
    width: 100%;
    min-width: 0;
  }

  #glCanvas {
    aspect-ratio: 4 / 3;
    max-height: clamp(200px, 40vh, 360px);
  }

  #fpsGauge,
  #fpsGraph {
    height: clamp(190px, 34vh, 280px);
  }

  #frameGraph {
    height: clamp(200px, 38vh, 300px);
  }
}

@media (max-width: 480px) {
  .panel {
    padding: 0.75rem;
  }

  .canvas-card {
    padding: 0.45rem;
  }

  .canvas-card h3 {
    font-size: 0.9rem;
  }

  .compare-result {
    min-height: 54px;
    font-size: 0.9rem;
  }

  #glCanvas {
    aspect-ratio: 1 / 1;
    max-height: clamp(180px, 34vh, 280px);
  }

  #fpsGauge,
  #fpsGraph {
    height: clamp(170px, 32vh, 240px);
  }

  #frameGraph {
    height: clamp(180px, 36vh, 260px);
  }
}
