/* Estilos de ImaThorly en Blazor.
   Generado desde public/styles (tokens.css, imathorly.css) con «html, body» → «.ima-raiz».
   Los iconos son de Tabler (fuente): el ajuste va al final. */

/* ==========================================================================
   THORLY AI — Design Tokens (CSS Custom Properties)
   Variables, brand colors, themes dark/light
   ========================================================================== */

:root {
    /* Brand Gradient */
    --brand-blue: #3B72FF;
    --brand-purple: #9B3BFF;
    --brand-pink: #FF2E60;

    /* Font */
    --font-main: 'Google Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'Google Sans Mono', 'Roboto Mono', 'Courier New', monospace;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-med: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-pill: 999px;

    /* Sidebar */
    --sidebar-width: 240px;
}

/* ── DARK THEME (default) ───────────────────────────────────────────────── */
[data-theme="dark"] {
    --bg-base: #191919;
    --bg-surface: #202020;
    --bg-elevated: #252525;
    --bg-hover: #2A2A2A;
    --bg-active: #303030;
    --bg-input: #1E1E1E;
    --bg-code: #141414;

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.16);

    --text-primary: #E3E3E3;
    --text-strong: #FFFFFF;
    --text-secondary: #ABABAB;
    --text-tertiary: #707070;
    --text-on-brand: #0F0F0F;

    --accent-primary: #8AB4F8;
    --accent-primary-dim: rgba(138, 180, 248, 0.12);
    --accent-primary-glow: rgba(138, 180, 248, 0.25);

    --pill-active-bg: rgba(138, 180, 248, 0.15);
    --pill-active-border: rgba(138, 180, 248, 0.40);
    --pill-active-text: #8AB4F8;

    --send-btn-bg: #8AB4F8;
    --send-btn-text: #0F0F0F;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.30);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.40);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.55);

    --scrollbar-thumb: rgba(255, 255, 255, 0.12);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.22);
}

/* ── LIGHT THEME ────────────────────────────────────────────────────────── */
[data-theme="light"] {
    --bg-base: #F8F9FA;
    --bg-surface: #FFFFFF;
    --bg-elevated: #F1F3F4;
    --bg-hover: #EAECEF;
    --bg-active: #E0E3E8;
    --bg-input: #FFFFFF;
    --bg-code: #F1F3F4;

    --border-subtle: rgba(0, 0, 0, 0.05);
    --border-default: rgba(0, 0, 0, 0.09);
    --border-strong: rgba(0, 0, 0, 0.15);

    --text-primary: #1A1A1A;
    --text-strong: #000000;
    --text-secondary: #5F6368;
    --text-tertiary: #9AA0A6;
    --text-on-brand: #FFFFFF;

    --accent-primary: #1A73E8;
    --accent-primary-dim: rgba(26, 115, 232, 0.10);
    --accent-primary-glow: rgba(26, 115, 232, 0.22);

    --pill-active-bg: rgba(26, 115, 232, 0.10);
    --pill-active-border: rgba(26, 115, 232, 0.35);
    --pill-active-text: #1A73E8;

    --send-btn-bg: #1A73E8;
    --send-btn-text: #FFFFFF;

    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.10);
    --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 6px 24px rgba(0, 0, 0, 0.15);

    --scrollbar-thumb: rgba(0, 0, 0, 0.13);
    --scrollbar-thumb-hover: rgba(0, 0, 0, 0.22);
}

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400;1,700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

.ima-raiz {
  height: 100%;
  font-family: 'DM Sans', 'Inter', 'Google Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #FFFFFF;
  color: #1F2937;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d0cc; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #b0b0aa; }

/* ── App Shell ── */
.ima-app {
  display: flex;
  flex-direction: row;
  height: 100vh;
  overflow: hidden;
  background: #FFFFFF;
}

/* ═══════════════════════════════════════
   LAYOUT ORDER (editor center, chat right)
   ═══════════════════════════════════════ */
.ima-sidebar { order: 1 !important; }
.ima-sep { order: 15 !important; display: none !important; }
.ima-right { order: 2 !important; }
.resize-handle { order: 3 !important; }
.ima-center { order: 4 !important; }

/* ── Vertical Separators ── */
.ima-sep {
  display: none;
}

/* ═══════════════════════════════════════
   LEFT SIDEBAR (icon rail — expandible)
   ═══════════════════════════════════════ */
.ima-sidebar {
  width: 64px;
  min-width: 64px;
  background: #FFFFFF;
  border-right: 1px solid #d0d0cc;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.25s ease;
  z-index: 50;
}
.ima-sidebar:hover {
  width: 220px;
  box-shadow: 4px 0 16px rgba(0,0,0,0.08);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 15px;
  border-bottom: 1px solid #d0d0cc;
  margin-bottom: 8px;
  min-height: 56px;
}

.ima-logo-circle-side {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #2a2e35;
  color: #ffffff;
}
.ima-logo-circle-side svg {
  width: 72%;
  height: 72%;
}

[data-theme="dark"] .ima-logo-circle-side {
  background: #f0f0f0;
  color: #1a1a1a;
}

.sidebar-logo-text,
.sidebar-logo span {
  display: none;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #36454F;
  white-space: nowrap;
}
.ima-sidebar:hover .sidebar-logo-text {
  display: block;
}

/* New Report Button */
.new-report-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 44px;
  height: 44px;
  margin: 4px auto 12px;
  padding: 0;
  background: #2072AF;
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 0;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(32,114,175,0.35);
  flex-shrink: 0;
}
.new-report-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(32,114,175,0.45);
}
.new-report-btn svg { width: 20px; height: 20px; }
.ima-sidebar:hover .new-report-btn {
  width: calc(100% - 28px);
  margin: 4px 14px 12px;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  justify-content: center;
}

.template-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  padding: 0;
  background: transparent;
  border: 1px solid #d0d0cc;
  border-radius: 12px;
  color: transparent;
  font-size: 0;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  flex-shrink: 0;
}
.template-btn svg { width: 18px; height: 18px; color: #6B7280; }
.template-btn:hover { border-color: #2072AF; }
.template-btn:hover svg { color: #2072AF; }
.ima-sidebar:hover .template-btn {
  width: calc(100% - 28px);
  margin: 0 14px 16px;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 12.5px;
  color: #6B7280;
  justify-content: center;
}

/* Search */
.sidebar-search {
  display: none;
  position: relative;
  margin: 0 14px 16px;
}
.ima-sidebar:hover .sidebar-search {
  display: block;
}

.sidebar-search .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #9CA3AF;
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.sidebar-search input {
  width: 100%;
  background: #F0F1F3;
  border: 1px solid #d0d0cc;
  border-radius: 8px;
  padding: 8px 12px 8px 34px;
  font-size: 12.5px;
  font-family: inherit;
  color: #36454F;
  outline: none;
  transition: border-color 0.2s;
}

.sidebar-search input:focus { border-color: rgba(32,114,175,0.4); outline: none; }
.sidebar-search input::placeholder { color: #9CA3AF; font-size: 12.5px; }

/* Sidebar Sections */
.sidebar-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  min-height: 0;
}

.sidebar-section-title {
  display: none;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: #9CA3AF;
  text-transform: uppercase;
  padding: 0 18px 8px;
}
.ima-sidebar:hover .sidebar-section-title {
  display: block;
}

.sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 10px;
  padding: 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  min-height: 44px;
  border: 1px solid transparent;
  justify-content: center;
}
.ima-sidebar:hover .sidebar-item {
  justify-content: flex-start;
}

.btn-delete-conv {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  color: #666;
  flex-shrink: 0;
  line-height: 0;
}
.btn-delete-conv:hover {
  background: rgba(239,68,68,0.15);
  color: #EF4444;
}
.sidebar-item:hover .btn-delete-conv {
  display: flex;
  align-items: center;
}

.sidebar-item:hover {
  background: rgba(32,114,175,0.06);
  border-color: rgba(32,114,175,0.15);
}

.sidebar-item.active {
  background: #F0F8FF;
  border-color: rgba(32,114,175,0.25);
}

.sidebar-item .item-indicator {
  display: none;
  background: #2072AF;
  border-radius: 2px;
  width: 3px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-item.active .item-indicator { display: block; }

.sidebar-item .item-icon {
  width: 16px;
  height: 16px;
  color: #6B7280;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-item.active .item-icon { color: #2072AF; }

.sidebar-item .item-info {
  display: none;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.ima-sidebar:hover .sidebar-item .item-info {
  display: flex;
}

.sidebar-item .item-name {
  font-size: 12.5px;
  font-weight: 400;
  color: #4B5563;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-item.active .item-name {
  color: #36454F;
  font-weight: 500;
}

.sidebar-item .item-patient {
  font-size: 11px;
  color: #9CA3AF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-empty {
  padding: 16px 8px;
  font-size: 13px;
  color: #9CA3AF;
  text-align: center;
  line-height: 1.5;
}

/* ═══════════════════════════════════════
   CENTER PANEL (Chat IA) — now right sidebar
   ═══════════════════════════════════════ */
.ima-center {
  flex: 0 0 34% !important;
  max-width: 44% !important;
  min-width: 300px !important;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #F8F9FA;
  border-left: 1px solid #d0d0cc;
  position: relative;
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 24px;
  border-bottom: 1px solid #d0d0cc;
  background: #FFFFFF;
  flex-shrink: 0;
  z-index: 10;
}
.chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10B981;
  box-shadow: 0 0 10px rgba(16,185,129,0.5);
  position: relative;
}
.chat-status-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #10B981;
  animation: imaStatusPulse 2s ease-in-out infinite;
}
@keyframes imaStatusPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0; transform: scale(2.2); }
}
.chat-header-title {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #36454F;
  letter-spacing: -0.2px;
}
.chat-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-header-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: #6B7280;
  cursor: pointer;
  transition: all 0.15s;
}
.chat-header-btn:hover {
  background: #F3F4F6;
  color: #36454F;
}

.center-inner {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  padding: 24px 20px 16px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Welcome — centered vertically */
.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-bottom: 0;
  position: relative;
  padding: 0 24px;
}

.welcome-logo-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  margin-bottom: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: imaLogoFloat 3s ease-in-out infinite;
}

