/**
 * SentinelCareAI — responsive.css
 * Responsive — todos los media queries (640px, 480px, 390px, 360px)
 * ─────────────────────────────────────────────────────────────
 */

/* ─── MEJORAS MÓVILES GENERALES — 640px ──────── */
@media(max-width:640px){

  /* ── Landing ── */
  #s-landing { padding: 16px 14px 24px; justify-content: flex-start; padding-top: 32px; }
  .landing-card { padding: 28px 20px 32px; border-radius: 22px; }
  .landing-title { font-size: 1.9rem; }
  .landing-subtitle { font-size: 0.88rem; margin-bottom: 28px; }
  .logo-mark { width: 58px; height: 58px; font-size: 22px; margin-bottom: 18px; }
  .divider { margin: 22px 0; }

  /* Profile grid: 2 cols siempre en >=360, pero la última sola queda centrada */
  .profile-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
  }
  /* Centrar última tarjeta si es la quinta (impar) */
  .profile-grid .profile-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    max-width: 260px;
    margin: 0 auto;
    width: 100%;
  }
  .profile-card { padding: 20px 14px; border-radius: 16px; }
  .profile-icon { width: 44px; height: 44px; font-size: 1.1rem; margin-bottom: 10px; }
  .profile-name { font-size: 0.95rem; }
  .profile-desc { font-size: 0.78rem; }
  .notice-box { font-size: 0.82rem; padding: 14px 16px; }

  /* ── App Header ── */
  .app-header { padding: 0 14px; height: 56px; gap: 8px; }
  .header-brand { font-size: 0.95rem; gap: 8px; }
  .header-dot { width: 28px; height: 28px; font-size: 12px; }
  .header-badge { font-size: 0.7rem; padding: 3px 10px; }
  .btn-back { padding: 6px 10px; font-size: 0.8rem; }
  .dark-toggle { width: 34px; height: 34px; font-size: 13px; }

  /* ── Personal / Padres hero ── */
  .personal-hero { padding: 28px 0 0; }
  .personal-hero h2 { font-size: 1.55rem; }
  .personal-hero p, .padres-hero p { font-size: 0.9rem; }
  .personal-content, .padres-content { padding: 0 14px; margin-top: 24px; }
  #s-personal, #s-padres { padding-bottom: 80px; }

  /* ── Chat CTA ── */
  .chat-cta { flex-direction: column; text-align: center; padding: 22px 18px; gap: 14px; }
  .chat-cta-arrow { display: none; }
  .chat-cta-text h4 { font-size: 1rem; }
  .chat-cta-text p { font-size: 0.82rem; }

  /* ── Crisis banner — colapsa verticalmente ── */
  .crisis-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 16px 18px;
  }
  .crisis-banner i { font-size: 1.4rem; }
  .crisis-phone { margin-left: 0; font-size: 1.1rem; }

  /* ── Step cards ── */
  .step-card { padding: 22px 18px; border-radius: 18px; margin-bottom: 18px; }
  .step-title { font-size: 1.05rem; }

  /* ── Why grid — 1 columna ── */
  .why-grid { grid-template-columns: 1fr; gap: 10px; }
  .why-item { padding: 14px; }

  /* ── Resources grid — 1 columna ── */
  .resources-grid { grid-template-columns: 1fr; gap: 10px; }
  .resource-card { padding: 16px 14px; }
  .resource-card .rc-phone { font-size: 1rem; }

  /* ── Courage section ── */
  .courage-section { padding: 28px 18px; margin-top: 28px; }
  .courage-section h3 { font-size: 1.3rem; }
  .btn-primary { padding: 14px 24px; font-size: 0.95rem; width: 100%; justify-content: center; }

  /* ── Chat screen ── */
  .chat-wrapper { padding: 0 10px 12px; }
  .msg-bubble { max-width: 88%; font-size: 0.9rem; padding: 11px 14px; }
  .msg-avatar { width: 28px; height: 28px; font-size: 0.75rem; }
  .chat-disclaimer { font-size: 0.78rem; padding: 9px 12px; margin: 10px 0 8px; }
  .chat-input-area { border-radius: 18px; padding: 10px 12px; }
  #chat-input { font-size: 16px; } /* Evita zoom en iOS */
  .chat-btn { width: 40px; height: 40px; font-size: 15px; }
  .chat-btn-mic { width: 40px; height: 40px; }
  .char-counter { font-size: 0.68rem; }
  .voice-bar { font-size: 0.72rem; }

  /* ── Wellness tracker ── */
  .mood-selector { gap: 6px; }
  .mood-btn { padding: 10px 6px; min-width: 56px; flex: 1 1 56px; }
  .mood-btn .mood-emoji { font-size: 1.6rem; }
  .mood-btn span { font-size: 0.72rem; }

  /* ── Padres: alert grid — 1 columna ── */
  .alert-grid { grid-template-columns: 1fr; gap: 10px; }
  .guias-grid { grid-template-columns: 1fr; gap: 14px; }
  .do-dont { grid-template-columns: 1fr; gap: 14px; }
  .padres-section { padding: 20px 16px; border-radius: 20px; margin-bottom: 20px; }
  .padres-hero { padding: 28px 0 0; }

  /* ── Chat parent CTA ── */
  .chat-parent-cta { padding: 18px 20px; gap: 14px; flex-direction: column; text-align: center; }
  .chat-parent-cta-arrow { display: none; }
  .chat-parent-cta-icon { margin: 0 auto; }

  /* ── Pro panel ── */
  .pro-container { padding: 14px 12px; }
  .pro-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; flex-wrap: nowrap; }
  .pro-tabs::-webkit-scrollbar { display: none; }
  .pro-tab { padding: 9px 14px; font-size: 0.82rem; white-space: nowrap; flex-shrink: 0; }
  .pro-charts { grid-template-columns: 1fr; }
  .pro-form-row { grid-template-columns: 1fr; }
  .two-col-grid { grid-template-columns: 1fr !important; }
  .guidance-grid { grid-template-columns: 1fr; }
  .score-bar { flex-direction: column; gap: 10px; align-items: flex-start; }
  .checklist-card { padding: 18px 14px; }

  /* ── Pro access card ── */
  .pro-access-card { padding: 36px 22px 32px; border-radius: 22px; }

  /* ── Session restore bar ── */
  .session-restore-bar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .session-restore-actions { width: 100%; justify-content: flex-end; }
}

