.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-link { margin-top: 0.8rem; }
.lead { margin-top: 0.45rem; color: var(--muted); max-width: 64ch; }
.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; }

.interpretation {
  margin-bottom: 0.7rem;
  padding: 0.68rem 0.82rem;
}
.interpretation h3 {
  margin: 0 0 0.35rem;
  font-size: 0.98rem;
}
.interpretation ul {
  margin: 0;
  padding-left: 1.05rem;
  color: var(--muted);
}
.interpretation li {
  margin: 0.16rem 0;
  line-height: 1.35;
}

.layout-grid { display: grid; grid-template-columns: repeat(2, minmax(320px, 1fr)); gap: 1rem; align-items: stretch; }
.panel { padding: 1rem; display: flex; flex-direction: column; min-width: 0; }
.panel-span-2 { grid-column: 1 / -1; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 0.7rem; margin-bottom: 0.8rem; }
.panel-head h2 { margin: 0; font-size: 1.12rem; }
.small { font-size: 0.86rem; }

.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem 0.8rem; margin-bottom: 0.7rem; }
.kv-grid .k { color: var(--muted); font-weight: 600; }
.kv-grid .v { word-break: break-word; }

.config-grid { display: grid; gap: 0.72rem; margin-bottom: 0.9rem; }
.row { display: grid; gap: 0.34rem; }
.row label { font-weight: 600; }
.hint { color: var(--muted); font-size: 0.86rem; }

.button-row { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.button-row .btn { min-width: 140px; flex: 1 1 140px; }

.telemetry-grid { display: grid; grid-template-columns: repeat(2, minmax(280px, 1fr)); gap: 0.85rem; margin-bottom: 0.9rem; }
.canvas-card { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-muted); padding: 0.6rem; }
.canvas-card.full { grid-column: 1 / -1; }
.canvas-card h3 { margin: 0 0 0.45rem; font-size: 0.95rem; }

.graph-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
canvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--border) 84%, var(--primary) 16%);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, var(--accent-soft) 4%), color-mix(in srgb, var(--surface) 92%, var(--accent-soft) 8%));
}

#throughputGauge, #stabilityMeter { height: clamp(210px, 30vh, 320px); }
#perfGraph { height: clamp(220px, 34vh, 340px); min-width: 760px; }
#latencyHistogram, #cacheChart { height: clamp(200px, 28vh, 260px); min-width: 420px; }

.stats-grid { display: grid; gap: 0.55rem; 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; font-family: "JetBrains Mono", "Fira Code", monospace; }

.status-row { min-height: 1.2rem; margin-bottom: 0.7rem; font-weight: 600; }
.status-row.warn { color: #ffb94a; }
#phaseStatus {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid color-mix(in srgb, var(--border) 78%, var(--primary) 22%);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-muted) 86%, var(--primary) 14%);
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.history-list { display: grid; gap: 0.48rem; max-height: 300px; overflow: auto; margin-bottom: 0.8rem; }
.history-item { border: 1px solid var(--border); border-radius: 10px; padding: 0.56rem 0.66rem; background: var(--surface-muted); }
.history-item strong { display: block; }
.history-meta { color: var(--muted); margin-top: 0.22rem; font-size: 0.86rem; }
.history-actions { margin-top: 0.45rem; display: flex; flex-wrap: wrap; gap: 0.42rem; }
.compare-grid { display: grid; gap: 0.7rem; grid-template-columns: 1fr; margin-bottom: 0.75rem; }
.compare-result { border: 1px dashed var(--border); border-radius: 10px; min-height: 68px; padding: 0.7rem; }

.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(560px, 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; }
  .panel { padding: 0.86rem; }
  .panel-head { flex-wrap: wrap; align-items: flex-start; }
}

@media (max-width: 767px) {
  .tool-header h1 { font-size: 1.42rem; line-height: 1.25; }
  .lead, .trust-line { font-size: 0.94rem; }
  .kv-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .button-row .btn, .actions .btn, .history-actions .btn, .compare-grid .btn { width: 100%; min-width: 0; }
  #throughputGauge, #stabilityMeter { height: clamp(180px, 30vh, 240px); }
  #perfGraph,
  #latencyHistogram,
  #cacheChart {
    height: clamp(170px, 30vh, 250px);
    min-width: 100%;
  }
  .history-list { max-height: 240px; }
  .panel-head h2 { font-size: 1rem; }
}

@media (max-width: 479px) {
  .panel { padding: 0.74rem; }
  .canvas-card { padding: 0.44rem; }
  .canvas-card h3 { font-size: 0.9rem; }
  .button-row { gap: 0.45rem; }
  .history-item { padding: 0.48rem 0.54rem; }
  #perfGraph,
  #latencyHistogram,
  #cacheChart {
    min-width: 100%;
    height: clamp(160px, 28vh, 220px);
  }
  .interpretation {
    padding: 0.56rem 0.66rem;
    margin-bottom: 0.55rem;
  }
  .interpretation h3 { margin-bottom: 0.28rem; font-size: 0.92rem; }
  .interpretation ul { padding-left: 0.95rem; }
  .interpretation li { margin: 0.12rem 0; }
}
