:root {
  --bg: #eef2f5;
  --panel: #ffffff;
  --panel-2: #f7fafc;
  --ink: #16202a;
  --muted: #5f6f7d;
  --line: #d8e0e8;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --warn: #b45309;
  --danger: #b91c1c;
  --shadow: 0 18px 45px rgba(18, 30, 44, 0.12);
}

.anode-sim-shell *,
.anode-sim-shell *::before,
.anode-sim-shell *::after {
  box-sizing: border-box;
}

.anode-sim-shell {
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.anode-sim-shell button,
.anode-sim-shell input,
.anode-sim-shell select {
  font: inherit;
}

.anode-sim-shell.app-shell {
  display: grid;
  grid-template-columns: minmax(330px, 390px) minmax(0, 1fr);
  min-height: calc(100vh - 64px);
  margin-top: 64px;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: calc(100vh - 64px);
  padding: 22px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.title-block {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.anode-sim-shell h1,
.anode-sim-shell h2 {
  margin: 0;
  letter-spacing: 0;
}

.anode-sim-shell h1 {
  font-size: 1.34rem;
  line-height: 1.2;
}

.anode-sim-shell h2 {
  font-size: 0.98rem;
}

.control-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.control-section,
.result-panel,
.model-notes {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px;
}

.control-section {
  display: grid;
  gap: 12px;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.anode-sim-shell label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.anode-sim-shell input,
.anode-sim-shell select {
  width: 100%;
  min-height: 36px;
  border: 1px solid #cbd5df;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 7px 9px;
  outline: none;
}

.anode-sim-shell input:focus,
.anode-sim-shell select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.anode-sim-shell button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 750;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary-button:hover {
  border-color: #aebdcc;
  background: #f5f8fb;
}

.result-panel {
  display: grid;
  gap: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin: 0;
}

.stats-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 9px;
}

.anode-sim-shell dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.anode-sim-shell dd {
  margin: 3px 0 0;
  font-size: 1rem;
  font-weight: 800;
}

.status-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.model-notes {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.48;
}

.model-notes summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.model-notes p {
  margin: 10px 0 0;
}

.viewport-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: calc(100vh - 64px);
  padding: 20px;
  gap: 14px;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.toolbar h2 {
  font-size: 1.12rem;
}

.toolbar-values {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.toolbar-values span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 750;
}

.canvas-wrap {
  position: relative;
  min-height: 540px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #d9e2e9;
  box-shadow: var(--shadow);
}

.anode-sim-shell canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

.anode-sim-shell canvas.is-dragging {
  cursor: grabbing;
}

.scene-guidance {
  position: absolute;
  left: 18px;
  top: 18px;
  z-index: 2;
  display: grid;
  gap: 9px;
  width: min(360px, calc(100% - 36px));
  border: 1px solid rgba(22, 32, 42, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  padding: 12px;
  box-shadow: 0 14px 34px rgba(18, 30, 44, 0.13);
}

.health-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.health-badge {
  border-radius: 999px;
  padding: 5px 9px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 850;
}

.health-badge.good {
  background: #0f766e;
}

.health-badge.watch {
  background: #b45309;
}

.health-badge.risk {
  background: #b91c1c;
}

.health-badge.neutral {
  background: #64748b;
}

.scene-guidance p {
  margin: 0;
  color: #314150;
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.38;
}

.mini-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mini-metrics div {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(247, 250, 252, 0.92);
  padding: 8px;
}

.mini-metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.mini-metrics strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.25;
}

.legend {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 2;
  display: grid;
  gap: 10px;
  width: min(330px, calc(100% - 36px));
  border: 1px solid rgba(22, 32, 42, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  padding: 10px;
  box-shadow: 0 14px 34px rgba(18, 30, 44, 0.13);
}

.legend-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.legend-head strong {
  font-size: 0.82rem;
}

.legend-head span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.legend-scale {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
}

.legend-bar {
  width: 100%;
  height: 16px;
  border-radius: 5px;
  border: 1px solid rgba(22, 32, 42, 0.18);
  background: linear-gradient(
    to right,
    #4c1d95 0%,
    #1d4ed8 18%,
    #0891b2 38%,
    #0f9f6e 58%,
    #d6a500 74%,
    #f97316 86%,
    #b91c1c 100%
  );
}

.legend-labels {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  justify-content: space-between;
  color: #344453;
  font-size: 0.66rem;
  font-weight: 800;
  text-align: center;
}

.band-list {
  display: grid;
  gap: 6px;
}

.band-list div {
  display: grid;
  grid-template-columns: 14px minmax(72px, 1fr) minmax(95px, 1fr);
  align-items: center;
  gap: 7px;
  color: #344453;
  font-size: 0.68rem;
  font-weight: 750;
}

.band-list strong {
  color: var(--ink);
  font-size: 0.68rem;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(22, 32, 42, 0.16);
}

.swatch.deep {
  background: #1d4ed8;
}

.swatch.protected {
  background: #0f9f6e;
}

.swatch.weak {
  background: #f97316;
}

.hover-readout {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  transform: translate(12px, -50%);
  border: 1px solid rgba(22, 32, 42, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  padding: 7px 9px;
  font-size: 0.78rem;
  font-weight: 800;
  box-shadow: 0 10px 28px rgba(18, 30, 44, 0.16);
  white-space: nowrap;
}

@media (max-width: 950px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-panel {
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .viewport-panel {
    min-height: 680px;
  }
}

@media (max-width: 560px) {
  .control-panel,
  .viewport-panel {
    padding: 14px;
  }

  .two-col,
  .button-row,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .canvas-wrap {
    min-height: 500px;
  }

  .scene-guidance,
  .legend {
    position: static;
    width: auto;
    margin: 10px;
  }

  .canvas-wrap {
    display: flex;
    flex-direction: column;
  }

  canvas {
    min-height: 430px;
  }

  .mini-metrics {
    grid-template-columns: 1fr;
  }
}