/* ─── MÓVIL PEQUEÑO — 390px (iPhone SE, Galaxy A) ── */
@media(max-width:390px){

  /* Landing: 1 columna absoluta */
  #s-landing { padding: 20px 10px; }
  .profile-grid { grid-template-columns: 1fr !important; }
  .profile-grid .profile-card:last-child:nth-child(odd) { max-width: 100%; }
  .landing-title { font-size: 1.65rem; }
  .landing-card { padding: 22px 14px 26px; }
  .profile-card { padding: 16px 14px; flex-direction: row; text-align: left; align-items: center; gap: 14px; }
  .profile-icon { margin: 0; flex-shrink: 0; width: 40px; height: 40px; }
  .profile-name { font-size: 0.9rem; margin-bottom: 2px; }
  .profile-desc { font-size: 0.75rem; }

  /* Header mínimo */
  .app-header { padding: 0 10px; height: 52px; }
  .header-badge { display: none; }

  /* Chat */
  .msg-bubble { max-width: 94%; font-size: 0.85rem; padding: 10px 12px; }
  .chat-wrapper { padding: 0 8px 10px; }

  /* Pro */
  .pro-tab { padding: 8px 10px; font-size: 0.76rem; }
  .pro-container { padding: 10px 8px; }

  /* Botones */
  .btn-primary { padding: 13px 16px; font-size: 0.9rem; }
}

/* ─── Prevenir zoom en inputs iOS ─────────────── */
@media(max-width:640px){
  input[type="text"],
  input[type="password"],
  input[type="email"],
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* ─── Safe area para iPhone con notch/home bar ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #s-chat .chat-wrapper { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  #panic-btn { bottom: calc(20px + env(safe-area-inset-bottom)); }
  #s-personal, #s-padres { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
}

/* ─── Touch targets mínimos 44px ─────────────── */
@media(max-width:640px){
  .btn-back, .dark-toggle, .chat-btn, .chat-btn-mic,
  .session-restore-btn, .accordion-header {
    min-height: 44px;
  }
  .profile-card { min-height: 44px; }
  .accordion-header { padding: 16px 18px; }
}

