/* ==========================================================================
   Grappling Lab — Teknik-mindmap (#tab-matstudio)
   Zero inline styles, strict CSP safe, zero-pill metadata, WCAG AA contrast
   ========================================================================== */

#tab-matstudio .ms-shell {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

#tab-matstudio .ms-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 0.9rem;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(51, 65, 85, 0.85);
}

#tab-matstudio .ms-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

#tab-matstudio .ms-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: -0.015em;
}

#tab-matstudio .ms-subtitle {
  margin: 0;
  font-size: 0.81rem;
  color: #94a3b8;
}

#tab-matstudio .ms-topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

#tab-matstudio .ms-select,
#tab-matstudio .ms-input {
  background: #0b1120;
  border: 1px solid #334155;
  color: #f1f5f9;
  border-radius: 0.55rem;
  font-size: 0.82rem;
  padding: 0.45rem 0.7rem;
  min-height: 40px;
  width: 100%;
  box-sizing: border-box;
}

#tab-matstudio .ms-input-sm,
#tab-matstudio .ms-select-sm {
  min-height: 36px;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
}

#tab-matstudio .ms-topbar-actions .ms-select {
  width: auto;
  max-width: 100%;
  min-height: 42px;
}

#tab-matstudio .ms-select:focus-visible,
#tab-matstudio .ms-input:focus-visible,
#tab-matstudio .ms-btn:focus-visible,
#tab-matstudio .ms-seg-btn:focus-visible,
#tab-matstudio .ms-link-btn:focus-visible,
#tab-matstudio .ms-tl-add:focus-visible {
  outline: 2px solid #22d3ee;
  outline-offset: 2px;
}

#tab-matstudio .ms-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 42px;
  min-width: 40px;
  padding: 0.42rem 0.85rem;
  border-radius: 0.55rem;
  border: 1px solid #334155;
  background: #162033;
  color: #e2e8f0;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease;
}

#tab-matstudio .ms-btn-sm {
  min-height: 36px;
  min-width: 36px;
  padding: 0.3rem 0.7rem;
  font-size: 0.76rem;
}

@media (hover: hover) and (pointer: fine) {
  #tab-matstudio .ms-btn:hover {
    background: #1e293b;
    border-color: #475569;
  }
}

#tab-matstudio .ms-btn-primary {
  background: #06b6d4;
  border-color: #22d3ee;
  color: #082f49;
}

@media (hover: hover) and (pointer: fine) {
  #tab-matstudio .ms-btn-primary:hover {
    background: #22d3ee;
  }
}

#tab-matstudio .ms-btn-amber {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.55);
  color: #fcd34d;
}

@media (hover: hover) and (pointer: fine) {
  #tab-matstudio .ms-btn-amber:hover {
    background: rgba(245, 158, 11, 0.25);
  }
}

#tab-matstudio .ms-btn[aria-pressed="true"] {
  background: rgba(34, 211, 238, 0.2);
  border-color: #22d3ee;
  color: #67e8f9;
}

#tab-matstudio .ms-btn-danger {
  border-color: rgba(244, 63, 94, 0.45);
  color: #fda4af;
}

@media (hover: hover) and (pointer: fine) {
  #tab-matstudio .ms-btn-danger:hover {
    background: rgba(244, 63, 94, 0.16);
    border-color: #f43f5e;
  }
}

#tab-matstudio .ms-link-btn {
  border: 0;
  background: transparent;
  color: #38bdf8;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.25rem 0.35rem;
  border-radius: 0.35rem;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  #tab-matstudio .ms-link-btn:hover {
    color: #7dd3fc;
    text-decoration: underline;
  }
}

#tab-matstudio .ms-segmented {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 0.55rem;
  background: #0b1120;
  border: 1px solid #334155;
  gap: 2px;
}

#tab-matstudio .ms-seg-btn {
  min-height: 34px;
  padding: 0.22rem 0.72rem;
  border: 0;
  border-radius: 0.42rem;
  background: transparent;
  color: #94a3b8;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 140ms ease,
    color 140ms ease;
}

#tab-matstudio .ms-seg-btn[aria-pressed="true"] {
  background: #1e293b;
  color: #22d3ee;
}

