.mpo-app {
  --mpo-bg: #f4f7fb;
  --mpo-panel: #ffffff;
  --mpo-ink: #172033;
  --mpo-muted: #64748b;
  --mpo-line: #dbe4ee;
  --mpo-accent: #2563eb;
  --mpo-accent-soft: #dbeafe;
  --mpo-shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
  background: linear-gradient(180deg, #f7fbff 0%, #eff5fb 100%);
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  color: var(--mpo-ink);
  box-shadow: var(--mpo-shadow);
  overflow: hidden;
}

body.mpo-viewer-open {
  overflow: hidden;
}

.mpo-app * {
  box-sizing: border-box;
}

.mpo-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 32px 20px;
  background: radial-gradient(circle at top right, rgba(37, 99, 235, 0.1), transparent 40%), #ffffff;
  border-bottom: 1px solid var(--mpo-line);
}

.mpo-eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: #2563eb;
  font-weight: 700;
}

.mpo-toolbar h2 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.1;
}

.mpo-subtitle,
.mpo-strip-caption,
.mpo-stage-header p,
.mpo-empty-copy,
.mpo-modal-card p,
.mpo-modal-hint {
  margin: 0;
  color: var(--mpo-muted);
  line-height: 1.5;
}

.mpo-toolbar-actions {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.mpo-file-button,
.mpo-primary-button,
.mpo-secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 999px;
  padding: 0 18px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.mpo-file-button,
.mpo-primary-button {
  background: var(--mpo-accent);
  color: #fff;
  border: none;
}

.mpo-secondary-button {
  background: #fff;
  color: var(--mpo-ink);
  border: 1px solid var(--mpo-line);
}

.mpo-primary-button[disabled],
.mpo-secondary-button[disabled] {
  cursor: not-allowed;
  opacity: 0.6;
}

.mpo-file-button input {
  display: none;
}

.mpo-banner,
.mpo-file-strip,
.mpo-panel,
.mpo-stage,
.mpo-modal-card {
  background: var(--mpo-panel);
}

.mpo-banner {
  margin: 20px 24px 20px;
  border: 1px solid #dbeafe;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 16px;
  padding: 14px 16px;
}

.mpo-file-strip {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 24px 20px;
  align-items: flex-start;
}

.mpo-file-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mpo-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  background: var(--mpo-accent-soft);
  color: #1e3a8a;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}

.mpo-chip-text {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mpo-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 999px;
  background: rgba(30, 58, 138, 0.14);
  color: #1e3a8a;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.mpo-chip-remove:hover,
.mpo-chip-remove:focus-visible {
  background: rgba(30, 58, 138, 0.22);
  color: #172554;
  transform: scale(1.04);
}

.mpo-chip-muted {
  background: #e2e8f0;
  color: #475569;
}

.mpo-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
  padding: 24px;
}

.mpo-layout-launcher {
  display: block;
}

.mpo-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mpo-layout-launcher .mpo-sidebar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.mpo-layout-launcher .mpo-panel-priority {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.mpo-panel {
  border: 1px solid var(--mpo-line);
  border-radius: 20px;
  padding: 18px;
}

.mpo-panel h3,
.mpo-stage-header h3,
.mpo-modal-card h3,
.mpo-viewer-copy h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.mpo-facts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.mpo-facts li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--mpo-line);
  padding-top: 12px;
}

.mpo-facts li:first-child {
  border-top: none;
  padding-top: 0;
}

.mpo-facts span {
  color: var(--mpo-muted);
}

.mpo-session-list {
  display: grid;
  gap: 10px;
}

.mpo-priority-panel {
  display: grid;
  gap: 10px;
}

.mpo-priority-copy {
  font-size: 12px;
}

.mpo-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--mpo-text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.mpo-toggle input[type="checkbox"] {
  margin: 2px 0 0;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  accent-color: var(--mpo-accent, #2563eb);
}

.mpo-inferred-toggle + .mpo-priority-copy {
  margin-top: -2px;
}

.mpo-priority-list {
  display: grid;
  gap: 8px;
}

.mpo-priority-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--mpo-line);
  border-radius: 14px;
  background: #f8fbff;
  cursor: grab;
}

.mpo-priority-item.is-dragging {
  opacity: 0.6;
}

.mpo-priority-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--mpo-accent-soft);
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
}

.mpo-priority-label {
  display: grid;
  gap: 2px;
}

.mpo-priority-label strong {
  font-size: 13px;
}

.mpo-priority-label span {
  color: var(--mpo-muted);
  font-size: 12px;
}

