/* Capa de organización responsive para el Chat Espiritual.
   Conserva la estética dorada existente y mejora jerarquía, lectura y tacto. */

html {
  scroll-behavior: smooth;
  height: auto !important;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: scroll !important;
  scrollbar-gutter: stable;
}

body {
  overflow-x: hidden;
  overflow-y: visible !important;
  height: auto !important;
  min-height: 100vh;
}

.page-header,
.main-nav,
.main-content,
.page-footer {
  width: 100%;
}

.main-content {
  grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1.65fr);
  align-items: start;
  gap: clamp(18px, 2.5vw, 34px);
  padding-inline: clamp(16px, 4vw, 56px);
}

.left-column,
.right-column,
.chat-section,
.chat-container {
  min-width: 0;
}

/* La página se desplaza completa; solo la lista de mensajes conserva su
   propio scroll. Sobrescribe la altura fija inyectada por la optimización móvil. */
.chat-container {
  height: auto !important;
  overflow: visible !important;
}

.left-column {
  position: sticky;
  top: 92px;
}

.chat-section,
.tools-section,
.daily-reflection-section {
  padding: clamp(18px, 2.5vw, 30px);
}

.chat-messages {
  min-height: clamp(390px, 55vh, 570px);
  max-height: 65vh;
  overflow-wrap: anywhere;
}

.message {
  width: fit-content;
  max-width: min(82%, 760px);
  line-height: 1.55;
  white-space: pre-wrap;
}

/* Indicador sagrado: Biblia animada, halo y destellos. */
.sacred-typing-indicator {
  display: flex !important;
  width: min(370px, calc(100% - 18px)) !important;
  max-width: 100% !important;
  min-height: 104px;
  align-items: center !important;
  gap: 18px;
  padding: 15px 20px !important;
  overflow: hidden;
  border: 1px solid rgba(167, 116, 26, 0.48) !important;
  border-radius: 19px !important;
  background:
    radial-gradient(circle at 22% 42%, rgba(255, 232, 147, 0.38), transparent 34%),
    linear-gradient(135deg, rgba(255, 253, 239, 0.97), rgba(242, 221, 159, 0.94)) !important;
  color: #3d290d !important;
  box-shadow:
    0 13px 30px rgba(75, 45, 4, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    0 0 22px rgba(231, 184, 65, 0.18) !important;
  white-space: normal !important;
  isolation: isolate;
}

.sacred-typing-indicator::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(105deg, transparent 22%, rgba(255, 255, 255, 0.72) 45%, transparent 68%);
  transform: translateX(-125%);
  animation: sacred-card-shimmer 3.1s ease-in-out infinite;
  pointer-events: none;
}

.sacred-loader-scene {
  position: relative;
  flex: 0 0 92px;
  width: 92px;
  height: 72px;
  display: grid;
  place-items: center;
  perspective: 360px;
}

.sacred-loader-scene::before {
  content: "";
  position: absolute;
  width: 74px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 207, 64, 0.31);
  filter: blur(12px);
  animation: sacred-aura 1.8s ease-in-out infinite;
}

.sacred-book {
  position: relative;
  width: 82px;
  height: 51px;
  transform: translateY(5px);
  transform-style: preserve-3d;
  animation: sacred-book-float 2.4s ease-in-out infinite;
}

.sacred-book-shadow {
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: -8px;
  height: 9px;
  border-radius: 50%;
  background: rgba(67, 35, 4, 0.3);
  filter: blur(5px);
  animation: sacred-shadow 2.4s ease-in-out infinite;
}

