:root {
    /* --- PALETA PREMIUM ORGANIC --- */
    /* Fondo: No blanco puro, sino un "papel" cálido y costoso */
    --bg-color: #FDFDFB;
    --bg-gradient: radial-gradient(circle at top left, #F4F9F7 0%, #FFF 40%);
    --bg-color-alt: #f4f4f2;

    /* Sidebar: Glassmorphism realzado */
    --sidebar-bg: rgba(255, 255, 255, 0.75);
    --sidebar-border: 1px solid rgba(255, 255, 255, 0.6);

    /* Texto */
    --primary-text-color: #111827;
    --secondary-text-color: #374151;
    --muted-text: #9CA3AF;
    --border-color: rgba(15, 76, 58, 0.08);

    /* Marca: Verde Bosque Profundo + Acento Menta */
    --brand-primary: #0F4C3A;
    --brand-secondary: #10B981;
    --brand-accent: #D1FAE5;

    /* Botones */
    --button-bg: #0F4C3A;
    --button-bg-strong: #0C3C2E;
    --button-text-color: #FFFFFF;

    /* Burbujas de Chat */
    --user-message-bg: linear-gradient(135deg, #0F4C3A 0%, #166550 100%);
    --user-text: #FFFFFF;
    --ai-message-bg: #FFFFFF;

    /* Sombras Elevadas (Soft Shadows) */
    --shadow-sm: 0 2px 8px rgba(15, 76, 58, 0.04);
    --shadow-md: 0 12px 24px -6px rgba(15, 76, 58, 0.08);
    --shadow-soft: 0 12px 40px -12px rgba(15, 76, 58, 0.12);
    --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.25);

    /* Extras heredados */
    --glass: rgba(255, 255, 255, 0.75);
    --shadow-inner: inset 0 1px 0 rgba(255,255,255,0.75);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-color);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--primary-text-color);
    -webkit-font-smoothing: antialiased;
    animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

h1, h2, h3, .sidebar-title, .brand-title {
    letter-spacing: -0.02em;
    color: var(--primary-text-color);
}

/* Contenedor principal tipo ChatGPT */
.chat-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
    background: linear-gradient(135deg, rgba(16, 163, 127, 0.05), rgba(10, 139, 111, 0.08));
    align-items: start;
}

.chat-container.sidebar-collapsed {
    grid-template-columns: 90px 1fr;
}

.chat-container .sidebar {
    grid-column: 1;
    grid-row: 1;
}

.chat-container .main-panel {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.32);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 80;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* ---------- SIDEBAR ---------- */

.sidebar {
    width: 260px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 24px;
    box-shadow: 20px 0 40px rgba(0,0,0,0.02);
    padding: 1.25rem 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh; /* Siempre a pantalla completa */
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-right: 1px solid rgba(255, 255, 255, 0.4);
}

.sidebar.collapsed {
    width: 72px;
    padding: 1.25rem 0.6rem 1rem;
    transition: width 0.3s ease;
}

.sidebar.collapsed .sidebar-header,
.sidebar.collapsed .sidebar-menu li a,
.sidebar.collapsed #new-chat-btn,
.sidebar.collapsed .user-profile,
.sidebar.collapsed .sidebar-bottom {
    justify-content: center;
}

.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .sidebar-subtitle,
.sidebar.collapsed .brand-text,
.sidebar.collapsed .sidebar-menu span,
.sidebar.collapsed .user-profile .user-name,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .chat-session-text,
.sidebar.collapsed .sidebar-menu li a svg + span,
.sidebar.collapsed .sidebar-toggle-text,
.sidebar.collapsed .chat-session-delete,
.sidebar.collapsed .chat-session-preview {
    display: none;
}

.sidebar.collapsed .sidebar-menu li a,
.sidebar.collapsed #new-chat-btn {
    padding: 0.55rem 0.4rem;
    text-align: center;
}

.sidebar.collapsed .sidebar-header .logo {
    margin-right: 0;
}

.sidebar.collapsed .sidebar-menu li a svg,
.sidebar.collapsed #new-chat-btn svg {
    margin-right: 0;
}

.sidebar.collapsed .brand-mark {
    padding: 0.5rem;
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 0 0 auto;
}

.sidebar-bottom {
    flex: 1 1 auto;
    margin-top: 1.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    overflow-y: auto;
}

/* Ocultar el interruptor de genograma y su panel cuando no se desea mostrar */
.sidebar-genogram-toggle {
    display: none;
}

#genogram-panel {
    display: none;
}

.sidebar-section-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted-text);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}

.sidebar-header {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    margin-bottom: 1.85rem;
}

.brand-mark {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1rem; /* más alto y cómodo, ya no se aplasta */
    background: transparent;
    border-radius: 999px;
    box-shadow: none;
    border: none;
    flex: 1;
    min-width: 0;
    margin-top: 0.15rem;
    position: relative;
}

.brand-mark::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(circle at 10% 0%, rgba(255,255,255,0.55), transparent 55%);
    opacity: 0.9;
    pointer-events: none;
}

.brand-text {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 0.45rem;
    line-height: 1.1;
    white-space: nowrap;
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    margin-right: 0.35rem;
    color: var(--secondary-text-color);
    padding: 0.35rem;
    border-radius: 12px;
    transition: background 0.2s ease;
}

.sidebar-toggle:hover {
    background: rgba(45, 79, 72, 0.08);
}

.sidebar-header .logo {
    width: 48px;
    height: 48px;
    background: linear-gradient(145deg, #1fb58a 0%, #0f7f63 50%, #0b5a46 100%);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 14px 30px -12px rgba(0,0,0,0.35);
    position: relative;
    overflow: hidden;
}

/* Separación correcta entre el ícono y el texto “Health-IA Chat” */
.sidebar-header .logo {
    margin-right: 0.55rem;
}

.logo-stetho::before {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 13px;
    background: radial-gradient(circle at 20% 20%, rgba(255,255,255,0.28), transparent 60%);
}

.logo-stetho {
    position: relative;
    overflow: hidden;
}

.sidebar-header .stetho-icon {
    width: 26px;
    height: 26px;
    position: relative;
    z-index: 1;
}

.brand-title {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #0F4C3A 0%, #10B981 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.sidebar-menu {
    flex-grow: 1;
    margin-top: 1rem;
}

.sidebar-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu li a,
#new-chat-btn {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: #4B5563;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: background-color 0.15s ease;
    text-align: left;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 500;
}

.sidebar-menu li a:hover,
#new-chat-btn:hover,
.sidebar-menu li a.active {
    background: var(--brand-accent);
    color: var(--brand-primary);
}

.sidebar-menu li a:active,
#new-chat-btn:active,
button:active {
    transform: scale(0.98);
}

.user-profile {
    display: flex;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    position: relative;
}

#login-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

#login-buttons button {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--glass);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--secondary-text-color);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

#login-buttons button:hover {
    background-color: #e5e7eb;
    border-color: var(--secondary-text-color);
}

#user-info {
    display: none;
    align-items: center;
    cursor: pointer;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    object-fit: cover;
    background: linear-gradient(135deg, #e0f4f0, #f5f9ff);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.sidebar-user-name {
    font-weight: 600;
    color: var(--primary-text-color);
    font-size: 0.95rem;
}

.user-profile .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 0.75rem;
    object-fit: cover;
}

.user-profile .user-name {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--primary-text-color);
}

.login-error {
    margin-top: 8px;
    font-size: 0.82rem;
    color: #b3261e;
}

