/* ── Return Path Calculator — Local Styles ─────────────────────────── */

/* Improvement suggestion block inside a recommendation */
.rpc-improve {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  border-left: 3px solid currentColor;
  border-radius: 0 6px 6px 0;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.78rem;
  line-height: 1.65;
  opacity: 0.92;
}
.rpc-rec.good .rpc-improve {
  border-color: #34d399;
  background: rgba(52, 211, 153, 0.06);
}
.rpc-rec.warn .rpc-improve {
  border-color: #fbbf24;
  background: rgba(251, 191, 36, 0.06);
}
.rpc-rec.bad .rpc-improve {
  border-color: #f87171;
  background: rgba(248, 113, 113, 0.06);
}
.rpc-rec.info .rpc-improve {
  border-color: #60a5fa;
  background: rgba(99, 179, 237, 0.06);
}
html[data-theme='light'] .rpc-improve {
  background: rgba(0, 0, 0, 0.03);
}

/* Page shell */
.rpc-page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--sp-5) var(--sp-12);
}

/* ── Hero ────────────────────────────────────────────────────────────── */
.rpc-hero {
  padding: var(--sp-10) 0 var(--sp-8);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-8);
}
.rpc-kicker {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--cyan, #06b6d4);
  margin-bottom: var(--sp-3);
}
.rpc-hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: var(--sp-3);
}
.rpc-hero p {
  font-size: 1.0625rem;
  color: var(--text-sub);
  max-width: 620px;
  line-height: 1.65;
  margin-bottom: var(--sp-5);
}
.rpc-tags {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-6);
}
.rpc-hero-actions {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

/* ── Workspace grid ──────────────────────────────────────────────────── */
.rpc-workspace {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: var(--sp-6);
  align-items: start;
}
@media (max-width: 900px) {
  .rpc-workspace {
    grid-template-columns: 1fr;
  }
}

/* ── Input panel ────────────────────────────────────────────────────── */
.rpc-inputs {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.rpc-card {
  padding: var(--sp-5);
}
.rpc-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}
.rpc-card-head h2 {
  font-size: 0.9375rem;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.rpc-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--cyan, #06b6d4);
  color: var(--bg-page);
  font-size: 0.7rem;
  font-weight: 800;
  flex-shrink: 0;
}
.rpc-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}
.rpc-form-grid label,
.rpc-form-full label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-sub);
}
.rpc-form-full {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.rpc-form-grid label span,
.rpc-form-full label span {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
}
.rpc-form-grid select,
.rpc-form-grid input,
.rpc-form-full select,
.rpc-form-full input {
  margin-top: 2px;
}

/* Input with unit suffix */
.rpc-input-unit {
  position: relative;
}
.rpc-input-unit input {
  padding-right: 3rem !important;
  width: 100%;
}
.rpc-input-unit .unit {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
  color: var(--text-muted);
  pointer-events: none;
}

/* Divider */
.rpc-divider {
  height: 1px;
  background: var(--border);
  margin: var(--sp-3) 0;
}

/* Calculate button */
.rpc-calc-btn {
  width: 100%;
  margin-top: var(--sp-2);
  font-size: 0.9375rem;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-lg);
}