.sacred-page {
  position: absolute;
  top: 3px;
  width: 40px;
  height: 45px;
  overflow: hidden;
  border: 1px solid #d2a943;
  background:
    linear-gradient(90deg, rgba(151, 101, 20, 0.18), transparent 18%),
    linear-gradient(145deg, #fffdf0 8%, #f5e6ae 100%);
  box-shadow: 0 4px 7px rgba(91, 55, 6, 0.23);
  backface-visibility: hidden;
}

.sacred-page-left {
  left: 1px;
  border-radius: 8px 2px 4px 11px;
  transform-origin: right center;
  animation: sacred-open-left 2.4s cubic-bezier(0.65, 0, 0.25, 1) infinite;
}

.sacred-page-right {
  right: 1px;
  border-radius: 2px 8px 11px 4px;
  transform-origin: left center;
  animation: sacred-open-right 2.4s cubic-bezier(0.65, 0, 0.25, 1) infinite;
}

.sacred-page i {
  position: relative;
  display: block;
  width: 23px;
  height: 2px;
  margin: 7px auto -2px;
  border-radius: 5px;
  background: rgba(126, 83, 16, 0.26);
}

.sacred-page-left i:nth-child(2),
.sacred-page-right i:nth-child(2) {
  width: 28px;
}

.sacred-book-spine {
  position: absolute;
  z-index: 4;
  top: 4px;
  left: 50%;
  width: 3px;
  height: 43px;
  border-radius: 50%;
  background: linear-gradient(#fff4bd, #a66f14, #f8d76b);
  box-shadow: 0 0 5px rgba(255, 228, 128, 0.8);
  transform: translateX(-50%);
}

.sacred-cross {
  position: absolute;
  right: 11px;
  bottom: 8px;
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: #c28a1f;
  box-shadow: 0 0 6px rgba(232, 176, 47, 0.65);
}

.sacred-cross::after {
  content: "";
  position: absolute;
  top: 4px;
  left: -3px;
  width: 9px;
  height: 3px;
  border-radius: 2px;
  background: inherit;
}

.sacred-ray {
  position: absolute;
  width: 2px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(transparent, #f1bd35, transparent);
  transform-origin: center 37px;
  animation: sacred-ray-pulse 1.8s ease-in-out infinite;
}

.sacred-ray-one { top: -2px; left: 45px; }
.sacred-ray-two { top: 5px; left: 22px; transform: rotate(-42deg); animation-delay: 0.42s; }

.sacred-spark {
  position: absolute;
  z-index: 6;
  width: 7px;
  height: 7px;
  background: #fff4a9;
  box-shadow: 0 0 8px #e9aa22, 0 0 14px rgba(255, 222, 94, 0.85);
  transform: rotate(45deg) scale(0);
  animation: sacred-sparkle 2s ease-in-out infinite;
}

.sacred-spark-one { top: 8px; right: 8px; }
.sacred-spark-two { top: 21px; left: 4px; animation-delay: 0.7s; }
.sacred-spark-three { right: 15px; bottom: 3px; width: 5px; height: 5px; animation-delay: 1.25s; }

.sacred-loader-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.sacred-loader-title {
  display: flex;
  align-items: flex-end;
  font-family: "Cinzel", Georgia, serif;
  font-size: clamp(1rem, 2vw, 1.13rem);
  font-weight: 800;
  letter-spacing: 0.055em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.sacred-loader-copy small {
  color: rgba(76, 48, 10, 0.72);
  font-family: Georgia, serif;
  font-size: 0.76rem;
  font-style: italic;
  letter-spacing: 0.02em;
}

.sacred-loader-dots {
  display: inline-flex;
  gap: 3px;
  margin: 0 0 3px 5px;
}

.sacred-loader-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #a66f14;
  animation: sacred-dot 1.25s ease-in-out infinite;
}

.sacred-loader-dots i:nth-child(2) { animation-delay: 0.16s; }
.sacred-loader-dots i:nth-child(3) { animation-delay: 0.32s; }

@keyframes sacred-open-left {
  0%, 12% { transform: rotateY(70deg) skewY(1deg); }
  42%, 88% { transform: rotateY(7deg) skewY(-2deg); }
  100% { transform: rotateY(70deg) skewY(1deg); }
}

@keyframes sacred-open-right {
  0%, 12% { transform: rotateY(-70deg) skewY(-1deg); }
  42%, 88% { transform: rotateY(-7deg) skewY(2deg); }
  100% { transform: rotateY(-70deg) skewY(-1deg); }
}

@keyframes sacred-book-float {
  0%, 100% { transform: translateY(6px); }
  50% { transform: translateY(1px); }
}

@keyframes sacred-shadow {
  0%, 100% { opacity: 0.42; transform: scaleX(0.8); }
  50% { opacity: 0.23; transform: scaleX(1.06); }
}

@keyframes sacred-aura {
  0%, 100% { opacity: 0.5; transform: scale(0.82); }
  50% { opacity: 1; transform: scale(1.18); }
}

@keyframes sacred-sparkle {
  0%, 100% { opacity: 0; transform: rotate(45deg) scale(0); }
  38%, 58% { opacity: 1; transform: rotate(45deg) scale(1); }
}

@keyframes sacred-ray-pulse {
  0%, 100% { opacity: 0; height: 9px; }
  50% { opacity: 0.9; height: 19px; }
}

@keyframes sacred-dot {
  0%, 70%, 100% { opacity: 0.28; transform: translateY(0) scale(0.8); }
  35% { opacity: 1; transform: translateY(-4px) scale(1.15); }
}

@keyframes sacred-card-shimmer {
  0%, 58% { transform: translateX(-125%); }
  88%, 100% { transform: translateX(125%); }
}

@media (max-width: 480px) {
  .sacred-typing-indicator {
    gap: 12px;
    min-height: 92px;
    padding: 11px 13px !important;
  }

  .sacred-loader-scene {
    flex-basis: 78px;
    width: 78px;
    transform: scale(0.9);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sacred-typing-indicator *,
  .sacred-typing-indicator::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}

.message-copy-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 12px;
  border: 1px solid currentColor;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  opacity: 1;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.22);
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.message-copy-button:hover,
.message-copy-button:focus-visible {
  opacity: 1;
  transform: translateY(-1px);
  outline: none;
  background: rgba(255, 255, 255, 0.27);
}

.message-copy-button.copied {
  opacity: 1;
  background: rgba(20, 145, 80, 0.28);
}

.bot-message .message-copy-button {
  border-color: rgba(0, 0, 0, 0.45);
  background: rgba(255, 255, 255, 0.38);
  color: #17120a;
}

.user-message .message-copy-button {
  background: rgba(0, 0, 0, 0.24);
  color: #fff;
}

.chat-input-container {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.chat-input {
  width: 100%;
  box-sizing: border-box;
}

.chat-controls {
  flex-wrap: nowrap;
}

.chat-attachment-preview {
  display: none;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 0 0;
}

.agent-balance-alert {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  padding: 15px 18px;
  border: 2px solid #ff5a5f;
  border-radius: 14px;
  background: rgba(125, 0, 8, 0.92);
  color: #fff;
  font-weight: 800;
  line-height: 1.4;
  text-align: center;
  letter-spacing: 0.025em;
  box-shadow: 0 0 24px rgba(255, 40, 50, 0.55);
}

.agent-balance-alert[hidden] {
  display: none !important;
}

.agent-balance-alert i {
  color: #ffdcdf;
  font-size: 1.35rem;
  flex: 0 0 auto;
}

.chat-attachment-preview.has-files {
  display: flex;
}

.chat-attachment-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--gold-medium);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.48);
  color: var(--white);
}

.chat-attachment-chip img {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 8px;
}

.chat-attachment-chip-name {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
}

.chat-attachment-remove {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
  cursor: pointer;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}

.message-attachment {
  padding: 6px 9px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 0.78rem;
}

.generated-attachments {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.generated-attachment-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  min-width: min(280px, 100%);
  padding: 11px 13px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
  color: #17120a;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.generated-attachment-card:hover,
.generated-attachment-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.22);
  outline: 2px solid rgba(0, 0, 0, 0.5);
}