/* Menú de logout */
#logout-menu {
    position: absolute;
    top: calc(100% + 0.65rem);
    right: 0;
    left: auto;
    background: #ffffff;
    border: 1px solid rgba(45, 79, 72, 0.1);
    border-radius: 12px;
    padding: 0.65rem 0.85rem;
    display: none;
    box-shadow: 0 18px 38px -18px rgba(0,0,0,0.28);
    z-index: 30;
    min-width: 170px;
}

#logout-menu button {
    background: none;
    border: none;
    padding: 0.35rem 0;
    cursor: pointer;
    font-size: 0.95rem;
    color: #b91c1c;
    width: 100%;
    text-align: left;
}

.recent-chats {
    padding: 1rem 0.5rem 1rem 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.recent-chats h3 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    color: var(--muted-text);
}

.recent-chats-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.recent-chat-item {
    padding: 0.6rem 0.7rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.2s ease;
}

.recent-chat-item:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
}

.recent-chat-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #f8fafc;
}

.recent-chat-subtitle {
    font-size: 0.85rem;
    color: var(--muted-text);
    margin-top: 0.15rem;
}

.chat-sessions-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-bottom: 0.5rem;
}

.chat-session-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.55rem 0.7rem;
    border-radius: 14px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.chat-session-item:hover {
    background: rgba(255,255,255,0.6);
    border-color: rgba(255,255,255,0.8);
    box-shadow: 0 6px 14px rgba(0,0,0,0.04);
    transform: translateY(-1px);
}

.chat-session-text {
    flex: 1 1 auto;
    min-width: 0;
}

.chat-session-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.chat-session-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--secondary-text-color);
    margin-bottom: 0.1rem;
}

.chat-session-preview {
    font-size: 0.78rem;
    color: var(--muted-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-session-star {
    border: none;
    background: transparent;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(240, 180, 60, 0.6);
    cursor: pointer;
    transition: transform 0.1s ease, background 0.15s ease, color 0.15s ease;
}

.chat-session-star.is-active {
    color: #fbbf24;
}

.chat-session-star:hover {
    background: rgba(251, 191, 36, 0.1);
    transform: translateY(-1px);
}

.chat-session-delete {
    flex: 0 0 auto;
    border: none;
    background: transparent;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
    color: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.chat-session-delete:hover {
    background: rgba(255,0,0,0.08);
    color: rgba(200,0,0,0.9);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 19, 16, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1200;
}

.modal-dialog {
    background: #ffffff;
    border-radius: 16px;
    padding: 1.2rem 1.2rem 1rem;
    width: min(420px, 94vw);
    box-shadow: 0 18px 50px rgba(0,0,0,0.12);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.modal-dialog h3 {
    margin: 0 0 0.2rem;
    color: var(--secondary-text-color);
    font-weight: 700;
}

.modal-dialog label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.9rem;
    color: var(--secondary-text-color);
}

.modal-dialog input,
.modal-dialog select,
.modal-dialog textarea {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    padding: 0.55rem 0.7rem;
    background: #f9fbfa;
    font-size: 0.92rem;
}

.modal-dialog textarea {
    resize: vertical;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: #ffffff;
    cursor: pointer;
    color: var(--muted-text);
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

.modal-actions .spacer {
    flex: 1;
}

.modal-actions button {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.55rem 0.9rem;
    background: rgba(255,255,255,0.95);
    cursor: pointer;
}

.modal-actions button.primary {
    background: linear-gradient(120deg, #15c39a, #0ca47f);
    color: #fff;
    border: none;
}

.modal-actions button.ghost {
    background: rgba(15,178,141,0.08);
    color: var(--secondary-text-color);
}

.checkbox-row {
    flex-direction: row !important;
    align-items: center;
    gap: 0.45rem !important;
}

/* ---------- PANEL PRINCIPAL ---------- */

.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    padding: 1.25rem 1.5rem 1rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.mobile-nav-toggle {
    display: none;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.85rem;
    margin: 0 0 0.75rem;
    border-radius: 12px;
    border: 1px solid rgba(15, 76, 58, 0.14);
    background: rgba(255, 255, 255, 0.92);
    color: var(--primary-text-color);
    font-weight: 700;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.mobile-nav-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.mobile-nav-label {
    font-size: 0.95rem;
    letter-spacing: -0.01em;
}

.main-content {
    display: block;
}

.chat-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    padding: 16px 24px 24px;
}

.chat-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-header-minimal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-radius: 18px;
    background: linear-gradient(120deg, #eefaf6, #f4fbff);
    border: 1px solid rgba(0,0,0,0.03);
}

.chat-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-logo-badge {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    background: #0fb88f1a;
    color: #0a8a68;
}

.chat-header-minimal h1 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.chat-header-minimal p {
    font-size: 0.82rem;
    margin: 0;
    color: #60717b;
}

.chat-mode-pill {
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.05);
    color: #4d5b64;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    border-right: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow:
        0 20px 40px -10px rgba(0,0,0,0.05),
        inset 0 0 0 1px rgba(255,255,255, 0.5);
    border-radius: 24px;
}

.chat-column {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.safety-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-left: 4px solid rgba(200, 70, 70, 0.28);
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.85));
    color: var(--primary-text-color);
}

.safety-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.safety-copy {
    font-size: 0.92rem;
    color: var(--muted-text);
}


.chat-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: linear-gradient(120deg, rgba(45, 79, 72, 0.08), rgba(212, 249, 83, 0.06));
    border: 1px solid var(--border-color);
    border-radius: 18px;
}

.chat-hero h2 {
    margin: 0 0 0.35rem;
    font-size: 1.6rem;
}

.chat-hero .lede {
    margin: 0;
    color: var(--muted-text);
    max-width: 640px;
    line-height: 1.5;
}

.hero-highlights {
    margin: 0.6rem 0 0;
    padding-left: 1.1rem;
    color: var(--primary-text-color);
    display: grid;
    gap: 0.25rem;
    list-style-type: disc;
}

.hero-with-figure {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 1.25rem;
    align-items: center;
    background: linear-gradient(135deg, rgba(45, 79, 72, 0.06), rgba(212, 249, 83, 0.07));
    position: relative;
    overflow: hidden;
    min-height: 240px;
}

.hero-with-figure::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(at 85% 30%, rgba(212, 249, 83, 0.22), transparent 55%),
                radial-gradient(at 20% 80%, rgba(45, 79, 72, 0.18), transparent 50%);
    pointer-events: none;
    filter: blur(6px);
}

.hero-copy {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    z-index: 1;
}

.hero-mini-chat {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.4rem;
    max-width: 560px;
}

.hero-bubble {
    padding: 0.85rem 1rem;
    border-radius: 14px;
    line-height: 1.55;
    box-shadow: var(--shadow-soft);
    letter-spacing: 0.005em;
    max-width: 520px;
}

.hero-bubble.user-bubble {
    background: var(--user-message-bg);
    color: #f5f7f5;
    box-shadow: var(--shadow-glow);
}

.hero-bubble.ai-bubble {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    color: var(--secondary-text-color);
}