/* ── Results panel ──────────────────────────────────────────────────── */
.rpc-results {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

/* KPI row */
.rpc-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--sp-3);
}
.rpc-kpi {
  padding: var(--sp-4);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  text-align: center;
}
.rpc-kpi-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}
.rpc-kpi-value {
  font-size: 1.375rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-base);
  font-family: 'JetBrains Mono', monospace;
}
.rpc-kpi-unit {
  font-size: 0.72rem;
  color: var(--text-sub);
  margin-top: 2px;
}
.rpc-kpi.good .rpc-kpi-value {
  color: var(--success, #34d399);
}
.rpc-kpi.warn .rpc-kpi-value {
  color: var(--warning, #fbbf24);
}
.rpc-kpi.bad .rpc-kpi-value {
  color: var(--danger, #f87171);
}

/* ── PCB Visualization canvas ───────────────────────────────────────── */
.rpc-viz-card {
  padding: var(--sp-5);
}
.rpc-viz-card h3 {
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rpc-viz-legend {
  display: flex;
  gap: var(--sp-4);
  font-size: 0.72rem;
  color: var(--text-sub);
  flex-wrap: wrap;
}
.rpc-viz-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rpc-viz-legend i {
  display: inline-block;
  width: 12px;
  height: 4px;
  border-radius: 2px;
}
.rpc-viz-legend i.good {
  background: #34d399;
}
.rpc-viz-legend i.warn {
  background: #fbbf24;
}
.rpc-viz-legend i.bad {
  background: #f87171;
}
.rpc-viz-legend i.trace {
  background: #d97706;
}
.rpc-viz-legend i.plane {
  background: #94a3b8;
}
#rpcCanvas {
  width: 100%;
  border-radius: var(--radius-lg);
  display: block;
  background: var(--bg-page);
}

/* ── Charts ─────────────────────────────────────────────────────────── */
.rpc-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}
@media (max-width: 640px) {
  .rpc-charts-row {
    grid-template-columns: 1fr;
  }
}
.rpc-chart-card {
  padding: var(--sp-4);
}
.rpc-chart-card h4 {
  font-size: 0.8125rem;
  font-weight: 700;
  margin-bottom: var(--sp-3);
  color: var(--text-sub);
}
.rpc-chart-wrap {
  position: relative;
  height: 200px;
}

/* EMI gauge */
.rpc-emi-card {
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.rpc-emi-card h4 {
  font-size: 0.8125rem;
  font-weight: 700;
  margin-bottom: var(--sp-3);
  color: var(--text-sub);
  align-self: flex-start;
}
.rpc-gauge-wrap {
  position: relative;
  width: 160px;
  height: 90px;
  margin: 0 auto;
}
#rpcGaugeCanvas {
  width: 100% !important;
  height: 100% !important;
}
.rpc-gauge-label {
  text-align: center;
  margin-top: var(--sp-2);
}
.rpc-gauge-score {
  font-size: 1.5rem;
  font-weight: 800;
}
.rpc-gauge-text {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Recommendations ────────────────────────────────────────────────── */
.rpc-recs {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.rpc-rec {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
  align-items: flex-start;
  font-size: 0.8125rem;
  line-height: 1.55;
}
.rpc-rec-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}
.rpc-rec strong {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  margin-bottom: 2px;
}
.rpc-rec.good {
  border-color: rgba(52, 211, 153, 0.3);
  background: rgba(52, 211, 153, 0.06);
}
.rpc-rec.good .rpc-rec-icon {
  color: #34d399;
}
.rpc-rec.warn {
  border-color: rgba(251, 191, 36, 0.3);
  background: rgba(251, 191, 36, 0.06);
}
.rpc-rec.warn .rpc-rec-icon {
  color: #fbbf24;
}
.rpc-rec.bad {
  border-color: rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.08);
}
.rpc-rec.bad .rpc-rec-icon {
  color: #f87171;
}
.rpc-rec.info {
  border-color: rgba(99, 179, 237, 0.3);
  background: rgba(99, 179, 237, 0.06);
}
.rpc-rec.info .rpc-rec-icon {
  color: #63b3ed;
}

/* ── Comparison panel ───────────────────────────────────────────────── */
.rpc-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  margin-top: var(--sp-5);
}
@media (max-width: 600px) {
  .rpc-compare-grid {
    grid-template-columns: 1fr;
  }
}
.rpc-scenario-card {
  padding: var(--sp-4);
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  background: var(--bg-card);
}
.rpc-scenario-card.active {
  border-color: var(--cyan, #06b6d4);
}
.rpc-scenario-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--cyan, #06b6d4);
  margin-bottom: var(--sp-2);
}
.rpc-scenario-name {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: var(--sp-3);
}
.rpc-scenario-metrics {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  font-size: 0.8125rem;
}
.rpc-scenario-metric {
  display: flex;
  justify-content: space-between;
}
.rpc-scenario-metric span:last-child {
  font-weight: 700;
  font-family: monospace;
}
.rpc-improve-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.3);
  margin-top: var(--sp-3);
}

/* ── Section headings ───────────────────────────────────────────────── */
.rpc-section {
  margin-top: var(--sp-12);
}
.rpc-section-head {
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-2);
}
.rpc-section-sub {
  font-size: 0.9375rem;
  color: var(--text-sub);
  max-width: 640px;
  margin-bottom: var(--sp-6);
  line-height: 1.6;
}

/* Concept cards */
.rpc-concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-4);
}
.rpc-concept {
  padding: var(--sp-5);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.rpc-concept-icon {
  font-size: 1.75rem;
  margin-bottom: var(--sp-3);
}
.rpc-concept h3 {
  font-size: 0.9375rem;
  font-weight: 700;
  margin-bottom: var(--sp-2);
}
.rpc-concept p {
  font-size: 0.8125rem;
  color: var(--text-sub);
  line-height: 1.6;
}

/* PCB Rules list */
.rpc-rules {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.rpc-rule {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 0.875rem;
}
.rpc-rule-num {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--cyan, #06b6d4);
  background: rgba(6, 182, 212, 0.1);
  border-radius: 6px;
  padding: 2px 8px;
  flex-shrink: 0;
  line-height: 2;
}

/* Standards table */
.rpc-std-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}
.rpc-std-table th {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.rpc-std-table td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border);
  color: var(--text-sub);
  vertical-align: top;
}
.rpc-std-table td:first-child {
  font-weight: 700;
  color: var(--text-base);
  white-space: nowrap;
}