.generated-attachment-card > i:first-child {
  font-size: 1.65rem;
  color: #8e1b1b;
}

.generated-attachment-info {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.generated-attachment-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.generated-attachment-info small {
  opacity: 0.7;
}

.generated-download-icon {
  color: #183f7a;
}

.generated-image-attachment {
  width: min(560px, 100%);
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.58);
}

.generated-image-preview-link {
  display: block;
  background: rgba(15, 15, 15, 0.92);
  line-height: 0;
}

.generated-image-preview {
  display: block;
  width: 100%;
  max-height: 440px;
  object-fit: contain;
}

.generated-image-attachment figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  color: #17120a;
  font-size: 0.78rem;
}

.generated-image-attachment figcaption > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.generated-image-save-label {
  flex: 0 0 auto;
  color: #183f7a;
  font-weight: 700;
}

@media (max-width: 480px) {
  .generated-image-attachment figcaption {
    align-items: flex-start;
    flex-direction: column;
  }
}

.control-button,
.reflection-btn,
.nav-button,
.tool-card {
  touch-action: manipulation;
}

.tool-card {
  cursor: pointer;
}

.role-select option {
  color: #17120a;
  background: #fffaf0;
}

/* El HTML heredado no definía la capa base del modal. Sin esta regla, su
   contenido podía quedar extendido sobre la página y capturar los clics. */