/* ─── TWO-COL-GRID (base) ─────────────────────── */
.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ─── PRO HEADER — responsive fixes ─────────── */
#s-professional .app-header {
  gap: 8px;
}
#s-professional .header-brand {
  min-width: 0;        /* permite que flexbox comprima */
  flex-shrink: 1;
}
.pro-header-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.pro-title-section h1 {
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}
.pro-title-section p {
  word-break: break-word;
  overflow-wrap: break-word;
}
.pro-info-box, .pro-info-box * {
  word-break: break-word;
  overflow-wrap: break-word;
}
/* Texto general en el panel pro no debe desbordar */
#s-professional * {
  max-width: 100%;
  box-sizing: border-box;
}

/* ─── PRO TITLE SECTION — ajuste móvil ──────── */
@media(max-width:640px){
  /* Header del panel pro */
  .pro-header-badge { display: none; }          /* ocultar badge, el título ya lo dice */
  .btn-back-label   { display: none; }          /* solo el ícono ← en pantalla chica */
  .pro-title-section { margin-bottom: 20px; }
  .pro-title-section h1  { font-size: 1.25rem; text-shadow: none; }
  .pro-title-section p   { font-size: 0.82rem; line-height: 1.5; }

  /* File uploader más compacto */
  .file-uploader { padding: 20px 14px; }
  .file-uploader i { font-size: 1.8rem; }
  .file-uploader p { font-size: 0.82rem; }

  /* Métricas apiladas */
  .pro-metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .pro-metric-value { font-size: 1.6rem; }

  /* Gráficas en columna */
  .pro-charts { grid-template-columns: 1fr; gap: 16px; }

  /* Sidebar pro */
  .pro-sidebar { padding: 18px 14px; }
  .pro-sidebar h3 { font-size: 0.9rem; }
  .pro-info-box { font-size: 0.8rem; padding: 12px 14px; }

  /* Score bar */
  .score-bar { flex-direction: column; gap: 8px; align-items: flex-start; }
  .score-val  { font-size: 1.5rem; }

  /* Checklist cards */
  .checklist-card { padding: 16px 12px; }
  .checklist-card h4 { font-size: 0.85rem; }
  .check-item label  { font-size: 0.82rem; }

  /* Protocol steps más angostos */
  .protocol-step { padding: 12px 14px; gap: 10px; }
  .protocol-step .step-body strong { font-size: 0.85rem; }
  .protocol-step .step-body p      { font-size: 0.78rem; }

  /* Script boxes */
  .script-box { padding: 14px; }
  .script-box p { font-size: 0.82rem; }

  /* two-col-grid colapsa en móvil */
  .two-col-grid { grid-template-columns: 1fr !important; gap: 10px; }

  /* Log entries */
  .log-entry { flex-direction: column; gap: 8px; }
  .log-entry .log-date { margin-left: 0; }

  /* Export buttons — en fila scrollable */
  .pro-form-actions { flex-wrap: wrap; gap: 8px; }
  .export-btn { font-size: 0.78rem; padding: 7px 11px; }

  /* Resource chips wrap bien */
  .resource-chips { gap: 6px; }
  .resource-chip  { font-size: 0.75rem; padding: 5px 10px; }

  /* Pro tabs barra */
  .pro-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    gap: 0;
    padding-bottom: 0;
  }
  .pro-tabs::-webkit-scrollbar { display: none; }
  .pro-tab { padding: 10px 12px; font-size: 0.8rem; white-space: nowrap; flex-shrink: 0; }
  .pro-tab i { display: none; } /* ocultar iconos en tabs para ahorrar espacio */

  /* Guidance grid */
  .guidance-grid { grid-template-columns: 1fr; }
}

@media(max-width:390px){
  .pro-metrics { grid-template-columns: 1fr; }
  .pro-tab { padding: 9px 10px; font-size: 0.74rem; }
}
.msg-bubble .md-body { line-height: 1.7; }
.msg-bubble .md-body p { margin: 0 0 8px; }
.msg-bubble .md-body p:last-child { margin-bottom: 0; }
.msg-bubble .md-body strong { font-weight: 700; }
.msg-bubble .md-body em { font-style: italic; }
.msg-bubble .md-body ul, .msg-bubble .md-body ol { padding-left: 20px; margin: 6px 0 8px; }
.msg-bubble .md-body li { margin-bottom: 4px; }
.msg-bubble .md-body h1,.msg-bubble .md-body h2,.msg-bubble .md-body h3 {
  font-family: 'Playfair Display', serif; margin: 10px 0 6px; font-size: 1rem;
}
.msg-bubble .md-body code {
  background: rgba(61,122,138,0.12); border-radius: 4px; padding: 1px 5px;
  font-family: monospace; font-size: 0.88em;
}
.msg-bubble .md-body blockquote {
  border-left: 3px solid var(--teal-light); margin: 8px 0; padding: 6px 12px;
  color: var(--text-mid); font-style: italic;
}
/* Dark mode markdown */
body.dark-mode .msg-bubble .md-body code { background: rgba(0,212,255,0.1); }

