@font-face {
  font-family: 'Twemoji';
  src: url('./Twemoji-16.0.1.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

* {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  margin: 0;
  padding: 10px 12px;
  background: #f8fafc;
  color: #0f172a;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  min-height: 0;
}

.sandbox-workspace {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Top Control Deck */
.control-deck {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
}

.deck-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 6px 12px;
}

.deck-row-top {
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  border-top-left-radius: 7px;
  border-top-right-radius: 7px;
}

.action-label {
  font-size: 11px;
  font-weight: 700;
  color: #0284c7;
  white-space: nowrap;
}

.badge {
  background: #0284c7;
  color: #ffffff;
  font-weight: bold;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

/* IEC 63339 Badges & Tooltips */
.iec-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #7dd3fc;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: help;
  position: relative;
}

.iec-badge:hover .iec-tooltip {
  visibility: visible;
  opacity: 1;
}

.iec-tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  top: 130%;
  left: 0;
  z-index: 200;
  background: #0f172a;
  color: #f8fafc;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  line-height: 1.35;
  min-width: 250px;
  max-width: 320px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  transition: opacity 0.15s ease-in-out;
  pointer-events: none;
}

.iec-tooltip::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 14px;
  border-width: 5px;
  border-style: solid;
  border-color: transparent transparent #0f172a transparent;
}

.iec-badge.align-right .iec-tooltip {
  left: auto;
  right: -5px;
}

.iec-badge.align-right .iec-tooltip::after {
  left: auto;
  right: 20px;
}

/* Buttons & Inputs */
button {
  background: #0f172a;
  color: #ffffff;
  border: none;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

button:hover {
  background: #334155;
}

button.secondary {
  background: #e2e8f0;
  color: #0f172a;
}

button.secondary:hover {
  background: #cbd5e1;
}

button.danger {
  background: #ef4444;
}

button.danger:hover {
  background: #dc2626;
}

.btn-group {
  display: flex;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
  background: #ffffff;
  flex-shrink: 0;
}

.btn-group button {
  border-radius: 0;
  background: #ffffff;
  color: #475569;
  padding: 4px 9px;
  border-right: 1px solid #cbd5e1;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
}

.btn-group button:last-child {
  border-right: none;
}

.btn-group button.active {
  background: #0284c7;
  color: #ffffff;
}

.btn-group.flag-group button {
  font-family: 'Twemoji', system-ui, sans-serif;
  font-size: 14px;
  padding: 3px 7px;
}

.btn-group.mini-toggle button {
  font-size: 10px;
  padding: 2px 7px;
  text-transform: uppercase;
}

input,
select {
  padding: 4px 7px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 12px;
}

.divider {
  height: 18px;
  width: 1px;
  background: #cbd5e1;
  margin: 0 2px;
  flex-shrink: 0;
}

/* Main Split Workspace & Graph Canvas */
.main-container {
  display: flex;
  flex: 1;
  gap: 8px;
  min-height: 0;
}

#canvas-container {
  flex: 2;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  min-width: 25%;
}

#vis-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

#mermaid-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  overflow: auto;
  padding: 24px 24px 140px 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: #ffffff;
}

#mermaid-container svg {
  width: auto;
  height: auto;
  max-width: none;
}

