:root {
  /* --- Harmonized site-level palette --- */
  --bg: #141517; /* soft charcoal navy background */
  --panel: #223145; /* rich steel-blue panel surface */
  --ink: #e6e9ed; /* primary light text */
  --ink-2: #9fa9b6; /* muted secondary text */
  --brand: #4cc2ff;
  --ok: #1bcf6a;
  --warn: #ffcc00;
  --bad: #ff5d5d;
  --line-a: #3bf922;
  --line-b: #f81313;
  --line-c: #6ecef4;
  --line-d: #ff8b1e;
  --line-range: #36d16c;

  /* Glow filters */
  --glow-green: drop-shadow(0 0 25px rgba(0, 255, 0, 0.35));
  --glow-yellow: drop-shadow(0 0 25px rgba(255, 255, 0, 0.4));
  --glow-red: drop-shadow(0 0 25px rgba(255, 0, 0, 0.45));
  --cg-glow: none;
}

.cg-app {
  padding-top: 25px;
  background: var(--bg);
  color: var(--ink);
}
/* ------------------------------
   Header
------------------------------ */
.cg-header {
  padding: 1.25rem 1rem 0.5rem;
  text-align: center;
}
.cg-header h1 {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.cg-header h1 span {
  color: var(--brand);
}
.muted {
  color: var(--ink-2);
  font-size: 0.95rem;
}

/* ------------------------------
   Layout Panels
------------------------------ */
.cg-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

@media (min-width: 980px) {
  .cg-panel {
    grid-template-columns: 1.1fr 0.9fr;
  }
}

/* ------------------------------
   Visual Section
------------------------------ */
.cg-visual {
  background: var(--panel);
  border-radius: 14px;
  padding: 12px;
  justify-content: space-evenly;
}

.visual-stage {
  aspect-ratio: 1600 / 700;
  overflow: hidden;
  position: relative;
  background: #0f1318;
}
.plane-img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.overlay1 {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.plane-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.plane-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: 50% 60%;
  transition: transform 0.8s ease, filter 0.8s ease;
  will-change: transform, filter;
  filter: var(--cg-glow);
}
/* ✅ Default green glow (CG OK) */
/* ✅ Green glow (within CG range — stable flight) */
.plane-wrap[data-glow='green'] {
  --cg-glow: drop-shadow(0 0 50px rgba(0, 255, 0, 0.6))
    drop-shadow(0 0 150px rgba(0, 255, 0, 0.7))
    drop-shadow(0 0 300px rgba(0, 255, 0, 0.9));
}

/* ⚠️ Yellow glow (borderline — caution) */
.plane-wrap[data-glow='yellow'] {
  --cg-glow: drop-shadow(0 0 40px rgba(255, 255, 0, 0.5))
    drop-shadow(0 0 120px rgba(255, 255, 0, 0.7))
    drop-shadow(0 0 220px rgba(255, 255, 150, 0.9));
}

/* ❌ Red glow (unsafe CG — warning) */
.plane-wrap[data-glow='red'] {
  --cg-glow: drop-shadow(0 0 60px rgba(255, 0, 0, 0.7))
    drop-shadow(0 0 160px rgba(255, 0, 0, 0.8))
    drop-shadow(0 0 320px rgba(255, 0, 0, 1));
}

/* Neutral (no data or reset) */
.plane-wrap[data-glow=''],
.plane-wrap:not([data-glow]) {
  --cg-glow: none;
}

/* Plane image */
.plane-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* SVG overlay */
.overlay1 {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.overlay1 marker path {
  fill: var(--ink);
}
.cg-range {
  stroke: var(--line-range);
  stroke-width: 4;
  opacity: 0.85;
}
.plane-wrap {
  transform-origin: 50% 60%; /* small tilt center bias for realism */
}

/* ------------------------------
   Lines and Labels
------------------------------ */
.vline {
  stroke-width: 4;
}
.vline.a {
  stroke: var(--line-a);
}
.vline.b {
  stroke: var(--line-b);
}
.vline.c {
  stroke: var(--line-c);
}
.vline.d {
  stroke: var(--line-d);
}

.tag {
  font: 700;
  font-size: 48px;

  text-anchor: End;
}
.tag.a {
  fill: var(--line-a);
}
.tag.b {
  fill: var(--line-b);
}
.tag.c {
  fill: var(--line-c);
}
.tag.d {
  fill: var(--line-d);
}

.hmeasure {
  stroke: var(--ink);
  stroke-width: 2.5;
}

.mlabel {
  fill: var(--ink);
  font: 600 28px/1.2 system-ui;
  text-anchor: Top;
}

/* ------------------------------
   Controls Panel
------------------------------ */
.cg-controls {
  background: var(--panel);
  border-radius: 14px;
  padding: 14px;
}

.grid2 {
  grid-template-columns: 1fr 1fr;
}

.row {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}
.row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
}
.row input,
.row select {
  background: var(--bg);
  border: 1px solid #2a323d;
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 16px;
}
.row input:focus,
.row select:focus {
  outline: none;
  border-color: var(--brand);
}

legend {
  font-weight: 800;
}

.limits {
  border: 1px dashed #2a323d;
  border-radius: 12px;
  padding: 10px;
}

.fraction-converter {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  gap: 8px;

  margin-top: 4.5rem;
  background: #111722;
  border-radius: 14px;
  padding: 12px;
}

/* ------------------------------
   Buttons
------------------------------ */
.actions {
  grid-template-columns: 1fr 1fr;
}
button {
  cursor: pointer;
  border-radius: 10px;
  padding: 12px 14px;
  border: 1px solid #2a323d;
  background: #111722;
  color: var(--ink);
  font-weight: 700;
  transition: all 0.3s ease;
}
button:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}
button.primary {
  background: var(--brand);
  color: #06131b;
  border-color: transparent;
}
button.secondary {
  background: #111722;
}

/* ------------------------------
   Results
------------------------------ */
.results {
  background-color: var(--bg);
  margin: 15px 0;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid #2a323d;
  border-radius: 18px;
  max-height: 100px;
  height: 100%;
}
.status {
  font-weight: 800;
}
.status.ok {
  color: var(--ok);
}
.status.warn {
  color: var(--warn);
}
.status.bad {
  color: var(--bad);
}
.readout {
  font: 600 16px/1.4 system-ui;
}
.tip {
  font-size: 0.9rem;
}

/* ------------------------------
   Legend Section
------------------------------ */
.legend {
  gap: 0.5rem;
  margin: 2.5rem 0;
  padding: 1rem 1.25rem;
  border-radius: 10px;
  background: #111722;
  border: 1px solid #2a323d;
}

.legend h3 {
  margin-top: 0;
  color: var(--brand);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.legend ul {
  list-style-type: none;
  padding-left: 0;
  margin: 0.5rem 0 0;
}

.legend li {
  margin-bottom: 0.4rem;
  color: var(--ink-2);
  line-height: 1.4;
}

.legend b {
  font-weight: 700;
}
.legend-a {
  color: var(--line-a);
}
.legend-b {
  color: var(--line-b);
}
.legend-c {
  color: var(--line-c);
}
.legend-d {
  color: var(--line-d);
}
/* ------------------------------
   Responsive
------------------------------ */
@media (max-width: 700px) {
  .tag {
    font-size: 18px;
  }
  .mlabel {
    font-size: 20px;
  }
  button {
    font-size: 0.9rem;
    padding: 10px 12px;
  }
}