/* FAQ accordion */
.rpc-faq {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.rpc-faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.rpc-faq-q {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: var(--sp-4) var(--sp-5);
  background: var(--bg-card);
  border: none;
  text-align: left;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-base);
  cursor: pointer;
  gap: var(--sp-3);
}
.rpc-faq-q:hover {
  background: var(--bg-alt);
}
.rpc-faq-chevron {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.rpc-faq-item.open .rpc-faq-chevron {
  transform: rotate(180deg);
}
.rpc-faq-a {
  display: none;
  padding: 0 var(--sp-5) var(--sp-4);
  background: var(--bg-page);
  font-size: 0.875rem;
  color: var(--text-sub);
  line-height: 1.7;
}
.rpc-faq-item.open .rpc-faq-a {
  display: block;
}

/* Alert banner */
.rpc-alert {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-lg);
  font-size: 0.8125rem;
  margin-bottom: var(--sp-4);
  display: none;
}
.rpc-alert.show {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.rpc-alert.warn {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: #fbbf24;
}
.rpc-alert.err {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #f87171;
}

/* Scenario toggle buttons */
.rpc-scenario-tabs {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
}
.rpc-tab {
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.rpc-tab.active {
  background: var(--cyan, #06b6d4);
  border-color: var(--cyan, #06b6d4);
  color: var(--bg-page);
}

/* Export row */
.rpc-export-row {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

/* Responsive tweaks */
@media (max-width: 500px) {
  .rpc-kpi-row {
    grid-template-columns: 1fr 1fr;
  }
  .rpc-form-grid {
    grid-template-columns: 1fr;
  }
}

/* Animation: pulse on recalc */
@keyframes rpc-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}
.rpc-recalculating {
  animation: rpc-pulse 0.6s ease infinite;
}

/* ── Audio explainer bar ────────────────────────────────────────────── */
.rpc-audio-bar {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  max-width: 440px;
}
.rpc-audio-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-base);
  padding: 0;
  flex-shrink: 0;
  white-space: nowrap;
}
.rpc-audio-btn:hover {
  color: var(--cyan, #06b6d4);
}
.rpc-audio-icon {
  width: 34px;
  height: 34px;
  color: var(--cyan, #06b6d4);
  flex-shrink: 0;
  transition: transform 0.15s;
}
.rpc-audio-btn:hover .rpc-audio-icon {
  transform: scale(1.08);
}

/* Waveform + progress (hidden until playing) */
.rpc-audio-progress-wrap {
  display: none;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 80px;
}
.rpc-audio-progress-wrap.visible {
  display: flex;
}

/* Animated bars */
.rpc-audio-waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 16px;
}
.rpc-audio-waveform span {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: var(--cyan, #06b6d4);
  height: 4px;
  opacity: 0.35;
}
@keyframes rpc-wave {
  0%,
  100% {
    height: 4px;
    opacity: 0.35;
  }
  50% {
    height: 14px;
    opacity: 1;
  }
}
.rpc-audio-waveform.playing span {
  animation: rpc-wave 0.8s ease-in-out infinite;
}
.rpc-audio-waveform.playing span:nth-child(1) {
  animation-delay: 0s;
}
.rpc-audio-waveform.playing span:nth-child(2) {
  animation-delay: 0.1s;
}
.rpc-audio-waveform.playing span:nth-child(3) {
  animation-delay: 0.2s;
}
.rpc-audio-waveform.playing span:nth-child(4) {
  animation-delay: 0.3s;
}
.rpc-audio-waveform.playing span:nth-child(5) {
  animation-delay: 0.4s;
}
.rpc-audio-waveform.playing span:nth-child(6) {
  animation-delay: 0.3s;
}
.rpc-audio-waveform.playing span:nth-child(7) {
  animation-delay: 0.2s;
}
.rpc-audio-waveform.playing span:nth-child(8) {
  animation-delay: 0.1s;
}
.rpc-audio-waveform.playing span:nth-child(9) {
  animation-delay: 0.05s;
}
.rpc-audio-waveform.playing span:nth-child(10) {
  animation-delay: 0.15s;
}

/* Progress bar */
.rpc-audio-progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.rpc-audio-progress-fill {
  height: 100%;
  background: var(--cyan, #06b6d4);
  border-radius: 2px;
  width: 0%;
  transition: width 0.5s linear;
}

/* Elapsed time */
.rpc-audio-time {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 30px;
  text-align: right;
}