/* ─── LLM VALIDATION BADGES ──────────────────── */
.val-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.72rem; font-weight: 600; border-radius: 10px;
  padding: 2px 8px; margin-top: 4px; white-space: nowrap;
}
.val-confirmed  { background: rgba(192,57,43,0.15); color: #ff6b5b; border: 1px solid rgba(192,57,43,0.3); }
.val-false-pos  { background: rgba(39,174,96,0.12);  color: #6fbf73; border: 1px solid rgba(39,174,96,0.3); }
.val-pending    { background: rgba(0,212,255,0.08);  color: #7ac8d4; border: 1px solid rgba(0,212,255,0.2); }
.val-spinner    { display: inline-block; width: 10px; height: 10px;
                  border: 2px solid rgba(0,212,255,0.3); border-top-color: #00d4ff;
                  border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.validation-header {
  display: flex; flex-direction: column; gap: 8px; margin: 14px 0 8px;
  padding: 12px 14px; border-radius: 10px;
  background: rgba(0,212,255,0.06); border: 1px solid rgba(0,212,255,0.15);
  font-size: 0.82rem; color: #7ac8d4;
}
.validation-header i { font-size: 1rem; }
.val-progress-row {
  display: flex; align-items: center; gap: 10px;
}
.val-progress-bar-wrap {
  flex: 1; height: 6px; border-radius: 3px;
  background: rgba(0,212,255,0.12); overflow: hidden;
}
.val-progress-bar-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #00d4ff, #7ac8d4);
  transition: width 0.4s ease;
}
.val-progress-pct {
  font-size: 0.75rem; font-weight: 700; color: #00d4ff;
  white-space: nowrap; min-width: 32px; text-align: right;
}
.val-progress-eta {
  font-size: 0.72rem; color: #5a7a88; white-space: nowrap;
}

/* IA Analysis markdown overrides for dark pro panel */
.ia-md h1,.ia-md h2,.ia-md h3 { color: #e8c48a; font-family: 'Playfair Display', serif; margin: 14px 0 6px; }
.ia-md strong { color: #e8c48a; }
.ia-md ul,.ia-md ol { padding-left: 22px; margin: 6px 0; }
.ia-md li { margin-bottom: 5px; }
.ia-md p { margin-bottom: 10px; }
.ia-md code { background: rgba(0,212,255,0.1); border-radius: 4px; padding: 1px 5px; font-size: 0.88em; }

/* ── PANTALLA AUTH (Login / Registro / Recuperación) ─────── */
#s-auth {
  background: linear-gradient(135deg, #0f0f1e 0%, #1a1a2e 100%);
  align-items: center; justify-content: center; padding: 40px 20px;
}
.auth-card {
  background: rgba(26,29,40,0.97);
  border: 1px solid rgba(0,212,255,0.18);
  border-radius: 28px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  padding: 48px 40px 40px;
  max-width: 440px; width: 100%;
  text-align: center;
  animation: fadeIn 0.4s ease;
}
.auth-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, rgba(0,212,255,0.15), rgba(0,212,255,0.05));
  border: 1.5px solid rgba(0,212,255,0.3);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px; font-size: 24px; color: #00d4ff;
}
.auth-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem; font-weight: 700; color: #e0e0e0;
  margin-bottom: 8px;
}
.auth-subtitle { font-size: 0.88rem; color: #707080; line-height: 1.6; margin-bottom: 28px; }
.auth-tabs {
  display: flex; background: rgba(255,255,255,0.04);
  border: 1px solid rgba(0,212,255,0.12);
  border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 24px;
}
.auth-tab {
  flex: 1; padding: 9px; border: none; border-radius: 9px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  font-family: 'DM Sans', sans-serif; transition: all 0.2s;
  background: none; color: #606070;
}
.auth-tab.active { background: rgba(0,212,255,0.15); color: #00d4ff; }
.auth-field { margin-bottom: 14px; text-align: left; }
.auth-field label { font-size: 0.8rem; color: #808090; display: block; margin-bottom: 5px; }
.auth-input {
  width: 100%; background: rgba(255,255,255,0.05);
  border: 1px solid rgba(0,212,255,0.2); border-radius: 10px;
  padding: 12px 14px; color: #e0e0e0;
  font-family: 'DM Sans', sans-serif; font-size: 0.9rem;
  transition: border-color 0.2s; box-sizing: border-box;
}
.auth-input:focus { outline: none; border-color: #00d4ff; box-shadow: 0 0 0 3px rgba(0,212,255,0.08); }
.auth-input::placeholder { color: #404050; }
.auth-btn {
  width: 100%; background: linear-gradient(90deg, #00d4ff, #0099cc);
  border: none; border-radius: 12px; padding: 13px;
  color: white; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: all 0.25s; margin-top: 6px;
  font-family: 'DM Sans', sans-serif;
}
.auth-btn:hover:not(:disabled) { box-shadow: 0 6px 24px rgba(0,212,255,0.4); transform: translateY(-1px); }
.auth-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.auth-error {
  display: none; background: rgba(192,57,43,0.12);
  border: 1px solid rgba(192,57,43,0.3); border-radius: 10px;
  padding: 10px 14px; font-size: 0.83rem; color: #ff6b5b;
  margin-bottom: 12px; text-align: left;
}
.auth-error.show { display: block; }
.auth-success {
  display: none; background: rgba(58,159,74,0.12);
  border: 1px solid rgba(58,159,74,0.3); border-radius: 10px;
  padding: 10px 14px; font-size: 0.83rem; color: #6fbf73;
  margin-bottom: 12px; text-align: left;
}
.auth-success.show { display: block; }
.auth-link {
  background: none; border: none; color: #00d4ff; cursor: pointer;
  font-size: 0.83rem; font-family: 'DM Sans', sans-serif;
  text-decoration: underline; padding: 0; margin-top: 14px; display: block;
}
.auth-link:hover { color: #7eb8c4; }
.auth-divider {
  height: 1px; background: rgba(0,212,255,0.1);
  margin: 20px 0; position: relative;
}
.auth-user-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(0,212,255,0.08); border: 1px solid rgba(0,212,255,0.2);
  border-radius: 20px; padding: 6px 14px; font-size: 0.82rem;
  color: #7ac8d4; margin-bottom: 16px;
}
@media (max-width: 480px) {
  .auth-card { padding: 36px 22px 30px; }
  .auth-title { font-size: 1.35rem; }
}

/* ══════════════════════════════════════════════
   MODO MAESTRO — Tema educativo cálido
   Se activa añadiendo la clase .maestro-mode a #s-professional
   Completamente independiente del tema oscuro de salud (cian)
═══════════════════════════════════════════════ */
#s-professional.maestro-mode {
  background: linear-gradient(135deg, #f0ebff 0%, #ede5fa 40%, #fdf8f0 100%) !important;
  color: #2c2c3a;
}

/* ── Header ── */
#s-professional.maestro-mode .app-header {
  background: rgba(255,255,255,0.96) !important;
  border-color: rgba(124,77,189,0.2) !important;
  box-shadow: 0 2px 16px rgba(124,77,189,0.08);
}
#s-professional.maestro-mode .header-brand { color: #2c2c3a !important; }
#s-professional.maestro-mode .pro-header-badge {
  background: rgba(124,77,189,0.12) !important;
  color: #7c4dbd !important;
}
#s-professional.maestro-mode .btn-back {
  border-color: rgba(124,77,189,0.3) !important;
  color: #7c4dbd !important;
  background: none !important;
}
#s-professional.maestro-mode .btn-back:hover {
  background: rgba(124,77,189,0.1) !important;
  color: #5c2ea0 !important;
}
#s-professional.maestro-mode .dark-toggle {
  border-color: rgba(124,77,189,0.3) !important;
  color: #7c4dbd !important;
  background: rgba(124,77,189,0.06) !important;
}

/* ── Título del panel ── */
#s-professional.maestro-mode .pro-title-section h1 {
  color: #6b4fa0 !important;
  text-shadow: 0 2px 12px rgba(124,77,189,0.2) !important;
}
#s-professional.maestro-mode #pro-subtitle { color: #6b6080 !important; }

/* ── Tabs ── */
#s-professional.maestro-mode .pro-tabs {
  border-bottom: 2px solid rgba(124,77,189,0.18) !important;
}
#s-professional.maestro-mode .pro-tab       { color: #a090c0 !important; }
#s-professional.maestro-mode .pro-tab:hover { color: #7c4dbd !important; }
#s-professional.maestro-mode .pro-tab.active {
  color: #7c4dbd !important;
  border-bottom-color: #7c4dbd !important;
}