/* Main Workspace: Slim Rail + Full-Space Mindmap Canvas */
#tab-matstudio .ms-workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 0.9rem;
  align-items: stretch;
}

#tab-matstudio .ms-rail {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-width: 0;
}

#tab-matstudio .ms-card {
  border-radius: 0.9rem;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(51, 65, 85, 0.85);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
}

#tab-matstudio .ms-rail-section {
  flex: 1 1 auto;
}

#tab-matstudio .ms-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

#tab-matstudio .ms-card-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 800;
  color: #f8fafc;
}

#tab-matstudio .ms-tl-filters {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

#tab-matstudio .ms-tl-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 270px;
  overflow-y: auto;
  padding-right: 0.15rem;
}

#tab-matstudio .ms-tl-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0.48rem 0.55rem;
  border-radius: 0.55rem;
  background: #0b1120;
  border: 1px solid #1e293b;
}

#tab-matstudio .ms-tl-item[data-on-map="true"] {
  border-color: rgba(56, 189, 248, 0.35);
}

#tab-matstudio .ms-tl-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

#tab-matstudio .ms-tl-name {
  font-size: 0.81rem;
  font-weight: 700;
  color: #f1f5f9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#tab-matstudio .ms-tl-sub {
  font-size: 0.72rem;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#tab-matstudio .ms-tl-add {
  min-height: 32px;
  min-width: 32px;
  padding: 0.2rem 0.55rem;
  border-radius: 0.45rem;
  border: 1px solid #334155;
  background: #162033;
  color: #67e8f9;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
}

@media (hover: hover) and (pointer: fine) {
  #tab-matstudio .ms-tl-add:hover {
    background: rgba(34, 211, 238, 0.18);
    border-color: #22d3ee;
  }
}

#tab-matstudio .ms-save-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#tab-matstudio .ms-scene-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 195px;
  overflow-y: auto;
}

#tab-matstudio .ms-scene-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0.48rem 0.55rem;
  border-radius: 0.55rem;
  background: #0b1120;
  border: 1px solid #1e293b;
}

#tab-matstudio .ms-scene-item[data-active="true"] {
  border-color: #22d3ee;
}

#tab-matstudio .ms-scene-load {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

#tab-matstudio .ms-scene-title {
  font-weight: 700;
  font-size: 0.81rem;
  color: #f1f5f9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#tab-matstudio .ms-scene-sub {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 0.7rem;
  color: #94a3b8;
}

#tab-matstudio .ms-scene-del {
  min-height: 30px;
  min-width: 30px;
  border-radius: 0.4rem;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

@media (hover: hover) and (pointer: fine) {
  #tab-matstudio .ms-scene-del:hover {
    color: #fda4af;
    border-color: rgba(244, 63, 94, 0.45);
    background: rgba(244, 63, 94, 0.12);
  }
}

#tab-matstudio .ms-empty {
  font-size: 0.78rem;
  color: #94a3b8;
  padding: 0.75rem 0.65rem;
  border: 1px dashed #334155;
  border-radius: 0.55rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}

/* Mindmap Canvas Panel */
#tab-matstudio .ms-canvas-card {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

#tab-matstudio .ms-canvas-toolbar,
#tab-matstudio .ms-zoom-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

#tab-matstudio .ms-zoom-readout {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 0.74rem;
  color: #cbd5e1;
  min-width: 44px;
  text-align: center;
}

#tab-matstudio .ms-svg-frame {
  position: relative;
  width: 100%;
  height: clamp(460px, 62vh, 700px);
  border-radius: 0.75rem;
  overflow: hidden;
  background: #080d17;
  border: 1px solid #1e293b;
}

#tab-matstudio .ms-svg-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  cursor: grab;
}

#tab-matstudio .ms-svg-canvas[data-panning="true"] {
  cursor: grabbing;
}

#tab-matstudio .ms-svg-canvas[data-connect="true"] {
  cursor: crosshair;
}

/* SVG Grid, Nodes & Trigger Arrows */
#tab-matstudio .ms-grid-dot {
  fill: rgba(148, 163, 184, 0.2);
  pointer-events: none;
}