.mpo-priority-handle {
  color: var(--mpo-muted);
  font-size: 16px;
  letter-spacing: 0.08em;
}

.mpo-match-summary {
  display: grid;
  gap: 10px;
}

.mpo-heat-legend {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(191, 219, 254, 0.9);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(241, 245, 249, 0.94)),
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.12), transparent 45%);
}

.mpo-heat-legend-copy {
  display: grid;
  gap: 2px;
}

.mpo-heat-legend-copy strong {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #0f172a;
}

.mpo-heat-legend-copy span {
  color: var(--mpo-muted);
  font-size: 12px;
  line-height: 1.4;
}

.mpo-heat-spectrum {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #1d4ed8 0%, #38bdf8 22%, #22c55e 50%, #facc15 72%, #f97316 86%, #dc2626 100%);
  box-shadow:
    inset 0 0 0 1px rgba(148, 163, 184, 0.45),
    0 4px 18px rgba(59, 130, 246, 0.12);
}

.mpo-heat-labels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  color: var(--mpo-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mpo-heat-labels span:nth-child(2) {
  text-align: center;
}

.mpo-heat-labels span:last-child {
  text-align: right;
}

.mpo-match-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mpo-stat-pill,
.mpo-status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.mpo-stat-pill {
  background: #e2e8f0;
  color: #334155;
}

.mpo-stat-high,
.mpo-status-high {
  background: #fee2e2;
  color: #b91c1c;
}

.mpo-stat-low,
.mpo-status-low {
  background: #dbeafe;
  color: #1d4ed8;
}

.mpo-stat-normal,
.mpo-status-normal {
  background: #dcfce7;
  color: #15803d;
}

.mpo-status-unknown {
  background: #e2e8f0;
  color: #475569;
}

.mpo-session-card {
  display: grid;
  gap: 4px;
  border: 1px solid var(--mpo-line);
  border-radius: 14px;
  padding: 12px;
}

.mpo-session-card span {
  color: var(--mpo-muted);
  font-size: 13px;
}

.mpo-match-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 12px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
  min-width: 0;
}

.mpo-match-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--mpo-line);
  border-radius: 14px;
  background: #f8fbff;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  box-shadow: inset 3px 0 0 var(--mpo-match-accent, transparent);
  width: 100%;
  min-width: 0;
}

.mpo-match-card:hover,
.mpo-match-card:focus-visible {
  border-color: var(--mpo-match-accent, #93c5fd);
  box-shadow:
    inset 3px 0 0 var(--mpo-match-accent, transparent),
    0 10px 24px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
  outline: none;
}

.mpo-match-card.is-active {
  border-color: var(--mpo-match-accent, rgba(14, 116, 144, 0.55));
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.12), transparent 44%),
    linear-gradient(180deg, rgba(240, 249, 255, 0.96), rgba(236, 253, 245, 0.94));
  box-shadow:
    inset 3px 0 0 var(--mpo-match-accent, transparent),
    0 16px 36px rgba(14, 116, 144, 0.16);
}

.mpo-match-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  min-width: 0;
}

.mpo-match-header strong {
  font-size: 14px;
  line-height: 1.3;
}

.mpo-match-header-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.mpo-match-subtitle {
  color: var(--mpo-muted);
  font-size: 12px;
  line-height: 1.4;
}

.mpo-match-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.mpo-overlay-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  border: 1px solid color-mix(in srgb, var(--mpo-match-accent, #94a3b8) 42%, white);
  background: color-mix(in srgb, var(--mpo-match-accent, #94a3b8) 12%, white);
  color: #0f172a;
  font-size: 11px;
  font-weight: 700;
}

.mpo-overlay-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--mpo-match-accent, #94a3b8);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--mpo-match-accent, #94a3b8) 18%, white);
}

.mpo-match-meta,
.mpo-match-range,
.mpo-match-deviation {
  color: var(--mpo-muted);
  font-size: 12px;
  line-height: 1.4;
}

.mpo-match-value-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.mpo-match-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--mpo-ink);
}

.mpo-observation-list {
  display: grid;
  gap: 8px;
  margin-top: 4px;
  min-width: 0;
}

.mpo-observation-row {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(219, 228, 238, 0.9);
  background: rgba(255, 255, 255, 0.78);
  min-width: 0;
}

