:root {
  --bg: radial-gradient(circle at center, #0b0020, #000010);
  --accent: #b66dff;
  --muted: #b9b3d0;
  --panel: rgba(255, 255, 255, 0.06);
  --w: 980px;
}

/* --- Global fixes --- */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
}

body {
  font-family: Inter, system-ui, Segoe UI, Roboto, Arial;
  background: var(--bg);
  color: #f5f5f7;
  display: flex;
  justify-content: center;
  padding: 28px;
}

/* --- Layout --- */
.wrap {
  width: 100%;
  max-width: var(--w);
}

/* --- Home bar --- */
.home-bar {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.home-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 16px;
}

.home-icon {
  width: 32px;
  height: 32px;
  margin-right: 8px;
  animation: pulseStar 3s ease-in-out infinite;
  filter: drop-shadow(0 0 6px rgba(124, 58, 237, 0.8));
  border-radius: 50%;
}

@keyframes pulseStar {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.85; }
}

/* --- Header --- */
header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: 20px;
  color: #e0c3ff;
  font-weight: 400;
  flex-shrink: 0;
}

h2 {
  margin: 0 0 14px;
  font-size: 17px;
  color: #e0c3ff;
  font-weight: 600;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.header-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.header-link:hover {
  text-decoration: underline;
}

/* --- Intro text --- */
.intro-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
  text-align: justify;
  margin-bottom: 20px;
  opacity: 0;
  transform: translateY(10px);
  animation: fadeIn 1.5s ease-in forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Cards --- */
.card {
  background: var(--panel);
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  margin-bottom: 16px;
}

.equation {
  color: #f5f5f7;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
  padding: 14px;
  margin: 14px 0;
  text-align: center;
  font-size: 20px;
  line-height: 1.6;
}

/* --- Grid --- */
.scenario-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* --- Inputs --- */
.calculator-card label {
  display: block;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 5px;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.input-row span {
  color: var(--muted);
  font-size: 13px;
  min-width: 42px;
}

input[type=number] {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  color: #f5f5f7;
  border: 1px solid rgba(182, 109, 255, 0.28);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

input[type=number]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(182, 109, 255, 0.35);
}

/* --- Results --- */
.result-box {
  margin-top: 14px;
  padding: 14px;
  border-radius: 12px;
  background-color: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
}

.result {
  margin-top: 4px;
  color: #7dd3fc;
  font-size: 22px;
  font-weight: 600;
}

/* --- Plot --- */
.plot-card {
  margin-top: 16px;
}

.plot-note {
  margin-top: -6px;
  margin-bottom: 12px;
}

#plotCanvas {
  width: 100%;
  height: auto;
  display: block;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
}

/* --- Responsive fix --- */
@media (max-width: 520px) {
  body {
    padding: 12px;
  }

  header {
    gap: 10px;
  }

  .card {
    padding: 14px;
  }

  .scenario-grid {
    gap: 10px;
  }

  .input-row {
    gap: 6px;
  }

  .input-row span {
    min-width: 34px;
  }

  .equation {
    font-size: 18px;
  }
}

@media (max-width: 360px) {
  body {
    padding: 18px;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

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

  .equation {
    font-size: 17px;
  }
}
.plot-explanation {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  margin: -4px 0 14px;
}