#tab-matstudio .ms-graph-node {
  cursor: grab;
}

#tab-matstudio .ms-graph-node:active {
  cursor: grabbing;
}

#tab-matstudio .ms-graph-node-rect {
  fill: #11192c;
  stroke: #334155;
  stroke-width: 1.5;
  rx: 8;
  ry: 8;
  transition:
    stroke 140ms ease,
    fill 140ms ease;
}

#tab-matstudio .ms-graph-node[data-cat="standing"] .ms-graph-node-rect {
  stroke: #64748b;
}

#tab-matstudio .ms-graph-node[data-cat="top"] .ms-graph-node-rect {
  stroke: #0891b2;
}

#tab-matstudio .ms-graph-node[data-cat="bottom"] .ms-graph-node-rect {
  stroke: #10b981;
}

#tab-matstudio .ms-graph-node[data-cat="submission"] .ms-graph-node-rect {
  stroke: #d97706;
}

#tab-matstudio .ms-graph-node[data-cat="defense"] .ms-graph-node-rect {
  stroke: #f43f5e;
}

#tab-matstudio .ms-graph-node[data-active="true"] .ms-graph-node-rect {
  fill: #17253f;
  stroke: #22d3ee;
  stroke-width: 2.5;
}

#tab-matstudio .ms-graph-node[data-connect-source="true"] .ms-graph-node-rect {
  stroke: #f59e0b;
  stroke-width: 2.5;
  stroke-dasharray: 5 3;
}

#tab-matstudio .ms-graph-node-cat {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9.5px;
  font-weight: 700;
  fill: #94a3b8;
  pointer-events: none;
}

#tab-matstudio .ms-graph-node[data-cat="top"] .ms-graph-node-cat {
  fill: #38bdf8;
}

#tab-matstudio .ms-graph-node[data-cat="bottom"] .ms-graph-node-cat {
  fill: #34d399;
}

#tab-matstudio .ms-graph-node[data-cat="submission"] .ms-graph-node-cat {
  fill: #fbbf24;
}

#tab-matstudio .ms-graph-node[data-cat="defense"] .ms-graph-node-cat {
  fill: #fda4af;
}

#tab-matstudio .ms-graph-node-title {
  font-size: 12.5px;
  font-weight: 700;
  fill: #f8fafc;
  pointer-events: none;
}

#tab-matstudio .ms-graph-edge {
  fill: none;
  stroke: #38bdf8;
  stroke-width: 2;
  opacity: 0.85;
  pointer-events: none;
}

#tab-matstudio .ms-graph-edge[data-kind="counter"] {
  stroke: #f59e0b;
  stroke-dasharray: 6 4;
}

#tab-matstudio .ms-graph-edge[data-active="true"] {
  stroke: #67e8f9;
  stroke-width: 3;
  opacity: 1;
}

#tab-matstudio .ms-graph-edge[data-kind="counter"][data-active="true"] {
  stroke: #fcd34d;
}

#tab-matstudio .ms-graph-edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 18;
  cursor: pointer;
}

#tab-matstudio .ms-graph-edge-box {
  fill: #080d17;
  stroke: #1e293b;
  stroke-width: 1;
  rx: 4;
  ry: 4;
  cursor: pointer;
}

#tab-matstudio .ms-graph-edge-box[data-active="true"] {
  stroke: #f59e0b;
}

#tab-matstudio .ms-graph-edge-label {
  font-size: 10.5px;
  font-weight: 600;
  fill: #cbd5e1;
  text-anchor: middle;
  pointer-events: none;
}

/* Compact 1-line Inline Editor Bar */
#tab-matstudio .ms-inline-bar {
  border-radius: 0.65rem;
  background: #0b1120;
  border: 1px solid #1e293b;
  padding: 0.55rem 0.7rem;
}

#tab-matstudio .ms-inline-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem;
}

#tab-matstudio .ms-inline-fields[hidden],
#tab-matstudio .ms-inline-empty[hidden] {
  display: none;
}

#tab-matstudio .ms-inline-field {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  flex: 1 1 180px;
  min-width: 0;
}