/* Resizers */
.resizer {
  width: 7px;
  background-color: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  cursor: col-resize;
  transition: background-color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.resizer:hover,
.resizer.dragging {
  background-color: #94a3b8;
  border-color: #64748b;
}

.resizer-h {
  height: 7px;
  background-color: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  cursor: row-resize;
  transition: background-color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.resizer-h:hover,
.resizer-h.dragging {
  background-color: #94a3b8;
  border-color: #64748b;
}

body.no-select {
  user-select: none;
}

/* Canvas Overlays: Caption & Legend */
.graph-caption {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(4px);
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  font-size: 11px;
  font-weight: 700;
  color: #1e293b;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.graph-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(4px);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  font-size: 11px;
  color: #334155;
  z-index: 20;
  max-width: 330px;
}

.legend-title {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #475569;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 4px;
}

.legend-section {
  margin-top: 5px;
}

.legend-section-title {
  font-weight: 600;
  color: #64748b;
  font-size: 10px;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 3px;
  line-height: 1.25;
}

/* Legend Swatches */
.swatch-box-sys { width: 13px; height: 11px; background: #0284c7; border: 1px solid #0369a1; border-radius: 2px; margin-right: 8px; flex-shrink: 0; }
.swatch-box-elem { width: 13px; height: 11px; background: #64748b; border: 1px solid #475569; border-radius: 2px; margin-right: 8px; flex-shrink: 0; }
.swatch-box-4d { width: 13px; height: 11px; background: #4f46e5; border: 1px solid #3730a3; border-radius: 2px; margin-right: 8px; flex-shrink: 0; }
.swatch-box-state { width: 13px; height: 11px; background: #0d9488; border: 1px solid #0f766e; border-radius: 2px; margin-right: 8px; flex-shrink: 0; }
.swatch-diamond { width: 9px; height: 9px; background: #f59e0b; border: 1px solid #d97706; transform: rotate(45deg); margin: 0 10px 0 2px; flex-shrink: 0; }
.swatch-literal { width: 14px; height: 9px; background: #f1f5f9; border: 1px dashed #94a3b8; border-radius: 2px; margin-right: 8px; flex-shrink: 0; }
.swatch-line-active { width: 16px; height: 2px; background: #10b981; margin-right: 8px; flex-shrink: 0; }
.swatch-line-past { width: 16px; height: 0; border-top: 2px dashed #94a3b8; margin-right: 8px; flex-shrink: 0; }
.swatch-line-transition { width: 16px; height: 2px; background: #f59e0b; margin-right: 8px; flex-shrink: 0; }
.swatch-box-vehicle { width: 13px; height: 11px; background: #0284c7; border: 1px solid #0369a1; border-radius: 2px; margin-right: 8px; flex-shrink: 0; }
.swatch-box-slot { width: 13px; height: 11px; background: #64748b; border: 1px solid #475569; border-radius: 2px; margin-right: 8px; flex-shrink: 0; }
.swatch-box-part { width: 13px; height: 11px; background: #10b981; border: 1px solid #059669; border-radius: 2px; margin-right: 8px; flex-shrink: 0; }
.swatch-diamond-defect { width: 9px; height: 9px; background: #ef4444; border: 1px solid #dc2626; transform: rotate(45deg); margin: 0 10px 0 2px; flex-shrink: 0; }
.swatch-box-warehouse { width: 13px; height: 11px; background: #f97316; border: 1px solid #ea580c; border-radius: 2px; margin-right: 8px; flex-shrink: 0; }
.swatch-line-slot { width: 16px; height: 2px; background: #0284c7; margin-right: 8px; flex-shrink: 0; }
.swatch-line-mount { width: 16px; height: 2px; background: #10b981; margin-right: 8px; flex-shrink: 0; }
.swatch-line-store { width: 16px; height: 2px; background: #f97316; margin-right: 8px; flex-shrink: 0; }
.swatch-line-defect { width: 16px; height: 2px; background: #ef4444; margin-right: 8px; flex-shrink: 0; }

/* Right Sidebar Cards */
.sidebar {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 360px;
  min-height: 0;
}

.card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.card h4 {
  margin: 0 0 6px 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.card-scroll-body {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* BOM Tree & Badges */
ul.tree,
ul.tree ul {
  list-style-type: none;
  padding-left: 16px;
  margin: 2px 0;
}

ul.tree.root-tree {
  padding-left: 4px;
}

ul.tree li {
  position: relative;
  padding: 2px 0;
  font-size: 12.5px;
}

ul.tree ul li::before {
  content: "├─ ";
  color: #94a3b8;
}

ul.tree ul li:last-child::before {
  content: "└─ ";
  color: #94a3b8;
}

.bom-node-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.bom-class-badge {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 600;
}

.bom-defect-badge {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 700;
}

.null-badge {
  color: #94a3b8;
  font-style: italic;
  font-size: 10.5px;
}

/* Under the Bonnet & Live Query Tables */
.store-sub-header {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #475569;
  background: #f8fafc;
  padding: 3px 6px;
  border-left: 3px solid #0284c7;
  margin-bottom: 4px;
}

.storage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin-bottom: 4px;
}

th,
td {
  text-align: left;
  padding: 4px 6px;
  border-bottom: 1px solid #f1f5f9;
}

th {
  color: #64748b;
  font-weight: 600;
  background: #fafafa;
}

.active-row {
  background: #f0fdf4;
}

.closed-row {
  color: #94a3b8;
  text-decoration: line-through;
}

.empty-placeholder {
  color: #94a3b8;
  font-size: 11.5px;
  padding: 6px 4px;
  font-style: italic;
}

pre.code-block {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  color: #334155;
  line-height: 1.38;
  background: #f8fafc;
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  overflow-x: auto;
  white-space: pre-wrap;
}

pre.query-code-block {
  flex-shrink: 0;
  margin-bottom: 8px;
}

.query-result-box {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px 8px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.query-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  color: #334155;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 4px;
}

.defect-counter-badge {
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}

.defect-alert-zero {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.defect-alert-found {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

/* Main Menu / Landing View */
.landing-view {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 24px;
}

.menu-card {
  max-width: 540px;
  width: 100%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 36px 32px;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-height: calc(100vh - 48px);
}

.menu-badge {
  display: inline-block;
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #7dd3fc;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.menu-title {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 8px 0;
  letter-spacing: -0.02em;
}

.menu-subtitle {
  font-size: 13px;
  color: #64748b;
  margin: 0 0 28px 0;
  line-height: 1.5;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;

  flex: 1;
  overflow-y: auto; 
  min-height: 0; /* чтобы flex-скроллинг заработал */
  padding-right: 8px; /* Небольшой отступ, чтобы ползунок скролла не перекрывал кнопки */
}

.menu-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 16px 20px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  width: 100%;
  white-space: normal;
}

.menu-btn .btn-main-text {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.menu-btn .btn-sub-text {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.85;
  line-height: 1.35;
}

.menu-btn-primary {
  background: #0284c7;
  color: #ffffff;
  border-color: #0369a1;
}

.menu-btn-primary:hover {
  background: #0369a1;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
  transform: translateY(-1px);
}

.menu-btn-scenario {
  background: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
}

.menu-btn-scenario:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

/* Floating Home Button */
.floating-home-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #0f172a;
  color: #ffffff;
  border: 1px solid #334155;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

.floating-home-btn:hover {
  background: #1e293b;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.35);
}

.floating-home-btn:active {
  transform: translateY(0);
}

/* Floating Player Panel & Subtitles Overlay (Scenario Mode) */
.scenario-subtitles {
  position: fixed;
  bottom: 82px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
  text-align: center;
  max-width: 680px;
  min-width: 320px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
}

.scenario-player-panel {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #0f172a;
  color: #f8fafc;
  padding: 8px 18px;
  border-radius: 40px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  border: 1px solid #334155;
  user-select: none;
}

.player-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #1e293b;
  color: #ffffff;
  border: 1px solid #475569;
  cursor: pointer;
  padding: 0;
  font-size: 13px;
  transition: background-color 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}

.player-btn:hover {
  background: #334155;
  border-color: #64748b;
  transform: scale(1.05);
}

.player-btn:active {
  transform: scale(0.95);
}

.player-btn.active {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
}

.player-btn-cc {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-radius: 6px;
  width: 34px;
  height: 30px;
}

.player-progress {
  width: 240px;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #334155;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.player-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #38bdf8;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.player-progress::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #7dd3fc;
}

.player-progress::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #38bdf8;
  border: none;
  cursor: pointer;
}

.player-time {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: #94a3b8;
  min-width: 80px;
  text-align: center;
  user-select: none;
}

/* Phantom User UI Highlight (Scenario Mode) */
.scenario-highlight {
  box-shadow: 0 0 10px 3px rgba(255, 215, 0, 0.8) !important;
  background-color: rgba(255, 255, 200, 0.3) !important;
  transition: all 0.3s ease;
}

/* Подсветка активного элемента во время демонстрационного тура */
@keyframes tourPulse {
  0% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(79, 70, 229, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}

.tour-pulse-highlight {
  outline: 2px solid #4f46e5 !important;
  outline-offset: 2px;
  animation: tourPulse 1.8s infinite;
  position: relative;
  z-index: 30;
}

/* Настройки для контейнера Mermaid */
#mermaid-container {
  overflow: auto; /* Включаем вертикальный и горизонтальный скролл */
  width: 100%;
  height: 100%;
  padding: 20px;
}

/* Запрещаем браузеру сжимать SVG-граф, сохраняя его 100% масштаб */
#mermaid-container svg {
  max-width: none !important; 
  height: auto;
  min-width: 100%; /* Граф не будет меньше ширины экрана, но сможет стать больше */
}

/* --- Fullscreen Narrative Figure Overlay (./figures/) --- */
.figure-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  z-index: 850;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px 24px 110px 24px;
  animation: fadeInFigure 0.35s ease;
}

@keyframes fadeInFigure {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.figure-modal-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 24px;
  max-width: 960px;
  width: 92%;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  border: 2px solid #4f46e5;
  position: relative;
}

.figure-modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: #f1f5f9;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
}

.figure-modal-img {
  max-width: 100%;
  max-height: 56vh;
  object-fit: contain;
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.figure-modal-caption {
  margin-top: 14px;
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
  text-align: center;
}

.figure-modal-attribution {
  margin-top: 6px;
  font-size: 12px;
  color: #64748b;
  text-align: center;
}

.figure-modal-attribution a {
  color: #0284c7;
  text-decoration: underline;
}

/* --- QDIKW Stage Progress & Role Banner --- */
.qdikw-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, #0f172a 0%, #1e293b 100%);
  color: #f8fafc;
  padding: 6px 14px;
  border-bottom: 2px solid #4f46e5;
  gap: 12px;
  flex-wrap: wrap;
}

.qdikw-steps {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qdikw-step-pill {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #334155;
  color: #94a3b8;
  border: 1px solid #475569;
  cursor: pointer;
  transition: all 0.2s;
}

.qdikw-step-pill.active {
  background: #4f46e5;
  color: #ffffff;
  border-color: #818cf8;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.6);
  transform: scale(1.05);
}

.qdikw-role-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
}

.qdikw-role-name {
  background: #f59e0b;
  color: #0f172a;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
}

.qdikw-role-desc {
  color: #cbd5e1;
}

/* --- SMRM Semantic Rules & Slot Context Toolbar --- */
.smrm-rules-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f5f3ff;
  border-top: 1px solid #ddd6fe;
  padding: 5px 12px;
  font-size: 11px;
  flex-wrap: wrap;
}

.rule-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #c4b5fd;
  color: #4c1d95;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.rule-chip.active {
  background: #6d28d9;
  color: #ffffff;
  border-color: #5b21b6;
}

/* --- Amber Highlight for Active Operations --- */
@keyframes amberPulse {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.85); }
  70% { box-shadow: 0 0 0 9px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.tour-amber-highlight {
  outline: 2.5px solid #f59e0b !important;
  outline-offset: 2px;
  animation: amberPulse 1.6s infinite;
  position: relative;
  z-index: 35;
}

/* --- Wisdom & Blind Spot Cards --- */
.wisdom-directive-card {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #fef2f2;
  border-left: 4px solid #dc2626;
  color: #7f1d1d;
  font-size: 11px;
}

.blindspot-warning-card {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #fffbeb;
  border-left: 4px solid #f59e0b;
  color: #78350f;
  font-size: 11px;
}

/* --- Distinct Legend Swatches for Inferred Knowledge & Wisdom --- */
.swatch-inf-stress {
  width: 14px;
  height: 12px;
  background: #7c3aed;
  border: 2px dashed #ddd6fe;
  border-radius: 2px;
  flex-shrink: 0;
}

.swatch-inf-hazard {
  width: 14px;
  height: 12px;
  background: #be123c;
  border: 1.5px dashed #fecdd3;
  clip-path: polygon(20% 0%, 80% 0%, 100% 50%, 80% 100%, 20% 100%, 0% 50%);
  flex-shrink: 0;
}

.swatch-wisdom-dir {
  width: 14px;
  height: 12px;
  background: #059669;
  border: 1.5px solid #065f46;
  clip-path: polygon(15% 0%, 85% 0%, 100% 100%, 0% 100%);
  flex-shrink: 0;
}

.swatch-blind-spot {
  width: 14px;
  height: 12px;
  background: #fef08a;
  border: 1.5px solid #ca8a04;
  transform: skewX(-15deg);
  flex-shrink: 0;
}

.swatch-line-inference {
  width: 18px;
  height: 0;
  border-top: 2.5px dashed #8b5cf6;
  flex-shrink: 0;
}

.swatch-box-state-past {
  width: 14px;
  height: 14px;
  background: #94a3b8;
  border: 1.5px dashed #64748b;
  border-radius: 2px;
  flex-shrink: 0;
}

/* --- Accurate Legend Swatch Shapes matching Mermaid & Vis --- */
.swatch-pill-quality {
  width: 16px;
  height: 11px;
  background: #f59e0b;
  border: 1.5px solid #b45309;
  border-radius: 999px;
  flex-shrink: 0;
}

.swatch-hex-statement {
  width: 16px;
  height: 12px;
  background: #fbbf24;
  border: 1.5px dashed #78350f;
  clip-path: polygon(22% 0%, 78% 0%, 100% 50%, 78% 100%, 22% 100%, 0% 50%);
  flex-shrink: 0;
}

.swatch-diamond-defect {
  width: 16px;
  height: 12px;
  background: #ef4444;
  border: 1.5px solid #991b1b;
  clip-path: polygon(22% 0%, 78% 0%, 100% 50%, 78% 100%, 22% 100%, 0% 50%);
  transform: none;
  flex-shrink: 0;
}

/* --- Menu Action Row with Shareable Link Button --- */
.menu-action-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}

.menu-action-row > .menu-btn {
  flex: 1;
}

.menu-share-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.menu-share-btn:hover {
  background: #e0f2fe;
  border-color: #0284c7;
  color: #0369a1;
  transform: translateY(-1px);
}

.menu-share-btn.copied {
  background: #dcfce7;
  border-color: #16a34a;
  color: #15803d;
  font-size: 12px;
  font-weight: 700;
}

/* --- Scenario Chapters Navigation Bar --- */
.scenario-chapters-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: linear-gradient(90deg, #0f172a 0%, #1e293b 100%);
  border-bottom: 1px solid #334155;
  overflow-x: auto;
}

.scenario-chapters-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  margin-right: 6px;
  white-space: nowrap;
}

.chapter-pill {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #475569;
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.chapter-pill:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  color: #ffffff;
}

.chapter-pill.active {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35);
}

/* --- Академическая атрибуция на главной странице --- */
.inspiration-block {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed #cbd5e1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0; /* Гарантирует, что блок не сплющится при длинном списке сценариев */
}

.inspiration-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.05em;
}

.inspiration-title {
  font-size: 12px;
  font-weight: 600;
  color: #0284c7;
  text-decoration: none;
  text-align: center;
  transition: color 0.2s ease;
}

.inspiration-title:hover {
  color: #0369a1;
  text-decoration: underline;
}

.inspiration-meta {
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.inspiration-divider {
  color: #cbd5e1;
  font-size: 10px;
}