/* ── Checklist cards ── */
#s-professional.maestro-mode .checklist-card {
  background: rgba(255,255,255,0.88) !important;
  border: 1px solid rgba(124,77,189,0.16) !important;
  box-shadow: 0 4px 20px rgba(124,77,189,0.07);
}
#s-professional.maestro-mode .checklist-card h4 { color: #6b4fa0 !important; }

/* ── Check items ── */
#s-professional.maestro-mode .check-item {
  border-bottom-color: rgba(124,77,189,0.1) !important;
}
#s-professional.maestro-mode .check-item input[type=checkbox] { accent-color: #7c4dbd !important; }
#s-professional.maestro-mode .check-item label { color: #3c3050 !important; }
#s-professional.maestro-mode .check-item.checked label {
  color: #b0a0c8 !important;
  text-decoration: line-through;
}

/* ── Barra de puntaje ── */
#s-professional.maestro-mode .score-bar {
  background: rgba(124,77,189,0.07) !important;
  border-radius: 12px;
}
#s-professional.maestro-mode .score-bar .score-val   { color: #7c4dbd !important; }
#s-professional.maestro-mode .score-bar .score-label { color: #8070a0 !important; }

/* ── Pasos de protocolo ── */
#s-professional.maestro-mode .protocol-step {
  background: rgba(255,255,255,0.78) !important;
  border: 1px solid rgba(124,77,189,0.13) !important;
  border-left: 4px solid #7c4dbd !important;
}
#s-professional.maestro-mode .protocol-step.step-warn   { border-left-color: #e8a020 !important; }
#s-professional.maestro-mode .protocol-step.step-danger { border-left-color: #d94040 !important; }
#s-professional.maestro-mode .protocol-step .step-num-pro {
  background: rgba(124,77,189,0.12) !important;
  color: #7c4dbd !important;
}
#s-professional.maestro-mode .protocol-step.step-warn .step-num-pro {
  background: rgba(232,160,32,0.14) !important;
  color: #b87820 !important;
}
#s-professional.maestro-mode .protocol-step.step-danger .step-num-pro {
  background: rgba(217,64,64,0.12) !important;
  color: #d94040 !important;
}
#s-professional.maestro-mode .protocol-step .step-body strong { color: #2c2240 !important; }
#s-professional.maestro-mode .protocol-step .step-body p      { color: #6b6080 !important; }