/* Revisión final del informe */
.revision-fondo { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0,0,0,0.5); }
.revision-modal { width: min(480px, 100%); padding: 28px; border-radius: 16px; text-align: center; background: #fff; color: #1F2937; animation: revision-entra 0.2s ease-out; }
[data-theme="dark"] .revision-modal { background: #1c1d21; color: #E0E0E0; }
.revision-modal h2 { margin: 12px 0 6px; font-size: 18px; }
.revision-modal p { margin: 0; font-size: 14px; color: #6B7280; }
.revision-carga { width: 40px; height: 40px; margin: 0 auto; border-radius: 50%; border: 3px solid rgba(32,114,175,0.25); border-top-color: #2072AF; animation: revision-gira 0.8s linear infinite; }
.revision-icono { font-size: 2rem; color: #2072AF; }
.revision-lista { margin: 12px 0 0; padding-left: 20px; text-align: left; font-size: 14px; line-height: 1.5; }
.revision-acciones { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
.bienvenida-fondo { position: fixed; inset: 0; z-index: 3000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .55); }
.bienvenida { display: flex; flex-direction: column; gap: 16px; width: min(860px, 100%); max-height: 100%; overflow-y: auto; padding: 24px 32px; border-radius: 24px; background: #1B1B1B; color: #FAF7F0; box-shadow: 0 18px 60px rgba(0, 0, 0, .55); }
.bienvenida-arriba, .bienvenida-abajo { display: flex; align-items: center; justify-content: space-between; }
.bienvenida-marca { font-size: 20px; font-weight: 700; }
.bienvenida-saltar { min-height: 44px; padding: 0 14px; border: none; border-radius: 22px; background: transparent; color: #C9C5BC; cursor: pointer; }
.bienvenida-seguir { min-height: 44px; padding: 0 22px; border: none; border-radius: 22px; background: #FAF7F0; color: #1B1B1B; font-weight: 700; cursor: pointer; }
.bienvenida-cuerpo { display: grid; grid-template-columns: 1fr 260px; gap: 24px; align-items: center; min-height: 340px; }
.bienvenida-paso h2 { margin: 0 0 16px; font-size: 38px; line-height: 1.15; font-weight: 700; }
.bienvenida-paso h2 em { font-style: normal; color: #529CCA; }
.bienvenida-paso p { margin: 0; color: #C9C5BC; font-size: 16px; line-height: 1.5; }
.bienvenida-tarjeta { display: block; width: 100%; margin-top: 10px; padding: 14px 18px; border: 2px solid transparent; border-radius: 16px; background: #FAF7F0; color: #1B1B1B; text-align: left; cursor: pointer; }
.bienvenida-tarjeta:hover, .bienvenida-tarjeta:focus-visible { border-color: #2072AF; }
.bienvenida-tarjeta strong, .bienvenida-tarjeta span { display: block; }
.bienvenida-tarjeta span { margin-top: 2px; color: #55524B; font-size: 14px; }
.bienvenida-avatar { position: relative; text-align: center; }
.bienvenida-avatar img { width: 100%; max-height: 300px; object-fit: contain; }
.bienvenida-bocadillo { display: inline-block; margin-bottom: 8px; padding: 8px 16px; border-radius: 18px; background: #FAF7F0; color: #1B1B1B; font-weight: 700; }
.bienvenida-puntos { display: flex; gap: 7px; }
.bienvenida-puntos span { width: 8px; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .24); }
.bienvenida-puntos .activo { width: 30px; background: #529CCA; }
@media (max-width: 720px) {
    .bienvenida { padding: 16px; }
    .bienvenida-cuerpo { grid-template-columns: 1fr; min-height: 0; }
    .bienvenida-avatar { display: none; }
    .bienvenida-paso h2 { font-size: 28px; }
}
.ajuste-fila { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; padding: 10px 0; cursor: pointer; }
.ajuste-texto strong { display: block; font-size: 14px; font-weight: 500; color: #1F2937; }
.ajuste-texto span { display: block; margin-top: 2px; font-size: 13px; line-height: 1.4; color: #6B7280; }
[data-theme="dark"] .ajuste-texto strong { color: #F0F0F0; }
[data-theme="dark"] #settingsPanel .ajuste-texto span { color: #A3A3A3 !important; }
.guia-fondo { position: fixed; inset: 0; z-index: 3000; }
.guia-foco { position: fixed; z-index: 3001; border: 2px solid #529CCA; border-radius: 12px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .62); pointer-events: none; transition: left .2s, top .2s, width .2s, height .2s; }
.guia-bocadillo { position: fixed; z-index: 3002; box-sizing: border-box; width: min(360px, calc(100vw - 32px)); padding: 16px; border-radius: 18px; background: #1B1B1B; color: #FAF7F0; box-shadow: 0 18px 60px rgba(0, 0, 0, .55); }
.guia-bocadillo.debajo::before, .guia-bocadillo.encima::before { content: ""; position: absolute; left: var(--punta); width: 16px; height: 16px; margin-left: -8px; background: #1B1B1B; transform: rotate(45deg); }
.guia-bocadillo.debajo::before { top: -7px; }
.guia-bocadillo.encima::before { bottom: -7px; }
.guia-cuerpo { display: flex; gap: 12px; align-items: flex-start; }
.guia-cuerpo img { flex: none; width: 84px; height: 96px; object-fit: contain; animation: guia-habla .5s ease-out 3 alternate; }
.guia-cuerpo h3 { margin: 0 0 6px; font-size: 18px; font-weight: 700; color: #FAF7F0; }
.guia-cuerpo p { margin: 0; font-size: 15px; line-height: 1.45; color: #C9C5BC; }
.guia-abajo { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 8px; }
.guia-abajo span { margin-right: auto; font-size: 13px; color: #C9C5BC; }
@keyframes guia-habla { from { transform: translateY(0) rotate(0); } to { transform: translateY(-5px) rotate(-3deg); } }
@media (prefers-reduced-motion: reduce) {
    .guia-foco { transition: none; }
    .guia-cuerpo img { animation: none; }
}
.licencia-fila { display: flex; gap: 8px; margin-top: 16px; }
.licencia-fila input { flex: 1; min-width: 0; padding: 10px 14px; border-radius: 10px; border: 1px solid #9CA3AF; background: transparent; color: inherit; font-size: 16px; text-transform: uppercase; }
.revision-modal .licencia-error { min-height: 1.4em; margin-top: 6px; color: #DC2626; }
.revision-acciones a { text-decoration: none; }
@keyframes revision-entra { from { opacity: 0; transform: translateY(8px); } }
@keyframes revision-gira { to { transform: rotate(360deg); } }

/* Luz azul detrás del logo */
.welcome-logo-wrap::before {
  content: '';
  position: absolute;
  inset: -44px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(32,114,175,0.5) 0%, rgba(32,114,175,0.2) 42%, transparent 70%);
}

@keyframes imaLogoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.ima-logo-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  background: #2a2e35;
  color: #ffffff;
  box-shadow:
    -8px -8px 18px rgba(255,255,255,0.3),
    8px 8px 18px rgba(0,0,0,0.3),
    inset -2px -2px 4px rgba(255,255,255,0.15),
    inset 2px 2px 4px rgba(0,0,0,0.2);
}
.ima-logo-circle svg {
  width: 66%;
  height: 66%;
}

[data-theme="dark"] .ima-logo-circle {
  background: #f0f0f0;
  color: #1a1a1a;
  box-shadow:
    -8px -8px 18px rgba(255,255,255,0.06),
    8px 8px 18px rgba(0,0,0,0.4),
    inset -2px -2px 4px rgba(0,0,0,0.15),
    inset 2px 2px 4px rgba(255,255,255,0.6);
}



.welcome h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 0 0 8px 0;
  line-height: 1.2;
  color: #36454F;
}


.welcome p,
.welcome-sub {
  font-size: 16px;
  font-weight: 400;
  color: #6B7280;
  margin: 4px 0 0;
  letter-spacing: -0.2px;
}

/* Welcome option buttons */
.welcome-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 440px;
  margin-top: 28px;
}
.welcome-options .welcome-opt-btn { width: auto; min-height: 0; padding: 14px 16px; align-items: flex-start; gap: 6px; }
.welcome-options .wopt-icon { color: var(--hoja-seccion); font-size: 1.4rem; margin-bottom: 4px; }
.welcome-options .wopt-title { text-align: left; font-size: 0.92rem; }
.welcome-options .wopt-desc { text-align: left; font-size: 0.78rem; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.welcome-opt-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 18px;
  background: var(--card-bg, #fff);
  border: 1.5px solid var(--border, #E5E7EB);
  border-radius: 16px;
  cursor: pointer;
  width: 160px;
  min-height: 120px;
  transition: all 0.22s cubic-bezier(.4,0,.2,1);
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.welcome-opt-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(32,114,175,0.08) 0%, rgba(32,114,175,0.08) 100%);
  opacity: 0;
  transition: opacity 0.22s;
  border-radius: inherit;
}

.welcome-opt-btn:hover::before { opacity: 1; }

.welcome-opt-btn:hover {
  border-color: #2072AF;
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(32,114,175,0.15);
}

.welcome-opt-btn:active {
  transform: translateY(-1px);
}

.wopt-icon {
  font-size: 1.8rem;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.wopt-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary, #1F2937);
  position: relative;
  z-index: 1;
  text-align: center;
  line-height: 1.3;
}

.wopt-desc {
  font-size: 0.72rem;
  color: var(--text-muted, #9CA3AF);
  position: relative;
  z-index: 1;
  text-align: center;
  line-height: 1.3;
}

[data-theme="dark"] .welcome-opt-btn {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.1);
}
[data-theme="dark"] .welcome-opt-btn:hover {
  border-color: #2072AF;
  box-shadow: 0 8px 24px rgba(32,114,175,0.18);
}
[data-theme="dark"] .wopt-title { color: #E0E0E6; }
[data-theme="dark"] .wopt-desc { color: #6B7280; }



/* Messages full (replaces card when conversation starts) */
.messages-full {
  flex: 1;
  display: none;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.messages-full.visible {
  display: flex;
}

.messages-inner {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding-left: 8px;
}

/* ── Message bubbles ── */
.msg-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  animation: msgFadeIn 0.35s ease;
}

.msg-row:last-child {
  margin-bottom: 0;
}

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #1F2937;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: visible;
  align-self: flex-start;
  position: relative;
  z-index: 1;
}

.msg-avatar::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: #2072AF;
  z-index: -1;
  opacity: 0.7;
  -webkit-mask: radial-gradient(circle, transparent 14.5px, black 14.75px);
  mask: radial-gradient(circle, transparent 14.5px, black 14.75px);
}

.msg-avatar svg {
  width: 16px;
  height: 16px;
  display: block;
  position: relative;
  z-index: 1;
}

.msg-avatar img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: 50%;
  position: relative;
  z-index: 1;
}

.msg-avatar:has(img)::before {
  display: none;
}

@keyframes imaAvatarRingSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.msg-bubble {
  flex: 1;
  max-width: 82%;
  font-size: 13px;
  line-height: 1.6;
  color: #1F2937;
  border: none;
  overflow-wrap: break-word;
  word-break: break-word;
}

.msg-row.user .msg-bubble {
  flex: none;
  width: fit-content;
  border-radius: 12px 12px 4px 12px;
  padding: 8px 14px;
  max-width: 75%;
  background: #DEE5ED;
}

.msg-bubble p { margin: 0 0 4px; }
.msg-bubble p:last-child { margin-bottom: 0; }

.msg-bubble p,
.msg-bubble span,
.msg-bubble li {
  color: inherit !important;
}

.msg-row.user {
  flex-direction: row-reverse;
}

.msg-row.user .msg-avatar { display: none; }

/* ── History report placeholder ── */
.msg-report-placeholder {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #9CA3AF;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 0;
}
.msg-report-placeholder svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.6;
}

/* ── Report generated placeholder ── */
.report-placeholder {
  background: rgba(32,114,175,0.08);
  border: 1px solid rgba(32,114,175,0.2);
  border-radius: 10px;
  color: #2072AF;
  font-size: 12.5px;
  font-style: italic;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
[data-theme="dark"] .msg-report-placeholder { color: #8b8fa3; }
[data-theme="dark"] .msg-report-placeholder svg { opacity: 0.5; }

/* ── Typing indicator ── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.typing-indicator-new {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  font-size: 14px;
  color: #6B7280;
}

/* iOS-style circular spinner loader */
.ios-spinner {
  position: relative;
  width: 24px;
  height: 24px;
  --spinner-idle-bg: rgba(181, 102, 255, 0.22);
  flex-shrink: 0;
}

[data-theme="dark"] .ios-spinner {
  --spinner-idle-bg: rgba(255, 255, 255, 0.15);
}

.ios-spinner .dot {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  margin-top: -2.5px;
  margin-left: -2.5px;
  background-color: var(--spinner-idle-bg);
  animation: iosSpinnerFadeColor 0.8s linear infinite;
}

.ios-spinner .dot:nth-child(1) { transform: rotate(0deg) translateY(-9px); animation-delay: 0s; --dot-color: #2072AF; }
.ios-spinner .dot:nth-child(2) { transform: rotate(45deg) translateY(-9px); animation-delay: -0.7s; --dot-color: #2a8cd4; }
.ios-spinner .dot:nth-child(3) { transform: rotate(90deg) translateY(-9px); animation-delay: -0.6s; --dot-color: #4da6e0; }
.ios-spinner .dot:nth-child(4) { transform: rotate(135deg) translateY(-9px); animation-delay: -0.5s; --dot-color: #6bb5e8; }
.ios-spinner .dot:nth-child(5) { transform: rotate(180deg) translateY(-9px); animation-delay: -0.4s; --dot-color: #2072AF; }
.ios-spinner .dot:nth-child(6) { transform: rotate(225deg) translateY(-9px); animation-delay: -0.3s; --dot-color: #2a8cd4; }
.ios-spinner .dot:nth-child(7) { transform: rotate(270deg) translateY(-9px); animation-delay: -0.2s; --dot-color: #4da6e0; }
.ios-spinner .dot:nth-child(8) { transform: rotate(315deg) translateY(-9px); animation-delay: -0.1s; --dot-color: #6bb5e8; }

@keyframes iosSpinnerFadeColor {
  0% {
    background-color: var(--dot-color);
    box-shadow: 0 0 6px var(--dot-color);
    opacity: 1;
  }
  100% {
    background-color: var(--spinner-idle-bg);
    box-shadow: none;
    opacity: 0.35;
  }
}

/* ── Input Area ── */
.input-area {
  flex-shrink: 0;
  padding: 12px 0 16px;
  margin-top: auto;
  background: transparent;
  border-top: none;
}

/* Aura azul mientras ImaThorly responde, la misma idea de Thorly IA con el azul de la marca */
.ima-raiz { --aura-rgb: 32, 114, 175; }
.ima-raiz[data-theme="dark"] { --aura-rgb: 90, 170, 255; }
.ima-raiz.app-is-thinking .input-area { position: relative; z-index: 2; }
.ima-raiz.app-is-thinking .input-area::before {
  content: '';
  position: absolute;
  left: -20%;
  right: -20%;
  bottom: 0;
  height: 240px;
  pointer-events: none;
  transform-origin: bottom;
  background:
    radial-gradient(ellipse 45% 75% at 15% 100%, rgba(var(--aura-rgb), 0.42) 0%, transparent 100%),
    radial-gradient(ellipse 40% 100% at 35% 100%, rgba(var(--aura-rgb), 0.5) 0%, transparent 100%),
    radial-gradient(ellipse 30% 60% at 50% 100%, rgba(var(--aura-rgb), 0.4) 0%, transparent 100%),
    radial-gradient(ellipse 40% 100% at 65% 100%, rgba(var(--aura-rgb), 0.52) 0%, transparent 100%),
    radial-gradient(ellipse 45% 75% at 85% 100%, rgba(var(--aura-rgb), 0.42) 0%, transparent 100%);
  animation: ima-aura-olas 3.5s infinite alternate ease-in-out;
}
.ima-raiz.app-is-thinking .input-box {
  border-color: rgba(var(--aura-rgb), 0.6);
  animation: ima-aura-input 2.5s ease-in-out infinite;
}
.ima-raiz .input-box:focus-within {
  border-color: rgb(var(--aura-rgb));
  box-shadow: 0 0 0 3px rgba(var(--aura-rgb), 0.3), 0 0 26px 2px rgba(var(--aura-rgb), 0.3);
}
@keyframes ima-aura-olas {
  0% { opacity: 0.6; transform: translateY(5%) scaleY(0.85) translateX(-1%); }
  50% { opacity: 1; transform: translateY(0) scaleY(1.05) translateX(1%); }
  100% { opacity: 0.8; transform: translateY(2%) scaleY(0.95) translateX(2%); }
}
@keyframes ima-aura-input {
  0%, 100% { box-shadow: 0 0 30px 3px rgba(var(--aura-rgb), 0.3), 0 5px 40px rgba(var(--aura-rgb), 0.3); }
  50% { box-shadow: 0 0 46px 8px rgba(var(--aura-rgb), 0.45), 0 8px 60px rgba(var(--aura-rgb), 0.4); }
}
@media (prefers-reduced-motion: reduce) {
  .ima-raiz.app-is-thinking .input-area::before,
  .ima-raiz.app-is-thinking .input-box { animation: none; }
}

.input-box {
  display: flex;
  align-items: center;
  min-height: 48px;
  background: #FFFFFF;
  border: 1.5px solid #d0d0cc;
  border-radius: 16px;
  padding: 4px 4px 4px 16px;
  gap: 4px;
  position: relative;
  z-index: 1;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.input-box:focus-within {
  border-color: #2072AF;
  box-shadow: 0 0 0 4px rgba(32,114,175,0.1);
}

.input-box textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: #36454F;
  resize: none;
  overflow-y: auto;
  max-height: 200px;
  min-height: 40px;
  line-height: 24px;
  padding: 8px 0;
}

.input-box textarea::placeholder { color: #6B7280; }

.input-mic {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #9CA3AF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.input-mic:hover { background: #F3F4F6; color: #36454F; }
.input-mic.active-listening {
  color: #EF4444;
  background: #FEF2F2;
  animation: imaPulse 1.5s ease-in-out infinite;
}

@keyframes imaPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

.input-send {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #9CA3AF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.input-send:hover:not(:disabled) {
  background: #2072AF;
  color: #fff;
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(32,114,175,0.3);
}
.input-send:disabled {
  display: none;
}

/* Voice indicator */
/* ═══════════════════════════════════════
   VOICE — GEMINI INLINE STYLE
   ═══════════════════════════════════════ */

.voice-indicator { display: none !important; }

/* Mic button recording state */
.input-mic.active-listening {
  color: #3b82f6 !important;
  background: transparent !important;
  animation: none !important;
}
/* Gentle glow on the input box when recording */
.input-box.voice-recording {
  border-color: rgba(59,130,246,0.5) !important;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12) !important;
  transition: border-color 0.2s, box-shadow 0.2s;
}

/* Inline waveform canvas — sits where the textarea text would be */
.voice-inline-wave {
  flex: 1;
  height: 28px;
  border-radius: 4px;
  display: none; /* shown via JS */
  align-self: center;
  min-width: 0;
}

/* Square stop button inside input */
.voice-inline-stop {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: none;
  background: rgba(239,68,68,0.12);
  color: #ef4444;
  cursor: pointer;
  display: none; /* shown via JS */
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.voice-inline-stop:hover {
  background: rgba(239,68,68,0.25);
}

/* Dark overrides */
[data-theme="dark"] .input-box.voice-recording {
  border-color: rgba(96,165,250,0.4) !important;
  box-shadow: 0 0 0 3px rgba(96,165,250,0.1) !important;
}


/* File preview */
.file-preview {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 0 4px 8px;
  font-size: 13px;
  color: #6B7280;
}

.file-preview.visible { display: flex; }

.file-preview button {
  border: none;
  background: transparent;
  color: #9CA3AF;
  cursor: pointer;
  padding: 2px;
  display: flex;
}

.file-preview button:hover { color: #EF4444; }

/* Message actions */
.msg-actions {
  display: flex;
  gap: 2px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 0.2s;
}

.msg-row:hover .msg-actions { opacity: 1; }

.msg-action {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #9CA3AF;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.msg-action:hover { background: #303030; color: #E0E0E6; }

/* ═══════════════════════════════════════
   RIGHT PANEL (Editor) — now occupies center
   ═══════════════════════════════════════ */

/* Colores del editor: el papel y el marco que lo rodea */
.ima-raiz {
  --hoja-papel: #FFFFFF;
  --hoja-texto: #1F2937;
  --hoja-titulo: #111827;
  --hoja-seccion: #2072AF;
  --hoja-corte: rgba(32,114,175,0.35);
  --hoja-lienzo: #E9EAEE;
  --hoja-sombra: 0 0 0 1px rgba(0,0,0,0.05), 0 2px 6px rgba(0,0,0,0.06), 0 12px 32px rgba(0,0,0,0.08);
  --marco-fondo: #FFFFFF;
  --marco-borde: #E2E4E9;
  --marco-texto: #4B5563;
  --marco-fuerte: #1F2937;
  --marco-suave: rgba(0,0,0,0.05);
  --marco-activo: rgba(32,114,175,0.12);
  --marco-acento: #2072AF;
  --mascota-hoja: url(../image/mascota/sentado-papel-claro.webp);
  --pista-zoom: #D9DBE1;
  --barra-marco: #8A8F99;
}
.ima-raiz[data-theme="dark"] {
  /* Carbón de Mind: la hoja es la superficie sobre el lienzo; al imprimir sale siempre en blanco */
  --hoja-papel: #252525;
  --hoja-texto: #D4D4D4;
  --hoja-titulo: #F0F0F0;
  --hoja-seccion: #529CCA;
  --hoja-corte: rgba(82,156,202,0.35);
  --mascota-hoja: url(../image/mascota/sentado-papel-oscuro.webp);
  --hoja-lienzo: #191919;
  --hoja-sombra: 0 0 0 1px rgba(255,255,255,0.07), 0 10px 30px rgba(0,0,0,0.55);
  --marco-fondo: #202020;
  --marco-borde: #373737;
  --marco-texto: #A0A0A6;
  --marco-fuerte: #F0F0F0;
  --marco-suave: rgba(255,255,255,0.06);
  --marco-activo: rgba(82,156,202,0.16);
  --marco-acento: #529CCA;
  --pista-zoom: #373737;
  --barra-marco: #77777D;
}

.ima-right {
  flex: 1 !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  background: #F3F4F6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  resize: none;
  padding: 0;
  /* La hoja es un A4 a escala: a 100 % cabe en el panel y todo lo que hay en ella crece con su ancho. Así lo que se
     lee aquí corta donde corta al imprimir, a cualquier zoom y con el chat del ancho que sea */
  container-type: inline-size;
  --ancho-hoja: calc(min(794px, 100cqw - 36px) * var(--zoom-scale));
  --cm-hoja: calc(var(--ancho-hoja) / 21);
  --margen-hoja: calc(var(--cm-hoja) * 2.5);
  --alto-hoja: calc(var(--ancho-hoja) * 1.4142);
  --util-hoja: calc(var(--alto-hoja) - 2 * var(--margen-hoja));
  --fuente-hoja: max(calc(12.5px * var(--zoom-scale)), calc(var(--ancho-hoja) * 14 / 794));
}

/* ── Resize Handle ── */
.resize-handle, #resizeHandle {
  width: 4px !important;
  min-width: 4px !important;
  max-width: 4px !important;
  flex-shrink: 0;
  background: transparent !important;
  cursor: col-resize !important;
  position: relative;
  border: none !important;
  border-left: none !important;
  border-right: none !important;
  padding: 0 !important;
  z-index: 10;
  transition: background 0.15s;
}
.resize-handle:hover, #resizeHandle:hover {
  background: rgba(32,114,175,0.25) !important;
}
.resize-handle.active, #resizeHandle.active {
  background: rgba(32,114,175,0.35) !important;
}
.resize-handle::before,
.resize-handle::after,
#resizeHandle::before,
#resizeHandle::after {
  display: none !important;
  content: none !important;
}

.resize-handle:hover::before,
.resize-handle.active::before {
  background: #2072AF;
  opacity: 0.5;
  height: 64px;
}

.ima-raiz.resizing {
  cursor: col-resize;
  user-select: none;
}

.ima-raiz.resizing .ima-right {
  transition: none;
}

.editor-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--marco-fondo);
  border-bottom: 1px solid var(--marco-borde);
  flex-shrink: 0;
}

.editor-header-left {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--marco-fuerte);
  letter-spacing: -0.2px;
}

.editor-header-left i { color: var(--marco-acento); font-size: 18px; flex-shrink: 0; }
.editor-title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.editor-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.editor-accion {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  background: transparent;
  border: 1px solid var(--marco-borde);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--marco-texto);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.editor-accion i.ti { font-size: 16px; }
.editor-accion:hover { background: var(--marco-suave); color: var(--marco-fuerte); }
.editor-accion.principal { background: #2072AF; border-color: #2072AF; color: #FFFFFF; }
.editor-accion.principal:hover { background: #1a5d8f; border-color: #1a5d8f; color: #FFFFFF; }
.editor-accion.hecho, .editor-accion.hecho:hover { background: #2e7d32; border-color: #2e7d32; color: #FFFFFF; }
.editor-accion:focus-visible { outline: 2px solid var(--marco-acento); outline-offset: 2px; }

.download-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  background: #FFFFFF;
  border: 1px solid #d0d0cc;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: #6B7280;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}

.download-btn:hover { background: #F8F9FA; border-color: #2072AF; color: #2072AF; }
.download-btn svg { width: 15px; height: 15px; }

/* Editor Card */
.editor-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--hoja-lienzo);
  overflow: hidden;
  position: relative;
}

:root {
  --zoom-scale: 1;
}

/* Cinta: un tramo fijo sobre la hoja, como en un procesador de textos. Antes de que Quill la adopte sus controles no
   tienen icono: se guarda el alto y no se enseñan */
.editor-card .editor-cinta {
  position: relative;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
  gap: 2px 0;
  min-height: 42px;
  padding: 4px 10px;
  background: var(--marco-fondo);
  border: 0;
  border-bottom: 1px solid var(--marco-borde);
  font-family: inherit;
}
.editor-cinta:not(.ql-toolbar) > * { visibility: hidden; }

.editor-card .editor-cinta .ql-formats {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  margin: 0;
  padding: 0 5px;
}
.editor-card .editor-cinta .ql-formats + .ql-formats { border-left: 1px solid var(--marco-borde); }

.editor-card .editor-cinta button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  float: none;
  width: 30px;
  height: 30px;
  padding: 6px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--marco-texto);
  cursor: pointer;
  transition: background 0.15s;
}
.editor-card .editor-cinta .cinta-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.editor-card .editor-cinta .cinta-interlineado { gap: 2px; }
.editor-card .editor-cinta .cinta-interlineado-btn { width: auto; padding: 0 6px; gap: 3px; font-size: 13px; }
.editor-card .editor-cinta .cinta-interlineado-btn svg { width: 15px; height: 15px; stroke-width: 2.2; }
.editor-card .editor-cinta .cinta-interlineado-btn .cinta-signo { font-size: 13px; font-weight: 700; line-height: 1; }
.editor-card .editor-cinta .cinta-interlineado-valor {
  width: auto;
  min-width: 34px;
  padding: 0 5px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--marco-texto);
}
.editor-card .editor-cinta .cinta-interlineado button:disabled { opacity: 0.35; cursor: default; }
.editor-card .editor-cinta .cinta-interlineado button:disabled:hover { background: transparent; color: var(--marco-texto); }
.editor-estado .estado-paginas.varias { color: #D97706; font-weight: 600; }
[data-theme="dark"] .editor-estado .estado-paginas.varias { color: #FBBF24; }

/* Anillo de límite de 5 horas (estilo Claude Code / Codex) dentro de .input-box */
.cuota-aviso {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.28);
  color: #B91C1C;
  font-size: 12.5px;
  line-height: 1.35;
}
[data-theme="dark"] .cuota-aviso {
  background: rgba(239, 68, 68, 0.14);
  color: #FCA5A5;
}
.cuota-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.cuota-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s;
}
.cuota-btn:hover { background: var(--marco-suave); }
.cuota-btn svg {
  width: 22px;
  height: 22px;
  transform: rotate(-90deg);
}
.cuota-pista {
  fill: none;
  stroke: rgba(107, 114, 128, 0.25);
  stroke-width: 2.6;
}
[data-theme="dark"] .cuota-pista { stroke: rgba(255, 255, 255, 0.14); }
.cuota-arco {
  fill: none;
  stroke: #2072AF;
  stroke-width: 2.6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.35s ease, stroke 0.2s ease;
}
.cuota-wrap.aviso .cuota-arco { stroke: #D97706; }
[data-theme="dark"] .cuota-wrap.aviso .cuota-arco { stroke: #FBBF24; }
.cuota-wrap.agotada .cuota-arco { stroke: #EF4444; }
.cuota-globo {
  display: none;
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: 248px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--marco-fondo, #FFFFFF);
  border: 1px solid var(--marco-borde, #E5E7EB);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
  color: var(--marco-texto, #374151);
  font-size: 12px;
  line-height: 1.4;
  z-index: 60;
}
.cuota-wrap:hover .cuota-globo,
.cuota-wrap.abierto .cuota-globo { display: block; }
.cuota-globo-arriba {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--marco-fuerte, #111827);
  font-size: 12.5px;
}
.cuota-barra {
  height: 5px;
  border-radius: 999px;
  background: rgba(107, 114, 128, 0.2);
  overflow: hidden;
  margin-bottom: 8px;
}
.cuota-barra span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #2072AF;
  transition: width 0.35s ease;
}
.cuota-wrap.aviso .cuota-barra span { background: #D97706; }
[data-theme="dark"] .cuota-wrap.aviso .cuota-barra span { background: #FBBF24; }
.cuota-wrap.agotada .cuota-barra span { background: #EF4444; }
.cuota-texto { margin: 0 0 6px; }
.cuota-tip { margin: 0; font-size: 11.5px; opacity: 0.78; }
.editor-card .editor-cinta button:hover { background: var(--marco-suave); color: var(--marco-fuerte); }
.editor-card .editor-cinta button.ql-active { background: var(--marco-activo); }
.editor-card .editor-cinta button:focus-visible,
.editor-card .editor-cinta .ql-picker-label:focus-visible { outline: 2px solid var(--marco-acento); outline-offset: 1px; }

.editor-card .editor-cinta .ql-stroke { stroke: var(--marco-texto) !important; }
.editor-card .editor-cinta .ql-fill { fill: var(--marco-texto) !important; }
.editor-card .editor-cinta button:hover .ql-stroke { stroke: var(--marco-fuerte) !important; }
.editor-card .editor-cinta button:hover .ql-fill { fill: var(--marco-fuerte) !important; }
.editor-card .editor-cinta .ql-active .ql-stroke { stroke: var(--marco-acento) !important; }
.editor-card .editor-cinta .ql-active .ql-fill { fill: var(--marco-acento) !important; }

.editor-card .editor-cinta .ql-picker {
  float: none;
  height: 30px;
  font-size: 13px;
  color: var(--marco-texto);
}
.editor-card .editor-cinta .ql-picker.ql-header { width: 104px; }
.editor-card .editor-cinta .ql-picker.ql-size { width: 66px; }
.editor-card .editor-cinta .ql-picker.ql-font { width: 156px; }
.editor-card .editor-cinta .ql-picker.ql-color-picker { width: 32px; }
.editor-card .editor-cinta .ql-color-picker .ql-picker-label { padding: 0 6px; }
.editor-card .editor-cinta .ql-color-picker svg { display: block; width: 18px; height: 18px; }
.editor-card .editor-cinta .ql-color-picker .ql-stroke { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.editor-card .editor-cinta .ql-color-picker .ql-fill { fill: currentColor; stroke: none; }
.editor-card .editor-cinta .ql-color-picker .ql-picker-options { width: 172px; }
.editor-card .editor-cinta .ql-color-picker .ql-picker-item { float: left; width: 18px; height: 18px; margin: 2px; padding: 0; border: 1px solid var(--marco-borde); }
.editor-card .editor-cinta .ql-picker-label::before { white-space: nowrap; }
.editor-card .editor-cinta .ql-picker-label {
  display: flex;
  align-items: center;
  height: 30px;
  padding: 0 20px 0 8px;
  border: 1px solid var(--marco-borde) !important;
  border-radius: 6px;
  color: inherit;
  cursor: pointer;
}
.editor-card .editor-cinta .ql-picker-label:hover,
.editor-card .editor-cinta .ql-picker.ql-expanded .ql-picker-label { background: var(--marco-suave); color: var(--marco-fuerte); }
.editor-card .editor-cinta .ql-picker-options {
  z-index: 40;
  margin-top: 4px;
  padding: 4px;
  background: var(--marco-fondo);
  border: 1px solid var(--marco-borde) !important;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.16);
}
.editor-card .editor-cinta .ql-picker-item { padding: 4px 8px; border-radius: 5px; color: var(--marco-texto); }
.editor-card .editor-cinta .ql-picker-item:hover { background: var(--marco-suave); color: var(--marco-fuerte); }
.editor-card .editor-cinta .ql-picker-item.ql-selected { color: var(--marco-acento); }

/* Quill trae estos nombres en inglés y los pone por CSS. Los dos valores por defecto dirían «Normal»: se distinguen */
.editor-card .editor-cinta .ql-picker.ql-header .ql-picker-label:not([data-value])::before,
.editor-card .editor-cinta .ql-picker.ql-header .ql-picker-item:not([data-value])::before { content: 'Párrafo'; }
.editor-card .editor-cinta .ql-picker.ql-size .ql-picker-label:not([data-value])::before,
.editor-card .editor-cinta .ql-picker.ql-size .ql-picker-item:not([data-value])::before { content: '10,5'; }
.editor-card .editor-cinta .ql-picker.ql-header .ql-picker-label[data-value="1"]::before,
.editor-card .editor-cinta .ql-picker.ql-header .ql-picker-item[data-value="1"]::before { content: 'Título 1'; }
.editor-card .editor-cinta .ql-picker.ql-header .ql-picker-label[data-value="2"]::before,
.editor-card .editor-cinta .ql-picker.ql-header .ql-picker-item[data-value="2"]::before { content: 'Título 2'; }
.editor-card .editor-cinta .ql-picker.ql-header .ql-picker-label[data-value="3"]::before,
.editor-card .editor-cinta .ql-picker.ql-header .ql-picker-item[data-value="3"]::before { content: 'Título 3'; }
.editor-card .editor-cinta .ql-picker.ql-size .ql-picker-label[data-value]::before,
.editor-card .editor-cinta .ql-picker.ql-size .ql-picker-item[data-value]::before,
.editor-card .editor-cinta .ql-picker.ql-font .ql-picker-label[data-value]::before,
.editor-card .editor-cinta .ql-picker.ql-font .ql-picker-item[data-value]::before { content: attr(data-label); }
.editor-card .editor-cinta .ql-picker.ql-font .ql-picker-label:not([data-value])::before,
.editor-card .editor-cinta .ql-picker.ql-font .ql-picker-item:not([data-value])::before { content: 'Arial'; }
.editor-card .editor-cinta .ql-picker.ql-size .ql-picker-options { max-height: 280px; overflow-y: auto; }

/* Marco: desplaza la hoja si no cabe. Es contenedor para que la hoja de una sola página sepa cuánto alto hay: el scroll
   solo sale cuando el texto, o el ancho con zoom alto, lo pide */
.editor-marco {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--hoja-lienzo);
  scrollbar-width: thin;
  scrollbar-color: var(--barra-marco) transparent;
  scrollbar-gutter: stable;
  container-type: size;
}

/* Hoja: el contenedor de Quill solo da el margen; el papel es .ql-editor. Lleva la letra, los márgenes y el interlineado
   de DocumentoDeInforme y crece de página en página. Con una sola página llega hasta un A4, sin pasar del alto del panel */
.editor-anfitrion {
  position: relative;
  min-width: calc(var(--ancho-hoja) + 24px);
}
#editorContainer {
  height: auto;
  padding: 12px;
  background: none;
  border: 0;
  font-family: Arial, Helvetica, sans-serif;
}
#editorContainer .ql-editor {
  position: relative;
  box-sizing: border-box;
  width: var(--ancho-hoja);
  height: auto;
  min-height: min(var(--alto-hoja), 100cqh - 24px);
  margin: 0 auto;
  padding: var(--margen-hoja);
  overflow: visible;
  background-color: var(--hoja-papel);
  box-shadow: var(--hoja-sombra);
  font-family: Arial, Helvetica, sans-serif;
  font-size: var(--fuente-hoja);
  line-height: var(--interlineado-hoja, 1.5);
  color: var(--hoja-texto);
}
.editor-marco.varias-paginas #editorContainer .ql-editor {
  min-height: calc(2 * var(--margen-hoja) + var(--util-hoja) * var(--paginas-hoja, 1));
}
#editorContainer .ql-editor p { margin: 0 0 calc(0.571em * var(--interlineado-hoja, 1.5) / 1.5); }
#editorContainer .ql-editor .ql-size-small { font-size: .86em; }
#editorContainer .ql-editor .ql-size-large { font-size: 1.25em; }
#editorContainer .ql-editor .ql-size-huge { font-size: 1.6em; }
#editorContainer .ql-editor h1 { margin: 0 0 0.333em; font-size: 1.571em; line-height: 1.25; font-weight: 700; color: var(--hoja-titulo); }
#editorContainer .ql-editor h2 {
  margin: 1.43em 0 0.43em;
  font-size: 1.143em;
  line-height: 1.3;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.036em;
  color: var(--hoja-seccion);
}
#editorContainer .ql-editor h3 { margin: 1em 0 0.3em; font-size: 1.071em; line-height: 1.3; font-weight: 700; color: var(--hoja-titulo); }
#editorContainer .ql-editor ol { margin: 0 0 calc(0.571em * var(--interlineado-hoja, 1.5) / 1.5); }
#editorContainer .ql-editor li { margin-bottom: calc(0.286em * var(--interlineado-hoja, 1.5) / 1.5); }

/* Dónde corta cada página al imprimir: banda visual de separación entre hojas para ver claro cuándo pasó a la siguiente */
#editorContainer .ql-editor:not(.ql-blank)::after {
  content: '';
  position: absolute;
  top: var(--margen-hoja);
  left: -2px;
  right: -2px;
  height: calc(var(--util-hoja) * (var(--paginas-hoja, 1) - 1));
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 calc(var(--util-hoja) - 20px),
    rgba(0, 0, 0, 0.14) calc(var(--util-hoja) - 20px) calc(var(--util-hoja) - 19px),
    var(--hoja-lienzo) calc(var(--util-hoja) - 19px) calc(var(--util-hoja) - 1px),
    rgba(0, 0, 0, 0.14) calc(var(--util-hoja) - 1px) var(--util-hoja)
  );
  pointer-events: none;
}

/* Hoja sin texto. Va sobre el papel de Quill (.ql-blank), no encima: se desplaza con la hoja y se va al hacer clic en
   ella (:focus), para escribir en limpio. Vuelve si se sale de la hoja sin haber escrito nada. A distancia fija del borde
   superior: un A4 es más alto que la pantalla y centrada quedaría fuera de lo visible. La mascota va en grises sacados
   del papel de cada tema, como una marca de agua que espera a que se escriba */
#editorContainer .ql-editor.ql-blank:not(:focus),
.editor-anfitrion:empty::before {
  background-image: var(--mascota-hoja);
  background-repeat: no-repeat;
  background-size: auto 132px;
  background-position: center 96px;
}
#editorContainer .ql-editor.ql-blank:not(:focus)::before,
#editorContainer .ql-editor.ql-blank:not(:focus)::after,
.editor-anfitrion:empty::after {
  position: absolute;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  text-align: center;
  font-family: var(--font-sans, 'Inter', sans-serif);
  font-style: normal;
  pointer-events: none;
}
#editorContainer .ql-editor.ql-blank:not(:focus)::before,
.editor-anfitrion:empty::after {
  content: 'Sin informe que mostrar';
  top: 244px;
  width: 100%;
  font-size: 16px;
  font-weight: 600;
  color: var(--marco-texto);
}
#editorContainer .ql-editor.ql-blank:not(:focus)::after {
  content: 'Genere o seleccione un informe desde el chat para comenzar';
  top: 272px;
  width: 260px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--marco-texto);
}

/* El papel antes de que Quill termine de cargar: la hoja no aparece de golpe ni mueve lo demás */
.editor-anfitrion:empty::before {
  content: '';
  display: block;
  width: var(--ancho-hoja);
  height: min(var(--alto-hoja), 100cqh - 24px);
  margin: 12px auto;
  background-color: var(--hoja-papel);
  box-shadow: var(--hoja-sombra);
}
.editor-anfitrion:empty::after { top: 256px; }

/* Barra de estado: lo que Word enseña al pie, en una sola línea fina */
.editor-footer {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    min-height: 30px;
    padding: 0 10px 0 14px;
    background: var(--marco-fondo);
    border-top: 1px solid var(--marco-borde);
    font-size: 12px;
    color: var(--marco-texto);
}
.editor-estado {
    display: flex;
    gap: 16px;
    min-width: 0;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.editor-zoom {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}
.editor-zoom button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    min-width: 24px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 5px;
    font-family: inherit;
    font-size: 12px;
    color: var(--marco-texto);
    cursor: pointer;
    transition: background 0.15s;
}
.editor-zoom button i.ti { font-size: 14px; }
.editor-zoom button:hover { background: var(--marco-suave); color: var(--marco-fuerte); }
.editor-zoom button:focus-visible,
.zoom-deslizador:focus-visible { outline: 2px solid var(--marco-acento); outline-offset: 2px; }
.editor-zoom .zoom-porcentaje { min-width: 44px; font-variant-numeric: tabular-nums; }
.zoom-deslizador {
    -webkit-appearance: none;
    appearance: none;
    width: 96px;
    height: 3px;
    margin: 0 4px;
    background: var(--pista-zoom);
    border-radius: 2px;
    cursor: pointer;
}
.zoom-deslizador::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--marco-acento);
    border: 0;
    border-radius: 50%;
}
.zoom-deslizador::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--marco-acento);
    border: 0;
    border-radius: 50%;
}

.editor-footer-left {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 8px;
    align-items: center;
    z-index: 30;
    background: rgba(30,33,48,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 6px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

/* Accept button — blue primario */
.btn-accept, #btnAcceptChanges,
.editor-footer-left .btn-accept {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px !important;
    background: #2072AF !important;
    color: #fff;
    border: none !important;
    border-radius: 9px !important;
    cursor: pointer;
    font-weight: 600 !important;
    font-size: 13px !important;
    font-family: inherit;
    transition: all 0.2s !important;
}
.btn-accept:hover, #btnAcceptChanges:hover,
.editor-footer-left .btn-accept:hover {
    background: #1a5d8f !important;
}

/* Reject button — neutro con borde */
.btn-reject, #btnCancelChanges,
.editor-footer-left .btn-reject {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px !important;
    background: rgba(255,255,255,0.06) !important;
    color: #C9CDD6 !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    border-radius: 9px !important;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px !important;
    font-family: inherit;
    transition: all 0.2s !important;
}
.btn-reject:hover, #btnCancelChanges:hover,
.editor-footer-left .btn-reject:hover {
    background: rgba(255,255,255,0.1) !important;
    border-color: rgba(255,255,255,0.2) !important;
}



.ima-right { border-right: none !important; border-left: none !important; }


/* ═══════════════════════════════════════
   NETWORK NOTIFICATION
   ═══════════════════════════════════════ */
.network-notification {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  white-space: nowrap;
}

.network-notification.show { top: 24px; }

.network-notification .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.network-notification .icon i { width: 18px; height: 18px; }

.network-notification .text {
  font-size: 14px;
  font-weight: 500;
  color: #1F2937;
}

.network-notification.offline { border-color: rgba(248, 113, 113, 0.4); }
.network-notification.offline .icon i { color: #f87171; }
.network-notification.online { border-color: rgba(52, 211, 153, 0.4); }
.network-notification.online .icon i { color: #34d399; }

/* ═══════════════════════════════════════
   TOAST
   ═══════════════════════════════════════ */
.ima-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1A1F2E !important;
  border: 1px solid #252D40 !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4) !important;
  border-radius: 12px !important;
  color: #FFFFFF;
  padding: 10px 20px;
  font-size: 13px !important;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 99999;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.ima-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ═══════════════════════════════════════
   SETTINGS PANEL
   ═══════════════════════════════════════ */
#settingsOverlay {
  position: fixed; inset: 0; z-index: 999998;
  background: rgba(0,0,0,0.5);
  opacity: 0; visibility: hidden; transition: all 0.25s;
}

#settingsPanel {
  position: fixed; top: 0; right: 0; width: 380px; max-width: 90vw; height: 100vh;
  z-index: 999999; background: #202020; border-left: 1px solid #303030;
  box-shadow: -8px 0 30px rgba(0,0,0,0.3);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16,1,0.3,1);
  display: flex; flex-direction: column; overflow: hidden;
}

#templatesOverlay {
  position: fixed; inset: 0; z-index: 999998;
  background: rgba(0,0,0,0.5);
  opacity: 0; visibility: hidden; transition: all 0.25s;
}
#templatesPanel {
  position: fixed; top: 0; right: 0; width: 380px; max-width: 90vw; height: 100vh;
  z-index: 999999; background: #202020; border-left: 1px solid #303030;
  box-shadow: -8px 0 30px rgba(0,0,0,0.3);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16,1,0.3,1);
  display: flex; flex-direction: column; overflow: hidden;
}
#templateList .template-empty { font-size:13px; color:#9CA3AF; padding:8px 0; }
#templateList .template-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 8px; font-size: 13px; color: #1F2937; transition: background 0.15s;
}
#templateList .template-item:hover { background: #F3F4F6; }
#templateList .template-item .template-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#templateList .template-item .template-del {
  width: 24px; height: 24px; border-radius: 50%; border: none; background: transparent;
  color: #9CA3AF; cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1; transition: all 0.15s; flex-shrink: 0;
}
#templateList .template-item .template-del:hover { background: #FEE2E2; color: #EF4444; }

[data-theme="dark"] #templatesPanel { background: #202020; border-left-color: #303030; box-shadow: -8px 0 30px rgba(0,0,0,0.3); }
[data-theme="dark"] #templatesPanel h5 { color: #E0E0E6 !important; }
[data-theme="dark"] #templatesPanel div[style*="border-bottom"] { border-bottom-color: #303030 !important; }
[data-theme="dark"] #templatesOverlay { background: rgba(0,0,0,0.5); }
[data-theme="dark"] #templatesPanel label[for="templateFileInput"] { border-color: rgba(255,255,255,0.12) !important; color: #9CA3AF !important; }
[data-theme="dark"] #templatesPanel label[for="templateFileInput"]:hover { background: rgba(255,255,255,0.06) !important; border-color: rgba(255,255,255,0.2) !important; color: #E5E7EB !important; }
[data-theme="dark"] #templateList .template-item { color: #E3E3E3; }
[data-theme="dark"] #templateList .template-item:hover { background: rgba(255,255,255,0.06); }
[data-theme="dark"] #templateList .template-item .template-del:hover { background: rgba(239,68,68,0.2); color: #FCA5A5; }

/* ═══════════════════════════════════════
   LOGO THEME SWITCH
   ═══════════════════════════════════════ */


/* Logo uses dual-img pattern below */

/* ═══════════════════════════════════════
   LOGOS CON FONDO TRANSPARENTE
   ═══════════════════════════════════════ */

/* Option Buttons */
.option-msg { margin-bottom: 12px; }
.option-btns { display: flex; flex-wrap: wrap; gap: 8px; max-width: 100%; }
.option-btn {
  padding: 8px 18px;
  border: 1px solid #d0d0cc;
  border-radius: 20px;
  background: #FFFFFF;
  color: #36454F;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  max-width: 100%;
  overflow-wrap: break-word;
}
.option-btn:hover {
  background: #F0F8FF;
  border-color: #2072AF;
  color: #2072AF;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(32,114,175,0.15);
}
.option-btn:active {
  transform: translateY(0);
  box-shadow: none;
}
/* Active sidebar item indicator — handled in base styles */

/* Download button handled in base styles */

/* Gradient text handled in base styles */

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */


@media (max-width: 1024px) {
  .ima-sidebar { display: none; }
  .resize-handle { display: none; }
  .ima-sep { display: none; }
  .center-inner { max-width: 100%; padding: 32px 20px 16px; }
  .welcome-logo-wrap { width: 95px; height: 95px; }
  .ima-logo-circle { width: 85px; height: 85px; }
  .welcome h1 { font-size: 30px; }

  /* En móvil el chat y el informe ocupan la pantalla completa por turnos.
     data-mobile-view lo controla imathorly.js (botones de las dos cabeceras). */
  .ima-center,
  .ima-right {
    flex: 1 1 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    border-left: none !important;
  }

  .ima-app[data-mobile-view="chat"] .ima-right { display: none !important; }
  .ima-app[data-mobile-view="editor"] .ima-center { display: none !important; }

  /* Enlace al inicio: en escritorio vive en la barra lateral, que aquí no existe */
  .mobile-only-btn { display: flex !important; text-decoration: none; }

  /* El informe necesita el ancho completo y poder hacer scroll */
  .editor-card { margin: 0 !important; border-radius: 0 !important; }
  .editor-header { padding: 10px 14px !important; }
}

@media (max-width: 768px) {
  .center-inner { padding: 16px 16px 12px; }
  .chat-header { padding: 0 12px; }
  .editor-header { padding: 10px 12px !important; }
  .editor-title-text { font-size: 13px; }
  .mobile-toggle { padding: 0 10px; height: 32px; font-size: 12px; }
  .welcome-logo-wrap { width: 70px; height: 70px; }
  .ima-logo-circle { width: 60px; height: 60px; }
  .welcome h1 { font-size: 26px; }
  .welcome p { font-size: 14px; }
  .input-box { min-height: 44px; border-radius: 22px; padding: 0 4px 0 10px; }
  .input-box textarea { font-size: 14px; }
  .msg-row.user .msg-bubble { max-width: 92%; }
  .msg-bubble { max-width: 92%; }
  .msg-row { margin-bottom: 16px; }
}

@media (min-width: 1025px) {
  .mobile-toggle { display: none; }
  .mobile-only-btn { display: none; }
}

/* ── Sidebar Footer ── */
.ima-sidebar .sidebar-footer {
  margin-top: auto;
  padding: 8px;
  border-top: 1px solid #d0d0cc;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ima-sidebar .sidebar-footer-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  color: #6B7280;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  width: 44px;
  height: 44px;
}
.ima-sidebar:hover .sidebar-footer-item {
  width: calc(100% - 8px);
  justify-content: flex-start;
  padding: 8px 12px;
}
.ima-sidebar .sidebar-footer-item span {
  display: none;
}
.ima-sidebar:hover .sidebar-footer-item span {
  display: inline;
}

.ima-sidebar .sidebar-footer-item:hover {
  background: rgba(32,114,175,0.06);
  color: #2072AF;
}

.ima-sidebar .sidebar-footer-item i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════
   DARK MODE
   ═══════════════════════════════════════ */
/* Scrollbar — already dark by default */
/* ═══════════════════════════════════════
   DARK MODE — Paleta Thorly AI
   ═══════════════════════════════════════ */

/* Scrollbar */
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #3a3d4a; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #53566a; }

/* App shell */
.ima-raiz[data-theme="dark"] { background: #191919; }
[data-theme="dark"] .ima-app {
  background: #191919 !important; 
}
[data-theme="dark"] .ima-center {
  background: #191919 !important;
  border-left: 1px solid #303030 !important;
}

/* Resize handle */
[data-theme="dark"] .resize-handle {
  background: #202020 !important;
}

/* Separador */
[data-theme="dark"] .ima-sep {
  background: #303030 !important;
}

/* Sidebar */
[data-theme="dark"] .ima-sidebar { 
  background: #202020 !important;
  border-right: 1px solid #303030 !important;
}
[data-theme="dark"] .sidebar-logo {
  border-bottom: 1px solid #303030 !important;
}
[data-theme="dark"] .sidebar-logo-text,
[data-theme="dark"] .sidebar-logo span {
  color: #F0F0F0 !important;
}
[data-theme="dark"] .sidebar-section-title {
  color: #555558 !important;
}
[data-theme="dark"] .sidebar-item .item-name {
  color: #888888 !important;
}
[data-theme="dark"] .sidebar-item.active .item-name {
  color: #F0F0F0 !important;
}
[data-theme="dark"] .sidebar-item .item-icon { color: #888888 !important; }
[data-theme="dark"] .sidebar-item.active .item-icon { color: #F0F0F0 !important; }
[data-theme="dark"] .sidebar-item .item-patient { color: #555558 !important; }
[data-theme="dark"] .sidebar-empty { color: #555558 !important; }
[data-theme="dark"] .sidebar-item:hover {
  background: rgba(255,255,255,0.04) !important;
  border-color: rgba(255,255,255,0.06) !important;
}
[data-theme="dark"] .sidebar-item.active {
  background: rgba(255,255,255,0.06) !important;
  border-color: rgba(32,114,175,0.2) !important;
}
[data-theme="dark"] .item-indicator {
  background: #2072AF !important;
}
[data-theme="dark"] .ima-sidebar .sidebar-footer {
  border-top: 1px solid #303030 !important;
}
[data-theme="dark"] .ima-sidebar .sidebar-footer-item { color: #888888 !important; }
[data-theme="dark"] .ima-sidebar .sidebar-footer-item:hover { background: rgba(255,255,255,0.04) !important; color: #F0F0F0 !important; }
[data-theme="dark"] .sidebar-search input {
  background: #1F1F1F !important;
  border: 1px solid #373737 !important;
  color: #E0E0E0 !important;
}
[data-theme="dark"] .sidebar-search input:focus {
  border-color: rgba(32,114,175,0.4) !important;
}
[data-theme="dark"] .sidebar-search input::placeholder { color: #555558 !important; }
[data-theme="dark"] .sidebar-search .search-icon { color: #555558 !important; }

/* Botón Nuevo informe */
[data-theme="dark"] .new-report-btn {
  background: #2072AF !important;
  box-shadow: 0 2px 8px rgba(32,114,175,0.35) !important;
  color: #FFFFFF !important;
}
[data-theme="dark"] .new-report-btn:hover {
  background: #1a5d8f !important;
  box-shadow: 0 4px 14px rgba(32,114,175,0.45) !important;
}

/* Template btn */
[data-theme="dark"] .template-btn {
  border-color: #373737 !important;
  color: #888888 !important;
}
[data-theme="dark"] .template-btn svg { color: #888888 !important; }
[data-theme="dark"] .template-btn:hover {
  border-color: #2072AF !important;
  color: #2072AF !important;
}
[data-theme="dark"] .template-btn:hover svg { color: #2072AF !important; }

[data-theme="dark"] .typing-indicator-new { color: #888888; }

[data-theme="dark"] .msg-report-placeholder { color: #555558 !important; }
[data-theme="dark"] .msg-report-placeholder svg { opacity: 0.4 !important; }

/* Welcome */
[data-theme="dark"] .welcome h1 { color: #F0F0F0 !important; }
[data-theme="dark"] .welcome p,
[data-theme="dark"] .welcome-sub { color: #888888 !important; }
[data-theme="dark"] .welcome-opt-btn {
  background: rgba(255,255,255,0.04) !important;
  border-color: rgba(255,255,255,0.08) !important;
}
[data-theme="dark"] .welcome-opt-btn:hover {
  border-color: rgba(32,114,175,0.4) !important;
  box-shadow: 0 8px 24px rgba(32,114,175,0.12) !important;
}
[data-theme="dark"] .wopt-title { color: #E0E0E0 !important; }
[data-theme="dark"] .wopt-desc { color: #888888 !important; }

/* Option buttons */
[data-theme="dark"] .option-btn {
  background: rgba(255,255,255,0.08) !important;
  border-color: rgba(255,255,255,0.15) !important;
  color: #E0E0E0 !important;
}
[data-theme="dark"] .option-btn:hover {
  background: rgba(32,114,175,0.08) !important;
  border-color: rgba(32,114,175,0.3) !important;
  color: #F0F0F0 !important;
}

/* Input */
[data-theme="dark"] .input-area {
  background: #191919 !important;
  border-top: 1px solid #1F1F1F !important;
  padding: 12px 16px !important;
}
[data-theme="dark"] .input-box {
  background: #1F1F1F !important;
  border: 1.5px solid #373737 !important;
  border-radius: 24px !important;
}
[data-theme="dark"] .input-box:focus-within {
  border-color: rgba(32,114,175,0.5) !important;
  box-shadow: 0 0 0 3px rgba(32,114,175,0.08) !important;
}
[data-theme="dark"] .input-box textarea { color: #F0F0F0 !important; }
[data-theme="dark"] .input-box textarea::placeholder { color: #8E8E96 !important; }
[data-theme="dark"] .input-send {
  background: transparent !important;
  color: #E0E0E0 !important;
  box-shadow: none !important;
}
[data-theme="dark"] .input-send:hover:not(:disabled) {
  background: #2072AF !important;
  color: #fff !important;
  box-shadow: 0 0 0 3px rgba(32,114,175,0.2) !important;
}
[data-theme="dark"] .input-mic { color: #888888 !important; }
[data-theme="dark"] .input-mic:hover { background: rgba(255,255,255,0.04) !important; color: #F0F0F0 !important; }
[data-theme="dark"] .input-mic.active-listening {
  color: #f87171;
  background: rgba(248,113,113,0.1);
  animation: imaPulseDark 1.5s ease-in-out infinite;
}

@keyframes imaPulseDark {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248,113,113,0.3); }
  50% { box-shadow: 0 0 0 8px rgba(248,113,113,0); }
}

/* File preview */
[data-theme="dark"] .file-preview { color: #888888 !important; }
[data-theme="dark"] .file-preview button { color: #555558 !important; }
[data-theme="dark"] .file-preview button:hover { color: #f87171 !important; }

/* Chat header */
[data-theme="dark"] .chat-header { background: #202020 !important; border-bottom: 1px solid #303030 !important; }
[data-theme="dark"] .chat-header-title { color: #F0F0F0 !important; }
[data-theme="dark"] .chat-header-btn { color: #888888 !important; }
[data-theme="dark"] .chat-header-btn:hover { background: rgba(255,255,255,0.04) !important; color: #F0F0F0 !important; }

/* Editor */
[data-theme="dark"] .download-btn { background: rgba(255,255,255,0.06) !important; border-color: rgba(255,255,255,0.1) !important; color: #888888 !important; }
[data-theme="dark"] .download-btn:hover { background: rgba(255,255,255,0.1) !important; border-color: rgba(255,255,255,0.2) !important; color: #F0F0F0 !important; }

/* Settings panel dark */
[data-theme="dark"] #settingsPanel { background: #202020 !important; border-left-color: #303030 !important; }
[data-theme="dark"] #settingsPanel h5 { color: #F0F0F0 !important; }
[data-theme="dark"] #settingsPanel span { color: #888888 !important; }
[data-theme="dark"] #settingsPanel div[style*="border-bottom"] { border-bottom-color: #303030 !important; }
[data-theme="dark"] #settingsPanel div[style*="font-size:13px"][style*="font-weight:600"] { color: #555558 !important; }
[data-theme="dark"] #customPromptInput { background: #1F1F1F !important; border-color: #373737 !important; color: #E0E0E0 !important; }
[data-theme="dark"] #settingsOverlay { background: rgba(0,0,0,0.6); }
#deleteHistoryBtn { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; font-family: inherit; transition: all 0.15s; padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 500; border: 1px solid rgba(0,0,0,0.08); background: rgba(0,0,0,0.03); color: inherit; }
[data-theme="dark"] #deleteHistoryBtn { background: rgba(255,255,255,0.04) !important; border-color: rgba(255,255,255,0.08) !important; color: #ccc !important; }

/* Templates panel dark */
[data-theme="dark"] #templatesPanel { background: #202020 !important; border-left-color: #303030 !important; }
[data-theme="dark"] #templatesPanel h5 { color: #F0F0F0 !important; }
[data-theme="dark"] #templatesPanel div[style*="border-bottom"] { border-bottom-color: #303030 !important; }
[data-theme="dark"] #templatesOverlay { background: rgba(0,0,0,0.6); }
[data-theme="dark"] #templatesPanel label[for="templateFileInput"] { border-color: #373737 !important; color: #888888 !important; }
[data-theme="dark"] #templatesPanel label[for="templateFileInput"]:hover { background: rgba(255,255,255,0.04) !important; border-color: rgba(255,255,255,0.15) !important; color: #F0F0F0 !important; }
[data-theme="dark"] #templateList .template-item { color: #E0E0E0 !important; }
[data-theme="dark"] #templateList .template-item:hover { background: rgba(255,255,255,0.04) !important; }
[data-theme="dark"] #templateList .template-item .template-del:hover { background: rgba(248,113,113,0.15) !important; color: #f87171 !important; }

/* Toast dark */
[data-theme="dark"] .ima-toast { background: #1F1F1F !important; color: #F0F0F0 !important; box-shadow: 0 8px 24px rgba(0,0,0,0.4) !important; border: 1px solid #373737 !important; }

/* Network notification dark */
[data-theme="dark"] .network-notification { background: #202020 !important; border-color: #373737 !important; }
[data-theme="dark"] .network-notification .text { color: #F0F0F0 !important; }

/* Voice modal dark (indicator kept for reference) */
[data-theme="dark"] .voice-indicator { color: #f87171; }
[data-theme="dark"] .voice-wave span { background: #f87171; }

/* ═══════════════════════════════════════
   MARKDOWN RENDERED CONTENT (modo oscuro)
   ═══════════════════════════════════════ */
.msg-content .md-h1 { font-size:1.3em; font-weight:700; margin:14px 0 6px; color:inherit; }
.msg-content .md-h2 { font-size:1.1em; font-weight:600; margin:12px 0 5px; color:inherit; }
.msg-content .md-h3 { font-size:1em; font-weight:600; margin:10px 0 4px; color:inherit; }
.msg-content .md-hr { border:none; border-top:1px solid rgba(128,128,128,0.2); margin:12px 0; }
.msg-content .md-blockquote {
  border-left:3px solid #2072AF; padding:6px 14px; margin:10px 0;
  background:rgba(32,114,175,0.08); border-radius:0 6px 6px 0; color:#9CA3AF; font-style:italic;
}
.msg-content .md-ul { padding-left:18px; margin:8px 0; }
.msg-content .md-ul li { margin-bottom:3px; }
.msg-content .md-link { color:#2072AF; text-decoration:none; word-break:break-all; }
.msg-content .md-link:hover { text-decoration:underline; }
.msg-content .inline-code {
  background:rgba(128,128,128,0.12); border:1px solid rgba(128,128,128,0.15);
  border-radius:4px; padding:1px 5px; font-family:monospace; font-size:0.85em; color:#f472b6;
}
.msg-content .code-block-container {
  background:#000; border:1px solid #333; border-radius:8px; overflow:hidden; margin:12px 0;
  box-shadow:0 2px 8px rgba(0,0,0,0.3);
}
.msg-content .code-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:5px 10px; background:#0d0d0d; border-bottom:1px solid #333;
  font-size:12px; color:#ccc;
}
.msg-content .code-header::before {
  content:''; display:inline-block; width:8px; height:8px; border-radius:50%;
  background:#ff5f57; margin-right:8px;
  box-shadow:12px 0 0 #fdbc36, 24px 0 0 #2acb4f;
}
.msg-content .code-lang { font-size:12px; color:#999; text-transform:lowercase; }
.msg-content .code-block-container pre {
  margin:0; padding:12px 14px; overflow-x:auto; font-size:13px; line-height:1.5;
  color:#d4d4d4; background:#000;
}
.msg-content .code-block-container code { font-family:monospace; font-size:13px; }
.msg-content .table-wrapper {
  overflow-x:auto; margin:14px 0; border-radius:8px;
  border:1px solid rgba(128,128,128,0.15); background:var(--msg-bg);
}
.msg-content .md-table { width:100%; min-width:350px; border-collapse:collapse; font-size:13px; }
.msg-content .md-table th,
.msg-content .md-table td {
  padding:8px 12px; border:1px solid rgba(128,128,128,0.12);
  color:inherit; text-align:left;
}
.msg-content .md-table th {
  background:rgba(128,128,128,0.08); font-weight:600; font-size:12px;
  border-bottom:2px solid #2072AF;
}
.msg-content .md-table tr:nth-child(even) { background:rgba(128,128,128,0.03); }
.msg-content .md-table tr:hover td { background:rgba(128,128,128,0.06); }
.msg-content .citation-pill {
  display:inline-flex; align-items:center; justify-content:center;
  background:rgba(128,128,128,0.12); color:#9CA3AF;
  border:1px solid rgba(128,128,128,0.18); border-radius:12px;
  padding:1px 7px; font-size:0.76em; font-weight:500; line-height:1.2;
  margin:0 3px; vertical-align:middle; cursor:pointer; text-decoration:none !important;
}
.msg-content .citation-pill:hover {
  background:rgba(128,128,128,0.22); color:#E5E7EB; border-color:rgba(128,128,128,0.3);
}
.msg-content .math-block {
  overflow-x:auto; padding:10px 14px; background:rgba(128,128,128,0.06);
  border-radius:8px; margin:10px 0; border:1px solid rgba(128,128,128,0.1); text-align:center;
}
.msg-content .copy-code-btn {
  display:flex; align-items:center; gap:4px; background:transparent; border:none;
  color:#999; font-size:12px; cursor:pointer; padding:2px 6px; border-radius:4px;
  font-family:inherit;
}
.msg-content .copy-code-btn:hover { background:rgba(255,255,255,0.08); color:#fff; }

/* Light mode overrides for markdown content */
[data-theme="light"] .msg-content .code-block-container {
  background:#fff; border-color:#e0e0e0; box-shadow:0 1px 4px rgba(0,0,0,0.08);
}
[data-theme="light"] .msg-content .code-header {
  background:#f3f3f3; border-bottom-color:#e0e0e0; color:#333;
}
[data-theme="light"] .msg-content .code-lang { color:#666; }
[data-theme="light"] .msg-content .code-block-container pre { background:#fff; color:#24292e; }
[data-theme="light"] .msg-content .inline-code { background:rgba(0,0,0,0.06); border-color:rgba(0,0,0,0.1); color:#d63384; }
[data-theme="light"] .msg-content .md-link { color:#2072AF; }
[data-theme="light"] .msg-content .md-blockquote { border-color:#2072AF; background:rgba(32,114,175,0.06); color:#6B7280; }
[data-theme="light"] .msg-content .md-table th { border-bottom-color:#2072AF; }
[data-theme="light"] .msg-content .citation-pill { color:#6B7280; }
[data-theme="light"] .msg-content .citation-pill:hover { background:rgba(0,0,0,0.1); color:#1F2937; }
[data-theme="light"] .msg-content .copy-code-btn { color:#888; }
[data-theme="light"] .msg-content .copy-code-btn:hover { background:rgba(0,0,0,0.06); color:#333; }

/* ── Nota ImaThorly highlight ── */
.msg-content .ima-note {
  margin-top: 12px;
  padding: 10px 14px;
  border-left: 4px solid #f59e0b;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  background: #fffbeb;
  color: #92400e;
}
[data-theme="dark"] .msg-content .ima-note {
  background: rgba(245, 158, 11, 0.12);
  border-left-color: #f59e0b;
  color: #fbbf24;
}

/* ── Bare report response (Gemini-style, no <report> tag) ── */
.msg-row.msg-bare-report .msg-bubble {
  border-left: 4px solid #f59e0b;
  padding-left: 14px;
  border-radius: 6px;
}
[data-theme="dark"] .msg-row.msg-bare-report .msg-bubble {
  border-left-color: #f59e0b;
}

/* ── Syntax Highlighting (hljs) ── */
.hljs { background:transparent; color:#d4d4d4; }
.hljs-keyword, .hljs-selector-tag, .hljs-type { color:#569cd6; }
.hljs-title, .hljs-title.function_, .hljs-function, .hljs-attr { color:#dcdcaa; }
.hljs-string, .hljs-bullet, .hljs-symbol { color:#ce9178; }
.hljs-number, .hljs-literal { color:#b5cea8; }
.hljs-comment, .hljs-quote { color:#6a9955; font-style:italic; }
.hljs-tag, .hljs-name { color:#569cd6; }
.hljs-attribute { color:#9cdcfe; }
.hljs-variable, .hljs-template-variable { color:#9cdcfe; }
.hljs-built_in { color:#4ec9b0; }
.hljs-meta { color:#d4d4d4; }
.hljs-doctag { color:#c586c0; }
.hljs-selector-id, .hljs-selector-class { color:#d7ba7d; }
.hljs-params { color:#9cdcfe; }
.hljs-property { color:#9cdcfe; }
.hljs-punctuation { color:#d4d4d4; }
[data-theme="light"] .hljs { color:#24292e; }
[data-theme="light"] .hljs-keyword, [data-theme="light"] .hljs-selector-tag, [data-theme="light"] .hljs-type { color:#d73a49; }
[data-theme="light"] .hljs-title, [data-theme="light"] .hljs-title.function_, [data-theme="light"] .hljs-attr { color:#6f42c1; }
[data-theme="light"] .hljs-string { color:#032f62; }
[data-theme="light"] .hljs-number, [data-theme="light"] .hljs-literal { color:#005cc5; }
[data-theme="light"] .hljs-comment { color:#6a737d; }
[data-theme="light"] .hljs-tag, [data-theme="light"] .hljs-name { color:#22863a; }
[data-theme="light"] .hljs-attribute { color:#6f42c1; }
[data-theme="light"] .hljs-variable { color:#e36209; }
[data-theme="light"] .hljs-built_in { color:#e36209; }
[data-theme="light"] .hljs-selector-id, [data-theme="light"] .hljs-selector-class { color:#6f42c1; }
[data-theme="light"] .hljs-property { color:#005cc5; }
[data-theme="light"] .hljs-params { color:#24292e; }

/* Sidebar items — mejor contraste (solo light) */
.ima-raiz:not([data-theme="dark"]) .sidebar-section-title {
  color: #4A5160 !important;
}

.ima-raiz:not([data-theme="dark"]) .sidebar-item .item-name {
  color: #7A8090 !important;
}

/* Option buttons (solo light) */
.ima-raiz:not([data-theme="dark"]) .option-btn {
  color: #C9CDD6 !important;
  border-color: #252D42 !important;
}
.ima-raiz:not([data-theme="dark"]) .option-btn:hover {
  color: #F0F2F5 !important;
  border-color: rgba(32,114,175,0.4) !important;
  background: rgba(32,114,175,0.06) !important;
}

/* ═══════════════════════════════════════
   LIGHT MODE — ImaThorly
   ═══════════════════════════════════════ */

/* === 6. SIDEBAR === */
.ima-raiz:not([data-theme="dark"]) .ima-sidebar,
[data-theme="light"] .ima-sidebar {
  background: #FFFFFF !important;
  border-right: 1px solid #E5E7EB !important;
}

[data-theme="light"] .sidebar-logo,
.ima-raiz:not([data-theme="dark"]) .sidebar-logo {
  border-bottom: 1px solid #d0d0cc !important;
}

[data-theme="light"] .sidebar-logo span,
[data-theme="light"] .sidebar-logo-text,
.ima-raiz:not([data-theme="dark"]) .sidebar-logo span,
.ima-raiz:not([data-theme="dark"]) .sidebar-logo-text {
  color: #36454F !important;
}

[data-theme="light"] .template-btn,
.ima-raiz:not([data-theme="dark"]) .template-btn {
  border: 1px solid #D1D5DB !important;
  color: #6B7280 !important;
  background: transparent !important;
}
[data-theme="light"] .template-btn:hover,
.ima-raiz:not([data-theme="dark"]) .template-btn:hover {
  border-color: #2072AF !important;
  color: #2072AF !important;
}

[data-theme="light"] .sidebar-search input,
.ima-raiz:not([data-theme="dark"]) .sidebar-search input {
  background: #F0F1F3 !important;
  border: 1px solid #d0d0cc !important;
  color: #36454F !important;
}
[data-theme="light"] .sidebar-search input:focus,
.ima-raiz:not([data-theme="dark"]) .sidebar-search input:focus {
  border-color: #2072AF !important;
  background: #F0F8FF !important;
}

[data-theme="light"] .sidebar-section-title,
.ima-raiz:not([data-theme="dark"]) .sidebar-section-title {
  color: #9CA3AF !important;
}

[data-theme="light"] .sidebar-item,
.ima-raiz:not([data-theme="dark"]) .sidebar-item {
  border-color: transparent !important;
}
[data-theme="light"] .sidebar-item:hover,
.ima-raiz:not([data-theme="dark"]) .sidebar-item:hover {
  background: rgba(32,114,175,0.06) !important;
  border-color: rgba(32,114,175,0.15) !important;
}
[data-theme="light"] .sidebar-item.active,
.ima-raiz:not([data-theme="dark"]) .sidebar-item.active {
  background: #F0F8FF !important;
  border-color: rgba(32,114,175,0.25) !important;
}
[data-theme="light"] .sidebar-item .item-name,
.ima-raiz:not([data-theme="dark"]) .sidebar-item .item-name {
  color: #36454F !important;
}
[data-theme="light"] .sidebar-item.active .item-name,
.ima-raiz:not([data-theme="dark"]) .sidebar-item.active .item-name {
  color: #36454F !important;
  font-weight: 600 !important;
}

[data-theme="light"] .ima-sidebar .sidebar-footer,
.ima-raiz:not([data-theme="dark"]) .ima-sidebar .sidebar-footer {
  border-top: 1px solid #d0d0cc !important;
}

.ima-raiz:not([data-theme="dark"]) .ima-sep,
[data-theme="light"] .ima-sep {
  background: #E5E7EB !important;
  width: 1px !important;
}

/* === 5. CHAT PANEL === */
.ima-raiz:not([data-theme="dark"]) .ima-center,
[data-theme="light"] .ima-center {
  background: #FFFFFF !important;
  border-left: 1px solid #E5E7EB !important;
}

.ima-raiz:not([data-theme="dark"]) .msg-avatar,
[data-theme="light"] .msg-avatar {
  background: #1F2937 !important;
  color: #FFFFFF !important;
}

.ima-raiz:not([data-theme="dark"]) .msg-bubble,
[data-theme="light"] .msg-bubble {
  color: #1F2937 !important;
}

.ima-raiz:not([data-theme="dark"]) .msg-row.user .msg-bubble,
[data-theme="light"] .msg-row.user .msg-bubble {
  background: #DEE5ED !important;
  color: #1F2937 !important;
}

.ima-raiz:not([data-theme="dark"]) .input-area,
[data-theme="light"] .input-area {
  background: #FFFFFF !important;
  border-top: 1px solid #F0F0F0 !important;
  padding: 12px 16px !important;
}

.ima-raiz:not([data-theme="dark"]) .input-box,
[data-theme="light"] .input-box {
  background: #F9FAFB !important;
  border: 1.5px solid #E5E7EB !important;
  border-radius: 24px !important;
}

.ima-raiz:not([data-theme="dark"]) .input-box:focus-within,
[data-theme="light"] .input-box:focus-within {
  border-color: #2072AF !important;
  box-shadow: 0 0 0 3px rgba(32,114,175,0.1) !important;
}

[data-theme="light"] .input-box textarea,
.ima-raiz:not([data-theme="dark"]) .input-box textarea {
  color: #36454F !important;
}

[data-theme="light"] .option-btn,
.ima-raiz:not([data-theme="dark"]) .option-btn {
  background: #FFFFFF !important;
  border: 1px solid #d0d0cc !important;
  color: #36454F !important;
}
[data-theme="light"] .option-btn:hover,
.ima-raiz:not([data-theme="dark"]) .option-btn:hover {
  border-color: #2072AF !important;
  background: #F0F8FF !important;
  color: #2072AF !important;
}

/* Floating action bar light mode */
.ima-raiz:not([data-theme="dark"]) .editor-footer-left,
[data-theme="light"] .editor-footer-left {
  background: rgba(255,255,255,0.92) !important;
  border: 1px solid rgba(0,0,0,0.08) !important;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12) !important;
}
.ima-raiz:not([data-theme="dark"]) .editor-footer-left .btn-reject,
[data-theme="light"] .editor-footer-left .btn-reject {
  background: rgba(0,0,0,0.04) !important;
  color: #6B7280 !important;
  border-color: rgba(0,0,0,0.1) !important;
}
.ima-raiz:not([data-theme="dark"]) .editor-footer-left .btn-reject:hover,
[data-theme="light"] .editor-footer-left .btn-reject:hover {
  background: rgba(0,0,0,0.08) !important;
  border-color: rgba(0,0,0,0.15) !important;
}

/* ── CHAT DARK MODE — bubbles ── */
[data-theme="dark"] .msg-avatar {
  background: #E0E0E6 !important;
  color: #1F2937 !important;
  position: relative;
  z-index: 1;
}
[data-theme="dark"] .msg-bubble,
[data-theme="dark"] .msg-bubble *,
[data-theme="dark"] .msg-content,
[data-theme="dark"] .msg-content * {
  color: #E0E0E6 !important;
}

[data-theme="dark"] .msg-row.user .msg-bubble,
[data-theme="dark"] .msg-row.user .msg-bubble * {
  color: #F0F0F0 !important;
}

[data-theme="dark"] .msg-row.user .msg-bubble {
  background: #2E3344 !important;
  border: none !important;
}

/* Settings panel light mode */
.ima-raiz:not([data-theme="dark"]) #settingsPanel,
[data-theme="light"] #settingsPanel {
  background: #FFFFFF !important;
  border-left-color: #E5E7EB !important;
  box-shadow: -8px 0 30px rgba(0,0,0,0.08) !important;
}
.ima-raiz:not([data-theme="dark"]) #settingsPanel h5,
[data-theme="light"] #settingsPanel h5 {
  color: #1F2937 !important;
}
.ima-raiz:not([data-theme="dark"]) #settingsPanel span,
[data-theme="light"] #settingsPanel span {
  color: #6B7280 !important;
}
.ima-raiz:not([data-theme="dark"]) #settingsPanel div[style*="border-bottom"],
[data-theme="light"] #settingsPanel div[style*="border-bottom"] {
  border-bottom-color: #E5E7EB !important;
}
.ima-raiz:not([data-theme="dark"]) #settingsPanel div[style*="font-size:13px"][style*="font-weight:600"],
[data-theme="light"] #settingsPanel div[style*="font-size:13px"][style*="font-weight:600"] {
  color: #4B5563 !important;
}
.ima-raiz:not([data-theme="dark"]) #customPromptInput,
[data-theme="light"] #customPromptInput {
  background: #F9FAFB !important;
  border-color: #E5E7EB !important;
  color: #36454F !important;
}
.ima-raiz:not([data-theme="dark"]) #deleteHistoryBtn,
[data-theme="light"] #deleteHistoryBtn {
  background: rgba(0,0,0,0.03) !important;
  border-color: rgba(0,0,0,0.08) !important;
  color: #6B7280 !important;
}
.ima-raiz:not([data-theme="dark"]) #deleteHistoryBtn:hover,
[data-theme="light"] #deleteHistoryBtn:hover {
  background: rgba(0,0,0,0.06) !important;
}
.ima-raiz:not([data-theme="dark"]) #settingsOverlay,
[data-theme="light"] #settingsOverlay {
  background: rgba(0,0,0,0.3) !important;
}

/* Templates panel light mode */
.ima-raiz:not([data-theme="dark"]) #templatesPanel,
[data-theme="light"] #templatesPanel {
  background: #FFFFFF !important;
  border-left-color: #E5E7EB !important;
  box-shadow: -8px 0 30px rgba(0,0,0,0.08) !important;
}
.ima-raiz:not([data-theme="dark"]) #templatesPanel h5,
[data-theme="light"] #templatesPanel h5 {
  color: #1F2937 !important;
}
.ima-raiz:not([data-theme="dark"]) #templatesPanel div[style*="border-bottom"],
[data-theme="light"] #templatesPanel div[style*="border-bottom"] {
  border-bottom-color: #E5E7EB !important;
}
.ima-raiz:not([data-theme="dark"]) #templatesOverlay,
[data-theme="light"] #templatesOverlay {
  background: rgba(0,0,0,0.3) !important;
}
.ima-raiz:not([data-theme="dark"]) #templatesPanel label[for="templateFileInput"],
[data-theme="light"] #templatesPanel label[for="templateFileInput"] {
  border-color: #D1D5DB !important;
  color: #6B7280 !important;
}
.ima-raiz:not([data-theme="dark"]) #templatesPanel label[for="templateFileInput"]:hover,
[data-theme="light"] #templatesPanel label[for="templateFileInput"]:hover {
  background: #F3F4F6 !important;
  border-color: #9CA3AF !important;
  color: #374151 !important;
}
.ima-raiz:not([data-theme="dark"]) #templateList .template-item,
[data-theme="light"] #templateList .template-item {
  color: #1F2937 !important;
}
.ima-raiz:not([data-theme="dark"]) #templateList .template-item:hover,
[data-theme="light"] #templateList .template-item:hover {
  background: #F3F4F6 !important;
}

/* ── Option button clicked state (at end to beat all overrides) ── */
.option-btn.used {
  background: #22C55E !important;
  border-color: #22C55E !important;
  color: #FFFFFF !important;
  opacity: 1 !important;
  cursor: default !important;
  pointer-events: none !important;
  transform: none !important;
  box-shadow: none !important;
}
[data-theme="dark"] .option-btn.used {
  background: #16A34A !important;
  border-color: #16A34A !important;
}
.msg-row .msg-avatar.loading-state {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
}
.msg-row .msg-avatar.loading-state::before {
  display: none !important;
}
.msg-row .msg-avatar.loading-state svg {
  display: none !important;
}

/* ── Blazor: raíz a pantalla completa, iconos de Tabler y paneles abiertos por clase ── */
.ima-raiz { height: 100vh; height: 100dvh; overflow: hidden; }
.ima-raiz i.ti { line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.ima-raiz .ti-spin { animation: ima-giro 1s linear infinite; }
@keyframes ima-giro { to { transform: rotate(360deg); } }
.ima-raiz #settingsOverlay.abierto, .ima-raiz #templatesOverlay.abierto { opacity: 1; visibility: visible; }
.ima-raiz #settingsPanel.abierto, .ima-raiz #templatesPanel.abierto { transform: translateX(0); }
/* Cerrados quedan pegados al borde: su sombra se colaba en la pantalla como una franja */
.ima-raiz #settingsPanel:not(.abierto), .ima-raiz #templatesPanel:not(.abierto) { box-shadow: none !important; }
.ima-raiz .ima-toast.show { opacity: 1; }
/* Los botones de la barra lateral ocultan el texto con font-size: 0; el icono (fuente) necesita su tamaño */
.ima-raiz .new-report-btn i.ti { font-size: 20px; }
.ima-raiz .template-btn i.ti { font-size: 18px; color: #6B7280; }
.ima-raiz .template-btn:hover i.ti { color: #2072AF; }

/* Panel de plantillas: pestañas Base y Mis plantillas */
.plantillas-pestanas { display: flex; gap: 4px; padding: 12px 24px 0; flex-shrink: 0; border-bottom: 1px solid var(--marco-borde); }
.plantillas-pestana {
  height: 44px; padding: 0 12px; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: none; color: var(--marco-texto); font-size: 14px; font-weight: 500; cursor: pointer; transition: color 0.15s;
}
.plantillas-pestana:hover { color: var(--marco-fuerte); }
.plantillas-pestana.activa { color: var(--marco-fuerte); border-bottom-color: var(--marco-acento); }
.plantillas-cuerpo { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 24px 24px; }
.plantillas-buscar { position: relative; }
.plantillas-buscar i.ti { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 16px; color: var(--marco-texto); pointer-events: none; }
.plantillas-buscar input, .plantillas-guardar input {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--marco-borde); border-radius: 8px;
  background: transparent; color: var(--marco-fuerte); font-size: 14px; outline: none;
}
.plantillas-buscar input { padding-left: 36px; }
.plantillas-buscar input::placeholder, .plantillas-guardar input::placeholder { color: var(--marco-texto); opacity: 1; }
.plantillas-buscar input:focus, .plantillas-guardar input:focus { border-color: var(--marco-acento); box-shadow: 0 0 0 2px var(--marco-activo); }
.plantillas-nota { margin: 12px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--marco-texto); }
.ima-raiz .plantillas-modalidad { margin: 20px 0 4px; font-size: 12px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--marco-texto); }
.plantillas-fila {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 44px; padding: 8px 10px;
  border: none; border-radius: 8px; background: none; color: var(--marco-fuerte); font-size: 14px; text-align: left; cursor: pointer; transition: background 0.15s;
}
.plantillas-fila i.ti { font-size: 16px; color: var(--marco-texto); opacity: 0; transition: opacity 0.15s; }
.plantillas-fila:hover:not(:disabled) { background: var(--marco-suave); }
.plantillas-fila:hover:not(:disabled) i.ti, .plantillas-fila:focus-visible i.ti { opacity: 1; }
.plantillas-fila:disabled, #templateList .template-name:disabled { opacity: 0.5; cursor: not-allowed; }
#templateList { display: flex; flex-direction: column; gap: 4px; min-height: 40px; }
#templateList .template-item .template-name { min-height: 28px; padding: 0; border: none; background: none; color: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.ima-raiz #templateList .template-item .template-del i.ti { font-size: 14px; }
#templatesPanel #templateList .template-empty { color: var(--marco-texto); }
.plantillas-guardar { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--marco-borde); }
.plantillas-guardar label { grid-column: 1 / -1; font-size: 13px; font-weight: 600; color: var(--marco-fuerte); }
.plantillas-accion {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border: none; border-radius: 8px;
  background: var(--hoja-seccion); color: var(--marco-fondo); font-size: 14px; font-weight: 600; cursor: pointer; transition: filter 0.15s;
}
.plantillas-accion:hover { filter: brightness(1.08); }
.plantillas-cargar {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px; margin-top: 12px;
  border: 1px dashed var(--marco-borde); border-radius: 8px; color: var(--marco-texto); font-size: 14px; font-weight: 500; cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.plantillas-cargar:hover, .plantillas-cargar:focus-within { color: var(--marco-fuerte); border-color: var(--marco-acento); }
.plantillas-cargar i.ti { font-size: 18px; }
.plantillas-pestana:focus-visible, .plantillas-fila:focus-visible, .plantillas-accion:focus-visible,
#templateList .template-name:focus-visible, #templateList .template-del:focus-visible { outline: 2px solid var(--marco-acento); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .plantillas-pestana, .plantillas-fila, .plantillas-fila i.ti, .plantillas-accion, .plantillas-cargar { transition: none; } }
@media (hover: none) {
  .plantillas-fila i.ti { opacity: 1; }
  #templateList .template-item .template-del { width: 44px; height: 44px; }
}

/* Confirmaciones: por encima del panel de plantillas, que vive en 999999 */
.ima-confirmar-fondo { position: fixed; inset: 0; z-index: 1000000; background: rgba(0,0,0,0.5); }
.ima-confirmar {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 1000001;
  width: min(380px, 90vw); padding: 24px; border: 1px solid var(--marco-borde); border-radius: 16px;
  background: var(--marco-fondo); color: var(--marco-fuerte); box-shadow: 0 20px 60px rgba(0,0,0,0.3); font-size: 14px; line-height: 1.5;
}
.ima-confirmar p { margin: 0 0 8px; }
.ima-confirmar p.ima-confirmar__detalle { margin-bottom: 20px; font-weight: 600; overflow-wrap: anywhere; }
.ima-confirmar__botones { display: flex; gap: 8px; justify-content: flex-end; }
.ima-raiz .ima-confirmar .ima-confirmar__peligro { color: #DC2626 !important; border-color: #DC2626 !important; }
.ima-raiz[data-theme="dark"] .ima-confirmar .ima-confirmar__peligro { color: #F87171 !important; border-color: #F87171 !important; }

/* Formatos de hoja (membrete y firma) y elección del formato al exportar */
.ima-confirmar.formatos { width: min(480px, 94vw); max-height: 90vh; display: flex; flex-direction: column; }
.ima-confirmar.formatos--ancho { width: min(900px, 96vw); }
.formatos-cabecera { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.formatos-cabecera h5 { margin: 0; font-size: 17px; font-weight: 600; }
.formatos-cerrar { display: flex; align-items: center; padding: 4px; border: none; border-radius: 6px; background: none; color: var(--marco-texto); cursor: pointer; }
.formatos-nota { margin: 0 0 14px; font-size: 13.5px; line-height: 1.5; color: var(--marco-texto); }
.formatos-fila { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--marco-borde); }
.formatos-nombre { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.formatos-nombre small { display: block; font-weight: 400; color: var(--marco-texto); }
.formatos-pie { margin-top: 16px; flex-wrap: wrap; }
.formatos-tipos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0 4px; }
.formatos-tipo {
  display: grid; align-content: start; gap: 6px; padding: 18px 16px; border: 1px solid var(--marco-borde); border-radius: 12px;
  background: transparent; color: var(--marco-fuerte); text-align: left; cursor: pointer; transition: border-color .15s, background .15s;
}
.formatos-tipo:hover, .formatos-tipo:focus-visible { border-color: var(--marco-acento); background: var(--marco-activo); outline: none; }
.formatos-tipo strong { font-size: 15px; }
.formatos-tipo span { font-size: 13px; line-height: 1.45; color: var(--marco-texto); }
.fm-editor { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 20px; min-height: 0; max-height: 66vh; overflow-y: auto; }
.formatos-cuerpo { padding-right: 6px; display: grid; gap: 18px; align-content: start; }
.fm-seccion { display: grid; gap: 12px; }
.fm-seccion h6 { margin: 0; font-size: 14px; font-weight: 700; }
.fm-campo { display: grid; gap: 5px; font-size: 13px; font-weight: 600; }
.fm-campo em { font-style: normal; font-weight: 400; color: var(--marco-texto); }
.fm-campo small { font-weight: 400; color: var(--marco-texto); }
.fm-campo input[type="text"], .fm-campo textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--marco-borde); border-radius: 8px;
  background: transparent; color: var(--marco-fuerte); font: inherit; font-weight: 400; outline: none; resize: vertical;
}
.fm-campo input:focus, .fm-campo textarea:focus { border-color: var(--marco-acento); box-shadow: 0 0 0 2px var(--marco-activo); }
.fm-subida {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 64px; padding: 10px 14px;
  border: 1.5px dashed var(--marco-borde); border-radius: 10px; color: var(--marco-texto); font-size: 13px; font-weight: 500; text-align: center; transition: border-color .15s, background .15s;
}
.fm-subida:hover, .fm-subida:focus-within { border-color: var(--marco-acento); background: var(--marco-activo); }
.fm-subida i.ti { font-size: 22px; }
.fm-subida img { max-height: 46px; max-width: 110px; object-fit: contain; background: #fff; border-radius: 4px; }
.fm-subida-archivo { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.fm-check { display: flex; align-items: flex-start; gap: 10px; margin-top: 4px; font-size: 13px; font-weight: 600; cursor: pointer; }
.fm-check input { flex: none; width: 18px; height: 18px; margin-top: 1px; cursor: pointer; }
.fm-check small { display: block; margin-top: 2px; font-weight: 400; color: var(--marco-texto); }
.fm-quitar { justify-self: start; padding: 0; border: none; background: none; color: var(--marco-texto); font-size: 12.5px; text-decoration: underline; cursor: pointer; }
.fm-colores { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.fm-color-opcion { width: 28px; height: 28px; border: 2px solid transparent; border-radius: 50%; cursor: pointer; box-shadow: inset 0 0 0 2px var(--marco-fondo); }
.fm-color-opcion.elegido { border-color: var(--marco-fuerte); }
.fm-color-otro { display: inline-flex; width: 28px; height: 28px; overflow: hidden; border: 1px dashed var(--marco-borde); border-radius: 50%; cursor: pointer; }
.fm-color-otro input { width: 40px; height: 40px; margin: -6px; padding: 0; border: none; background: none; cursor: pointer; }
.fm-vista { position: sticky; top: 0; display: grid; gap: 8px; align-content: start; justify-items: center; align-self: start; }
.fm-vista-titulo { font-size: 12.5px; font-weight: 600; color: var(--marco-texto); }
.fm-papel { position: relative; width: 294px; height: 415px; flex: none; background: #fff; border-radius: 4px; box-shadow: 0 2px 14px rgba(0,0,0,.22); overflow: hidden; }
.fm-papel iframe { position: absolute; left: 35px; top: 35px; width: 606px; height: 1000px; border: 0; transform: scale(.37); transform-origin: 0 0; pointer-events: none; }
@media (max-width: 760px) {
  .formatos-tipos { grid-template-columns: 1fr; }
  .fm-editor { grid-template-columns: 1fr; }
  .fm-vista { position: static; order: -1; }
}
.formatos-opciones { display: grid; gap: 4px; margin: 12px 0 16px; }
.formatos-opciones .formato-ultimo { background: var(--marco-activo); }
.formatos-opciones small { font-weight: 400; color: var(--marco-texto); }
.paciente-barra input.paciente-edad { flex: 0 0 130px; }

/* La barra lateral se abre por encima: al crecer empujaba al editor y al chat y re-maquetaba toda la página en cada fotograma */
.ima-sidebar { transition: width 0.25s ease, margin-right 0.25s ease, box-shadow 0.25s ease; }
.ima-sidebar:hover { margin-right: -156px; }
.ima-sidebar:not(:hover) .sidebar-empty { visibility: hidden; }

/* Ancho del chat elegido con el divisor. El tope deja al editor 420 px aunque el ancho guardado venga de una pantalla mayor */
@media (min-width: 1025px) {
  .ima-app .ima-center.con-ancho {
    flex: 0 0 var(--ancho-chat) !important;
    max-width: calc(100% - 488px) !important;
  }
}

/* Panel del editor angosto: cada ancho deja lo que cabe. Se mide el panel y no la ventana porque el divisor lo cambia */
@container (max-width: 640px) {
  .editor-accion span { display: none; }
  .editor-accion { width: 32px; padding: 0; justify-content: center; }
}
@container (max-width: 560px) {
  .estado-paginas,
  .estado-idioma,
  .zoom-deslizador,
  .editor-title-text,
  .editor-header-left > i,
  .editor-card .editor-cinta .cinta-tamano,
  .editor-card .editor-cinta .ql-strike,
  .editor-card .editor-cinta .ql-align[value="justify"],
  .editor-card .editor-cinta .ql-indent,
  .editor-card .editor-cinta .ql-formats:has(> .ql-clean) { display: none; }
  #editorContainer .ql-editor:not(.ql-blank)::after { display: none; }
  #editorContainer { --paginas-hoja: 1; }
}

/* Dedo: las áreas de toque llegan a 44 px */
@media (max-width: 768px) {
  .editor-accion { width: 44px; height: 44px; }
  .editor-card .editor-cinta button { width: 38px; height: 38px; }
  .editor-zoom button { width: 44px; height: 44px; }
  .editor-footer { min-height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .editor-accion,
  .editor-cinta button,
  .editor-zoom button { transition: none; }
}

/* Preferencias de ImaThorly */
::highlight(ima-revision) { background: #FDE9B8; color: #1F2937; text-decoration: underline wavy #B45309; }
.paciente-barra { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--ima-borde, #E5E7EB); color: #6B7280; font-size: 12px; }
.paciente-barra input { flex: 1; min-width: 0; padding: 5px 8px; border: 1px solid #D1D5DB; border-radius: 6px; font-size: 13px; background: transparent; color: #1F2937; }
[data-theme="dark"] .paciente-barra input { color: #E5E7EB; }
.tramos { max-height: 190px; overflow-y: auto; border-top: 1px solid #E5E7EB; padding: 8px 12px; display: grid; gap: 8px; }
.tramo { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.tramo-texto { flex: 1; min-width: 0; display: grid; gap: 2px; }
.tramo-texto del { color: #991B1B; }
.tramo-texto ins { color: #166534; text-decoration: none; }
.tramo.descartado ins { text-decoration: line-through; opacity: .7; }
.tramo.descartado del { text-decoration: none; }
.estado-revision { border: 0; background: none; padding: 0; font: inherit; color: #166534; cursor: pointer; }
.estado-revision.pendiente { color: #92400E; font-weight: 600; }
.revision-ir, .comparar-previo { border: 0; background: none; padding: 0 4px; font: inherit; font-weight: 600; color: #2072AF; cursor: pointer; text-decoration: underline; }
.revision-ia { border: 1px solid #D1D5DB; border-radius: 8px; background: none; color: inherit; padding: 8px 12px; margin-top: 12px; font: inherit; cursor: pointer; }
.revision-ia:disabled { cursor: progress; opacity: .7; }
[data-theme="dark"] ::highlight(ima-revision) { background: #5C4314; color: #FFF7E6; text-decoration-color: #FBBF24; }
[data-theme="dark"] .paciente-barra, [data-theme="dark"] .tramos { border-color: #2A2A2E; color: #A1A1AA; }
[data-theme="dark"] .paciente-barra input, [data-theme="dark"] .revision-ia { border-color: #3F3F46; }
[data-theme="dark"] .tramo-texto del { color: #FCA5A5; }
[data-theme="dark"] .tramo-texto ins, [data-theme="dark"] .estado-revision { color: #86EFAC; }
[data-theme="dark"] .estado-revision.pendiente { color: #FCD34D; }
[data-theme="dark"] .revision-ir, [data-theme="dark"] .comparar-previo { color: #529CCA; }

/* ── Prueba gratis, plantillas de la clínica y ajustes nuevos (actividad, membrete, frases) ── */
.prueba-pastilla {
  display: inline-flex; align-items: center; gap: 6px; margin-left: 10px; padding: 4px 11px;
  border-radius: 999px; border: 1px solid #BFDBFE; background: #EFF6FF; color: #1D4ED8;
  font: 600 12px/1.2 inherit; cursor: pointer; white-space: nowrap;
}
.prueba-pastilla:hover { background: #DBEAFE; }
[data-theme="dark"] .prueba-pastilla { border-color: #1E3A8A; background: rgba(59,130,246,0.14); color: #93C5FD; }
.prueba-boton { width: 100%; justify-content: center; margin-top: 6px; padding: 12px 16px; font-size: 15px; }
.licencia-o { margin-top: 18px !important; font-size: 13px; opacity: 0.75; }

#templateList .template-item .template-clinica {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; color: #1D4ED8; background: #EFF6FF; white-space: nowrap;
}
#templateList .template-item .template-compartir {
  border: 0; background: none; padding: 4px; border-radius: 6px; color: #9CA3AF; cursor: pointer; display: flex;
}
#templateList .template-item .template-compartir.activa { color: #2563EB; }
[data-theme="dark"] #templateList .template-item .template-clinica { color: #93C5FD; background: rgba(59,130,246,0.14); }

.ajustes-seccion { margin-bottom: 28px; }
.ajustes-titulo { font-size: 13px; font-weight: 600; color: #6B7280; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }
#settingsPanel .ajustes-nota { font-size: 12.5px; line-height: 1.5; color: #6B7280; margin: 0 0 12px; }
.ajustes-campo { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; font-size: 13px; color: #374151; }
.ajustes-campo input, .ajustes-campo textarea {
  width: 100%; padding: 9px 12px; border-radius: 9px; border: 1px solid #D1D5DB; background: transparent;
  color: inherit; font: inherit; font-size: 14px; resize: vertical;
}
.ajustes-campo input:focus, .ajustes-campo textarea:focus { outline: 2px solid #3B82F6; outline-offset: 1px; border-color: transparent; }
.ajustes-imagenes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.ajustes-imagen { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px; border: 1px dashed #D1D5DB; border-radius: 10px; font-size: 12.5px; color: #4B5563; }
.ajustes-imagen img { max-width: 100%; max-height: 54px; object-fit: contain; background: #fff; border-radius: 6px; padding: 4px; }
.ajustes-imagen label.editor-accion { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.actividad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.actividad > div { display: flex; flex-direction: column; gap: 3px; padding: 12px 10px; border-radius: 12px; background: #F3F4F6; text-align: center; }
.actividad strong { font-size: 18px; color: #111827; }
#settingsPanel .actividad span { font-size: 11.5px; color: #6B7280; }
.actividad-modalidades { list-style: none; margin: 12px 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.actividad-modalidades li { display: flex; justify-content: space-between; font-size: 13px; color: #374151; padding-bottom: 6px; border-bottom: 1px solid #F3F4F6; }
.frase { display: flex; align-items: flex-start; gap: 8px; padding: 10px 0; border-bottom: 1px solid #F3F4F6; }
.frase > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.frase strong { font-size: 13.5px; color: #111827; }
#settingsPanel .frase span { font-size: 12.5px; color: #6B7280; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.frase .template-del { border: 0; background: none; color: #9CA3AF; cursor: pointer; padding: 4px; }
[data-theme="dark"] .ajustes-campo { color: #D4D4D4; }
[data-theme="dark"] .ajustes-campo input, [data-theme="dark"] .ajustes-campo textarea, [data-theme="dark"] .ajustes-imagen { border-color: #3F3F46; }
[data-theme="dark"] .actividad > div { background: #2A2A2A; }
[data-theme="dark"] .actividad strong, [data-theme="dark"] .frase strong { color: #F0F0F0; }
[data-theme="dark"] .actividad-modalidades li, [data-theme="dark"] .frase { border-bottom-color: #303030; color: #D4D4D4; }
