/* =============================================================================
   Synapse — EMG Lab page styles (loaded with site.css). Self-contained:
   re-declares the shared .ctl / .grp control language used on the EEG page.
   ========================================================================== */
.emg-head { margin-bottom: 18px; }
.emg-head h1 { font-size: clamp(1.6rem, 3.5vw, 2.4rem); letter-spacing: -.02em; }
.emg-head p { color: var(--muted); max-width: 76ch; margin-top: 8px; }

.emg-state-desc {
  margin: 0 0 16px; padding: 11px 15px; border: 1px solid var(--border);
  border-left: 3px solid var(--cyan); border-radius: 10px; background: var(--surface);
  color: var(--text); font-size: .9rem; line-height: 1.5; max-width: 96ch;
}

/* scope + side panel */
.emg-stage { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .emg-stage { grid-template-columns: 1fr; } }

.emg-viewer {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius);
  background: #0c1430; padding: 0; overflow: hidden; box-shadow: 0 1px 2px rgba(28, 48, 118, .05);
}
#emg-scope { display: block; width: 100%; height: 460px; }
@media (max-width: 900px) { #emg-scope { height: 360px; } }
.emg-status { position: absolute; left: 14px; top: 12px; z-index: 3; font-size: .82rem; color: #aeb9da;
  background: rgba(12,20,48,.7); padding: 3px 10px; border-radius: 999px; }
.emg-status:empty { display: none; }
.emg-status.err { color: #ff9b9b; }
.emg-scale { position: absolute; right: 12px; bottom: 10px; z-index: 3; font-size: .72rem; font-weight: 700;
  color: #aeb9da; background: rgba(12,20,48,.6); padding: 3px 9px; border-radius: 7px; letter-spacing: .02em; }

/* side panel cards */
.emg-side { display: flex; flex-direction: column; gap: 14px; }
.emg-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px;
}
.emg-card h4 { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 0 0 9px; }
.emg-who { font-size: .9rem; color: var(--text); font-weight: 600; line-height: 1.4; }
.emg-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.emg-metric { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; }
.emg-metric .v { font-family: "Space Grotesk", sans-serif; font-size: 1.15rem; font-weight: 700; color: var(--text); }
.emg-metric .k { font-size: .68rem; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }
.emg-read { font-size: .85rem; color: var(--muted); line-height: 1.5; }
.emg-read b { color: var(--text); }

/* measured peak-amplitude comparison bars (from the real signals) */
.emg-bars { display: flex; flex-direction: column; gap: 8px; }
.emg-bar-row { display: grid; grid-template-columns: 78px 1fr 56px; align-items: center; gap: 8px; font-size: .78rem; }
.emg-bar-row .lab { color: var(--muted); font-weight: 600; }
.emg-bar-row .val { color: var(--text); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.emg-bar-track { height: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.emg-bar-fill { height: 100%; border-radius: 6px 0 0 6px; transition: width .4s ease; }
.emg-bar-row.on .lab, .emg-bar-row.on .val { color: var(--cyan); }

/* controls (shared language with EEG page) */
.emg-controls {
  margin-top: 16px; display: flex; flex-wrap: wrap; gap: 22px 30px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px;
}
.emg-controls .grp { min-width: 140px; }
.grp-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--faint); margin-bottom: 10px; }
.emg-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.ctl {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
  font-size: .85rem; font-weight: 600; padding: 9px 13px; border-radius: 10px; cursor: pointer;
  transition: .15s; -webkit-tap-highlight-color: transparent; user-select: none;
}
.ctl:hover { border-color: var(--border-2); color: var(--text); background: var(--surface-3); }
.ctl.active { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 6px 16px -8px rgba(34, 211, 238, .5); }
.ctl.listen { background: var(--surface); }
.ctl.listen.playing { background: var(--grad); color: #fff; border-color: transparent; }
.ctl:active { transform: scale(.97); }

.emg-slider { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--muted); font-weight: 600; }
.emg-slider input[type=range] { accent-color: var(--cyan); width: 110px; }

.emg-note { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); font-size: .82rem; color: var(--faint); line-height: 1.6; }
.emg-note a { color: var(--cyan); }

/* ===== EMG mode toggle (Needle EMG ↔ Muscle map) ========================= */
.emg-modeseg { display: inline-flex; gap: 4px; padding: 4px; margin: 4px 0 18px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; }
.emg-modeseg .seg { border: 0; background: transparent; color: var(--muted); font-weight: 700;
  font-size: .86rem; padding: 8px 18px; border-radius: 999px; cursor: pointer; transition: .15s; font-family: inherit; }
.emg-modeseg .seg:hover { color: var(--text); }
.emg-modeseg .seg.active { background: var(--grad); color: #fff; box-shadow: var(--shadow); }

/* ===== Muscle ↔ nerve map =============================================== */
.mm-toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 16px; }
.mm-search { flex: 1 1 230px; min-width: 180px; padding: 9px 14px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); color: var(--text); font-size: .88rem; font-family: inherit; }
.mm-search:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(8,145,178,.14); }
.mm-roots { display: flex; flex-wrap: wrap; gap: 6px; }
.mm-chip { border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-weight: 700;
  font-size: .74rem; padding: 5px 11px; border-radius: 999px; cursor: pointer; transition: .14s; font-family: inherit;
  font-variant-numeric: tabular-nums; }