.mpo-observation-row.is-winner {
  border-color: color-mix(in srgb, var(--mpo-match-accent, #94a3b8) 40%, white);
  background: color-mix(in srgb, var(--mpo-match-accent, #94a3b8) 8%, white);
}

.mpo-observation-header,
.mpo-observation-value-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  min-width: 0;
}

.mpo-observation-source {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.mpo-observation-source strong {
  font-size: 12px;
}

.mpo-observation-source span,
.mpo-observation-note {
  color: var(--mpo-muted);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.mpo-observation-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--mpo-ink);
}

.mpo-observation-range {
  color: var(--mpo-muted);
  font-size: 11px;
}

.mpo-stage {
  border: 1px solid var(--mpo-line);
  border-radius: 24px;
  padding: 18px;
  min-width: 0;
}

.mpo-stage-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.mpo-stage-actions {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.mpo-zoom-controls {
  display: grid;
  gap: 6px;
  justify-items: end;
  min-width: 0;
}

.mpo-zoom-button-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.mpo-zoom-hint,
.mpo-zoom-readout {
  color: var(--mpo-muted);
  font-size: 12px;
  line-height: 1.4;
}

.mpo-zoom-hint {
  max-width: 430px;
  text-align: right;
  text-wrap: pretty;
}

.mpo-zoom-button {
  min-width: 42px;
  min-height: 36px;
  padding: 0 12px;
}

.mpo-zoom-readout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(203, 213, 225, 0.9);
  font-weight: 700;
  color: var(--mpo-ink);
  font-size: 12px;
}

.mpo-diagram-shell {
  border-radius: 20px;
  min-height: 540px;
  background: linear-gradient(180deg, #f8fbff 0%, #f3f7fc 100%);
  border: 1px dashed #cbd5e1;
  overflow: auto;
  position: relative;
  cursor: grab;
  overscroll-behavior: contain;
}

.mpo-diagram-canvas {
  padding: 20px;
  min-width: 100%;
  min-height: 100%;
  position: relative;
}

.mpo-diagram-shell.is-dragging,
.mpo-viewer-shell.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.mpo-viewer[hidden] {
  display: none;
}

.mpo-viewer {
  position: fixed;
  inset: 12px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 28%),
    rgba(241, 245, 249, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 28px;
  box-shadow: 0 32px 120px rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(14px);
}

.mpo-viewer-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
  column-gap: 14px;
  row-gap: 6px;
}

.mpo-viewer-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
}

.mpo-viewer-title-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.mpo-viewer-title-row .mpo-eyebrow {
  margin: 0;
  white-space: nowrap;
}

.mpo-viewer-copy h3 {
  margin: 0;
  font-size: 22px;
  line-height: 1.08;
  min-width: 0;
}

.mpo-viewer-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.mpo-viewer-copy [data-mpo-viewer-status],
.mpo-viewer-topbar .mpo-viewer-nav-hint {
  margin: 0;
  color: var(--mpo-muted);
  font-size: 12px !important;
  line-height: 1.35;
}

.mpo-viewer-topbar .mpo-viewer-nav-hint {
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.mpo-viewer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: flex-start;
  flex: 0 0 auto;
}

.mpo-close-icon {
  display: none;
  font-size: 24px;
  line-height: 1;
}

.mpo-viewer-mobile-controls {
  display: none;
}

.mpo-viewer-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 12px;
  grid-template-areas: "sidebar stage";
}

.mpo-viewer-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
  grid-area: sidebar;
}

.mpo-viewer-stage {
  min-width: 0;
  min-height: 0;
  grid-area: stage;
}

.mpo-viewer-shell {
  height: 100%;
  min-height: 0;
  border-radius: 24px;
  background: linear-gradient(180deg, #f8fbff 0%, #eef4fb 100%);
  border: 1px solid #cbd5e1;
  overflow: auto;
  position: relative;
  cursor: grab;
  overscroll-behavior: contain;
}

.mpo-viewer-loading[hidden] {
  display: none;
}

.mpo-viewer-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.76), rgba(226, 232, 240, 0.84));
  backdrop-filter: blur(8px);
}

.mpo-viewer-loading-card {
  min-width: min(360px, 100%);
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 26px;
  text-align: center;
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  background:
    radial-gradient(circle at top, rgba(59, 130, 246, 0.14), transparent 52%),
    rgba(255, 255, 255, 0.92);
  box-shadow: 0 22px 56px rgba(15, 23, 42, 0.16);
}