.hero-pills {
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

.hero-figure {
    position: relative;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1;
}

.figure-backdrop {
    position: absolute;
    inset: 12px;
    background: radial-gradient(circle at 40% 30%, rgba(45, 79, 72, 0.16), transparent 55%),
                radial-gradient(circle at 70% 70%, rgba(212, 249, 83, 0.16), transparent 50%),
                rgba(255, 255, 255, 0.6);
    filter: blur(1px);
    border-radius: 24px;
    box-shadow: var(--shadow-soft);
}

.human-figure {
    position: relative;
    width: 68%;
    max-width: 220px;
    filter: drop-shadow(0 10px 24px rgba(0,0,0,0.06));
    mix-blend-mode: multiply;
}

.figure-rings {
    position: absolute;
    right: 0;
    top: 14px;
    display: grid;
    gap: 0.5rem;
}

.figure-ring {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    display: grid;
    place-content: center;
    color: var(--primary-text-color);
    box-shadow: var(--shadow-soft);
    background: #fff;
    position: relative;
    border: 1px solid var(--border-color);
}

.figure-ring::before {
    content: "";
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
}

.figure-ring.primary-ring {
    background: conic-gradient(from 270deg, rgba(45, 79, 72, 0.12) 0 100%);
}

.figure-ring.secondary-ring {
    background: conic-gradient(from 270deg, rgba(45, 79, 72, 0.08) 0 100%);
}


.figure-ring .ring-label {
    font-size: 0.7rem;
    color: var(--muted-text);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    z-index: 1;
    text-align: center;
}

.figure-ring .ring-value {
    font-weight: 700;
    font-size: 1.1rem;
    z-index: 1;
    text-align: center;
}


.figure-chip {
    position: absolute;
    left: 8px;
    bottom: 14px;
    padding: 0.65rem 0.85rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
    display: grid;
    gap: 0.2rem;
    max-width: 220px;
}

.figure-chip .chip-title {
    font-weight: 700;
    color: var(--secondary-text-color);
}

.figure-chip .chip-sub {
    color: var(--muted-text);
    font-size: 0.9rem;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--secondary-text-color);
    margin: 0 0 0.35rem;
    font-size: 0.75rem;
}

.pill-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    border: 1px solid rgba(15, 178, 141, 0.2);
    color: var(--secondary-text-color);
    background: rgba(255, 255, 255, 0.85);
}

.pill.success {
    background: rgba(15, 178, 141, 0.12);
    color: #0f6b5a;
    border-color: rgba(15, 178, 141, 0.35);
}

.pill.muted { color: var(--muted-text); }

/* Banner superior e inferior tipo AdSense */

.ad-top, .ad-bottom {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem;
}

.ad-top {
    min-height: 52px;
    max-width: 880px;
    width: 100%;
}

.ad-bottom {
    min-height: 52px;
    max-width: 100%;
    border: 1px dashed rgba(15, 178, 141, 0.25);
}