.mm-chip:hover { border-color: var(--cyan); color: var(--text); }
.mm-chip.active { background: var(--cyan); border-color: transparent; color: #fff; }

.mm-stage { display: grid; grid-template-columns: 286px 1fr; gap: 16px; align-items: start; }
.mm-list { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  max-height: 560px; overflow-y: auto; padding: 8px; }
.mm-group { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 800;
  color: var(--faint); padding: 12px 10px 6px; }
.mm-item { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; border: 0;
  background: transparent; padding: 9px 11px; border-radius: 10px; cursor: pointer; transition: .12s; font-family: inherit; }
.mm-item:hover { background: var(--surface-2); }
.mm-item.active { background: var(--grad-soft); box-shadow: inset 0 0 0 1px var(--border); }
.mm-item-name { font-size: .9rem; font-weight: 650; color: var(--text); line-height: 1.25; }
.mm-item.active .mm-item-name { color: var(--cyan); }
.mm-item-sub { font-size: .74rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.mm-empty { padding: 20px 12px; color: var(--faint); font-size: .85rem; }

.mm-detail { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  padding: 20px 22px; min-height: 360px; }
.mm-name { font-family: var(--display); font-size: 1.35rem; color: var(--text); margin: 0; }
.mm-subline { font-size: .9rem; color: var(--cyan); font-weight: 700; margin-top: 4px; }
/* myotome body figure */
.mm-figure { display: flex; flex-direction: column; align-items: center; margin: 12px 0 4px;
  padding: 10px 12px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.myo-svg { width: 100%; max-width: 210px; height: auto; display: block; }
.myo-cap { font-size: .8rem; color: var(--muted); line-height: 1.45; margin-top: 8px; text-align: center; }
.myo-cap b { color: var(--text); }
.mm-lab { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 800;
  color: var(--faint); margin: 18px 0 8px; }
.mm-path { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mm-step { font-size: .78rem; font-weight: 650; padding: 5px 10px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.mm-step.is-root { background: rgba(8,145,178,.12); border-color: rgba(8,145,178,.3); color: var(--cyan);
  font-variant-numeric: tabular-nums; }
.mm-step.is-muscle { background: rgba(124,58,237,.12); border-color: rgba(124,58,237,.3); color: var(--violet); font-weight: 750; }
.mm-arrow { color: var(--faint); font-size: .8rem; }

.mm-fact { display: grid; grid-template-columns: 116px 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.mm-fact:first-of-type { margin-top: 14px; }
.mm-fact-k { font-size: .74rem; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; padding-top: 1px; }
.mm-fact-v { font-size: .9rem; color: var(--text); line-height: 1.5; }

.mm-ex { display: flex; flex-wrap: wrap; gap: 7px; }
.mm-extag { font-size: .8rem; font-weight: 600; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; }
.mm-fineprint { font-size: .82rem; color: var(--muted); line-height: 1.5; }
.mm-lesion { margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: rgba(225,29,72,.06);
  border: 1px solid rgba(225,29,72,.18); font-size: .88rem; color: var(--text); line-height: 1.55; }
.mm-lesion b { color: var(--red); }

@media (max-width: 760px) {
  .mm-stage { grid-template-columns: 1fr; }
  .mm-list { max-height: 300px; }
}

/* ===== Dermatome / sensory map ========================================= */
.dm-stage { display: grid; grid-template-columns: minmax(220px, 310px) 1fr; gap: 18px; align-items: start; }
.dm-figure { margin: 0; text-align: center; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 12px 12px 10px; position: sticky; top: 84px; }
.dm-figtoggle { display: inline-flex; gap: 4px; margin-bottom: 10px; }
.dm-figure img { width: 100%; max-height: 540px; object-fit: contain; display: block; margin: 0 auto;
  background: #fff; border-radius: 8px; }
.dm-figure figcaption { font-size: .66rem; color: var(--faint); margin-top: 9px; line-height: 1.4; }
.dm-side { display: flex; flex-direction: column; gap: 14px; }
.dm-side .mm-list { max-height: 270px; }
@media (max-width: 900px) {
  .dm-stage { grid-template-columns: 1fr; }
  .dm-figure { position: static; }
  .dm-figure img { max-height: 420px; }
}

/* ===== Interactive pathway diagram (motor + sensory localisation) ====== */
.mm-diagram { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); padding: 12px 14px; margin: 14px 0 6px; }
.mmd-station + .mmd-conn { padding-top: 6px; }
.mmd-stationlab { font-size: .63rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 800; color: var(--faint); margin-bottom: 6px; }
.mmd-row { display: flex; flex-wrap: wrap; gap: 5px; }
.mmd-zone, .mmd-level { font-size: .72rem; font-weight: 700; padding: 4px 9px; border-radius: 7px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-variant-numeric: tabular-nums; }
.mmd-zone.on { background: var(--pink); border-color: transparent; color: #fff; box-shadow: 0 2px 9px -3px rgba(219,39,119,.6); }
.mmd-level.on { background: var(--cyan); border-color: transparent; color: #fff; box-shadow: 0 2px 9px -3px rgba(8,145,178,.6); }
.mmd-conn { font-size: .69rem; color: var(--muted); font-weight: 600; padding: 6px 2px 2px; text-align: center; }
.mmd-endpoint { font-size: .82rem; font-weight: 750; color: var(--violet); background: rgba(124,58,237,.1);
  border: 1px solid rgba(124,58,237,.28); border-radius: 8px; padding: 7px 12px; text-align: center; margin-top: 4px; }
.mm-step.is-cortex { background: rgba(219,39,119,.12); border-color: rgba(219,39,119,.32); color: var(--pink); }