#tab-matstudio .ms-inline-field-wide {
  flex: 2 1 260px;
}

#tab-matstudio .ms-inline-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
}

#tab-matstudio .ms-inline-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#tab-matstudio .ms-inline-empty {
  font-size: 0.78rem;
  color: #94a3b8;
  padding: 0.25rem 0;
}

#tab-matstudio .ms-legend-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.75rem;
  color: #94a3b8;
}

@media (max-width: 1040px) {
  #tab-matstudio .ms-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  #tab-matstudio .ms-canvas-card {
    order: -1;
  }

  #tab-matstudio .ms-rail {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  #tab-matstudio .ms-rail {
    grid-template-columns: minmax(0, 1fr);
  }

  #tab-matstudio .ms-svg-frame {
    height: 400px;
  }
}

/* MatStudio v2 — layered on top of the original 2D editor styles. */
#tab-matstudio { --ms-v2-bg:#0c111b;--ms-v2-panel:#141d2b;--ms-v2-border:#283649;--ms-v2-text:#f1f5f9;--ms-v2-dim:#a5b4c8; }
#tab-matstudio .ms-shell {gap:12px;}
#tab-matstudio .ms-topbar {border-radius:13px;background:linear-gradient(135deg,#152035 0%,#111925 100%);padding:16px 18px;border:1px solid var(--ms-v2-border);}
#tab-matstudio .ms-title {font-size:clamp(1.25rem,1.8vw,1.65rem);letter-spacing:-.025em;}
#tab-matstudio .ms-subtitle {max-width:52ch;line-height:1.5;}
#tab-matstudio .ms-v2-commandbar {display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px;padding:9px 11px;border:1px solid var(--ms-v2-border);border-radius:11px;background:var(--ms-v2-panel);}
#tab-matstudio .ms-v2-command-group {display:flex;align-items:center;flex-wrap:wrap;gap:7px;}
#tab-matstudio .ms-v2-command-group .ms-btn {min-height:38px;}
#tab-matstudio .ms-v2-heading {font-size:.73rem;font-weight:800;letter-spacing:.08em;text-transform:uppercase;color:var(--ms-v2-dim);}
#tab-matstudio .ms-save-indicator {font-size:.77rem;font-weight:700;color:#7ee1c0;white-space:nowrap;}
#tab-matstudio .ms-save-indicator[data-dirty="true"]{color:#fcd34d;}
#tab-matstudio .ms-workspace {grid-template-columns:minmax(215px,248px) minmax(0,1fr) minmax(230px,280px);gap:12px;}
#tab-matstudio .ms-rail {gap:12px;}
#tab-matstudio .ms-card {background:var(--ms-v2-panel);border-color:var(--ms-v2-border);border-radius:12px;box-shadow:0 9px 24px rgba(0,0,0,.1);}
#tab-matstudio .ms-canvas-card {min-width:0;}
#tab-matstudio .ms-svg-frame {height:clamp(500px,68vh,810px);background-color:var(--ms-v2-bg);border-color:var(--ms-v2-border);}
#tab-matstudio .ms-svg-canvas:focus-visible {outline:2px solid #67e8f9;outline-offset:-3px;}
#tab-matstudio .ms-graph-node:focus-visible .ms-graph-node-rect {stroke:#f8fafc;stroke-width:3;}
#tab-matstudio .ms-graph-node-rect {transition:stroke .12s,fill .12s;}
#tab-matstudio .ms-graph-node[data-active="true"] .ms-graph-node-rect {stroke:var(--accent, #65dce9);stroke-width:2.2;}
#tab-matstudio .ms-board-stats {font:600 .75rem/1.5 "JetBrains Mono",ui-monospace,monospace;color:var(--ms-v2-dim);}
#tab-matstudio .ms-inspector {display:flex;flex-direction:column;gap:12px;align-self:stretch;min-width:0;}
#tab-matstudio .ms-inspector[hidden] {display:none;}
#tab-matstudio .ms-inspector h3{font-size:1rem;font-weight:800;color:var(--ms-v2-text);margin:0;overflow-wrap:anywhere;}
#tab-matstudio .ms-inspector label{display:flex;flex-direction:column;gap:5px;font-size:.78rem;font-weight:700;color:var(--ms-v2-dim);}
#tab-matstudio .ms-inspector textarea{width:100%;min-height:120px;resize:vertical;border:1px solid #3a4a60;background:#0c1320;color:var(--ms-v2-text);border-radius:8px;padding:10px;box-sizing:border-box;font:inherit;line-height:1.5;}
#tab-matstudio .ms-inspector textarea:focus-visible{outline:2px solid #67e8f9;outline-offset:2px;}
#tab-matstudio .ms-video-preview video{display:block;width:100%;max-height:200px;background:#000;border-radius:8px;}
#tab-matstudio .ms-video-preview[hidden]{display:none;}
#tab-matstudio .ms-video-preview figcaption{margin-top:6px;color:var(--ms-v2-dim);font-size:.75rem;}
#tab-matstudio .ms-training-pane{padding:16px;border:1px solid #3a5366;background:#101e30;border-radius:10px;display:flex;flex-direction:column;gap:9px;}
#tab-matstudio .ms-training-pane[hidden]{display:none;}
#tab-matstudio .ms-training-pane h3{margin:0;color:#ecfeff;font-size:1.07rem;}
#tab-matstudio .ms-training-pane p{font-size:.83rem;color:#bccbda;margin:0;}
#tab-matstudio .ms-training-options{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr));gap:8px;}
#tab-matstudio .ms-training-choice{border:1px solid #3b6073;border-radius:8px;background:#192c40;color:#e1f8ff;padding:12px;text-align:left;font-weight:650;cursor:pointer;min-height:50px;}
#tab-matstudio .ms-training-choice:focus-visible{background:#24465a;border-color:#67e8f9;outline-offset:2px;}
@media (hover: hover) and (pointer: fine) {
  #tab-matstudio .ms-training-choice:hover{background:#24465a;border-color:#67e8f9;}
}
#tab-matstudio .ms-v2-mobile-only{display:none;}
#tab-matstudio .ms-btn:disabled{opacity:.37;cursor:not-allowed;}
#tab-matstudio :is(.ms-graph-node,.ms-graph-edge-hit){outline:none;}
@media(max-width:1200px){
  #tab-matstudio .ms-workspace{grid-template-columns:minmax(210px,260px) minmax(0,1fr);}
  #tab-matstudio .ms-inspector{grid-column:1 / -1;}
  #tab-matstudio .ms-svg-frame{height:clamp(440px,60vh,710px);}
}
@media(max-width:900px){
  #tab-matstudio .ms-v2-mobile-only{display:inline-flex;}
  #tab-matstudio .ms-workspace{grid-template-columns:minmax(0,1fr);}
  #tab-matstudio .ms-canvas-card{order:0;}
  #tab-matstudio .ms-rail{order:1;display:none;grid-template-columns:minmax(0,1fr);}
  #tab-matstudio.ms-show-library .ms-rail{display:grid;}
  #tab-matstudio .ms-inspector{order:2;grid-column:auto;display:none;}
  #tab-matstudio.ms-show-inspector .ms-inspector:not([hidden]){display:flex;}
  #tab-matstudio .ms-svg-frame{height:clamp(400px,60dvh,650px);}
  #tab-matstudio .ms-topbar-actions{width:100%;}
  #tab-matstudio .ms-topbar-actions .ms-select{flex:1 1 210px;}
}
@media(max-width:600px){
  #tab-matstudio .ms-v2-commandbar{padding:9px;}
  #tab-matstudio .ms-v2-command-group{width:100%;}
  #tab-matstudio .ms-v2-command-group .ms-btn{flex:1 1 auto;}
  #tab-matstudio .ms-svg-frame{height:clamp(390px,54dvh,540px);}
  #tab-matstudio .ms-topbar{padding:12px;}
  #tab-matstudio .ms-canvas-toolbar{flex-wrap:wrap;}
  #tab-matstudio .ms-inline-bar{position:relative;}
}
@media(prefers-reduced-motion:reduce){#tab-matstudio .ms-graph-node-rect{transition:none;}}

/* MatStudio 2.2: AI-assisted graph suggestions; no inline styles / no external assets. */
#tab-matstudio .ms-ai-launch {
  border-color: #80674a;
  background: linear-gradient(130deg, #2c2b30 0%, #3e3128 100%);
  color: #ffddb0;
}
#tab-matstudio .ms-ai-launch[aria-expanded="true"] {
  border-color: #e9b96f;
  background: #493629;
}
@media (hover: hover) and (pointer: fine) {
  #tab-matstudio .ms-ai-launch:hover {
    border-color: #e9b96f;
    background: #493629;
  }
}
#tab-matstudio .ms-ai-suggestions {
  margin: 10px 0 14px;
  padding: 15px;
  color: #e5eaf3;
  border: 1px solid #41546a;
  border-radius: 12px;
  background: linear-gradient(150deg, #192537 0%, #131d2c 100%);
  box-shadow: 0 8px 25px rgba(0, 0, 0, .16);
}
#tab-matstudio .ms-ai-suggestions[hidden] {display:none;}
#tab-matstudio .ms-ai-header,
#tab-matstudio .ms-ai-card-header,
#tab-matstudio .ms-ai-controls,
#tab-matstudio .ms-ai-card-actions {
  display:flex;align-items:center;gap:9px;flex-wrap:wrap;
}
#tab-matstudio .ms-ai-header {justify-content:space-between;}
#tab-matstudio .ms-ai-title {margin:0;font-size:1rem;font-weight:750;letter-spacing:-.02em;}
#tab-matstudio .ms-ai-intro {margin:8px 0 12px;color:var(--text-dim,#aebdd1);font-size:.82rem;line-height:1.55;}
#tab-matstudio .ms-ai-controls {margin-bottom:10px;}
#tab-matstudio .ms-ai-controls .ms-ai-label {display:flex;flex:1 1 180px;min-width:160px;}
#tab-matstudio .ms-ai-controls .ms-select {width:100%;min-width:0;}
#tab-matstudio .ms-ai-status {margin:6px 0 10px;font-size:.78rem;color:var(--text-info,#b7d4ef);line-height:1.5;}
#tab-matstudio .ms-ai-status[data-error="true"] {color:var(--kpi-rose,#ffc7ac);}
#tab-matstudio .ms-ai-results {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,270px),1fr));gap:10px;max-height:360px;overflow-y:auto;}
#tab-matstudio .ms-ai-card {padding:13px;border-radius:10px;border:1px solid var(--line-strong,#34485e);background:var(--surface-subtle,#101b2b);min-width:0;}
#tab-matstudio .ms-ai-card-header {align-items:flex-start;justify-content:space-between;}
#tab-matstudio .ms-ai-card-title {margin:0;line-height:1.4;font-size:.84rem;font-weight:700;flex:1 1 150px;overflow-wrap:anywhere;}
#tab-matstudio .ms-ai-kind {font-size:.75rem;font-weight:700;border:1px solid var(--line-strong,#526478);border-radius:6px;padding:2px 8px;white-space:nowrap;color:var(--text-dim,#c9d8ea);}
#tab-matstudio .ms-ai-trigger {margin:10px 0 6px;font-size:.78rem;color:var(--accent,#88c9f3);overflow-wrap:anywhere;}
#tab-matstudio .ms-ai-reason {margin:5px 0;color:var(--text-dim,#c3cfdd);font-size:.78rem;line-height:1.55;}
#tab-matstudio .ms-ai-cue {margin:7px 0 0;color:var(--kpi-amber,#eecaa3);font-size:.78rem;line-height:1.55;}
#tab-matstudio .ms-ai-card-actions {margin-top:12px;gap:6px;}
#tab-matstudio .ms-ai-card-actions .ms-btn {font-size:.76rem;}
#tab-matstudio .ms-graph-node[data-ms-ai-preview="true"] .ms-graph-node-rect {
  stroke:var(--kpi-amber,#f59e0b);stroke-width:2.6;stroke-dasharray:6 3;
}
@media (max-width:600px) {
  #tab-matstudio .ms-ai-suggestions {padding:11px;margin:9px 0;}
  #tab-matstudio .ms-ai-controls .ms-ai-label {flex:1 1 100%;}
  #tab-matstudio .ms-ai-controls > button {width:100%;}
  #tab-matstudio .ms-ai-results {grid-template-columns:1fr;max-height:300px;}
}
@media(prefers-reduced-motion:reduce) {
  #tab-matstudio .ms-ai-launch {transition:none;}
}