.chat-shell {
    padding: 0.9rem 1.1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.chat-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.session-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.session-meta .label {
    margin: 0;
    font-weight: 700;
}

.session-meta .sub-label {
    margin: 0;
    color: var(--muted-text);
    font-size: 0.9rem;
}

.session-mode-indicator {
    font-weight: 600;
    color: var(--secondary-text-color);
}

.session-meta .dot {
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 0 8px rgba(34, 197, 94, 0.12);
}

.quick-actions {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
}

.quick-actions.compact {
    background: rgba(15, 178, 141, 0.06);
    border-radius: 14px;
    padding: 0.35rem 0.55rem;
    border: 1px solid rgba(15, 178, 141, 0.12);
}

.quick-actions .sub-label {
    font-weight: 600;
    color: var(--secondary-text-color);
    margin: 0 0.2rem 0 0;
}

.mode-buttons {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.mode-buttons.inline {
    flex-wrap: nowrap;
}

.chip {
    border: 1px solid rgba(15, 178, 141, 0.35);
    background: rgba(255, 255, 255, 0.9);
    color: var(--secondary-text-color);
    border-radius: 999px;
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.chip:hover {
    background: rgba(15, 178, 141, 0.1);
    transform: translateY(-1px);
}

.chip.mode-chip.active-mode {
    background: linear-gradient(120deg, #15c39a, #0ca47f);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 10px 24px rgba(15, 178, 141, 0.25);
}

.prompt-chips {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
}

.prompt-chips.inline {
    flex-wrap: nowrap;
}

/* Área del chat (mensajes + bienvenida) */

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.9rem 0.7rem 0.45rem;
    background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(244,255,251,0.95));
    border: 1px solid rgba(15, 178, 141, 0.08);
    border-radius: 18px;
    box-shadow: var(--shadow-inner), 0 10px 28px rgba(0,0,0,0.05);
}

/* Mensaje de bienvenida */
.welcome-message {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem 1rem 1rem;
    flex-direction: column;
    gap: 2rem;
}

.metrics-sidebar {
    width: 360px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.metrics-main-card {
    border-radius: 28px;
    padding: 18px 18px 20px;
    background: radial-gradient(circle at 0 0, #f5fff9 0, #e8faf5 35%, #f4fbff 100%);
    box-shadow: 0 18px 40px rgba(6, 75, 58, 0.10);
    border: 1px solid rgba(10, 138, 104, 0.10);
}

.metrics-main-inner {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.metrics-main-top {
    display: flex;
    gap: 16px;
    align-items: center;
}

.ring-wrapper {
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ring-wrapper canvas {
    position: absolute;
    inset: 0;
}

.ring-center-label {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.ring-center-label span:first-child {
    font-size: 1.4rem;
    font-weight: 700;
    color: #0a8a68;
}

.ring-center-label span:last-child {
    font-size: 0.75rem;
    color: #7a8a93;
}

.metrics-main-summary .metrics-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 4px;
    color: #1e2b33;
}

.metrics-caption {
    font-size: 0.8rem;
    margin: 0 0 8px;
    color: #60717b;
}

.metrics-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.badge-soft {
    font-size: 0.72rem;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    color: #2d6f56;
}

.badge-outline {
    background: transparent;
    border: 1px solid rgba(13, 148, 136, 0.25);
}

.metrics-main-section {
    padding-top: 8px;
    border-top: 1px dashed rgba(15, 184, 143, 0.25);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.metrics-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.metrics-label {
    font-size: 0.78rem;
    color: #81939f;
}

.metrics-value {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 2px 0;
}

.metrics-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    background: #ecfdf3;
    color: #137a4c;
}

.metrics-link {
    border: none;
    background: rgba(255, 255, 255, 0.7);
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    color: #166f5b;
    cursor: pointer;
}

.metrics-chart-wrapper {
    margin-top: 10px;
}

.metrics-card {
    background: #ffffff;
    border-radius: 24px;
    padding: 14px 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.03);
}

.metrics-card.secondary h3 {
    font-size: 0.9rem;
    margin: 0 0 4px;
}

.metrics-subtitle {
    font-size: 0.8rem;
    color: #6b7b86;
    margin: 0 0 6px;
}

.habits-list {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
}

/* Ítems de hábitos en el lateral derecho */
.habit-sidebar-item {
    padding: 8px 10px;
    border-radius: 14px;
    background: #f7fbf9;
    border: 1px solid rgba(15, 76, 58, 0.04);
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 6px;
}

.habit-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}

.habit-sidebar-title {
    font-size: 0.84rem;
    font-weight: 600;
    color: #0f172a;
}

.habit-sidebar-status {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 999px;
    background: #ecfdf3;
    color: #166534;
}

.habit-sidebar-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.72rem;
    color: #6b7280;
}

.habit-sidebar-meta {
    display: inline-flex;
    align-items: center;
}

.habit-sidebar-actions {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pill-button.pill-compact {
    min-height: 30px;
    padding: 4px 10px;
    font-size: 0.75rem;
}

.habit-empty {
    font-size: 0.78rem;
    color: #6b7280;
    padding: 6px 4px 2px;
}

.body-card {
    display: flex;
    gap: 14px;
    align-items: center;
}

.body-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.body-wrapper img,
.body-wrapper svg {
    max-height: 120px;
    width: auto;
}

.body-metrics {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.body-pill {
    padding: 6px 10px;
    border-radius: 999px;
    background: #f1fbff;
    font-size: 0.78rem;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.body-pill:nth-child(2) {
    background: #f3fff7;
}

.body-pill:nth-child(3) {
    background: #fdf7ff;
}

.pill-label {
    color: #60717b;
}

.pill-value {
    font-weight: 600;
    color: #1e2b33;
}

@media (max-width: 1024px) {
    .chat-layout {
        flex-direction: column;
    }

    .metrics-sidebar {
        width: 100%;
        order: 2;
    }
}

.welcome-message h2 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #111827 0%, #4B5563 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

/* Contenedor de mensajes */
.chat-messages {
    flex: 1;
    padding: 0 1.5rem 8rem;
    max-width: 48rem;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Burbujas de mensajes */

.message {
    padding: 1.25rem 1.5rem;
    border-radius: 20px;
    max-width: 75%;
    line-height: 1.65;
    word-wrap: break-word;
    animation: slideUpFade 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    margin-bottom: 1.5rem;
    font-size: 0.98rem;
    letter-spacing: 0.01em;
    border: none;
    position: relative;
    transition: transform 0.2s ease;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.user-message {
    background: var(--user-message-bg);
    color: var(--user-text);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: var(--shadow-glow);
    margin-left: 2rem;
    font-weight: 500;
}

.ai-message {
    background-color: var(--ai-message-bg);
    color: var(--secondary-text-color);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
    margin-right: 2rem;
}

.ai-message {
    border: 1px solid rgba(0,0,0,0.03);
}

.md-list {
    padding-left: 1.1rem;
    margin: 0.35rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.md-list li {
    color: var(--secondary-text-color);
    line-height: 1.5;
}

.message h1,
.message h2,
.message h3,
.message h4,
.message h5,
.message h6 {
    margin: 0.35rem 0 0.2rem;
    font-weight: 650;
    color: var(--secondary-text-color);
    letter-spacing: -0.01em;
}

.message h4,
.message h5,
.message h6 {
    font-size: 0.98rem;
}

.message ul,
.message ol {
    padding-left: 1.1rem;
    margin: 0.35rem 0 0.6rem;
    color: var(--secondary-text-color);
    line-height: 1.55;
}

.message table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0 0.9rem;
    font-size: 0.92rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.message table thead {
    background: rgba(15, 76, 58, 0.05);
}

.message table th,
.message table td {
    padding: 0.6rem 0.8rem;
    border: 1px solid rgba(15, 76, 58, 0.08);
    text-align: left;
}

.md-paragraph {
    margin: 0.2rem 0;
    line-height: 1.6;
    color: var(--secondary-text-color);
}

.progress-card {
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(15, 178, 141, 0.08), rgba(255, 255, 255, 0.95));
    border: 1px solid rgba(15, 178, 141, 0.18);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.health-score-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0.5rem 0.9rem;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(21, 195, 154, 0.14), rgba(255, 255, 255, 0.9));
    border: 1px solid rgba(15, 178, 141, 0.18);
}

.health-score-card.health-score-rusty {
    background: linear-gradient(135deg, rgba(229, 133, 27, 0.12), rgba(255, 255, 255, 0.94));
    border-color: rgba(229, 133, 27, 0.18);
    box-shadow: 0 12px 30px rgba(229, 133, 27, 0.08);
}

.health-score-ring {
    position: relative;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, #ffffff 55%, rgba(15, 178, 141, 0.14) 60%);
    overflow: hidden;
    flex-shrink: 0;
}

.health-score-card.health-score-rusty .health-score-ring {
    background: radial-gradient(circle at 50% 50%, #ffffff 55%, rgba(229, 133, 27, 0.16) 60%);
}

.health-score-ring-fill {
    position: absolute;
    inset: 0;
}

.health-score-ring-center {
    position: absolute;
    inset: 18px;
    border-radius: 50%;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.15rem;
    box-shadow: inset 0 0 0 1px rgba(15, 178, 141, 0.12);
}

.health-score-value {
    font-weight: 700;
    font-size: 1.2rem;
    color: #0f8b72;
}

.health-score-card.health-score-rusty .health-score-value {
    color: #b45309;
}

.health-score-label {
    font-size: 0.78rem;
    color: var(--muted-text);
}

.health-score-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.health-score-title {
    margin: 0;
    font-weight: 700;
    color: var(--secondary-text-color);
}

.health-score-helper {
    margin: 0;
    color: var(--muted-text);
    font-size: 0.9rem;
}

.progress-header {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--secondary-text-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.progress-header-title {
    display: flex;
    flex-direction: column;
}

.progress-link {
    border: none;
    background: transparent;
    color: var(--accent-color, #0f8b72);
    font-size: 0.82rem;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    white-space: nowrap;
}

.progress-link:hover {
    color: #0c735e;
}

.progress-subheader {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--secondary-text-color);
}

.progress-metrics {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-metric {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.9rem;
}

.progress-metric-label {
    display: flex;
    justify-content: space-between;
    color: var(--muted-text);
}

.progress-bar {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(15, 178, 141, 0.12);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(120deg, #15c39a, #0ca47f);
    width: 0%;
    transition: width 0.4s ease-out;
}

.progress-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    border: 1px solid rgba(15, 178, 141, 0.25);
    color: var(--secondary-text-color);
    background: rgba(255, 255, 255, 0.85);
    width: fit-content;
}

.progress-task-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.progress-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.story-capture-frame {
    position: fixed;
    left: -9999px;
    top: -9999px;
    width: 360px;
    padding: 1rem;
    border-radius: 16px;
    background: linear-gradient(180deg, #f6fbf8, #ffffff);
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.story-headline {
    font-weight: 800;
    font-size: 1.05rem;
    color: #0f8b72;
}

.story-clone {
    width: 100%;
    box-shadow: none;
    border: none;
    background: transparent;
    padding: 0;
}

.task-item {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.75rem 0.85rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(15, 178, 141, 0.12);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.03);
}

.task-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.task-title {
    margin: 0;
    font-weight: 600;
    color: var(--secondary-text-color);
}

.task-description {
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted-text);
}

.task-meta {
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted-text);
}

.task-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chart-card {
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(15, 178, 141, 0.08), rgba(255, 255, 255, 0.97));
    border: 1px solid rgba(15, 178, 141, 0.16);
    box-shadow: 0 8px 18px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.chart-header {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--secondary-text-color);
}

.chart-subtitle {
    font-size: 0.86rem;
    color: var(--muted-text);
    line-height: 1.45;
}

.chart-canvas-wrapper {
    position: relative;
    width: 100%;
    height: 170px;
}

.progress-chart-section {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.progress-chart-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary-text-color);
    opacity: 0.9;
}

.chart-note {
    font-size: 0.78rem;
    color: var(--muted-text);
}

/* ===== Modales genéricos para hábitos y métricas ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #fff;
    border-radius: 16px;
    padding: 1.1rem 1.2rem 1.3rem;
    width: min(420px, 92vw);
    box-shadow: 0 16px 36px rgba(0,0,0,0.15);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.modal-content h3 {
    margin: 0 0 0.3rem;
    font-size: 1.05rem;
    color: var(--secondary-text-color);
}

.modal-content label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.9rem;
    color: var(--secondary-text-color);
}

.modal-content input,
.modal-content select,
.modal-content textarea {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    padding: 0.55rem 0.65rem;
    font-size: 0.9rem;
    background: rgba(249, 252, 251, 0.85);
    color: var(--text-color);
}

.modal-content textarea {
    resize: vertical;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    border: none;
    background: transparent;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--muted-text);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 0.4rem;
}

.pill-button {
    border: 1px solid rgba(15, 178, 141, 0.35);
    background: linear-gradient(135deg, rgba(21, 195, 154, 0.12), rgba(12, 164, 127, 0.12));
    color: var(--secondary-text-color);
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.88rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    box-shadow: 0 10px 18px rgba(0,0,0,0.04);
}

.pill-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 24px rgba(0,0,0,0.08);
}

.pill-button.ghost {
    background: #fff;
    border-color: rgba(15, 178, 141, 0.2);
    color: var(--muted-text);
    box-shadow: none;
}

.task-activation-card {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    background: linear-gradient(135deg, rgba(15, 178, 141, 0.1), rgba(255,255,255,0.95));
    border: 1px solid rgba(15, 178, 141, 0.2);
    border-radius: 14px;
    padding: 0.9rem 1rem;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.06);
}

.nutrition-card {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    background: linear-gradient(135deg, rgba(15, 178, 141, 0.06), rgba(255, 255, 255, 0.96));
    border: 1px solid rgba(15, 178, 141, 0.22);
    border-radius: 14px;
    padding: 1rem 1.05rem;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.05);
}

.nutrition-card-title {
    font-weight: 700;
    font-size: 0.98rem;
    color: var(--secondary-text-color);
}

.nutrition-card-copy {
    margin: 0;
    color: var(--muted-text);
    font-size: 0.9rem;
    line-height: 1.5;
}

.nutrition-date-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nutrition-date-input {
    padding: 0.4rem 0.6rem;
    border-radius: 10px;
    border: 1px solid rgba(15, 178, 141, 0.25);
    background: #fff;
    font-size: 0.9rem;
}

.nutrition-preview {
    padding-left: 1.1rem;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    color: var(--muted-text);
    font-size: 0.9rem;
}

.nutrition-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nutrition-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.nutrition-table th,
.nutrition-table td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid rgba(15, 178, 141, 0.12);
    text-align: left;
}

.nutrition-table th {
    font-weight: 600;
    color: var(--secondary-text-color);
    background: rgba(15, 178, 141, 0.06);
}

.nutrition-table tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.8);
}

.task-activation-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.error-message {
    color: #b91c1c;
    font-weight: 500;
}

.thinking-message {
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.thinking-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--secondary-text-color);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.14), rgba(15, 76, 58, 0.08));
    border: 1px solid rgba(16, 185, 129, 0.18);
    box-shadow: 0 14px 30px -16px rgba(15, 76, 58, 0.35), var(--shadow-sm);
    border-radius: 18px;
    padding: 0.65rem 1rem;
    font-weight: 600;
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.thinking-indicator::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 10% 10%, rgba(255, 255, 255, 0.6), transparent 40%);
    opacity: 0.9;
    pointer-events: none;
}

.thinking-label {
    position: relative;
    z-index: 1;
}

.thinking-dots {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    position: relative;
    z-index: 1;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10B981 0%, #0F4C3A 100%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6);
    animation: thinkingPulse 1s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.12s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.24s; }

@keyframes thinkingPulse {
    0% { transform: translateY(0); opacity: 0.55; }
    50% { transform: translateY(-3px); opacity: 1; }
    100% { transform: translateY(0); opacity: 0.55; }
}

/* ---------- INPUT FLOTANTE ---------- */

.chat-input-area {
    background: transparent;
    padding: 0 1.5rem 2rem;
    position: sticky;
    bottom: 0;
    z-index: 20;
    pointer-events: none;
}

.chat-input-wrapper {
    pointer-events: auto;
    display: flex;
    align-items: flex-end;
    max-width: 48rem;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.1);
    border-radius: 24px;
    padding: 0.75rem 1rem;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.chat-input-wrapper:focus-within {
    transform: translateY(-4px);
    box-shadow: 0 25px 50px -12px rgba(15, 76, 58, 0.15);
    border-color: var(--brand-secondary);
}

/* Confetti feedback para hábitos completados */
.confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 1200;
}

.confetti-piece {
    position: absolute;
    top: 10%;
    width: 10px;
    height: 18px;
    border-radius: 4px;
    opacity: 0.95;
    animation: confetti-fall 1s ease-out forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(120vh) rotate(360deg);
        opacity: 0;
    }
}

#chat-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 1.05rem;
    padding: 0.45rem 0.85rem;
    background: transparent;
    max-height: 200px;
    min-height: 24px;
    line-height: 1.5;
    font-family: inherit;
    color: var(--primary-text-color);
}

#chat-input::placeholder {
    color: #9ca3af;
}

#chat-input:disabled {
    background-color: transparent;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Botones de acción en el input */

.chat-input-wrapper button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.55rem;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border-radius: 14px;
}

.chat-input-wrapper button:hover:not(:disabled) {
    color: var(--primary-text-color);
    background-color: rgba(16, 185, 129, 0.08);
}

.chat-input-wrapper button:active:not(:disabled) {
    transform: scale(0.98);
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.input-icons svg {
    width: 22px;
    height: 22px;
    color: var(--muted-text);
}

#send-btn {
    background-color: var(--button-bg);
    color: var(--button-text-color);
    border-radius: 18px;
    width: 38px;
    height: 38px;
    margin-left: 0.35rem;
    transition: all 0.2s;
    box-shadow: 0 10px 25px rgba(15, 178, 141, 0.35);
}

#send-btn:hover:not(:disabled) {
    background-color: var(--button-bg-strong);
    transform: translateY(-1px) scale(1.03);
}

#send-btn:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
    transform: scale(1);
    box-shadow: none;
}

