/* ==========================================================
   MRI WORKSPACE — 2D tumor classifier
   Light clinical chrome around a dark imaging stage.
   ========================================================== */
.mri-workspace {
  --stage: #070b14;
  --stage-line: rgba(148, 163, 184, .16);
  --stage-text: #cbd5e1;
  --c-glioma: #e5484d;
  --c-meningioma: #f59e0b;
  --c-pituitary: #8b5cf6;
  --c-notumor: #0e9384;
}
.mri-workspace .main-grid { grid-template-columns: 300px minmax(520px, 1fr) 300px; grid-template-rows: calc(100vh - 225px); }   /* header 73 + steps 49 + classes 49 + grid padding 54 */

/* ── Tumor classes strip (under the workflow bar) ────────── */
.mri-classbar { background: rgba(255,255,255,.55); border-bottom: 1px solid var(--workspace-line); backdrop-filter: blur(16px); }
.mri-classbar-inner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 48px; padding: 0 32px; overflow-x: auto; scrollbar-width: none;
}
.mri-classbar-inner::-webkit-scrollbar { display: none; }
.mri-classbar-label { flex-shrink: 0; margin-right: 4px; font-size: .62rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #98a2b3; }
.mri-class-chip {
  display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0;
  padding: 5px 13px 5px 10px; border: 1px solid var(--workspace-line); border-radius: 999px;
  background: rgba(255,255,255,.85); font-size: .72rem; white-space: nowrap; cursor: default;
  transition: border-color .25s, background .25s, box-shadow .25s, transform .25s;
}
.mri-class-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.mri-class-chip strong { color: var(--ink); font-weight: 650; }
.mri-class-chip span { color: #98a2b3; }
.mri-class-chip span::before { content: "·"; margin-right: 6px; color: #d0d5dd; }
.mri-class-chip.active {
  border-color: var(--c); background: color-mix(in srgb, var(--c) 9%, #fff);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 16%, transparent); transform: translateY(-1px);
}
.mri-class-chip.active i { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent); }
.mri-class-chip.dim { opacity: .5; }
.mri-workspace .panel-right { overflow: hidden; }
.mri-workspace .panel-section-title .mri-count {
  margin-left: auto; font-size: .66rem; font-weight: 700; color: var(--workspace-blue);
  background: #eef2ff; border-radius: 999px; padding: 2px 8px;
}
.mri-kbd {
  font: 600 .62rem 'JetBrains Mono', monospace; color: #475467;
  padding: 0 4px; border-radius: 4px; border: 1px solid #d0d5dd; background: #fff;
}
.mri-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

/* ── Sample grid ────────────────────────────────────────── */
.mri-thumb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px; flex-shrink: 0; }
.mri-thumb {
  position: relative; aspect-ratio: 1; border-radius: 11px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; background: var(--stage); padding: 0;
  transition: border-color .18s, transform .18s, box-shadow .18s;
}
.mri-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.mri-thumb span {
  position: absolute; inset: auto 0 0 0; padding: 12px 4px 4px; font-size: .62rem; font-weight: 650;
  color: #fff; text-align: center; background: linear-gradient(transparent, rgba(0,0,0,.8)); text-transform: capitalize;
}
.mri-thumb:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(16,24,40,.16); }
.mri-thumb:hover img { transform: scale(1.05); }
.mri-thumb.active { border-color: var(--workspace-blue); box-shadow: 0 0 0 3px rgba(52,87,213,.18); }

/* ── Center workspace ───────────────────────────────────── */
.mri-study-head { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.mri-study-title { font-size: .86rem; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mri-study-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .7rem; color: #667085; }
.mri-study-sub .mono { font-family: 'JetBrains Mono', monospace; font-size: .66rem; }
.mri-study-sub .sep { width: 3px; height: 3px; border-radius: 50%; background: #d0d5dd; }

.mri-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, 1fr); }
.mri-stage {
  position: relative; display: flex; align-items: center; justify-content: center; padding: 28px 24px 70px; overflow: hidden;
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, rgba(52,87,213,.16), transparent 70%),
    var(--stage);
}
.mri-figure {
  position: relative; width: min(100%, 440px); aspect-ratio: 1; border-radius: 16px; overflow: hidden;
  background: #000; box-shadow: 0 24px 60px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.07);
}
.mri-figure img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.mri-figure #heatImg { inset: auto; mix-blend-mode: screen; transition: opacity .2s; }
.mri-scanline {
  position: absolute; left: 0; right: 0; height: 30%; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(124,140,255,.28) 85%, rgba(165,180,252,.85) 100%);
  border-bottom: 1px solid rgba(199,210,254,.9);
  animation: mriScan 1.3s cubic-bezier(.45,0,.55,1) infinite;
}
@keyframes mriScan { from { top: -30%; } to { top: 100%; } }
.mri-stage-tag {
  position: absolute; top: 14px; left: 16px; font: 500 10.5px 'JetBrains Mono', monospace; color: rgba(203,213,225,.75);
}
.mri-heat-controls {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; padding: 7px 14px; border-radius: 999px; white-space: nowrap;
  background: rgba(12,19,34,.78); border: 1px solid var(--stage-line); backdrop-filter: blur(10px); color: var(--stage-text);
}
.mri-heat-controls input[type=range] { width: 84px; accent-color: #a78bfa; }
.mri-heat-legend { display: flex; align-items: center; gap: 5px; font-size: .62rem; color: #94a3b8; }
.mri-heat-legend i { width: 54px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #1e40af, #7c3aed, #ec4899, #fbbf24); }
.mri-switch { display: flex; align-items: center; gap: 8px; font-size: .72rem; cursor: pointer; user-select: none; }
.mri-switch input { display: none; }
.mri-switch span { position: relative; width: 28px; height: 16px; border-radius: 999px; background: rgba(148,163,184,.35); transition: background .2s; flex-shrink: 0; }
.mri-switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: transform .2s; }
.mri-switch input:checked + span { background: #6d5bd0; }
.mri-switch input:checked + span::after { transform: translateX(12px); }

/* ── Result column ──────────────────────────────────────── */
.mri-result { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.mri-ready { margin: auto; text-align: center; max-width: 280px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.mri-ready h3 { font-size: 1rem; color: var(--ink); }
.mri-ready p { font-size: .8rem; color: #667085; line-height: 1.6; }
.mri-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #e0e7ff; border-top-color: var(--workspace-blue); animation: mriSpin .85s linear infinite; }
@keyframes mriSpin { to { transform: rotate(360deg); } }

.mri-hero {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 16px; padding: 18px;
  border-radius: 16px; color: #fff; background: linear-gradient(145deg, #0c1322, #18244a);
}
.mri-hero::after { content: ""; position: absolute; right: -50px; top: -50px; width: 160px; height: 160px; border-radius: 50%; background: radial-gradient(circle, var(--hero, #7c8cff), transparent 70%); opacity: .45; }
.mri-ring { position: relative; z-index: 1; width: 84px; height: 84px; flex-shrink: 0; }
.mri-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.mri-ring circle:last-child { transition: stroke-dashoffset .9s cubic-bezier(.2,.7,.3,1); }
.mri-ring b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1rem; font-weight: 750; }
.mri-hero-text { position: relative; z-index: 1; min-width: 0; }
.mri-hero-label { font-size: .6rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #a5b4fc; }
.mri-hero-pred { font-size: 1.35rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; margin: 2px 0 4px; }
.mri-hero-meta { font-size: .68rem; color: #94a3b8; }
.mri-badge { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; padding: 2px 8px; border-radius: 999px; font-size: .64rem; font-weight: 650; }
.mri-badge.b-high { background: rgba(18,183,106,.16); color: #6ce9a6; }
.mri-badge.b-mid { background: rgba(247,144,9,.16); color: #fec84b; }
.mri-badge.b-low { background: rgba(240,68,56,.18); color: #fda29b; }

.mri-card { border: 1px solid var(--workspace-line); border-radius: 14px; background: #fff; padding: 13px; box-shadow: 0 1px 2px rgba(16,24,40,.03); }
.mri-card-label { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 10px; font-size: .62rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #98a2b3; }
.mri-prob { display: grid; grid-template-columns: 10px 1fr auto; gap: 4px 9px; align-items: center; font-size: .78rem; color: #344054; }
.mri-prob > i { width: 8px; height: 8px; border-radius: 50%; }
.mri-prob strong { font-variant-numeric: tabular-nums; font-weight: 650; }
.mri-prob-bar { grid-column: 2 / -1; height: 6px; border-radius: 3px; background: #f2f4f7; overflow: hidden; margin-bottom: 8px; }
.mri-prob-bar b { display: block; height: 100%; width: 0; border-radius: 3px; transition: width .8s cubic-bezier(.2,.7,.3,1); }
.mri-prob.top { color: var(--ink); font-weight: 600; }
.mri-note { font-size: .72rem; color: #667085; line-height: 1.6; }
.mri-note.warn { color: #b54708; background: #fffaeb; border: 1px solid #fedf89; border-radius: 10px; padding: 9px 11px; }
.mri-disclaimer { font-size: .66rem; color: #98a2b3; line-height: 1.6; }
.mri-unavailable { margin: auto; max-width: 380px; padding: 12px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.mri-unavailable h3 { font-size: 1rem; color: var(--ink); }
.mri-unavailable p { font-size: .8rem; color: #667085; line-height: 1.65; }
.mri-rejected h3 { color: #b42318; }
.mri-reject-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 4px; }
.mri-unavailable code { font: 500 .72rem 'JetBrains Mono', monospace; background: #f2f4f7; padding: 2px 6px; border-radius: 5px; color: #344054; }

/* ── Right panel ────────────────────────────────────────── */
/* Title stays put; only the list scrolls (with a soft fade at the bottom) */
.mri-side {
  flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
  padding: 12px 12px 18px; scrollbar-width: thin; scrollbar-color: #d0d5dd transparent;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent);
}
.mri-side::-webkit-scrollbar { width: 6px; }
.mri-side::-webkit-scrollbar-thumb { background: #d0d5dd; border-radius: 3px; }
.mri-clear-btn {
  margin-left: 6px; padding: 4px 9px; border: 1px solid transparent; border-radius: 7px; cursor: pointer;
  background: transparent; color: #667085; font: 600 .7rem 'Inter', sans-serif; transition: all .15s;
}
.mri-clear-btn:hover { color: #b42318; background: #fef3f2; border-color: #fecdca; }

.mri-model-head { display: flex; align-items: center; gap: 10px; }
.mri-model-head strong { display: block; font-size: .82rem; color: var(--ink); }
.mri-model-head span { font-size: .68rem; color: #667085; }
.mri-model-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: #f79009; box-shadow: 0 0 0 4px rgba(247,144,9,.14); }

.mri-history { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.mri-history-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 34px 12px; text-align: center; }
.mri-history-empty svg { width: 42px; height: 42px; margin-bottom: 4px; }
.mri-history-empty strong { font-size: .8rem; color: #344054; }
.mri-history-empty span { font-size: .72rem; color: #98a2b3; }
.mri-hist {
  position: relative; display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 10px 8px 8px;
  text-align: left; cursor: pointer; overflow: hidden;
  border: 1px solid var(--workspace-line); border-radius: 12px; background: #fff;
  transition: border-color .16s, background .16s, box-shadow .16s;
}
.mri-hist::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c); opacity: 0; transition: opacity .16s; }
.mri-hist:hover { border-color: rgba(52,87,213,.28); background: #fafbff; box-shadow: 0 4px 12px rgba(16,24,40,.05); }
.mri-hist.active { border-color: rgba(52,87,213,.45); background: #f5f7ff; box-shadow: 0 0 0 3px rgba(52,87,213,.08); }
.mri-hist.active::before { opacity: 1; }
.mri-hist img { width: 44px; height: 44px; border-radius: 9px; object-fit: cover; background: var(--stage); flex-shrink: 0; box-shadow: 0 0 0 1px rgba(16,24,40,.06); }
.mri-hist div { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.mri-hist strong { display: flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 650; color: var(--ink); }
.mri-hist strong::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.mri-hist span { font-size: .68rem; color: #667085; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mri-hist small { font-size: .62rem; color: #98a2b3; }
.mri-hist em {
  flex-shrink: 0; padding: 3px 8px; border-radius: 999px; font-style: normal;
  font: 700 .68rem 'Inter', sans-serif; font-variant-numeric: tabular-nums;
  color: color-mix(in srgb, var(--c) 80%, #101828); background: color-mix(in srgb, var(--c) 12%, #fff);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1360px) { .mri-workspace .main-grid { grid-template-columns: 276px minmax(460px, 1fr) 272px; } }
@media (max-width: 1180px) {
  .mri-class-chip span { display: none; }
  .mri-workspace .main-grid { grid-template-columns: 262px minmax(0, 1fr) 250px; }
  .mri-body { grid-template-columns: 1fr; overflow-y: auto; }
  .mri-stage { min-height: 420px; }
}
@media (max-width: 900px) {
  .mri-workspace .main-grid { grid-template-columns: 1fr; grid-template-rows: auto; }
  .mri-workspace .panel-left, .mri-workspace .panel-center, .mri-workspace .panel-right { grid-column: 1; grid-row: auto; max-height: none; }
  .mri-workspace .panel-center { min-height: 70vh; }
  .mri-workspace .panel-right .mri-side { max-height: 460px; }
}
@media (max-width: 640px) {
  .mri-classbar-inner { justify-content: flex-start; height: 46px; padding: 0 14px; }
  .mri-classbar-label { display: none; }
  .mri-stage { padding: 18px 12px 70px; min-height: 360px; }
  .mri-heat-legend { display: none; }
}
