/* ================================================================
   Sherwin Universe — Mini-App Shared Styles
   Base styles used by ALL mini-apps / simulations.
   Each game can add scoped overrides via its own class.
   ================================================================ */

/* --- Canvas container -------------------------------------------- */
.miniapp-container {
  position: relative;
  width: 100%;
  height: 75vh;
  min-height: 500px;
  border-radius: 12px;
  overflow: hidden;
  background: #080810;
}
@media (min-width: 768px) {
  .miniapp-container { height: 80vh; }
}

/* --- Overlay panels ---------------------------------------------- */
.miniapp-panel {
  position: absolute;
  z-index: 20;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(10, 10, 20, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e5e7eb;
  font-size: 13px;
  max-height: 50%;
  overflow-y: auto;
  pointer-events: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.miniapp-panel--top-left     { top: 12px;  left: 12px;  max-width: 240px; }
.miniapp-panel--top-right    { top: 12px;  right: 12px; max-width: 220px; }
.miniapp-panel--bottom-left  { bottom: 12px; left: 12px;  max-width: 260px; }
.miniapp-panel--bottom-right { bottom: 12px; right: 12px; max-width: 240px; }

.miniapp-mobile-dock {
  display: none;
}

.miniapp-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px), (max-width: 960px) and (max-height: 540px) and (orientation: landscape) {
  .miniapp-container {
    height: min(74vh, 700px);
    min-height: 430px;
  }

  .miniapp-panel {
    top: auto !important;
    right: 12px !important;
    bottom: 72px !important;
    left: 12px !important;
    width: auto !important;
    max-width: none !important;
    max-height: min(34%, 260px);
    padding: 10px 11px;
    font-size: 11px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(16px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
  }

  .miniapp-panel.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }

  .miniapp-mobile-dock {
    position: absolute;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 24;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 7px;
    border-radius: 14px;
    background: rgba(6, 10, 18, 0.9);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  }

  .miniapp-mobile-tab {
    position: relative;
    min-width: 0;
    min-height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 11px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: #d1d5db;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .miniapp-mobile-tab.is-active {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fff;
  }

  .miniapp-mobile-tab-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
  }

  .miniapp-mobile-tab-icon svg {
    width: 100%;
    height: 100%;
  }

  .miniapp-mobile-hint {
    position: absolute;
    right: 12px;
    bottom: 72px;
    left: 12px;
    z-index: 25;
    padding: 9px 12px;
    border-radius: 12px;
    background: rgba(10, 10, 20, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #d1d5db;
    font-size: 11px;
    line-height: 1.4;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
  }

  .miniapp-mobile-hint.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
}

@media (max-width: 960px) and (max-height: 540px) and (orientation: landscape) {
  .miniapp-container {
    height: min(72vh, 520px);
    min-height: 380px;
  }

  .miniapp-panel {
    bottom: 68px !important;
    left: 10px !important;
    right: 10px !important;
    max-height: min(46%, 220px);
  }

  .miniapp-mobile-dock {
    right: 10px;
    bottom: 10px;
    left: 10px;
  }

  .miniapp-mobile-hint {
    right: 10px;
    bottom: 68px;
    left: 10px;
  }
}

/* --- Title / subtitle -------------------------------------------- */
.miniapp-title {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  margin-bottom: 10px;
}
.miniapp-subtitle {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: #d1d5db;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* --- Buttons ----------------------------------------------------- */
.miniapp-btn {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #e5e7eb;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  margin: 3px 4px 3px 0;
}
.miniapp-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}
.miniapp-btn--proton  { border-color: rgba(231,76,60,0.4); color: #f87171; }
.miniapp-btn--proton:hover { background: rgba(231,76,60,0.15); }
.miniapp-btn--neutron { border-color: rgba(52,152,219,0.4); color: #60a5fa; }
.miniapp-btn--neutron:hover { background: rgba(52,152,219,0.15); }
.miniapp-btn--reset   { border-color: rgba(255,255,255,0.2); color: #9ca3af; }
.miniapp-btn--decay   { margin-bottom: 4px; }
.miniapp-btn--alpha            { border-color: rgba(255,215,0,0.4);  color: #fbbf24; }
.miniapp-btn--beta_minus       { border-color: rgba(0,255,204,0.4);  color: #34d399; }
.miniapp-btn--beta_plus        { border-color: rgba(255,102,255,0.4);color: #e879f9; }
.miniapp-btn--electron_capture { border-color: rgba(102,204,255,0.4);color: #7dd3fc; }
.miniapp-btn--gamma            { border-color: rgba(255,255,0,0.4);  color: #fde047; }

/* --- Slider ------------------------------------------------------ */
.miniapp-slider-group {
  margin: 6px 0;
}
.miniapp-slider-group label {
  display: block;
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 2px;
}
.miniapp-slider-group label span {
  color: #e5e7eb;
  font-weight: 600;
}
.miniapp-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}
.miniapp-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ef4444;
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.2);
}
.miniapp-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ef4444;
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.2);
}

.miniapp-field {
  margin: 8px 0;
}
.miniapp-field label {
  display: block;
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 4px;
}
.miniapp-select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e5e7eb;
  color-scheme: dark;
  font-size: 12px;
  outline: none;
}
.miniapp-select:focus {
  border-color: rgba(99, 102, 241, 0.4);
}
.miniapp-select option {
  color: #e5e7eb;
  background: #0b1020;
}

/* --- Display fields ---------------------------------------------- */
.miniapp-display {
  margin: 4px 0;
}

/* --- Info grid (nuclear sim specific but generic enough) ---------- */
.miniapp-info-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.miniapp-info-big {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 2px;
}
.miniapp-info-symbol {
  font-family: 'Space Grotesk', monospace;
  font-size: 32px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}
.miniapp-info-mass {
  font-size: 14px;
  color: #9ca3af;
  vertical-align: super;
}
.miniapp-element-tile {
  width: 88px;
  min-height: 92px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(165deg, rgba(96, 165, 250, 0.2), rgba(15, 23, 42, 0.85));
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 7px 8px;
  margin-bottom: 6px;
}
.miniapp-element-number {
  font-size: 11px;
  color: #cbd5e1;
  font-weight: 600;
  justify-self: start;
}
.miniapp-element-symbol {
  font-family: 'Space Grotesk', monospace;
  font-size: 30px;
  line-height: 1;
  color: #f8fafc;
  font-weight: 700;
  justify-self: center;
  align-self: center;
}
.miniapp-element-mass {
  font-size: 11px;
  color: #bfdbfe;
  font-weight: 600;
  justify-self: end;
}
.miniapp-info-name {
  font-size: 14px;
  color: #d1d5db;
  margin-bottom: 6px;
}
.miniapp-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 1px 0;
}
.miniapp-info-row span:first-child { color: #9ca3af; }
.miniapp-info-note {
  font-size: 11px;
  color: #6b7280;
  font-style: italic;
  margin-top: 4px;
}
.miniapp-info-heuristic {
  color: #92400e;
}

/* --- Badges ------------------------------------------------------ */
.miniapp-badges { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.miniapp-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.miniapp-badge--magic  { background: rgba(139,92,246,0.15); color: #a78bfa; border: 1px solid rgba(139,92,246,0.3); }
.miniapp-badge--double { background: rgba(250,204,21,0.15); color: #fbbf24; border: 1px solid rgba(250,204,21,0.3); }

/* --- History list ------------------------------------------------ */
.miniapp-history-step {
  font-size: 11px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: #d1d5db;
}
.miniapp-history-idx { color: #6b7280; margin-right: 4px; }
.miniapp-history-mode {
  font-size: 10px;
  background: rgba(255,255,255,0.06);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  color: #9ca3af;
}

.miniapp-chart {
  width: 100%;
  height: 180px;
  display: block;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.5), rgba(8, 8, 16, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.miniapp-chart-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: #9ca3af;
  margin-top: 8px;
}
.miniapp-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.miniapp-status-chip--low { color: #86efac; background: rgba(34, 197, 94, 0.12); }
.miniapp-status-chip--moderate { color: #facc15; background: rgba(250, 204, 21, 0.12); }
.miniapp-status-chip--high { color: #fb923c; background: rgba(249, 115, 22, 0.12); }
.miniapp-status-chip--critical { color: #f87171; background: rgba(239, 68, 68, 0.14); }

/* --- Preset bar -------------------------------------------------- */
.miniapp-presets {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(10, 10, 20, 0.8);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  flex-wrap: wrap;
  justify-content: center;
}
.miniapp-presets-label {
  font-size: 11px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.miniapp-preset-btn {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: #d1d5db;
  cursor: pointer;
  transition: all 0.15s;
}
.miniapp-preset-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fff;
}

@media (max-width: 640px), (max-width: 960px) and (max-height: 540px) and (orientation: landscape) {
  .miniapp-presets {
    right: 12px;
    left: 12px;
    transform: none;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 7px 9px;
    border-radius: 14px;
    scrollbar-width: none;
  }

  .miniapp-presets::-webkit-scrollbar {
    display: none;
  }

  .miniapp-presets-label,
  .miniapp-preset-btn {
    flex: 0 0 auto;
  }

  .miniapp-preset-btn {
    white-space: nowrap;
  }
}

/* --- Checkbox toggle --------------------------------------------- */
.miniapp-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #9ca3af;
  cursor: pointer;
  margin-top: 8px;
}
.miniapp-checkbox input[type="checkbox"] {
  accent-color: #ef4444;
  width: 14px;
  height: 14px;
}

/* --- AI Assistant floating button -------------------------------- */
.miniapp-ai-fab {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
  transition: all 0.2s;
}
.miniapp-ai-fab:hover {
  box-shadow: 0 6px 30px rgba(99, 102, 241, 0.6);
  transform: translateX(-50%) translateY(-2px);
}
.miniapp-ai-fab svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 640px), (max-width: 960px) and (max-height: 540px) and (orientation: landscape) {
  .miniapp-ai-fab {
    right: 12px;
    bottom: 78px;
    left: auto;
    transform: none;
    width: 46px;
    height: 46px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
    font-size: 0;
  }

  .miniapp-ai-fab:hover {
    transform: translateY(-2px);
  }

  .miniapp-ai-panel {
    top: 56px;
    right: 12px;
    bottom: 70px;
    left: 12px;
    width: auto;
    max-width: none;
    max-height: none;
    transform: none;
  }
}

@media (max-width: 960px) and (max-height: 540px) and (orientation: landscape) {
  .miniapp-ai-fab {
    right: 10px;
    bottom: 74px;
    width: 42px;
    height: 42px;
  }

  .miniapp-ai-panel {
    top: 48px;
    right: 10px;
    bottom: 66px;
    left: 10px;
  }
}

/* --- AI Chat panel ----------------------------------------------- */
.miniapp-ai-panel {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  width: 90%;
  max-width: 420px;
  max-height: 50vh;
  border-radius: 16px;
  background: rgba(10, 10, 24, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(99, 102, 241, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}
.miniapp-ai-header {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.miniapp-ai-header span {
  font-weight: 600;
  font-size: 14px;
  color: #a5b4fc;
}
.miniapp-ai-close {
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.miniapp-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.miniapp-ai-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
}
.miniapp-ai-msg--user {
  align-self: flex-end;
  background: rgba(99, 102, 241, 0.2);
  color: #c7d2fe;
  border-bottom-right-radius: 4px;
}
.miniapp-ai-msg--assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  color: #e5e7eb;
  border-bottom-left-radius: 4px;
}
.miniapp-ai-msg--thinking {
  align-self: flex-start;
  color: #6b7280;
  font-style: italic;
}
.miniapp-ai-input-row {
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  gap: 8px;
  align-items: center;
}
.miniapp-ai-input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e5e7eb;
  font-size: 13px;
  outline: none;
}
.miniapp-ai-input::placeholder { color: #6b7280; }
.miniapp-ai-input:focus { border-color: rgba(99, 102, 241, 0.4); }
.miniapp-ai-voice-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #9ca3af;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.miniapp-ai-voice-btn:hover { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; }
.miniapp-ai-voice-btn.recording {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  color: #ef4444;
  animation: pulse-recording 1.5s ease-in-out infinite;
}
@keyframes pulse-recording {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}
.miniapp-ai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.miniapp-ai-send-btn:hover { opacity: 0.85; }

/* ================================================================
   Light theme overrides for mini-app panels
   ================================================================ */
[data-theme="light"] .miniapp-container {
  background: #f0f0f5;
}
[data-theme="light"] .miniapp-panel {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(0, 0, 0, 0.08);
  color: #374151;
}
[data-theme="light"] .miniapp-title { color: #111827; }
[data-theme="light"] .miniapp-subtitle { color: #4b5563; }
[data-theme="light"] .miniapp-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
  color: #374151;
}
[data-theme="light"] .miniapp-btn:hover { background: rgba(0, 0, 0, 0.08); }
[data-theme="light"] .miniapp-info-symbol { color: #111827; }
[data-theme="light"] .miniapp-element-tile {
  background: linear-gradient(165deg, rgba(59, 130, 246, 0.14), rgba(255, 255, 255, 0.92));
  border-color: rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .miniapp-element-number { color: #334155; }
[data-theme="light"] .miniapp-element-symbol { color: #0f172a; }
[data-theme="light"] .miniapp-element-mass { color: #1e3a8a; }
[data-theme="light"] .miniapp-info-name { color: #374151; }
[data-theme="light"] .miniapp-info-row span:first-child { color: #6b7280; }
[data-theme="light"] .miniapp-select {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
  color: #374151;
  color-scheme: light;
}
[data-theme="light"] .miniapp-select option {
  color: #111827;
  background: #ffffff;
}
[data-theme="light"] .miniapp-presets {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .miniapp-preset-btn { color: #374151; border-color: rgba(0,0,0,0.1); }
[data-theme="light"] .miniapp-preset-btn:hover { background: rgba(239,68,68,0.1); }
[data-theme="light"] .miniapp-mobile-dock {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .miniapp-mobile-tab {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: #374151;
}
[data-theme="light"] .miniapp-mobile-tab.is-active {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.28);
  color: #991b1b;
}
[data-theme="light"] .miniapp-mobile-hint {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(0, 0, 0, 0.08);
  color: #374151;
}
[data-theme="light"] .miniapp-chart {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(243, 244, 246, 0.95));
  border-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .miniapp-ai-panel {
  background: rgba(255, 255, 255, 0.97);
  border-color: rgba(99, 102, 241, 0.15);
}
[data-theme="light"] .miniapp-ai-msg--assistant { background: rgba(0,0,0,0.04); color: #374151; }
[data-theme="light"] .miniapp-ai-msg--user { background: rgba(99,102,241,0.1); color: #4338ca; }
[data-theme="light"] .miniapp-ai-input { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.1); color: #374151; }

/* ============================================================
   Lab framework chrome � added by lab framework refactor.
   ============================================================ */

.lab-mount {
    position: relative;
    width: 100%;
}

.lab-shell {
    position: relative;
    width: 100%;
    height: auto;
}

.lab-shell.is-pseudo-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #0b1220;
}

.lab-shell.is-pseudo-fullscreen .lab-stage {
    height: 100vh !important;
}

/*
 * The toolbar sits ABOVE the stage in normal flow so it never collides
 * with sim-internal absolutely-positioned UI panels (e.g. nuclear-decay's
 * element-info card, which lives in the top-right corner of the stage).
 * In pseudo-fullscreen we float it over the stage so the canvas can
 * still use the full viewport.
 */
.lab-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    min-height: 36px;
}

.lab-shell.is-pseudo-fullscreen .lab-toolbar {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    margin-bottom: 0;
    z-index: 10000;
}

.lab-toolbar-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(10, 16, 28, 0.7);
    backdrop-filter: blur(8px);
    color: #e5e7eb;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.lab-toolbar-btn:hover { background: rgba(20, 30, 48, 0.85); }
.lab-toolbar-btn:focus-visible {
    outline: 2px solid #38bdf8;
    outline-offset: 2px;
}
.lab-toolbar-btn[aria-pressed="true"] {
    background: rgba(56, 189, 248, 0.25);
    border-color: rgba(56, 189, 248, 0.6);
}

.lab-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: #94a3b8;
    background: rgba(10, 16, 28, 0.5);
    z-index: 5;
}

.lab-loading-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid rgba(148, 163, 184, 0.25);
    border-top-color: #38bdf8;
    animation: lab-spin 0.9s linear infinite;
}

@keyframes lab-spin { to { transform: rotate(360deg); } }

.lab-reduced-motion .lab-loading-spinner {
    animation: none;
    border-top-color: rgba(148, 163, 184, 0.6);
}

.lab-error-card {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    background: rgba(15, 23, 42, 0.95);
    color: #f1f5f9;
    z-index: 20;
    text-align: center;
}
.lab-error-card h3 { color: #f87171; font-size: 1.25rem; font-weight: 600; }
.lab-error-detail {
    max-width: 100%;
    max-height: 220px;
    overflow: auto;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    padding: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.75rem;
    color: #fca5a5;
    white-space: pre-wrap;
    text-align: left;
}
.lab-error-card .lab-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid rgba(56, 189, 248, 0.6);
    background: rgba(56, 189, 248, 0.15);
    color: #e0f2fe;
    cursor: pointer;
}

.lab-help-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 12, 22, 0.7);
    backdrop-filter: blur(4px);
}
.lab-help-panel {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.5rem 1.5rem 1.25rem;
    max-width: 480px;
    width: calc(100% - 2rem);
    color: #e5e7eb;
    position: relative;
}
.lab-help-panel:focus { outline: none; }
.lab-help-content h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.75rem; color: #f8fafc; }
.lab-help-content ul { list-style: disc; padding-left: 1.25rem; display: flex; flex-direction: column; gap: 0.35rem; color: #cbd5e1; font-size: 0.875rem; }
.lab-help-close {
    position: absolute;
    top: 0.5rem;
    right: 0.6rem;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}
.lab-help-close:hover { color: #f1f5f9; }

.lab-debug-overlay {
    position: absolute;
    right: 0.5rem;
    bottom: 0.5rem;
    z-index: 25;
    max-width: 360px;
    max-height: 50%;
    overflow: auto;
    background: rgba(8, 12, 22, 0.85);
    color: #a7f3d0;
    border: 1px solid rgba(74, 222, 128, 0.3);
    border-radius: 6px;
    padding: 0.5rem 0.6rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.7rem;
    white-space: pre;
    pointer-events: none;
}

/* Hide animated UI bits when user prefers reduced motion. */
.lab-reduced-motion *,
.lab-reduced-motion *::before,
.lab-reduced-motion *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
}
