/* v36 performance + usability overrides: use the debugging checklist to remove layout/perf footguns. */
:root {
  --ui-fast-shadow: 0 10px 30px rgba(0,0,0,0.22);
}

/* Expensive backdrop filters and stacked gradients caused mobile lag. Keep the atmosphere but avoid GPU-heavy effects. */
.sidebar,
.dialog,
.card,
.notice,
.tools-card,
.intent-panel,
.corr-mixer-panel {
  backdrop-filter: none !important;
}

body {
  background-attachment: fixed;
}

@media (max-width: 760px), (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  body {
    background-image: linear-gradient(180deg, #120a1e, #1a1028) !important;
  }
  .spell-item,
  .card,
  .dialog,
  .btn,
  .chip {
    box-shadow: none !important;
  }
}

/* First-time-user clarity: make the main entry points visually obvious. */
#aiChatBtn,
#spellWizardBtn,
#toolsBtn,
#sourcesBtn,
#tarotDeckBtn {
  position: relative;
}
#aiChatBtn::before { content: "✦ "; }
#spellWizardBtn::before { content: "⚗ "; }
#toolsBtn::before { content: "☰ "; }
#sourcesBtn::before { content: "☾ "; }
#tarotDeckBtn::before { content: "✧ "; }

/* Stop horizontal overflow from any dialog/card/button row. */
html, body, .app, .sidebar, .detail, .dialog-body, .card {
  max-width: 100%;
}
* {
  box-sizing: border-box;
}
img, svg, canvas, video {
  max-width: 100%;
}
pre, code, textarea, input {
  overflow-wrap: anywhere;
}

/* Long lists are a major DOM pressure source; contain layout/paint where supported. */
.spell-list,
.corr-list,
.shopping-list,
.tools-hub,
.intent-results,
.corr-mixer-results,
#aiChatMessages {
  contain: layout paint style;
}

.spell-item,
.use-btn,
.attachment-card,
.tools-card {
  content-visibility: auto;
  contain-intrinsic-size: 78px;
}

/* Broken media fallback. */
img[data-broken="true"] {
  min-height: 72px;
  object-fit: contain;
  background: rgba(255,255,255,0.08);
  border: 1px dashed rgba(255,255,255,0.22);
}

/* Keep modal close controls reachable. */
dialog .dialog-head,
dialog .ai-chat-topbar {
  position: relative;
  z-index: 5;
}
dialog .btn.icon[id^="close"],
dialog .btn.icon[aria-label="Close"] {
  flex: 0 0 auto;
}

/* Mobile: the old sidebar could overwhelm first-time users. */
@media (max-width: 880px) {
  .controls .control-label,
  .sidebar-footer {
    font-size: 0.78rem;
  }
  .controls .row {
    gap: 8px;
  }
  .btn {
    min-height: 40px;
  }
}
