/* =========================================================================
   BİYOSERA MASTER NEURO ATLAS EXTENSION
   Tam ekran (100vw x 100vh) · Sıfır sarı · Monokrom + Biyosera zümrüt (#269F8F / #34d399) + Mercan (#e07a5f)
   ========================================================================= */

/* Unified 8-tab top chapter bar fit without clipping on desktop/tablet */
@media (min-width: 761px) {
  .chapters {
    max-width: calc(100vw - 280px);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .chapters::-webkit-scrollbar { display: none; }
}
@media (max-width: 1480px) and (min-width: 761px) {
  .chapters button { padding: 7px 9.5px; font-size: 12.5px; }
}

/* İlaçlar & Sinaps — Sağ paneller (üstte bilgi kartı, altta canlı reseptör aktivasyonu), Orta Moleküler Kesit (#synStage) ve Sol Üst 3B Beyin Inset */
body[data-ch="drugs"].syn-view #info {
  top: 76px;
  width: 348px;
  max-height: calc(100% - 76px - 368px);
  min-height: 170px;
}

#synStage {
  position: fixed;
  z-index: 3;
  left: 316px;
  right: 374px;
  top: 106px;
  bottom: 66px;
  pointer-events: auto;
}
#synStage[hidden] { display: none !important; }
#synCanvas { width: 100%; height: 100%; display: block; }

#drugBrainInset {
  position: fixed;
  z-index: 5;
  left: 324px;
  top: 114px;
  bottom: auto;
  width: 248px;
  height: 192px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 2px;
  border: 1px solid #262b2e;
  background: rgba(6, 8, 10, 0.72);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.65);
}
#drugBrainInset[hidden] { display: none !important; }
@media (max-width: 1360px) {
  #synStage { left: 316px; right: 372px; top: 108px; }
  #drugBrainInset { left: 322px; width: 196px; height: 158px; }
}
@media (max-width: 959px) {
  #synStage { left: 12px; right: 12px; top: 106px; bottom: 180px; }
}

.db-hd {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  background: rgba(7, 10, 12, 0.92);
  border-bottom: 1px solid var(--line);
}
.db-hd .db-k {
  font: 600 9.5px/1 var(--f-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #34d399;
}
.db-hd .db-n {
  font: 500 11.5px/1.2 var(--f-sans);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: auto;
}
.db-hd .db-btn,
#syn .acts .btn,
#modes button {
  border-radius: 2px;
  border: 1px solid #2b3035;
  background: #0c0e10;
  color: #cbd5e1;
}
.db-hd .db-btn {
  flex: none;
  padding: 3px 7px;
  font: 500 9.5px/1.2 var(--f-mono);
  letter-spacing: 0.04em;
}
.db-hd .db-btn:hover,
#syn .acts .btn:hover,
#modes button:hover {
  color: #ffffff;
  border-color: #cbd5e1;
}
#syn .acts .btn[aria-pressed="true"],
#modes button[aria-selected="true"] {
  background: rgba(52, 211, 153, 0.12);
  border-color: #34d399;
  color: #ffffff;
}
#modes.seg {
  border-radius: 2px;
  border-color: #262b2e;
  background: rgba(8, 10, 12, 0.92);
}

/* Şeffaf WebGL Scissor Penceresi — arkasındaki 3B MNI152 beyin bu açıklıktan görünür */
#drugBrainSlot {
  flex: 1;
  min-height: 0;
  background: transparent;
  pointer-events: none;
}

.db-ft {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 7px 10px;
  background: rgba(7, 13, 16, 0.90);
  border-top: 1px solid var(--line);
}
.db-ft span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font: 500 9.5px/1.2 var(--f-mono);
  color: var(--ink-2);
}
.db-ft span i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.db-ft span.path {
  border-color: rgba(52, 211, 153, 0.35);
  color: #6ee7b7;
}

/* =========================================================================
   CH.STATES — HASTALIKLAR & 46 DURUM (TAM EKRAN ENTEGRE)
   ========================================================================= */
@media (min-width: 761px) {
  body[data-ch="states"] #gizmo { bottom: 260px; }
  body[data-ch="states"] #info { top: 76px; max-height: calc(100% - 170px); width: 392px; }
}