/* ── Info boxes ── */
#s-professional.maestro-mode .pro-info-box {
  background: rgba(124,77,189,0.07) !important;
  border-left: 3px solid #7c4dbd !important;
  color: #5a5070 !important;
}
#s-professional.maestro-mode .pro-info-box h4 { color: #6b4fa0 !important; }

/* ── Script boxes (guía familiar) ── */
#s-professional.maestro-mode .script-box {
  background: rgba(124,77,189,0.05) !important;
  border: 1px solid rgba(124,77,189,0.18) !important;
}
#s-professional.maestro-mode .script-box .script-label { color: #7c4dbd !important; }
#s-professional.maestro-mode .script-box p             { color: #3c3050 !important; }
#s-professional.maestro-mode .script-box .script-note  { color: #8070a0 !important; }

/* ── Resource chips ── */
#s-professional.maestro-mode .resource-chip {
  background: rgba(124,77,189,0.08) !important;
  border-color: rgba(124,77,189,0.22) !important;
  color: #7c4dbd !important;
}
#s-professional.maestro-mode .resource-chip:hover {
  background: rgba(124,77,189,0.16) !important;
  color: #5c2ea0 !important;
}
#s-professional.maestro-mode .resource-chip.gold {
  background: rgba(232,160,32,0.1) !important;
  border-color: rgba(232,160,32,0.28) !important;
  color: #b87820 !important;
}