.mpo-viewer-loading-card strong {
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.mpo-viewer-loading-card p {
  margin: 0;
  color: var(--mpo-muted);
}

.mpo-viewer-loading-spinner {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 3px solid rgba(148, 163, 184, 0.28);
  border-top-color: #2563eb;
  border-right-color: #0ea5e9;
  box-shadow: 0 0 0 8px rgba(37, 99, 235, 0.08);
  animation: mpo-spin 0.9s linear infinite;
}

.mpo-viewer-canvas {
  padding: 24px;
  min-width: 100%;
  min-height: 100%;
  position: relative;
}

@keyframes mpo-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.mpo-diagram-shell .mxgraph,
.mpo-viewer-shell .mxgraph {
  transform-origin: 0 0;
  will-change: transform;
}

svg [data-mpo-highlight-target] {
  cursor: pointer;
}

svg [data-mpo-highlight-target] .mpo-highlight-glow,
svg [data-mpo-highlight-target] .mpo-highlight-fill,
svg [data-mpo-highlight-target] .mpo-highlight-frame {
  transition: opacity 0.18s ease, stroke-width 0.18s ease;
}

svg [data-mpo-highlight-target] .mpo-highlight-glow {
  opacity: var(--mpo-highlight-glow-opacity, 0.18);
}

svg [data-mpo-highlight-target] .mpo-highlight-fill {
  opacity: var(--mpo-highlight-fill-opacity, 0.12);
}

svg [data-mpo-highlight-target] .mpo-highlight-frame {
  opacity: var(--mpo-highlight-frame-opacity, 0.58);
  stroke-width: var(--mpo-highlight-frame-width, 1px);
}

svg [data-mpo-highlight-target].is-hovered .mpo-highlight-glow,
svg [data-mpo-highlight-target].is-focus-flash .mpo-highlight-glow {
  opacity: calc(var(--mpo-highlight-glow-opacity, 0.18) + 0.1);
}

svg [data-mpo-highlight-target].is-hovered .mpo-highlight-fill,
svg [data-mpo-highlight-target].is-focus-flash .mpo-highlight-fill {
  opacity: calc(var(--mpo-highlight-fill-opacity, 0.12) + 0.1);
}

svg [data-mpo-highlight-target].is-hovered .mpo-highlight-frame,
svg [data-mpo-highlight-target].is-focus-flash .mpo-highlight-frame {
  opacity: 0.86;
  stroke-width: calc(var(--mpo-highlight-frame-width, 1px) + 0.35px);
}

.mpo-modal[hidden] {
  display: none;
}

.mpo-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 9999;
}

.mpo-modal-card {
  width: min(460px, 100%);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 32px 64px rgba(15, 23, 42, 0.2);
}

.mpo-modal-card label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
}

.mpo-modal-card input[type="date"] {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--mpo-line);
  padding: 0 12px;
  margin-bottom: 12px;
}

.mpo-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

html[data-theme="dark"] .mpo-app {
  --mpo-bg: #020617;
  --mpo-panel: rgba(15, 23, 42, 0.9);
  --mpo-ink: #e2e8f0;
  --mpo-muted: #94a3b8;
  --mpo-line: #334155;
  --mpo-accent: #60a5fa;
  --mpo-accent-soft: rgba(96, 165, 250, 0.18);
  --mpo-shadow: 0 32px 84px rgba(2, 6, 23, 0.56);
  color-scheme: dark;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.96) 0%, rgba(2, 6, 23, 0.98) 100%);
  border-color: rgba(51, 65, 85, 0.9);
}

html[data-theme="dark"] .mpo-app .mpo-toolbar {
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.14), transparent 40%),
    rgba(15, 23, 42, 0.96);
  border-bottom-color: rgba(51, 65, 85, 0.9);
}

html[data-theme="dark"] .mpo-app .mpo-toolbar h2 {
  color: #f8fafc;
}

html[data-theme="dark"] .mpo-app .mpo-banner {
  background: rgba(15, 23, 42, 0.88);
  border-color: rgba(59, 130, 246, 0.24);
  color: #bfdbfe;
}

html[data-theme="dark"] .mpo-app .mpo-file-button,
html[data-theme="dark"] .mpo-app .mpo-secondary-button {
  background: rgba(15, 23, 42, 0.88);
  color: var(--mpo-ink);
  border-color: var(--mpo-line);
}

html[data-theme="dark"] .mpo-app .mpo-primary-button {
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.24);
}

html[data-theme="dark"] .mpo-app .mpo-chip {
  background: rgba(37, 99, 235, 0.18);
  color: #dbeafe;
}

html[data-theme="dark"] .mpo-app .mpo-chip-remove {
  background: rgba(37, 99, 235, 0.26);
  color: #dbeafe;
}