#mic-btn {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(15, 178, 141, 0.10);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted-text);
    cursor: pointer;
    transition: all 0.2s ease;
}

#mic-btn svg {
    width: 20px;
    height: 20px;
}

#mic-btn:hover:not(:disabled) {
    background: rgba(15, 178, 141, 0.20);
    transform: translateY(-1px);
}

#mic-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Estado grabando */
#mic-btn.mic-recording {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.8);
    color: #fecaca;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.5);
    animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.ad-rail {
    position: sticky;
    top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-self: start;
}

.ad-card {
    padding: 0.75rem;
    background: var(--glass);
    border: 1px solid rgba(15, 178, 141, 0.12);
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(12px);
}

/* ---------- ADS RESPONSIVE ---------- */

@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .ad-rail {
        display: none;
    }

    .hero-with-figure {
        grid-template-columns: 1fr;
        row-gap: 0.5rem;
    }

    .figure-rings {
        right: 10px;
        top: 10px;
    }
}

@media (max-width: 768px) {
    .chat-container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        height: 100vh;
        z-index: 100;
        transition: left 0.3s;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay.visible {
        display: block;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .mobile-nav-toggle {
        display: inline-flex;
        position: sticky;
        top: 0.75rem;
        z-index: 110;
        margin-left: 0.1rem;
    }

    .ad-top, .ad-bottom {
        max-width: 320px;
        min-height: 50px;
    }

    .chat-shell {
        padding: 0.75rem 0.85rem 1rem;
    }

    .chat-messages {
        padding: 0 1rem 7rem;
        max-width: 100%;
    }

    .message {
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }

    .chat-input-wrapper {
        max-width: 100%;
    }

    .chat-hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .hero-with-figure {
        grid-template-columns: 1fr;
    }

    .hero-figure {
        min-height: 200px;
    }

    .figure-ring {
        width: 82px;
        height: 82px;
    }

    .chat-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .welcome-message h2 {
        font-size: 1.5rem;
    }

    .main-panel {
        padding: 1rem 0.75rem 0.75rem;
    }
}

@media (max-width: 560px) {
    .chat-hero {
        padding: 0.85rem 0.95rem;
    }

    .chat-hero h2 {
        font-size: 1.25rem;
        line-height: 1.35;
    }

    .hero-bubble,
    .hero-bubble.ai-bubble,
    .hero-bubble.user-bubble {
        font-size: 0.95rem;
    }

    .hero-figure {
        display: none;
    }

    .chat-toolbar {
        gap: 0.7rem;
    }

    .quick-actions {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
    }

    .mode-buttons,
    .prompt-chips {
        width: 100%;
        flex-wrap: wrap;
    }

    .ad-top,
    .ad-bottom {
        max-width: 100%;
    }
}

/* Scrollbar suave para toda la página */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.chat-heading {
    margin: 0.4rem 0 0.2rem;
    font-weight: 600;
    color: var(--secondary-text-color);
}

.chat-divider {
    border: none;
    border-top: 1px solid rgba(15, 178, 141, 0.2);
    margin: 0.8rem 0;
}

.chat-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0 0.9rem;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    overflow: hidden;
}