/* ── Formularios ── */
#s-professional.maestro-mode .pro-form-group label { color: #6b6080 !important; }
#s-professional.maestro-mode .pro-form-input,
#s-professional.maestro-mode .pro-form-textarea {
  background: rgba(255,255,255,0.82) !important;
  border-color: rgba(124,77,189,0.24) !important;
  color: #2c2c3a !important;
}
#s-professional.maestro-mode .pro-form-input:focus,
#s-professional.maestro-mode .pro-form-textarea:focus {
  border-color: #7c4dbd !important;
  box-shadow: 0 0 0 3px rgba(124,77,189,0.12);
}
#s-professional.maestro-mode .pro-form-input::placeholder,
#s-professional.maestro-mode .pro-form-textarea::placeholder { color: #b0a0c8 !important; }
#s-professional.maestro-mode .pro-btn-sm.primary {
  background: linear-gradient(135deg, #7c4dbd, #9b6dd4) !important;
  color: white !important;
}
#s-professional.maestro-mode .pro-btn-sm.primary:hover {
  box-shadow: 0 4px 18px rgba(124,77,189,0.4) !important;
}
#s-professional.maestro-mode .pro-btn-sm.outline {
  border-color: rgba(124,77,189,0.35) !important;
  color: #7c4dbd !important;
  background: none !important;
}
#s-professional.maestro-mode .pro-btn-sm.outline:hover {
  background: rgba(124,77,189,0.08) !important;
}

/* ── Log entries (notas guardadas) ── */
#s-professional.maestro-mode .log-entry {
  background: rgba(255,255,255,0.72) !important;
  border-color: rgba(124,77,189,0.14) !important;
}
#s-professional.maestro-mode .log-entry .log-text strong { color: #2c2240 !important; }
#s-professional.maestro-mode .log-entry .log-text p      { color: #7060a0 !important; }
#s-professional.maestro-mode .log-entry .log-date        { color: #a090c0 !important; }

/* ── Two-col-grids interiores ── */
#s-professional.maestro-mode .two-col-grid > div {
  background: rgba(255,255,255,0.65) !important;
}

/* ── Botones de exportar ── */
#s-professional.maestro-mode .export-btn {
  background: rgba(124,77,189,0.08) !important;
  border-color: rgba(124,77,189,0.35) !important;
  color: #7c4dbd !important;
}
#s-professional.maestro-mode .export-btn:hover {
  background: rgba(124,77,189,0.16) !important;
  box-shadow: 0 0 12px rgba(124,77,189,0.25) !important;
}

/* ── Pro sidebar ── */
#s-professional.maestro-mode .pro-sidebar {
  background: rgba(255,255,255,0.78) !important;
  border-color: rgba(124,77,189,0.18) !important;
}
#s-professional.maestro-mode .pro-sidebar h3 { color: #7c4dbd !important; }

/* ── Spinner ── */
#s-professional.maestro-mode .spinner {
  border-color: rgba(124,77,189,0.2) !important;
  border-top-color: #7c4dbd !important;
}

/* ── Tabla ── */
#s-professional.maestro-mode table  { background: rgba(255,255,255,0.7) !important; }
#s-professional.maestro-mode th     { background: rgba(124,77,189,0.1) !important; color: #6b4fa0 !important; }
#s-professional.maestro-mode td     { border-bottom-color: rgba(124,77,189,0.1) !important; color: #2c2c3a; }

/* ── Eventos de crisis / Uso API (texto) ── */
#s-professional.maestro-mode .checklist-card p,
#s-professional.maestro-mode .checklist-card span { color: #6b6080 !important; }

/* ══════════════════════════════════════════════
   OPTIMIZACIONES MÓVIL — Consolidadas
   Probadas en iPhone SE (375px), iPhone 14 (390px),
   Android típico (360px) y pantallas hasta 640px
═══════════════════════════════════════════════ */