#spiritual-resources-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  background: rgba(3, 5, 12, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow-y: auto;
  pointer-events: none;
}

#spiritual-resources-modal[style*="display: flex"] {
  pointer-events: auto;
}

#spiritual-resources-modal .spiritual-resources-content {
  position: relative;
  margin: auto;
}

body.resources-modal-open {
  overflow: hidden;
}

#spiritual-resources-modal .modal-header {
  flex: 0 0 auto;
  gap: 18px;
}

#spiritual-resources-modal .resources-title {
  min-width: 0;
}

#spiritual-resources-modal .resources-title p {
  margin: 5px 0 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.85rem;
  line-height: 1.35;
}

#spiritual-resources-modal .resources-close {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  padding: 0;
  color: #fff;
  background: rgba(35, 21, 4, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
}

#spiritual-resources-modal .drive-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px 20px 0;
}

#spiritual-resources-modal .drive-summary-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 10px 12px;
  color: #5f4509;
  background: rgba(255, 250, 232, 0.82);
  border: 1px solid rgba(186, 137, 24, 0.24);
  border-radius: 12px;
  font-size: 0.82rem;
}

#spiritual-resources-modal .drive-summary-item i {
  color: #b98516;
  font-size: 1.05rem;
}

#spiritual-resources-modal .drive-summary-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#spiritual-resources-modal .drive-online i {
  color: #258b4b;
}

#spiritual-resources-modal .upload-limit {
  display: block;
  margin-top: 16px;
  color: #69521f;
}

#spiritual-resources-modal .resource-filename {
  display: block;
  margin: -2px 0 9px;
  overflow: hidden;
  color: #806b3c;
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#spiritual-resources-modal .file-name {
  min-width: 0;
  color: #40330f;
}

#spiritual-resources-modal .resource-actions .action-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(186, 137, 24, 0.18);
  background: rgba(255, 248, 221, 0.7);
}

#spiritual-resources-modal .resource-actions .action-btn:hover {
  color: #795508;
  background: #fff2bd;
}

#spiritual-resources-modal .no-resources,
#spiritual-resources-modal .no-results {
  grid-column: 1 / -1;
  padding: 42px 20px;
  color: #70571c;
  text-align: center;
}

#spiritual-resources-modal .no-resources > i,
#spiritual-resources-modal .no-results > i {
  color: #c79725;
  font-size: 2.6rem;
}

@media (max-width: 992px) {
  .main-content {
    display: flex;
    flex-direction: column;
  }

  .right-column {
    order: 1;
    width: 100%;
  }

  .left-column {
    order: 2;
    position: static;
    width: 100%;
  }

  .chat-messages {
    max-height: 58vh;
  }
}