html[data-theme="dark"] .mpo-app .mpo-chip-remove:hover,
html[data-theme="dark"] .mpo-app .mpo-chip-remove:focus-visible {
  background: rgba(37, 99, 235, 0.36);
  color: #eff6ff;
}

html[data-theme="dark"] .mpo-app .mpo-chip-muted {
  background: rgba(30, 41, 59, 0.9);
  color: #cbd5e1;
}

html[data-theme="dark"] .mpo-app .mpo-panel,
html[data-theme="dark"] .mpo-app .mpo-file-strip,
html[data-theme="dark"] .mpo-app .mpo-stage,
html[data-theme="dark"] .mpo-app .mpo-modal-card {
  background: rgba(15, 23, 42, 0.9);
  border-color: var(--mpo-line);
}

html[data-theme="dark"] .mpo-app .mpo-session-card,
html[data-theme="dark"] .mpo-app .mpo-priority-item,
html[data-theme="dark"] .mpo-app .mpo-match-card,
html[data-theme="dark"] .mpo-app .mpo-observation-row {
  background: rgba(15, 23, 42, 0.88);
  border-color: var(--mpo-line);
}

html[data-theme="dark"] .mpo-app .mpo-priority-rank {
  background: rgba(37, 99, 235, 0.18);
  color: #dbeafe;
}

html[data-theme="dark"] .mpo-app .mpo-heat-legend {
  border-color: rgba(51, 65, 85, 0.95);
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.84)),
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.1), transparent 45%);
}

html[data-theme="dark"] .mpo-app .mpo-heat-legend-copy strong {
  color: #e2e8f0;
}

html[data-theme="dark"] .mpo-app .mpo-stat-pill {
  background: rgba(30, 41, 59, 0.92);
  color: #cbd5e1;
}

html[data-theme="dark"] .mpo-app .mpo-match-card {
  background: rgba(15, 23, 42, 0.88);
}

html[data-theme="dark"] .mpo-app .mpo-match-card:hover,
html[data-theme="dark"] .mpo-app .mpo-match-card:focus-visible {
  border-color: rgba(96, 165, 250, 0.44);
  box-shadow:
    inset 3px 0 0 var(--mpo-match-accent, transparent),
    0 10px 24px rgba(2, 6, 23, 0.4);
}

html[data-theme="dark"] .mpo-app .mpo-match-card.is-active {
  border-color: color-mix(in srgb, var(--mpo-match-accent, #94a3b8) 40%, var(--mpo-line));
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.12), transparent 44%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.84));
  box-shadow:
    inset 3px 0 0 var(--mpo-match-accent, transparent),
    0 16px 36px rgba(2, 6, 23, 0.36);
}