/* ── Pantalla completa + scroll suave ──────── */
@media (max-width: 640px) {

  /* ── App header: más compacto ── */
  .app-header {
    padding: 10px 14px;
    gap: 6px;
  }
  .header-brand { font-size: 0.9rem; gap: 7px; }
  .header-dot   { width: 28px; height: 28px; font-size: 0.85rem; }
  .header-badge { font-size: 0.68rem; padding: 3px 8px; }

  /* ── Chat: padding inferior para teclado iOS/Android ── */
  #s-chat { padding-bottom: env(safe-area-inset-bottom, 0); }
  .chat-messages {
    padding: 14px 12px 8px;
    /* Espacio suficiente para que el último msg no quede tapado por el teclado */
    padding-bottom: 12px;
  }
  .chat-input-area {
    padding: 8px 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0;
  }
  .chat-input-row { gap: 6px; }
  #chat-input { font-size: 16px; padding: 9px 10px; } /* 16px evita zoom en iOS */
  .chat-btn { width: 38px; height: 38px; }
  .chat-btn-mic { width: 38px; height: 38px; }
  .voice-bar { padding: 4px 2px 2px; flex-wrap: wrap; gap: 6px; }

  /* ── Mensajes del chat ── */
  .msg { gap: 7px; }
  .msg-avatar { width: 28px; height: 28px; font-size: 0.75rem; }
  .msg-bubble { font-size: 0.88rem; padding: 10px 13px; max-width: 85%; }
  .msg-time   { font-size: 0.67rem; }

  /* ── Crisis overlay: cards apiladas sin botón que se sale ── */
  .crisis-overlay-inner {
    padding: 20px 14px 24px;
    overflow-y: auto;
    max-height: 100dvh;
  }
  .crisis-aura { width: 60px; height: 60px; font-size: 22px; margin-bottom: 14px; }
  .crisis-headline { font-size: clamp(1.3rem, 5vw, 1.7rem); margin-bottom: 6px; }
  .crisis-subline  { font-size: 0.88rem; margin-bottom: 6px; }
  .crisis-aura-msg { padding: 12px 14px; margin: 12px 0 16px; }
  .crisis-aura-msg p { font-size: 0.88rem; line-height: 1.65; }
  .crisis-phones { gap: 8px; margin-bottom: 16px; }

  /* Cards de teléfono: número y botón apilados en pantallas muy chicas */
  .crisis-call-card {
    padding: 12px 14px;
    gap: 10px;
    flex-wrap: wrap;
  }
  .crisis-call-icon  { width: 38px; height: 38px; font-size: 0.95rem; }
  .crisis-call-name  { font-size: 0.88rem; }
  .crisis-call-number { font-size: 1.05rem; }
  .crisis-call-desc  { font-size: 0.72rem; }
  .crisis-call-btn   {
    padding: 8px 12px;
    font-size: 0.8rem;
    width: 100%;           /* botón ancho completo en móvil */
    justify-content: center;
  }
  .crisis-call-info  { flex: 1 1 60%; }

  /* ── Panic button: más grande y accesible en touch ── */
  #panic-btn { bottom: max(18px, env(safe-area-inset-bottom)); right: 14px; }

  /* ── Drawer de historial: ancho completo en móvil ── */
  #history-drawer { width: 100%; right: -100%; }

  /* ── Panel profesional: tabs más pequeños ── */
  .pro-tab { padding: 8px 10px; font-size: 0.76rem; gap: 4px; }
  .pro-tab i { font-size: 0.8rem; }

  /* ── Botones de guardar en chat ── */
  .btn-save-session { padding: 6px 10px; font-size: 0.75rem; }
  .btn-back         { padding: 6px 10px; font-size: 0.78rem; }

  /* ── Modal de logout y session expired ── */
  [id="logout-modal"] > div,
  [id="pro-data-modal"] > div { padding: 24px 18px; }

  /* ── Onboarding: padding reducido ── */
  #onboarding-overlay > div { margin: 0 8px; }
  #onboarding-overlay > div > div:nth-child(2) { padding: 24px 20px 16px; }

  /* ── Notice box en landing ── */
  .notice-box { font-size: 0.82rem; padding: 14px 16px; }

  /* ── Step cards ── */
  .step-card   { padding: 20px 16px; }
  .step-title  { font-size: 1rem; }
  .step-num    { width: 28px; height: 28px; font-size: 0.85rem; }

  /* ── Botón primario ── */
  .btn-primary { padding: 14px 24px; font-size: 0.92rem; }

  /* ── Accesibilidad: botones de contraste y fuente ── */
  #hc-toggle-landing, #lf-toggle-landing { font-size: 0.7rem; padding: 5px 8px; }
}

/* ── Extra chico: 360px y menos (Galaxy S, iPhone SE) ── */
@media (max-width: 360px) {
  .crisis-call-card { padding: 10px 12px; }
  .crisis-call-name { font-size: 0.82rem; }
  .crisis-call-number { font-size: 0.95rem; }
  .pro-tab { font-size: 0.7rem; padding: 7px 8px; }
  .msg-bubble { max-width: 90%; font-size: 0.85rem; }
  .chat-btn, .chat-btn-mic { width: 34px; height: 34px; }
  .landing-title { font-size: 1.6rem; }
}

/* ── Safe area para dispositivos con notch (iPhone X+) ── */
@supports (padding-top: env(safe-area-inset-top)) {
  .app-header {
    padding-top: max(10px, env(safe-area-inset-top));
  }
  #crisis-overlay {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .chat-input-area {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}