@media (max-width: 768px) {
  .page-header {
    padding: 14px 16px;
  }

  .logo-container {
    gap: 10px;
  }

  .logo {
    width: 48px;
    height: 48px;
  }

  .page-title {
    font-size: clamp(1.12rem, 5vw, 1.55rem);
    line-height: 1.2;
  }

  .main-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    overflow: hidden;
  }

  .nav-container {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    padding: 10px 14px;
    gap: 8px;
  }

  .nav-container::-webkit-scrollbar {
    display: none;
  }

  .nav-button {
    flex: 0 0 auto;
    min-height: 44px;
    white-space: nowrap;
  }

  .main-content {
    padding: 14px;
    gap: 18px;
  }

  /* En una sola columna, el chat (right-column) va PRIMERO: el usuario llega
     directo a la conversación y al micrófono sin atravesar las herramientas. */
  .right-column {
    order: -1;
  }

  .right-column,
  .left-column {
    gap: 18px;
  }

  /* Scroll táctil confiable: la página se desplaza en vertical y el fondo no
     usa attachment fixed (traba el scroll en Chrome Android). */
  html,
  body {
    touch-action: pan-y;
  }

  body {
    background-attachment: scroll !important;
    /* mobile-optimization.js inyecta overscroll-behavior: contain en <body>.
       Body no tiene su propio recorrido de scroll (height:auto lo ajusta al
       contenido), pero al ser un contenedor de scroll (overflow-y resuelto a
       "auto" por su overflow-x:hidden) igual corta la cadena antes de llegar
       a <html>, que es quien realmente debe desplazarse. */
    overscroll-behavior: auto !important;
  }

  .chat-messages {
    max-height: 55vh;
    touch-action: pan-y;
    /* auto (no "contain"): cuando la lista de mensajes no tiene su propio
       recorrido de scroll (pocos mensajes), el gesto debe encadenarse y
       desplazar la página. "contain" lo bloqueaba por completo aquí. */
    /* !important: algunos scripts fijan overscroll-behavior inline en tiempo
       de ejecución; esta regla debe ganar siempre para no re-bloquear el
       scroll de la página. */
    overscroll-behavior: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .chat-section,
  .tools-section,
  .daily-reflection-section {
    border-radius: 16px;
    padding: 16px;
  }

  .chat-header {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .role-selector {
    justify-content: space-between;
    width: 100%;
  }

  .role-select {
    flex: 1;
    min-width: 0;
    max-width: 230px;
  }

  .chat-messages {
    min-height: 52vh;
    max-height: 58vh;
    padding: 14px;
  }

  .message {
    max-width: 90%;
  }

  .chat-input-container {
    grid-template-columns: 1fr;
    gap: 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .chat-input-icon {
    top: 35px;
  }

  .chat-controls {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    width: 100%;
  }

  .control-button {
    width: 100%;
    height: 48px;
    border-radius: 14px;
  }

  #send-button {
    background: rgba(255, 215, 0, 0.22);
  }

  .tools-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-card {
    min-height: 105px;
  }

  .spiritual-resources-content {
    width: calc(100% - 20px) !important;
    max-width: none !important;
    margin: 10px !important;
    max-height: calc(100dvh - 20px) !important;
  }

  #spiritual-resources-modal {
    align-items: flex-start;
    padding: 10px;
  }

  #spiritual-resources-modal .modal-header {
    padding: 14px 15px;
  }

  #spiritual-resources-modal .resources-title h2 {
    font-size: 1.08rem;
  }

  #spiritual-resources-modal .resources-title p {
    font-size: 0.75rem;
  }

  #spiritual-resources-modal .resources-tabs {
    overflow-x: auto;
    scrollbar-width: thin;
  }

  #spiritual-resources-modal .tab-button {
    flex: 0 0 auto;
    min-width: 145px;
    padding: 12px 14px;
    white-space: nowrap;
  }

  #spiritual-resources-modal .drive-summary {
    display: flex;
    padding: 10px 12px 0;
    overflow-x: auto;
  }

  #spiritual-resources-modal .drive-summary-item {
    flex: 0 0 auto;
  }

  #spiritual-resources-modal .tab-content {
    padding: 14px 12px 20px;
  }

  #spiritual-resources-modal .drag-drop-area {
    padding: 28px 12px;
  }

  #spiritual-resources-modal .management-header,
  #spiritual-resources-modal .filters,
  #spiritual-resources-modal .bulk-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  #spiritual-resources-modal .filters select,
  #spiritual-resources-modal .filters button,
  #spiritual-resources-modal .bulk-actions button {
    justify-content: center;
    width: 100%;
  }

  #spiritual-resources-modal .resources-grid,
  #spiritual-resources-modal .search-results-grid {
    grid-template-columns: 1fr;
  }

  #spiritual-resources-modal .form-actions {
    flex-direction: column-reverse;
  }

  #spiritual-resources-modal .form-actions button {
    justify-content: center;
    width: 100%;
  }

  #spiritual-resources-modal .file-preview-item {
    flex-wrap: wrap;
  }

  #spiritual-resources-modal .file-preview-item .file-name {
    flex: 1 1 calc(100% - 52px);
  }
}

@media (max-width: 420px) {
  .main-content {
    padding-inline: 10px;
  }

  .chat-section,
  .tools-section,
  .daily-reflection-section {
    padding: 13px;
  }

  .section-title {
    font-size: 1.12rem;
  }

  .chat-messages {
    min-height: 48vh;
    padding: 10px;
  }

  .message {
    max-width: 94%;
    padding: 10px 12px;
  }

  .tools-grid {
    gap: 10px;
  }

  .tool-card {
    padding: 12px 8px;
  }

  .tool-card h4 {
    font-size: 0.88rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