.chat-table thead {
    background: rgba(15, 178, 141, 0.06);
}

.chat-table th,
.chat-table td {
    padding: 0.4rem 0.6rem;
    border: 1px solid rgba(15, 178, 141, 0.15);
    text-align: left;
}

.chat-table th {
    font-weight: 600;
    color: var(--secondary-text-color);
}

.chat-table td {
    color: var(--muted-text);
}

.chat-bubble-chart {
    margin-top: 0.75rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 0.65rem 0.8rem 0.75rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(15, 76, 58, 0.06);
}

.chat-bubble-chart-header {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin-bottom: 0.4rem;
}

.chat-bubble-chart-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary-text-color);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.chat-bubble-chart-title::before {
    content: '📊';
    font-size: 0.9rem;
}

.chat-bubble-chart-note {
    font-size: 0.78rem;
    color: var(--muted-text);
}

.chat-bubble-chart-canvas-wrap {
    position: relative;
    width: 100%;
    height: 160px;
}

.chat-bubble-social-mirror {
    margin-top: 0.55rem;
    border-radius: 14px;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(120deg, rgba(16,185,129,0.08), rgba(15,76,58,0.03));
    border: 1px solid rgba(16,185,129,0.15);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.social-mirror-header {
    flex: 1 1 auto;
}

.social-mirror-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--brand-primary);
}

.social-mirror-sub {
    font-size: 0.78rem;
    color: var(--secondary-text-color);
}

.social-mirror-tribe {
    width: 100%;
    font-size: 0.86rem;
    color: var(--brand-primary);
    font-weight: 600;
    background: rgba(16, 185, 129, 0.14);
    border-radius: 12px;
    padding: 0.55rem 0.65rem;
    box-shadow: inset 0 0 0 1px rgba(16,185,129,0.18);
}

.social-mirror-canvas-wrap {
    width: 72px;
    height: 72px;
    flex: 0 0 auto;
    align-self: flex-start;
}

.social-mirror-cloud {
    width: 100%;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(15, 76, 58, 0.08);
    border-radius: 12px;
    padding: 0.45rem 0.6rem 0.55rem;
    box-shadow: var(--shadow-sm, 0 10px 22px -12px rgba(15, 76, 58, 0.16));
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.social-mirror-cloud-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--secondary-text-color);
}

.social-mirror-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.social-mirror-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(16,185,129,0.14), rgba(15,76,58,0.08));
    color: var(--brand-primary);
    font-size: calc(0.78rem * var(--chip-intensity, 1));
    font-weight: 600;
    letter-spacing: 0.005em;
    box-shadow: 0 4px 12px -8px rgba(15, 76, 58, 0.4), inset 0 0 0 1px rgba(16,185,129,0.18);
    backdrop-filter: blur(6px);
}

.chat-scale-card {
    margin-top: 0.75rem;
    padding: 1.2rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 18px;
    box-shadow: var(--shadow-sm, 0 12px 24px -8px rgba(15, 76, 58, 0.12));
    border: 1px solid rgba(15, 76, 58, 0.08);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.chat-scale__header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: space-between;
}

.chat-scale__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--secondary-text-color);
}

.chat-scale__chip {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.75rem;
    border-radius: 999px;
    background: rgba(15, 76, 58, 0.08);
    color: var(--secondary-text-color);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.chat-scale__instructions {
    background: rgba(15, 178, 141, 0.06);
    border: 1px solid rgba(15, 178, 141, 0.15);
    border-radius: 14px;
    padding: 0.9rem 1rem;
    font-size: 0.95rem;
    color: var(--secondary-text-color);
    line-height: 1.6;
}

.chat-scale__form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-scale__item {
    border: 1px solid rgba(15, 76, 58, 0.08);
    border-radius: 14px;
    padding: 0.85rem 0.9rem;
    background: rgba(255,255,255,0.75);
}

.chat-scale__prompt {
    margin: 0 0 0.5rem;
    font-weight: 700;
    color: var(--secondary-text-color);
    font-size: 0.98rem;
}

.chat-scale__options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.chat-scale__option {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border-radius: 12px;
    border: 1px solid rgba(15, 76, 58, 0.1);
    background: rgba(255,255,255,0.85);
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-scale__option:hover,
.chat-scale__option:focus-within {
    border-color: rgba(15, 178, 141, 0.4);
    box-shadow: 0 12px 24px -10px rgba(15, 178, 141, 0.25);
}

.chat-scale__option input {
    accent-color: var(--brand-primary, #0F4C3A);
    width: 16px;
    height: 16px;
}

.chat-scale__option-label {
    font-weight: 600;
    color: var(--secondary-text-color);
    font-size: 0.92rem;
}

.chat-scale__actions {
    display: flex;
    gap: 0.65rem;
}

.chat-scale__status {
    font-size: 0.9rem;
    color: var(--secondary-text-color);
}

.chat-scale__status.is-error {
    color: #b91c1c;
}

.chat-scale__result {
    border: 1px solid rgba(15, 76, 58, 0.1);
    border-radius: 14px;
    padding: 0.85rem 0.9rem;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(15, 76, 58, 0.04));
    box-shadow: 0 12px 28px -10px rgba(15, 178, 141, 0.2);
}

.chat-scale__result-title {
    font-weight: 700;
    color: var(--secondary-text-color);
}

.chat-scale__result-score {
    font-size: 0.96rem;
    color: var(--primary-text-color);
}

.hidden {
    display: none !important;
}

.genogram-panel {
    margin-top: 0.75rem;
    margin-bottom: 0.4rem;
    padding: 0.7rem 0.9rem;
    border-radius: 14px;
    background: rgba(255,255,255,0.95);
    border: 1px solid rgba(15,178,141,0.18);
    box-shadow: 0 8px 22px rgba(0,0,0,0.03);
    font-size: 0.82rem;
}

.genogram-panel.hidden {
    display: none;
}

.genogram-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--secondary-text-color);
    margin-bottom: 0.35rem;
}