/* Local reaction quiz and map filtering. Keep controls within narrow phone widths. */
#tab-matstudio .ms-reaction-quiz {
  min-width:0;max-width:100%;border:1px solid #35536b;border-radius:12px;
  background:#111f2f;color:#eef7ff;margin:0 0 12px;
}
#tab-matstudio .ms-quiz-layout {display:grid;gap:10px;padding:clamp(12px,2vw,18px);min-width:0}
#tab-matstudio .ms-quiz-heading {display:flex;flex-wrap:wrap;gap:8px;justify-content:space-between;align-items:center}
#tab-matstudio .ms-quiz-caption,#tab-matstudio .ms-quiz-score {font-size:.74rem;color:#b9cedd}
#tab-matstudio .ms-quiz-explainer,#tab-matstudio .ms-quiz-empty {font-size:.8rem;line-height:1.55;color:#cbdbe9;margin:0}
#tab-matstudio .ms-quiz-prompt {display:grid;gap:5px;padding:12px;border:1px solid #39546a;border-radius:10px;background:#0e1a29}
#tab-matstudio .ms-quiz-prompt strong {overflow-wrap:anywhere;color:#f0ffff}
#tab-matstudio .ms-quiz-prompt p {margin:0}
#tab-matstudio .ms-quiz-choices {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,185px),1fr));gap:8px}
#tab-matstudio .ms-quiz-button {
  min-width:0;min-height:44px;white-space:normal;overflow-wrap:anywhere;text-align:left;
  font:inherit;font-size:.8rem;font-weight:750;padding:10px 13px;cursor:pointer;
  border:1px solid #4b7787;border-radius:9px;background:#183d4b;color:#e7fafe;
}
#tab-matstudio .ms-quiz-button[data-answer="correct"]{background:#145b43;border-color:#8be6ba;color:#fff}
#tab-matstudio .ms-quiz-button[data-answer="incorrect"]{background:#5a2f33;border-color:#e99a94;color:#fff}
#tab-matstudio .ms-quiz-button:disabled{cursor:default;opacity:.88}
#tab-matstudio .ms-quiz-secondary {background:#213248;border-color:#4f6276}
#tab-matstudio .ms-quiz-result{margin:0;font-weight:750;color:#a8f1d9}
#tab-matstudio .ms-map-filters {
  display:flex;flex-wrap:wrap;gap:7px;align-items:center;min-width:0;
  padding:9px 0 12px;
}
#tab-matstudio .ms-map-filter-label,#tab-matstudio .ms-map-filter-count {font-size:.75rem;color:#c1d4e0}
#tab-matstudio .ms-map-filter {
  border:1px solid #415e75;background:#18283c;color:#d7e8f6;
  border-radius:8px;min-height:44px;padding:9px 11px;cursor:pointer;
  font-weight:700;font-size:.76rem;font-family:inherit;
}
#tab-matstudio .ms-map-filter[aria-pressed="true"] {background:#13515d;border-color:#7bdbe7;color:#fff}
#tab-matstudio .ms-graph-node.ms-filter-dimmed,
#tab-matstudio [data-edge-id].ms-filter-dimmed {opacity:.17}
#tab-matstudio .ms-reaction-quiz button:focus-visible,
#tab-matstudio .ms-map-filter:focus-visible {outline:2px solid #9df5ef;outline-offset:2px}
@media (max-width:600px){
  #tab-matstudio .ms-quiz-choices{grid-template-columns:minmax(0,1fr)}
  #tab-matstudio .ms-reaction-quiz,#tab-matstudio .ms-map-filters{max-width:100%;box-sizing:border-box}
}
@media(prefers-reduced-motion:reduce){#tab-matstudio .ms-map-filter,#tab-matstudio .ms-quiz-button{transition:none}}
