#emgTrainingPanel {
  --emg-accent: #14804a;
  --emg-ball: #42c978;
  --emg-scale: 1;
  --emg-vibration: 0px;
  margin: 18px 0 22px;
  padding: 18px;
  border: 1px solid #cfd9e4;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(26, 47, 69, 0.08);
  color: #182434;
}

.emgPanelHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid #dce4ec;
}

#emgTrainingPanel .emgEyebrow {
  margin: 0 0 4px;
  color: #39708f;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

#emgTrainingPanel h1 {
  margin: 0;
  padding: 0;
  color: #17263a;
  font-size: 24px;
}

.emgPanelIntro {
  max-width: 720px;
  margin: 6px 0 0;
  color: #526376;
  font-size: 14px;
  line-height: 1.45;
}

.emgCalibrateButton {
  min-width: 118px;
  border-color: #176b91;
  background: #176b91;
  color: #fff;
  font-weight: 700;
}

.emgDashboardGrid {
  display: grid;
  grid-template-columns: minmax(320px, 1.4fr) minmax(260px, 0.8fr);
  gap: 16px;
  margin-top: 16px;
}

.emgTrainingStage {
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid #dce4ec;
  border-radius: 8px;
  background: #f6fafc;
}

#emgBall {
  width: 164px;
  height: 164px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--emg-ball);
  box-shadow: 0 16px 32px rgba(27, 80, 108, 0.17), inset 0 -18px 28px rgba(0, 0, 0, 0.10), inset 0 14px 24px rgba(255, 255, 255, 0.30);
  transform: scale(var(--emg-scale));
  transform-origin: center;
  transition: background-color 260ms ease, box-shadow 260ms ease;
  will-change: transform;
}

#emgBall.vibrating {
  animation: emgBallVibration 120ms linear infinite;
}

@keyframes emgBallVibration {
  0%, 100% { transform: translate(0, 0) scale(var(--emg-scale)); }
  25% { transform: translate(var(--emg-vibration), calc(0px - var(--emg-vibration))) scale(var(--emg-scale)); }
  50% { transform: translate(calc(0px - var(--emg-vibration)), var(--emg-vibration)) scale(var(--emg-scale)); }
  75% { transform: translate(var(--emg-vibration), calc(0px - var(--emg-vibration))) scale(var(--emg-scale)); }
}

@media (prefers-reduced-motion: reduce) {
  #emgBall.vibrating { animation: none; }
}

.emgStatus {
  min-height: 30px;
  margin-top: 24px;
  color: #405268;
  font-size: 23px;
  font-weight: 800;
  text-align: center;
}

.emgStatus.relaxed { color: #14804a; }
.emgStatus.moderate { color: #9a6800; }
.emgStatus.high { color: #bd2d2d; }
.emgStatus.calibrating { color: #176b91; }
.emgStatus.lost { color: #bd2d2d; }

.emgCalibration {
  min-height: 24px;
  margin-top: 4px;
  color: #5b6b7b;
  font-size: 15px;
  font-weight: 700;
}

.emgCalibrationSteps {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.emgCalibrationSteps > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid #d5e0e9;
  border-radius: 8px;
  background: #fff;
  color: #718092;
  font-size: 12px;
  font-weight: 700;
}

.emgCalibrationSteps b {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #e6edf3;
  color: #526376;
  font-size: 11px;
}

.emgCalibrationSteps > span.active {
  border-color: #55a9d1;
  background: #eaf7fc;
  color: #176b91;
}

.emgCalibrationSteps > span.active b {
  background: #176b91;
  color: #fff;
}

.emgCalibrationSteps > span.done {
  border-color: #86c9a6;
  background: #edf9f2;
  color: #14804a;
}

.emgCalibrationSteps > span.done b {
  background: #14804a;
  color: #fff;
}

.emgActivationReadout {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 16px;
  color: #5a6a7c;
  font-size: 14px;
}

.emgActivationReadout strong {
  color: #17263a;
  font-size: 30px;
}

.emgStats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-content: stretch;
}

.emgStat {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #dce4ec;
  border-radius: 8px;
  background: #f9fbfd;
}

.emgStat span {
  color: #5a6878;
  font-size: 13px;
}

.emgStat strong {
  color: #17263a;
  font-size: 20px;
  text-align: end;
}

.emgManualCalibration {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid #dce4ec;
  border-radius: 8px;
  background: #f9fbfd;
}

.emgManualHeading h2 {
  margin: 0;
  color: #17263a;
  font-size: 16px;
}

.emgManualHeading p {
  margin: 4px 0 0;
  color: #68788a;
  font-size: 12px;
  line-height: 1.4;
}

.emgManualControls {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(170px, 1fr) auto;
  align-items: end;
  gap: 10px;
  margin-top: 10px;
}

.emgManualControls label {
  display: grid;
  gap: 5px;
  color: #526376;
  font-size: 12px;
  font-weight: 700;
}

.emgManualControls input {
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid #bfcddb;
  border-radius: 6px;
  background: #fff;
  color: #17263a;
  font: inherit;
  font-size: 14px;
}

.emgManualControls input:focus {
  border-color: #176b91;
  outline: 2px solid rgba(23, 107, 145, 0.15);
}

.emgApplyButton {
  min-height: 38px;
  border-color: #176b91;
  background: #fff;
  color: #176b91;
  font-weight: 700;
}

.emgManualFeedback {
  min-height: 18px;
  margin-top: 7px;
  color: #526376;
  font-size: 12px;
  font-weight: 700;
}

.emgManualFeedback.success { color: #14804a; }
.emgManualFeedback.error { color: #bd2d2d; }
.emgManualFeedback.warning { color: #9a6800; }

.emgChartPanel {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid #dce4ec;
  border-radius: 8px;
  background: #fff;
}

.emgChartHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: #17263a;
}

.emgChartHeader div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.emgChartHeader span {
  color: #68788a;
  font-size: 12px;
}

#emgChartValue {
  color: #c52d35;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

#emgRawChart {
  width: 100%;
  height: 240px;
  display: block;
  background: #fff;
}

html[dir="rtl"] .emgPanelHeader,
html[dir="rtl"] .emgChartHeader,
html[dir="rtl"] .emgStat,
html[dir="rtl"] .emgManualCalibration {
  direction: rtl;
}

@media (max-width: 820px) {
  #emgTrainingPanel { padding: 14px; }
  .emgPanelHeader { align-items: stretch; flex-direction: column; }
  .emgCalibrateButton { width: 100%; }
  .emgDashboardGrid { grid-template-columns: 1fr; }
  .emgTrainingStage { min-height: 330px; }
  .emgStats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .emgStat { align-items: flex-start; flex-direction: column; gap: 4px; }
  .emgStat strong { font-size: 18px; }
  .emgManualControls { grid-template-columns: 1fr 1fr; }
  .emgApplyButton { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  #emgTrainingPanel { margin-top: 12px; padding: 10px; }
  #emgTrainingPanel h1 { font-size: 21px; }
  .emgTrainingStage { min-height: 300px; }
  #emgBall { width: 136px; height: 136px; }
  .emgStatus { font-size: 19px; }
  .emgStats { grid-template-columns: 1fr 1fr; }
  .emgManualControls { grid-template-columns: 1fr; }
  .emgApplyButton { grid-column: auto; width: 100%; }
  .emgChartHeader { align-items: flex-start; }
  .emgChartHeader div { align-items: flex-start; flex-direction: column; gap: 2px; }
  #emgRawChart { height: 200px; }
}