.genogram-risk-alert {
    margin: 0.25rem 0 0.55rem;
    padding: 0.65rem 0.75rem;
    border-radius: 12px;
    background: linear-gradient(120deg, rgba(16,185,129,0.12), rgba(15,76,58,0.06));
    border: 1px solid rgba(16,185,129,0.2);
    color: var(--brand-primary);
    font-weight: 600;
    font-size: 0.82rem;
    box-shadow: var(--shadow-sm);
}

.genogram-canvas {
    position: relative;
    width: 100%;
    min-height: 140px;
    max-height: 260px;
    overflow: auto;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(248,253,252,0.9), #ffffff);
}

.genogram-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.genogram-nodes {
    position: relative;
    padding: 12px 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.genogram-generation-row {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
}

.genogram-generation-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--muted-text);
    min-width: 80px;
}

.genogram-generation-nodes {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-start;
}

.family-block {
    position: relative;
    padding: 10px 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(15,178,141,0.16);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 6px 18px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 140px;
    align-items: center;
}

.family-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.family-parents-row,
.family-children-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    position: relative;
}

.family-children-row {
    padding-top: 4px;
}

.gen-node {
    position: relative;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
}

.gen-node-shape {
    width: 26px;
    height: 26px;
    border: 2px solid rgba(15,178,141,0.9);
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.gen-node-shape.male {
    border-radius: 6px;
}

.gen-node-shape.female {
    border-radius: 50%;
}

.gen-node-shape.ego {
    box-shadow: 0 0 0 3px rgba(15,178,141,0.35);
}

.gen-node-deceased::after {
    content: "✝";
    position: absolute;
    top: -6px;
    right: -1px;
    font-size: 0.6rem;
    color: rgba(200, 70, 70, 0.9);
}

.gen-node-label {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.68rem;
    color: var(--muted-text);
    white-space: nowrap;
}

.gen-node-edit {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 1px solid rgba(15,178,141,0.28);
    background: rgba(255,255,255,0.92);
    color: var(--muted-text);
    font-size: 0.72rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.gen-node-edit:hover {
    color: var(--secondary-text-color);
    border-color: rgba(15,178,141,0.55);
}

.gen-node-risk .gen-node-shape {
    border: 2px solid rgba(16,185,129,0.65);
    box-shadow: 0 0 0 6px rgba(16,185,129,0.1), 0 10px 20px rgba(0,0,0,0.06);
}

.gen-node-risk-diabetes .gen-node-shape {
    border-color: #10B981;
    background: linear-gradient(145deg, rgba(16,185,129,0.18), rgba(15,76,58,0.08));
}

.gen-node-risk-cardio .gen-node-shape {
    border-color: #f87171;
    background: linear-gradient(145deg, rgba(248,113,113,0.16), rgba(248,113,113,0.06));
    box-shadow: 0 0 0 6px rgba(248,113,113,0.12);
}

.gen-node-risk-cancer .gen-node-shape {
    border-color: #a855f7;
    background: linear-gradient(145deg, rgba(168,85,247,0.16), rgba(168,85,247,0.05));
    box-shadow: 0 0 0 6px rgba(168,85,247,0.12);
}

.gen-node-risk-neuro .gen-node-shape {
    border-color: #38bdf8;
    background: linear-gradient(145deg, rgba(56,189,248,0.16), rgba(56,189,248,0.05));
    box-shadow: 0 0 0 6px rgba(56,189,248,0.12);
}

.genogram-empty {
    font-size: 0.82rem;
    color: var(--muted-text);
}

.genogram-sidebar-toggle {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.85rem;
    border-radius: 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
}

.genogram-toggle-icon svg {
    color: #e2f5f0;
}

.genogram-toggle-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.genogram-toggle-text span {
    color: #f8fafc;
    font-weight: 600;
}

.genogram-toggle-text small {
    color: var(--muted-text);
    font-size: 0.78rem;
}

.toggle-switch {
    position: relative;
    width: 42px;
    height: 22px;
    display: inline-block;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255,255,255,0.25);
    transition: 0.3s;
    border-radius: 999px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 3px;
    background-color: #ffffff;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: rgba(15,178,141,0.55);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(18px);
}

/* Drawer de gráficos en chat */
.chart-drawer {
    position: fixed;
    inset: 0;
    z-index: 45;
    pointer-events: none;
}

.chart-drawer.open {
    pointer-events: auto;
}

.chart-drawer-overlay {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.18);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.chart-drawer.open .chart-drawer-overlay {
    opacity: 1;
}

.chart-drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: min(420px, 92vw);
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem 1.4rem 1.4rem;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: -24px 0 48px rgba(0, 0, 0, 0.04), 0 20px 40px rgba(15, 76, 58, 0.1);
    backdrop-filter: blur(18px) saturate(180%);
    transform: translateX(24px);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.chart-drawer.open .chart-drawer-panel {
    transform: translateX(0);
    opacity: 1;
}

.chart-drawer-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(15, 76, 58, 0.06);
    border: 1px solid rgba(15, 76, 58, 0.12);
    color: var(--primary-text-color);
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chart-drawer-close:hover {
    box-shadow: 0 10px 30px -12px rgba(15, 76, 58, 0.2);
}

.chart-drawer-close:active {
    transform: scale(0.98);
}

.chart-drawer-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding-top: 0.3rem;
}

.chart-drawer-eyebrow {
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted-text);
    margin-bottom: 0.15rem;
}

.chart-drawer-title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--primary-text-color);
    margin: 0;
}

.chart-drawer-sub {
    margin: 0.1rem 0 0;
    color: var(--secondary-text-color);
    font-size: 0.95rem;
}

.chart-drawer-pill {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.14), rgba(15, 76, 58, 0.14));
    color: var(--primary-text-color);
    border-radius: 999px;
    padding: 0.4rem 0.9rem;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 6px 20px -10px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
}

