/* elektron — same design family as the ultrasound simulator on radiology.at:
   a dark instrument (mono, uppercase, teal accent) plus a light reading sidebar. */
:root {
  --sidebar-width: clamp(260px, 21vw, 320px);
  --ui-font: "SF Mono", Menlo, Consolas, monospace;
  --ui-panel: #0d0d0d;
  --ui-btn: #111;
  --ui-btn-hover: #1a1a1a;
  --ui-border: #2a2a2a;
  --ui-btn-border: #333;
  --ui-text: #cfcfcf;
  --ui-text-dim: #9a9a9a;
  --accent: #3f9d7f;
  --accent-lit: #5fd3a9;
  --accent-text: #a6ead2;
  --warn: #e8d27a;
  --bad: #ff6b6b;
}

html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #000; }
[hidden] { display: none !important; }
body {
  font-family: var(--ui-font);
  color: var(--ui-text);
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: 2px;
  min-height: 100vh;
}

/* ---------------- light reading sidebar (cases, quiz, inspector) ---------------- */
.menu {
  background: #f7f8f8;
  color: #33383b;
  height: 100vh;
  padding: 14px;
  overflow-y: auto;
  border-right: 1px solid #e3e6e8;
  box-sizing: border-box;
}
.app-name { display: flex; align-items: baseline; gap: 7px; margin: 0 0 14px; padding: 0 2px 12px; border-bottom: 1px solid #e3e6e8; }
.app-icon { width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid #16191b; align-self: center; }
.app-title { font-size: 12px; font-weight: 700; letter-spacing: 1.3px; text-transform: uppercase; color: #16191b; }
.app-sub { font-size: 10px; color: #8a9195; letter-spacing: 0.5px; }

.menu label {
  display: block; margin: 14px 0 6px;
  color: #5b6166; font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
}
#caseList button, .quiet-btn {
  width: 100%; padding: 7px 8px; margin-bottom: 5px;
  background: #fff; border: 1px solid #dfe3e4; color: #3c4145;
  cursor: pointer; border-radius: 3px;
  font-family: var(--ui-font); font-size: 11px; letter-spacing: 0.5px; text-align: left;
}
#caseList button:hover, .quiet-btn:hover { background: #eef1f1; color: #16191b; border-color: #b9bfc3; }
#caseList button.active { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
#caseList button small { display: block; color: #8a9195; font-size: 10px; margin-top: 2px; }
.quiet-btn { background: transparent; color: #5b6166; }

/* quiz */
.quiz-q { background: #fff; border: 1px solid #dfe3e4; border-radius: 3px; padding: 8px; margin-bottom: 8px; }
.quiz-q p { margin: 0 0 6px; font-size: 11px; font-weight: 700; color: #33383b; }
.quiz-q label { display: block; margin: 0; padding: 4px 4px; font-size: 11px; letter-spacing: 0; text-transform: none; color: #3c4145; border-radius: 2px; cursor: pointer; }
.quiz-q label:hover { background: #eef1f1; }
.quiz-q input { margin-right: 7px; accent-color: var(--accent); }
.quiz-q .expl { display: none; margin: 6px 0 0 22px; font-size: 10px; line-height: 1.45; color: #5b6166; }
.quiz-q.done .expl { display: block; }
.quiz-q label.correct { color: var(--accent); font-weight: 700; }
.quiz-q label.wrong { color: #c0392b; }
#quizSubmit { margin-top: 4px; }
#quizScore { font-size: 11px; font-weight: 700; margin-left: 10px; }

/* inspector cards (light) */
#inspectorBody .card { background: #fff; border: 1px solid #dfe3e4; border-radius: 3px; padding: 8px; margin-bottom: 8px; }
#inspectorBody h3 { margin: 0 0 6px; font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); }
#inspectorBody ul { margin: 0; padding-left: 16px; }
#inspectorBody li { font-size: 10.5px; margin-bottom: 3px; color: #3c4145; }
#inspectorBody b { color: #16191b; }

/* ---------------- dark instrument ---------------- */
.dynamic-view {
  background: #000;
  height: 100vh;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}
:root {
  --side-col-width: clamp(270px, 22vw, 320px);
  --param-console-height: 100px;
  --emg-console-height: 56px;
}
#viewer {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin-right: var(--side-col-width);
  display: flex; flex-direction: column;
}
#scope { display: block; width: 100%; flex: 1 1 0; min-height: 0; }

/* measurement readout — docked strip below the scope so it never covers traces */
.meas-card {
  flex: 0 0 auto;
  display: flex; gap: 20px; align-items: flex-start;
  background: #0d0d0d;
  border-top: 1px solid var(--ui-border);
  padding: 6px 12px 8px;
  font-size: 10.5px; line-height: 1.5;
  color: var(--ui-text);
  max-height: 36%; overflow: auto;
}
.meas-card .meas-col { flex: 0 0 auto; }
.meas-card table { border-collapse: collapse; }
.meas-card td { padding: 0 8px 0 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.meas-card .h { color: var(--ui-text-dim); font-size: 9px; letter-spacing: 1px; text-transform: uppercase; }
.meas-card .abn { color: var(--bad); }
.meas-card .site-cur { color: var(--accent-lit); }
.scope-hint {
  position: absolute; top: 8px; right: 10px;
  font-size: 9.5px; color: #666; letter-spacing: 0.5px; text-align: right;
}

/* right column: anatomy overlay + control pods */
.side-column {
  position: absolute;
  top: 0; right: 0; bottom: calc(var(--param-console-height) + var(--emg-console-height));
  width: var(--side-col-width);
  display: flex; flex-direction: column;
  gap: 8px; padding: 8px;
  box-sizing: border-box;
  overflow: hidden;
}
.overlay-panel {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: rgba(13, 13, 13, 0.92);
  border: 1px solid var(--ui-border);
  padding: 8px;
  display: flex;
  flex-direction: column;
}
.overlay-label { font-size: 9px; letter-spacing: 1px; color: #8aa; }
.overlay-note { font-size: 9.5px; color: #777; margin-top: 6px; min-height: 2em; line-height: 1.4; }
#anatomy { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
#anatomy svg { width: auto; max-width: 100%; height: 100%; display: block; }
.anat-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.click-mode { display: flex; align-items: center; gap: 3px; font-size: 8.5px; letter-spacing: 1px; color: #8aa; }
.click-mode span { margin-right: 3px; }
.click-mode button {
  background: #111; border: 1px solid #333; color: #9a9a9a; font-family: var(--ui-font);
  font-size: 8.5px; letter-spacing: 1px; padding: 2px 6px; border-radius: 3px; cursor: pointer;
}
.click-mode button:hover { color: #ddd; border-color: #555; }
.click-mode button.active { background: var(--accent); border-color: var(--accent); color: #000; }
.click-mode button[data-click="lesion"].active { background: #ff7a54; border-color: #ff7a54; }
.anat-hint { font-size: 9px; line-height: 1.35; color: #9aa; margin: 5px 0 2px; min-height: 2.7em; }
.anat-hint b { color: var(--accent-text); font-weight: normal; }
.anat-hint.lesion b { color: #ff9a7a; }
#anatomy .site { cursor: pointer; }
#anatomy .site:hover .cathode, #anatomy .site:focus-visible .cathode { stroke: var(--accent); stroke-width: 2.4; }
#anatomy .click-lesion .site { opacity: .45; cursor: default; pointer-events: none; }
#anatomy .seg-hit {
  fill: none; stroke: #5fd3a9; stroke-width: 16; stroke-linecap: round; opacity: .16;
  pointer-events: stroke; cursor: pointer; transition: opacity .12s;
}
#anatomy .seg-hit:hover, #anatomy .seg-hit:focus-visible { opacity: .34; outline: none; }
#anatomy .seg-hit.active { stroke: #ff7a54; opacity: .32; }

/* horizontal parameter console above the instrument keys */
.param-console {
  flex: 0 0 var(--param-console-height);
  display: flex;
  gap: 8px;
  padding: 6px 8px;
  box-sizing: border-box;
  border-top: 1px solid var(--ui-border);
  overflow-x: auto;
  overflow-y: hidden;
}
.pod-group { border: 1px solid #2f3a37; border-radius: 4px; background: #0a0f0e; display: flex; min-height: 0; }
.pod-pathology { flex: 1 1 0; min-width: 480px; }
.pod-technique { flex: 0 0 330px; }
.group-label {
  writing-mode: vertical-rl; transform: rotate(180deg);
  align-self: center; color: #8aa; font-size: 9px; letter-spacing: 2px; padding: 0 3px;
}
.pod-stack { flex: 1; display: grid; gap: 0; min-width: 0; }
.pod-pathology .pod-stack { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pod-technique .pod-stack { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pod-stack .pod { border-color: transparent; background: transparent; }
.pod-pathology .pod:not(:nth-child(4n)), .pod-technique .pod:not(:nth-child(3n)) { border-right: 1px solid #22303a; }
.pod-pathology .pod:nth-child(-n+4) { border-bottom: 1px solid #22303a; }

.pod { display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 4px 8px; background: var(--ui-panel); border: 1px solid #222; flex: 1 1 0; min-width: 0; }
.ui-label { color: var(--ui-text); font-size: 9px; letter-spacing: 1.5px; text-transform: uppercase; display: flex; justify-content: space-between; }
.ui-label b { font-weight: normal; color: var(--accent-text); font-variant-numeric: tabular-nums; }

.ui-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 3px; background: #333; outline: none; border-radius: 2px; }
.ui-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 13px; height: 13px; border-radius: 50%; background: #fff; border: 1px solid #000; cursor: pointer; }
.ui-slider::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: #fff; border: 1px solid #000; cursor: pointer; }
.ui-slider:focus-visible::-webkit-slider-thumb { background: var(--accent-lit); }
.ui-slider:focus-visible::-moz-range-thumb { background: var(--accent-lit); }

/* bottom console */
#emg-console {
  flex: 0 0 var(--emg-console-height);
  display: flex; align-items: stretch; gap: 1px;
  border-top: 1px solid var(--ui-border);
  padding: 6px 8px;
  box-sizing: border-box;
  min-height: var(--emg-console-height);
  overflow: hidden;
}
#emg-console::before { content: ''; flex: 1 1 0; }
#emg-console .pod { flex: 0 0 auto; }
.pod-modes { min-width: 150px; }
.modes { display: flex; gap: 4px; }
.mode-btn {
  padding: 6px 9px; background: var(--ui-btn); color: #bbb;
  border: 1px solid var(--ui-btn-border); border-radius: 3px;
  font-family: inherit; font-size: 10px; letter-spacing: 1px; cursor: pointer;
}
.mode-btn:hover { background: var(--ui-btn-hover); color: #fff; }
.mode-btn.active { background: #fff; color: #000; border-color: #fff; }
.pod-slider { min-width: 120px; }
.pod-keys { flex-direction: row; align-items: center; gap: 7px; }
.round-key {
  width: 32px; height: 32px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: linear-gradient(#1d1d1d, #0e0e0e);
  color: #9a9a9a; border: 1px solid #3a3a3a;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.07), 0 1px 0 #000;
  font-family: inherit; font-size: 10px; letter-spacing: 0.5px; cursor: pointer;
  transition: color .15s, border-color .15s, box-shadow .15s;
}
.round-key:hover { color: #fff; border-color: #555; }
.round-key:active { transform: translateY(1px); }
.round-key.active {
  color: var(--accent-text); border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(63,157,127,0.3), 0 0 10px rgba(63,157,127,0.35);
}

.site-legal { flex: 1 1 0; display: flex; justify-content: flex-end; align-items: flex-end; padding-left: 10px; font-size: 9px; line-height: 1.35; letter-spacing: 0.3px; color: #555; }
.site-legal > span { display: flex; flex-direction: column; align-items: flex-end; }
.site-legal a { color: #555; text-decoration: none; }
.site-legal a:hover { color: #999; }

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; overflow: auto; }
  .menu { height: auto; }
  .dynamic-view { height: 100vh; }
}

/* description panel — meditor-style, fixed below the anatomy */
.desc-panel {
  position: relative;
  flex: 0 0 176px;
  box-sizing: border-box;
  background: rgba(13, 13, 13, 0.94);
  border: 1px solid var(--ui-border);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: contain;
}
.desc-panel.locked { border-color: var(--accent); }
#descPin {
  position: absolute;
  top: 6px;
  right: 8px;
  background: #111;
  border: 1px solid #333;
  color: #9a9a9a;
  font-family: var(--ui-font);
  font-size: 9px;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 3px;
  cursor: pointer;
}
#descPin:hover { color: #cfcfcf; border-color: #555; }
#descPin:focus-visible, .desc-body:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
.desc-panel.locked #descPin {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}
.desc-title { font-size: 10px; letter-spacing: 1px; color: var(--accent-text); margin: 5px 34px 5px 0; text-transform: uppercase; }
.desc-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  font-size: 10px;
  line-height: 1.55;
  color: var(--ui-text-dim);
}

/* case groups + severity grades (sidebar) */
.case-group { margin: 10px 0 4px; font-size: 9px; letter-spacing: 1px; color: #8a9195; text-transform: uppercase; }
.grades { display: flex; gap: 4px; margin-bottom: 8px; }
.grade-btn {
  flex: 1; padding: 4px 0; background: #fff; border: 1px solid #dfe3e4;
  color: #3c4145; font-family: var(--ui-font); font-size: 9px; letter-spacing: 1px;
  border-radius: 3px; cursor: pointer;
}
.grade-btn:hover { background: #eef1f1; }
.grade-btn.active { background: #16191b; color: #fff; border-color: #16191b; }
.muted-label { color: #8a9195; text-transform: none; letter-spacing: 0; }
#normsCard .card { background: #fff; border: 1px solid #dfe3e4; border-radius: 3px; padding: 8px; margin-bottom: 8px; }
#normsCard ul { margin: 0; padding-left: 16px; }
#normsCard li { font-size: 10.5px; margin-bottom: 3px; color: #3c4145; }
#normsCard b { color: #16191b; }