#maStateStage {
  position: fixed;
  z-index: 3;
  left: 320px;
  right: 420px;
  top: 72px;
  bottom: 244px;
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  box-sizing: border-box;
  overflow: hidden;
}
#maStateStage[hidden] { display: none !important; }
.ma-fig-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 500 10px/1 var(--f-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.ma-fig-hd .ma-seg { display: flex; gap: 4px; margin-left: auto; }
.ma-fig-hd button {
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-2);
  border-radius: 6px;
  padding: 3px 8px;
  font: 500 10px/1.2 var(--f-mono);
}
.ma-fig-hd button[aria-pressed="true"] {
  background: var(--nissl);
  color: var(--nissl-ink);
  border-color: var(--nissl);
}
#maBrainFig {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  position: relative;
}
#maBrainFig canvas {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  display: block;
}
.ma-fig-leg {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font: 500 10px/1.3 var(--f-mono);
  color: var(--ink-3);
  margin-top: 4px;
}
.ma-fig-leg span { display: inline-flex; align-items: center; gap: 5px; }
.ma-fig-leg i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Alt Canlı EEG + Otonom Şerit */
#maStateDock {
  position: fixed;
  z-index: 4;
  left: 320px;
  right: 420px;
  bottom: 86px;
  height: 146px;
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  box-sizing: border-box;
}
#maStateDock[hidden] { display: none !important; }
.ma-sd-hd {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 500 10px/1 var(--f-mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.ma-sd-hd b { color: #e6eeec; letter-spacing: 0.03em; font-size: 11px; }
.ma-sd-hd .ma-dot { width: 6px; height: 6px; border-radius: 50%; background: #34d399; }
.ma-sd-hd .ma-open-lab {
  margin-left: auto;
  border: 1px solid rgba(52, 211, 153, 0.45);
  background: rgba(52, 211, 153, 0.10);
  color: #6ee7b7;
  border-radius: 6px;
  padding: 3px 9px;
  font: 600 10px/1.2 var(--f-mono);
}
.ma-sd-hd .ma-open-lab:hover { background: #34d399; color: #03211d; }
.ma-sd-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.55fr 0.72fr 1.1fr;
  gap: 10px;
  align-items: stretch;
}
#maMiniEEG, #maMiniBody { width: 100%; height: 100%; display: block; border-radius: 6px; background: rgba(0, 0, 0, 0.35); }
.ma-bands {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  align-items: end;
  padding: 6px 6px 4px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
}
.ma-band-col { display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 3px; }
.ma-band-col .track { width: 100%; flex: 1; display: flex; align-items: flex-end; background: rgba(255, 255, 255, 0.04); border-radius: 3px; overflow: hidden; }
.ma-band-col .bar { width: 100%; height: 10%; border-radius: 3px; transition: height .2s; }
.ma-band-col .gl { font: 600 10.5px/1 var(--f-mono); color: var(--ink-2); }
.ma-band-col .pc { font: 500 9px/1 var(--f-mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* =========================================================================
   CH.EEGLAB — TAM EKRAN 19 KANAL EEG + TOPOGRAFİ + P300 ERP LAB
   ========================================================================= */
body[data-ch="eeglab"] #browser,
body[data-ch="eeglab"] #info,
body[data-ch="eeglab"] #gizmo { display: none !important; }

#maLabStage {
  position: fixed;
  z-index: 5;
  left: 16px;
  right: 16px;
  top: 72px;
  bottom: 72px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  box-sizing: border-box;
  overflow: hidden;
}
#maLabStage[hidden] { display: none !important; }

.ma-lab-bar {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.ma-lab-bar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  font: 500 10.5px/1.2 var(--f-mono);
  color: var(--ink-3);
}
.ma-lab-bar select {
  background: transparent;
  border: 0;
  color: var(--ink);
  font: 500 12px/1.2 var(--f-sans);
  outline: none;
}
.ma-lab-bar select option { background: #0a1115; color: #e6eeec; }
.ma-src-seg { display: inline-flex; padding: 2px; border-radius: 8px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); gap: 2px; }
.ma-src-seg button { border: 0; background: none; padding: 5px 10px; border-radius: 6px; font: 500 11.5px var(--f-sans); color: var(--ink-2); }
.ma-src-seg button[aria-pressed="true"] { background: var(--nissl); color: var(--nissl-ink); }
.ma-sim-pill {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid rgba(52, 211, 153, 0.3);
  background: rgba(52, 211, 153, 0.08);
  font: 600 9.5px/1 var(--f-mono);
  letter-spacing: 0.08em;
  color: #6ee7b7;
}
.ma-sim-pill i { width: 6px; height: 6px; border-radius: 50%; background: #34d399; }

.ma-lab-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 368px;
  gap: 10px;
}
.ma-lab-body[hidden] { display: none !important; }

.ma-trace-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 8px;
}
.ma-trace-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.ma-trace-hd {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 500 10.5px/1 var(--f-mono);
  color: var(--ink-2);
  margin-bottom: 6px;
}
.ma-trace-hd .live { color: #34d399; font-weight: 600; }
.ma-trace-hd .bands { display: inline-flex; gap: 3px; margin-left: 8px; }
.ma-trace-hd .bands button { border: 1px solid var(--line); background: transparent; color: var(--ink-3); border-radius: 5px; padding: 2px 7px; font: 500 10.5px var(--f-mono); }
.ma-trace-hd .bands button[aria-pressed="true"] { background: #fff; color: #05090b; border-color: #fff; }
.ma-trace-hd .sp { flex: 1; }
#maLabTrace { flex: 1; width: 100%; min-height: 0; display: block; }
.ma-lab-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.34);
  font-size: 12.5px;
  color: var(--ink-2);
}
.ma-lab-foot p { margin: 0; flex: 1; line-height: 1.4; }
.ma-lab-foot .file-acts { display: flex; gap: 6px; flex: none; }

.ma-side-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}
.ma-subcard {
  background: rgba(0, 0, 0, 0.40);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.ma-subcard-h {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 600 9.5px/1 var(--f-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.ma-subcard-h small { margin-left: auto; color: var(--ink-2); font-size: 10px; text-transform: none; }
.ma-topo-bands, .ma-art-grid { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.ma-topo-bands button, .ma-art-grid button {
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink-2);
  border-radius: 5px;
  padding: 3px 7px;
  font: 500 10.5px var(--f-mono);
}
.ma-topo-bands button[aria-pressed="true"], .ma-art-grid button[aria-pressed="true"] {
  background: var(--nissl); color: var(--nissl-ink); border-color: var(--nissl);
}
#maLabTopo { width: 100%; height: 158px; display: block; }
#maLabSpec { width: 100%; height: 118px; display: block; }
#maLabBody { width: 100%; height: 108px; display: block; }
.ma-mix-row { display: grid; grid-template-columns: 74px 1fr 34px; align-items: center; gap: 6px; font: 500 10.5px var(--f-mono); color: var(--ink-2); margin: 2px 0; }
.ma-mix-row input { margin: 0; accent-color: #34d399; }

/* P300 ERP Görünümü */
.ma-p300-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 12px;
}
.ma-p300-body[hidden] { display: none !important; }
.ma-erp-main {
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 0;
}
.ma-erp-main h3 { margin: 0 0 4px; font-size: 18px; color: var(--ink); }
.ma-erp-main p { margin: 0 0 10px; font-size: 13px; color: var(--ink-2); line-height: 1.45; }
#maErpCanvas { flex: 1; width: 100%; min-height: 220px; display: block; }
.ma-erp-ctrl {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  overflow-y: auto;
}
#maErpStat { font: 500 11.5px/1.6 var(--f-mono); color: var(--ink-2); display: grid; gap: 3px; }
#maHeadSvg { width: 100%; max-height: 210px; display: block; }

@media (max-width: 1120px) {
  #drugBrainInset { display: none !important; }
  #maStateStage { left: 16px; right: 16px; }
  #maStateDock { left: 16px; right: 16px; }
  .ma-lab-body, .ma-p300-body { grid-template-columns: 1fr; overflow-y: auto; }
}
@media (max-width: 760px) {
  #maStateDock {
    left: 8px;
    right: 8px;
    bottom: calc(102px + env(safe-area-inset-bottom, 0px));
    height: auto;
    padding: 7px 9px;
    z-index: 5;
  }
  .ma-sd-hd {
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 5px;
  }
  .ma-sd-hd b {
    font-size: 10px;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .ma-sd-hd .ma-open-lab {
    font-size: 9px;
    padding: 3px 7px;
  }
  .ma-sd-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    height: 114px;
    gap: 6px;
  }
  .ma-bands { display: none; }
  #maStateStage {
    left: 8px;
    right: 8px;
    top: calc(96px + env(safe-area-inset-top, 0px));
    bottom: calc(256px + env(safe-area-inset-bottom, 0px));
    padding: 8px 10px;
  }
  #maLabStage {
    left: 6px;
    right: 6px;
    top: calc(96px + env(safe-area-inset-top, 0px));
    bottom: calc(98px + env(safe-area-inset-bottom, 0px));
    padding: 8px;
    gap: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .ma-lab-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 5px;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
  }
  .ma-lab-bar::-webkit-scrollbar { display: none; }
  .ma-lab-bar label {
    flex: none;
    padding: 4px 6px;
    font-size: 9.5px;
  }
  .ma-sim-pill { display: none; }
  .ma-lab-body {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    gap: 8px;
    overflow: visible;
  }
  .ma-trace-col { flex: none; min-width: 0; }
  .ma-trace-card { flex: none; height: 280px; padding: 7px 8px; min-width: 0; }
  .ma-trace-hd { flex-wrap: wrap; gap: 5px; font-size: 9px; margin-bottom: 5px; }
  .ma-trace-hd .live { flex: 1 1 100%; font-size: 9px; }
  .ma-trace-hd .bands { margin-left: 0; flex-wrap: wrap; }
  .ma-trace-hd .sp { display: none; }
  .ma-trace-hd .btn { padding: 4px 8px; font-size: 11px; }
  .ma-lab-foot { flex-direction: column; align-items: stretch; gap: 8px; font-size: 11.5px; padding: 8px; }
  .ma-lab-foot .file-acts { flex-wrap: wrap; justify-content: flex-start; gap: 6px; }
  .ma-side-col { flex: none; overflow: visible; padding-right: 0; }
  .ma-p300-body { display: flex; flex-direction: column; flex: 0 0 auto; gap: 8px; overflow: visible; }
  #maErpCanvas { height: 230px; flex: none; }
  #synStage {
    left: 8px;
    right: 8px;
    top: calc(96px + env(safe-area-inset-top, 0px));
    bottom: calc(255px + env(safe-area-inset-bottom, 0px));
  }
}