.chart-drawer-body {
    overflow: auto;
    padding-right: 0.15rem;
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chart-drawer-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(241, 245, 243, 0.92));
    border-radius: 18px;
    padding: 1rem 1.05rem;
    border: 1px solid rgba(15, 76, 58, 0.08);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chart-drawer-card-header {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.chart-drawer-card-title {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    color: var(--primary-text-color);
    margin: 0;
}

.chart-drawer-card-sub {
    margin: 0;
    color: var(--muted-text);
    font-size: 0.9rem;
}

.chart-drawer-frequency {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.chart-drawer-frequency-label {
    margin: 0;
    color: var(--secondary-text-color);
    font-weight: 600;
    font-size: 0.9rem;
}

.chart-drawer-frequency-options {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.chart-drawer-chip {
    border: 1px solid rgba(15, 76, 58, 0.18);
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary-text-color);
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-drawer-chip.active {
    background: linear-gradient(135deg, #0F4C3A, #10B981);
    color: #fff;
    box-shadow: 0 10px 24px -12px rgba(15, 76, 58, 0.35);
    border-color: transparent;
}

.chart-drawer-canvas-wrap {
    position: relative;
    width: 100%;
    height: 170px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(15, 76, 58, 0.06);
    border-radius: 14px;
    padding: 0.5rem;
}

.chart-drawer-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: space-between;
    flex-wrap: wrap;
}

.chart-drawer-status {
    color: var(--secondary-text-color);
    font-size: 0.9rem;
    font-weight: 600;
}

.chart-drawer .pill-button {
    min-height: 42px;
}

.chart-drawer .pill-button.ghost {
    background: rgba(15, 76, 58, 0.05);
}

  .chart-drawer .pill-ready {
      background: linear-gradient(135deg, #0F4C3A, #10B981);
      color: #fff;
  }

  /* ===== Drawer lateral para hábitos / gráficos sencillos ===== */
  .habit-drawer {
      position: fixed;
      inset: 0;
      z-index: 950;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.25s ease;
  }

  .habit-drawer.habit-drawer-open {
      pointer-events: auto;
      opacity: 1;
  }

  .habit-drawer-overlay {
      position: absolute;
      inset: 0;
      background: rgba(15, 23, 42, 0.45);
  }

  .habit-drawer-panel {
      position: absolute;
      top: 0;
      right: 0;
      height: 100%;
      width: min(480px, 100%);
      padding: 1.6rem 1.8rem 1.8rem;
      background: linear-gradient(180deg, #f6fbf8 0%, #ffffff 100%);
      box-shadow: -24px 0 45px rgba(15, 23, 42, 0.25);
      display: flex;
      flex-direction: column;
      gap: 1rem;
      transform: translateX(100%);
      transition: transform 0.28s ease;
      border-radius: 1.2rem 0 0 1.2rem;
  }

  .habit-drawer.habit-drawer-open .habit-drawer-panel {
      transform: translateX(0);
  }

  .habit-drawer-body {
      flex: 1;
      overflow-y: auto;
      padding-top: 0.5rem;
  }

  .habit-drawer-header {
      padding-right: 2.2rem;
  }

  .habit-drawer-tag {
      display: inline-flex;
      padding: 0.2rem 0.7rem;
      border-radius: 999px;
      font-size: 0.75rem;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      background: rgba(34, 197, 94, 0.12);
      color: #065f46;
  }

  .habit-drawer-title {
      margin: 0.4rem 0 0.2rem;
      font-size: 1.2rem;
      font-weight: 700;
      color: #111827;
  }

  .habit-drawer-subtitle {
      margin: 0;
      font-size: 0.9rem;
      color: #6b7280;
  }

  .habit-drawer-close {
      position: absolute;
      top: 14px;
      right: 18px;
      border: none;
      background: transparent;
      font-size: 1.4rem;
      line-height: 1;
      cursor: pointer;
      color: #9ca3af;
  }

  .habit-drawer-close:hover {
      color: #4b5563;
  }

  .habit-drawer-body .task-activation-card {
      margin: 0;
      width: 100%;
      max-width: 100%;
  }

  .habit-frequency {
      display: flex;
      flex-direction: column;
      gap: 0.35rem;
      margin: 0.5rem 0 0;
  }

  .habit-frequency-label {
      margin: 0;
      color: var(--secondary-text-color);
      font-weight: 600;
      font-size: 0.92rem;
  }

  .habit-frequency-chips {
      display: flex;
      gap: 0.4rem;
      flex-wrap: wrap;
  }

  .habit-chip {
      border: 1px solid rgba(15, 76, 58, 0.18);
      background: rgba(255, 255, 255, 0.9);
      color: var(--primary-text-color);
      padding: 0.4rem 0.75rem;
      border-radius: 999px;
      font-weight: 600;
      font-size: 0.9rem;
      cursor: pointer;
      transition: all 0.2s ease;
  }

  .habit-chip.active {
      background: linear-gradient(135deg, #0F4C3A, #10B981);
      color: #fff;
      box-shadow: 0 10px 24px -12px rgba(15, 76, 58, 0.35);
      border-color: transparent;
  }

  @media (max-width: 768px) {
      .habit-drawer-panel {
          width: 100%;
          border-radius: 0;
      }
  }

  /* Diagnóstico asistente */
.assistant-dx-drawer {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: flex-end;
    pointer-events: none;
    z-index: 1200;
    transition: opacity 0.25s ease;
    opacity: 0;
}

.assistant-dx-drawer.open {
    pointer-events: auto;
    opacity: 1;
}

.assistant-dx-drawer.dragging .assistant-dx-sheet {
    transition: none;
}

.assistant-dx-overlay {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.24);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.assistant-dx-drawer.open .assistant-dx-overlay {
    opacity: 1;
}

.assistant-dx-sheet {
    position: relative;
    width: min(480px, 92vw);
    height: 100%;
    max-height: 100vh;
    overflow-y: auto;
    transform: translateX(calc(105% + var(--dx-drag-offset, 0px)));
    transition: transform 0.35s cubic-bezier(0.4, 0.14, 0.2, 1), opacity 0.35s ease;
    opacity: 0;
    margin: 0;
    border-radius: 0;
    border-left: 1px solid rgba(15, 76, 58, 0.08);
    box-shadow: -12px 0 40px -18px rgba(0, 0, 0, 0.18);
}

.assistant-dx-drawer.open .assistant-dx-sheet {
    transform: translateX(var(--dx-drag-offset, 0px));
    opacity: 1;
}

.assistant-dx {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(15, 76, 58, 0.08);
}

.assistant-dx__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.assistant-dx__label {
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.78rem;
    color: var(--muted-text);
}

.assistant-dx__pill {
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.18), rgba(15, 76, 58, 0.12));
    color: var(--brand-primary);
    font-weight: 700;
    font-size: 0.82rem;
    box-shadow: 0 10px 24px rgba(15, 76, 58, 0.16);
}

.assistant-dx__pill.pill-ready {
    background: linear-gradient(135deg, rgba(15, 76, 58, 0.22), rgba(16, 185, 129, 0.25));
    color: #0b3d2f;
}

.assistant-dx__body {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 1.5rem;
    align-items: center;
}

.assistant-dx__main {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.assistant-dx__eyebrow {
    margin: 0;
    color: var(--muted-text);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.assistant-dx__title {
    margin: 0;
    font-size: 1.2rem;
    color: var(--primary-text-color);
    letter-spacing: -0.015em;
}

.assistant-dx__hint {
    margin: 0;
    color: var(--secondary-text-color);
    font-size: 0.92rem;
    line-height: 1.5;
}

.assistant-dx__scales {
    margin-top: 0.5rem;
    background: rgba(16, 185, 129, 0.08);
    color: var(--brand-primary);
    padding: 0.65rem 0.75rem;
    border-radius: 14px;
    border: 1px solid rgba(16, 185, 129, 0.16);
    font-weight: 600;
}

.assistant-dx__chart {
    position: relative;
    min-height: 160px;
}

.assistant-dx__chart canvas {
    width: 100% !important;
    height: 180px !important;
}

.assistant-dx__list {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.assistant-dx__drag {
    position: absolute;
    left: -14px;
    top: 14px;
    width: 12px;
    height: 64px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.35));
    box-shadow: -12px 0 24px -18px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    z-index: 2;
}

.assistant-dx__drag:active {
    cursor: grabbing;
}

.assistant-dx__drag-bar {
    width: 4px;
    height: 32px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.55), rgba(15, 76, 58, 0.55));
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.assistant-dx__close {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(15, 76, 58, 0.08);
    border-radius: 999px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--primary-text-color);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    z-index: 2;
}

.assistant-dx__close:hover {
    transform: translateY(-1px);
    background: #fff;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
}

.assistant-dx__close:active {
    transform: translateY(0);
}

.assistant-dx__item {
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(15, 76, 58, 0.06);
    box-shadow: var(--shadow-sm);
}

.assistant-dx__item .label {
    display: block;
    font-weight: 700;
    color: var(--primary-text-color);
    margin-bottom: 0.15rem;
}

.assistant-dx__item .code {
    color: var(--muted-text);
    font-weight: 600;
    font-size: 0.9rem;
}

@media (max-width: 960px) {
    .assistant-dx__body {
        grid-template-columns: 1fr;
    }

    .assistant-dx__chart canvas {
        height: 140px !important;
    }
}