html[data-theme="dark"] .mpo-app .mpo-overlay-badge {
  border-color: color-mix(in srgb, var(--mpo-match-accent, #94a3b8) 34%, var(--mpo-panel));
  background: color-mix(in srgb, var(--mpo-match-accent, #94a3b8) 18%, var(--mpo-panel));
  color: var(--mpo-ink);
}

html[data-theme="dark"] .mpo-app .mpo-overlay-dot {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--mpo-match-accent, #94a3b8) 18%, var(--mpo-panel));
}

html[data-theme="dark"] .mpo-app .mpo-observation-row.is-winner {
  border-color: color-mix(in srgb, var(--mpo-match-accent, #94a3b8) 40%, var(--mpo-line));
  background: color-mix(in srgb, var(--mpo-match-accent, #94a3b8) 10%, var(--mpo-panel));
}

html[data-theme="dark"] .mpo-app .mpo-zoom-readout {
  background: rgba(15, 23, 42, 0.9);
  border-color: var(--mpo-line);
  color: var(--mpo-ink);
}

html[data-theme="dark"] .mpo-app .mpo-diagram-shell {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.94) 0%, rgba(2, 6, 23, 0.92) 100%);
  border-color: rgba(71, 85, 105, 0.7);
}

html[data-theme="dark"] .mpo-app .mpo-viewer {
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 28%),
    rgba(2, 6, 23, 0.94);
  border-color: rgba(51, 65, 85, 0.65);
  box-shadow: 0 32px 120px rgba(2, 6, 23, 0.62);
}

html[data-theme="dark"] .mpo-app .mpo-viewer-shell {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.92), rgba(2, 6, 23, 0.98));
  border-color: rgba(51, 65, 85, 0.72);
}

html[data-theme="dark"] .mpo-app .mpo-viewer-shell .mxgraph {
  color-scheme: dark !important;
}

html[data-theme="dark"] .mpo-app .mpo-viewer-shell .mxgraph [style*="color: light-dark(#0000FF, #cdcdff)"] {
  color: #2af !important;
}

html[data-theme="dark"] .mpo-app .mpo-viewer-shell .mxgraph [style*="color: light-dark(#99CCFF, #1e4a76)"] {
  color: rgb(66, 146, 227) !important;
}

html[data-theme="dark"] .mpo-app .mpo-viewer-shell .mxgraph [style*="color: light-dark(rgb(204, 204, 0), rgb(87, 87, 0))"] {
  color: rgb(177, 177, 10) !important;
}

html[data-theme="dark"] .mpo-app .mpo-viewer-loading {
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.72), rgba(15, 23, 42, 0.9));
}

html[data-theme="dark"] .mpo-app .mpo-viewer-loading-card {
  border-color: rgba(51, 65, 85, 0.9);
  background:
    radial-gradient(circle at top, rgba(96, 165, 250, 0.16), transparent 52%),
    rgba(15, 23, 42, 0.94);
  box-shadow: 0 22px 56px rgba(2, 6, 23, 0.38);
}

html[data-theme="dark"] .mpo-app .mpo-viewer-loading-spinner {
  border-color: rgba(148, 163, 184, 0.24);
  border-top-color: #60a5fa;
  border-right-color: #38bdf8;
  box-shadow: 0 0 0 8px rgba(37, 99, 235, 0.12);
}

html[data-theme="dark"] .mpo-app .mpo-modal {
  background: rgba(2, 6, 23, 0.7);
}

html[data-theme="dark"] .mpo-app .mpo-modal-card input[type="date"] {
  background: rgba(15, 23, 42, 0.9);
  color: var(--mpo-ink);
}

@media (max-width: 1100px) {
  .mpo-layout {
    grid-template-columns: 1fr;
  }

  .mpo-layout-launcher .mpo-sidebar {
    grid-template-columns: 1fr;
  }

  .mpo-layout-launcher .mpo-panel-priority {
    grid-column: auto;
    grid-row: auto;
  }

  .mpo-toolbar,
  .mpo-file-strip,
  .mpo-stage-header {
    flex-direction: column;
  }

  .mpo-file-list {
    justify-content: flex-start;
  }

  .mpo-viewer-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 6px;
  }

  .mpo-zoom-controls {
    justify-items: start;
  }

  .mpo-viewer-actions .mpo-zoom-controls {
    display: none;
  }

  .mpo-close-button {
    min-width: 40px;
    width: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: 999px;
  }

  .mpo-close-label {
    display: none;
  }

  .mpo-close-icon {
    display: inline-block;
  }

  .mpo-zoom-hint,
  .mpo-viewer-nav-hint {
    max-width: none;
    text-align: left;
    white-space: normal;
  }

  .mpo-viewer {
    inset: 0;
    border-radius: 0;
    padding: 12px;
  }

  .mpo-viewer-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 2fr) auto minmax(0, 3fr);
    grid-template-areas:
      "sidebar"
      "controls"
      "stage";
  }

  .mpo-viewer-sidebar {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
  }

  .mpo-viewer-mobile-controls {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    grid-area: controls;
    min-width: 0;
  }

  .mpo-zoom-controls-mobile {
    justify-items: start;
  }

  .mpo-viewer-stage,
  .mpo-viewer-shell {
    min-height: 0;
    height: 100%;
  }

  .mpo-viewer-copy h3 {
    font-size: 20px;
  }

  .mpo-viewer-canvas {
    min-width: 100%;
    padding: 18px;
  }
}

@media (max-width: 640px) {
  .mpo-viewer {
    gap: 10px;
    padding: 10px;
  }

  .mpo-viewer-topbar {
    row-gap: 4px;
  }

  .mpo-viewer-title-row {
    gap: 8px;
  }

  .mpo-viewer-copy h3 {
    font-size: 18px;
  }

  .mpo-viewer-copy [data-mpo-viewer-status],
  .mpo-viewer-topbar .mpo-viewer-nav-hint {
    font-size: 11px !important;
  }

  .mpo-viewer-layout {
    gap: 10px;
  }

  .mpo-viewer-mobile-controls .mpo-zoom-button-row {
    gap: 4px;
  }

  .mpo-close-button {
    min-width: 36px;
    width: 36px;
    min-height: 36px;
  }

  .mpo-viewer-canvas {
    padding: 14px;
  }
}
