/* ==========================================================================
   J.A.R.V.I.S. AI CORE - DESIGN SYSTEM & 100% RESPONSIVE STYLESHEET
   Optimizado para móviles, tablets, computadoras y pantallas táctiles
   ========================================================================== */

:root {
    /* ==========================================
       TEMA OFICIAL LYRA: SOMBRA AMATISTA
       ========================================== */
    --lyra-bg-dark: #0D0B14;        /* Fondo general (Obsidiana Violeta) */
    --lyra-panel-bg: #36195E;       /* Superficies, contenedores y paneles secundarios */
    --lyra-primary: #7B2CBF;        /* Color primario de acción, botones y elementos activos */
    
    /* Estados e Iluminación */
    --lyra-accent-glow: #C77DFF;    /* Halos de voz, bordes activos, partículas y destellos */
    --lyra-hover: #8A2BE2;          /* Estado hover de elementos interactivos */
    
    /* Textos y Bordes */
    --lyra-text-main: #F4EEF8;      /* Texto principal de alta legibilidad */
    --lyra-text-muted: #BCA0DC;     /* Texto secundario / subtítulos */
    --lyra-border: rgba(123, 44, 191, 0.3); /* Bordes sutiles con brillo violeta */

    /* Mapeo al Core Design System */
    --bg-base: var(--lyra-bg-dark);
    --bg-surface: #1E0D38;
    --bg-surface-elevated: #28114A;
    --bg-card: rgba(54, 25, 94, 0.65);
    --bg-card-hover: rgba(78, 32, 130, 0.85);
    --bg-glass: rgba(30, 13, 56, 0.85);
    
    /* Neon Accents */
    --accent-cyan: var(--lyra-accent-glow);
    --accent-cyan-glow: rgba(199, 125, 255, 0.45);
    --accent-cyan-subtle: rgba(123, 44, 191, 0.22);
    --accent-blue: var(--lyra-primary);
    --accent-purple: var(--lyra-hover);
    --accent-purple-glow: rgba(199, 125, 255, 0.5);
    --accent-emerald: #10B981;
    --accent-amber: #F59E0B;
    --accent-rose: #EC4899;

    /* Typography Colors */
    --text-primary: var(--lyra-text-main);
    --text-secondary: var(--lyra-text-muted);
    --text-muted: #9578B5;
    --text-accent: var(--lyra-accent-glow);

    /* Borders & Outlines */
    --border-subtle: var(--lyra-border);
    --border-glow: rgba(199, 125, 255, 0.35);
    --border-active: var(--lyra-accent-glow);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.9);

    /* Dimensions */
    --sidebar-width: 280px;
    --context-width: 320px;
    --header-height: 60px;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    /* Fonts */
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-heading: 'Outfit', 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Safe Area Insets para Celulares */
    --sat: env(safe-area-inset-top, 0px);
    --sar: env(safe-area-inset-right, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left, 0px);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    height: 100dvh;
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-cyan-glow);
}

/* ==========================================================================
   Layout Architecture
   ========================================================================== */
.app-container {
    display: flex;
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: radial-gradient(circle at 50% 0%, #101c36 0%, #06090e 75%);
    position: relative;
    overflow: hidden;
}

/* ==========================================================================
   Overlays & Backdrops
   ========================================================================== */
.sidebar-backdrop, .context-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 75;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.sidebar-backdrop.active, .context-backdrop.active {
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* ==========================================================================
   Main Sidebar
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 80;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s ease;
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 1.25rem;
    padding-top: var(--sat);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
    gap: 0.5rem;
}

.sidebar-close-btn {
    display: none;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sidebar-close-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-glow);
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    user-select: none;
}

.arc-reactor-mini {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--accent-cyan);
    box-shadow: 0 0 12px var(--accent-cyan-glow), inset 0 0 8px var(--accent-cyan-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: arc-spin 12s linear infinite;
}

.arc-core {
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 10px #ffffff, 0 0 18px var(--accent-cyan);
}

@keyframes arc-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--text-primary);
    background: linear-gradient(135deg, #ffffff 30%, var(--accent-cyan) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-tag {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--accent-cyan);
}

.sidebar-action-box {
    padding: 1rem 1.25rem;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 0.75rem 0.5rem 0.25rem;
    user-select: none;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.nav-item {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.65rem 1rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    touch-action: manipulation;
}

.nav-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.nav-item:hover, .nav-item:active {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

.nav-item.active {
    background: var(--accent-cyan-subtle);
    color: var(--accent-cyan);
    border-color: var(--border-glow);
    box-shadow: inset 0 0 12px rgba(0, 240, 255, 0.1);
}

.nav-item.active i {
    color: var(--accent-cyan);
    text-shadow: 0 0 8px var(--accent-cyan-glow);
}

.nav-badge {
    margin-left: auto;
    background: var(--accent-cyan);
    color: var(--bg-base);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
}

.conversations-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding-bottom: 1rem;
}

.conv-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
}

.conv-item-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.conv-item-left i {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.conv-item:hover, .conv-item:active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.conv-item.active {
    background: rgba(0, 240, 255, 0.08);
    color: var(--accent-cyan);
    border-color: rgba(0, 240, 255, 0.3);
}

.sidebar-footer {
    padding: 0.85rem 1rem;
    padding-bottom: calc(0.85rem + var(--sab));
    border-top: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.2);
}

.system-status-pill {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.system-status-pill:hover, .system-status-pill:active {
    background: rgba(0, 240, 255, 0.06);
    border-color: var(--border-glow);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online {
    background: var(--accent-emerald);
    box-shadow: 0 0 10px var(--accent-emerald);
    animation: pulse-dot 2s infinite;
}

.status-dot.offline {
    background: var(--accent-rose);
    box-shadow: 0 0 10px var(--accent-rose);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

.status-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.status-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.status-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.status-arrow {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Main Content Area & Views
   ========================================================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
    z-index: 10;
}

.top-navbar {
    height: var(--header-height);
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    padding-top: var(--sat);
    z-index: 50;
    flex-shrink: 0;
}

.top-nav-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.mobile-menu-btn {
    display: none;
    min-width: 40px;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1.05rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.mobile-menu-btn:hover {
    background: rgba(0, 240, 255, 0.12);
    border-color: var(--border-glow);
    color: var(--accent-cyan);
}

.current-view-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.view-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mode-pill-header {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.75rem;
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-cyan);
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    white-space: nowrap;
}

.mode-pill-header:hover, .mode-pill-header:active {
    background: rgba(0, 240, 255, 0.16);
    box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.pill-arrow {
    font-size: 0.65rem;
    opacity: 0.7;
}

.top-nav-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

/* HUD Monitor */
.summary-hud-container {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
}

.hud-labels {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
}

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

.hud-count {
    font-family: var(--font-mono);
    color: var(--accent-cyan);
    font-weight: 700;
}

.hud-bar-bg {
    width: 60px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.hud-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.hud-action-btn {
    background: transparent;
    border: none;
    color: var(--accent-amber);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.2rem;
    min-width: 32px;
    min-height: 32px;
    border-radius: 4px;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.hud-action-btn:hover {
    color: #ffffff;
    text-shadow: 0 0 8px var(--accent-amber);
    transform: scale(1.1);
}

/* Views Management */
.view-container {
    flex: 1;
    display: none !important;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.view-container.active-view {
    display: flex !important;
    animation: fadeInView 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInView {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Chat View & Message Rendering
   ========================================================================== */
#view-chat {
    position: relative;
    height: 100%;
    flex-direction: column;
}

/* Barra de Filtro de Modo en Chat */
.chat-mode-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.45rem 1.25rem;
    background: rgba(18, 10, 32, 0.75);
    border-bottom: 1px solid rgba(0, 240, 255, 0.15);
    backdrop-filter: blur(8px);
    z-index: 5;
    flex-shrink: 0;
}

.chat-mode-filter-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-cyan);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-mode-pills-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    overflow-x: auto;
    scrollbar-width: thin;
    padding: 2px 0;
}

.chat-mode-pill {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    user-select: none;
}

.chat-mode-pill:hover {
    background: rgba(0, 240, 255, 0.12);
    color: var(--accent-cyan);
    border-color: rgba(0, 240, 255, 0.35);
    transform: translateY(-1px);
}

.chat-mode-pill.active {
    background: rgba(0, 240, 255, 0.2);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.35);
}

.chat-mode-pill-badge {
    font-size: 0.68rem;
    padding: 0 5px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    font-weight: 600;
}

.chat-history-loader-box {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.4rem 0 0.8rem;
    width: 100%;
}

.btn-load-earlier {
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid rgba(0, 240, 255, 0.3);
    color: var(--accent-cyan);
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 9999px;
    padding: 0.35rem 1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    user-select: none;
}

.btn-load-earlier:hover:not(:disabled) {
    background: rgba(0, 240, 255, 0.22);
    border-color: var(--accent-cyan);
    transform: translateY(-1px);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.35);
}

.btn-load-earlier:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-history-start {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.25rem 0.85rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    user-select: none;
}

.message-mode-badge {
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: 6px;
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    background: rgba(0, 240, 255, 0.08);
    margin-left: 0.4rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    vertical-align: middle;
}

.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    scroll-behavior: auto;
    overflow-anchor: none;
}

/* Welcome Box */
.chat-welcome-box {
    margin: auto;
    max-width: 650px;
    width: 100%;
    text-align: center;
    padding: 2rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-md);
    animation: welcomeFloat 0.8s ease-out;
}

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

.welcome-avatar {
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: center;
}

.arc-reactor-large {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px solid var(--accent-cyan);
    box-shadow: 0 0 24px var(--accent-cyan-glow), inset 0 0 16px var(--accent-cyan-glow);
    display: flex;
    align-items: center;
    justify-content: center;
}

.arc-core-pulse {
    width: 22px;
    height: 22px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 16px #ffffff, 0 0 28px var(--accent-cyan);
    animation: arc-pulse 2s infinite ease-in-out;
}

@keyframes arc-pulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.2); opacity: 1; }
}

.chat-welcome-box h2 {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #ffffff;
}

.chat-welcome-box p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.prompt-suggestions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    text-align: left;
}

.suggestion-chip {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.9rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.suggestion-chip i {
    color: var(--accent-cyan);
    font-size: 1.1rem;
}

.suggestion-chip:hover, .suggestion-chip:active {
    background: var(--accent-cyan-subtle);
    border-color: var(--border-glow);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* Messages List */
.messages-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}

.message-bubble {
    display: flex;
    gap: 0.85rem;
    width: 100%;
    animation: messageIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes messageIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.95rem;
    font-weight: 700;
}

.message-bubble.user .message-avatar {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: #ffffff;
    box-shadow: 0 0 10px rgba(0, 112, 243, 0.4);
}

.message-bubble.assistant .message-avatar {
    background: var(--bg-surface-elevated);
    border: 1.5px solid var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.message-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.75rem;
}

.message-sender {
    font-weight: 600;
    color: var(--text-secondary);
}

.message-bubble.assistant .message-sender {
    color: var(--accent-cyan);
}

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

.message-content {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-md);
    line-height: 1.6;
    font-size: 0.95rem;
    color: var(--text-primary);
    word-break: break-word;
}

.message-bubble.user .message-content {
    background: linear-gradient(135deg, #132240, #1b2f56);
    border: 1px solid rgba(0, 112, 243, 0.3);
    border-top-right-radius: 4px;
    margin-left: auto;
    max-width: 85%;
}

.message-bubble.assistant .message-content {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-top-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

/* Toolbar de acciones de mensaje (Copiar y Re-escuchar) */
.message-actions-toolbar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.35rem;
    padding-top: 0.25rem;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}

.message-bubble.user .message-actions-toolbar {
    justify-content: flex-end;
}

.message-bubble:hover .message-actions-toolbar {
    opacity: 1;
}

.msg-action-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.09);
    color: var(--text-muted);
    font-size: 0.73rem;
    font-family: inherit;
    font-weight: 500;
    padding: 0.22rem 0.55rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.32rem;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.msg-action-btn:hover {
    background: var(--accent-cyan-subtle);
    border-color: var(--border-glow);
    color: var(--accent-cyan);
}

.msg-action-btn:active {
    transform: scale(0.95);
}

.msg-action-btn.copied {
    color: var(--accent-emerald) !important;
    border-color: var(--accent-emerald) !important;
    background: rgba(0, 255, 136, 0.1) !important;
}

/* Markdown Styling */
.message-content p {
    margin-bottom: 0.65rem;
}
.message-content p:last-child {
    margin-bottom: 0;
}
.message-content strong {
    color: #ffffff;
    font-weight: 600;
}
.message-content ul, .message-content ol {
    margin-left: 1.25rem;
    margin-bottom: 0.65rem;
}
.message-content li {
    margin-bottom: 0.25rem;
}
.message-content pre {
    background: #04060a;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    overflow-x: auto;
    margin: 0.75rem 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}
.message-content code {
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.08);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--accent-cyan);
}
.message-content pre code {
    background: transparent;
    padding: 0;
    color: #e2e8f0;
}

.message-content table {
    width: 100%;
    max-width: 100%;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
    margin: 0.75rem 0;
}

.message-content th, .message-content td {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-subtle);
    font-size: 0.88rem;
}

.message-content th {
    background: rgba(255, 255, 255, 0.06);
    color: var(--accent-cyan);
    font-weight: 600;
}

.message-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    margin: 0.5rem 0;
}

/* Typing Bubble */
.typing-bubble {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.15rem;
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-full);
    width: fit-content;
    margin: 0 auto 0 2.5rem;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--accent-cyan);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

.typing-text {
    font-size: 0.8rem;
    color: var(--accent-cyan);
    font-weight: 500;
}

/* Attached Files Bar */
.attached-files-bar {
    padding: 0.6rem 1.25rem;
    background: rgba(0, 0, 0, 0.4);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.attached-bar-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.attached-chips-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.file-chip-attached {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.65rem;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--accent-cyan);
}

.file-chip-remove {
    cursor: pointer;
    opacity: 0.7;
    min-width: 24px;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}
.file-chip-remove:hover, .file-chip-remove:active {
    opacity: 1;
    color: var(--accent-rose);
}

/* Sticky Input Footer */
.chat-input-sticky-footer {
    padding: 0.75rem 1rem;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding-bottom: calc(0.75rem + var(--sab));
    flex-shrink: 0;
}

.chat-input-form {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 0.4rem 0.65rem;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}

.chat-input-form:focus-within {
    border-color: var(--border-active);
    box-shadow: 0 0 15px var(--accent-cyan-glow);
}

.input-actions-left, .input-actions-right {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.textarea-container {
    flex: 1;
    display: flex;
}

.chat-textarea {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    line-height: 1.4;
    resize: none;
    max-height: 120px;
    padding: 0.45rem 0.2rem;
}

.chat-textarea::placeholder {
    color: var(--text-muted);
}

.tool-btn {
    color: var(--text-muted);
    font-size: 1.15rem;
    min-width: 42px;
    min-height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: transparent;
    border: none;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.tool-btn:hover, .tool-btn:active {
    color: var(--accent-cyan);
    background: rgba(255, 255, 255, 0.08);
}

.voice-btn.recording {
    color: var(--accent-rose);
    background: rgba(255, 51, 102, 0.15);
    animation: voiceRecordPulse 1.2s infinite;
}

@keyframes voiceRecordPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 51, 102, 0.4); }
    50% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(255, 51, 102, 0); }
}

.send-btn {
    min-width: 42px;
    min-height: 42px;
    border-radius: 50%;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    touch-action: manipulation;
}

.input-footer-hint {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    user-select: none;
}

/* ==========================================================================
   Generic Module Wrapper
   ========================================================================== */
.module-wrapper {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.5rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.module-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.module-header-title h2 {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 700;
    color: #ffffff;
}

.module-header-title p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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

.filter-chips {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 0.45rem 0.95rem;
    min-height: 36px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.filter-chip:hover, .filter-chip:active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.filter-chip.active {
    background: var(--accent-cyan);
    color: var(--bg-base);
    font-weight: 700;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px var(--accent-cyan-glow);
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.card-item {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.card-item:hover {
    transform: translateY(-2px);
    border-color: var(--border-glow);
    box-shadow: var(--shadow-md);
}

.card-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #ffffff;
}

.card-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-badge.pendiente {
    background: rgba(255, 170, 0, 0.15);
    color: var(--accent-amber);
    border: 1px solid rgba(255, 170, 0, 0.4);
}
.card-badge.en_progreso {
    background: rgba(0, 240, 255, 0.15);
    color: var(--accent-cyan);
    border: 1px solid var(--border-glow);
}
.card-badge.completada {
    background: rgba(0, 255, 136, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(0, 255, 136, 0.4);
}

.card-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
}

.card-footer-row {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border-subtle);
    padding-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.card-actions {
    display: flex;
    gap: 0.4rem;
}

/* Files / R2 Storage */
.drop-zone-box {
    border: 2px dashed rgba(0, 240, 255, 0.3);
    background: rgba(0, 240, 255, 0.02);
    border-radius: var(--radius-lg);
    padding: 2rem 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.drop-zone-box:hover, .drop-zone-box:active {
    border-color: var(--accent-cyan);
    background: rgba(0, 240, 255, 0.08);
    box-shadow: 0 0 20px var(--accent-cyan-glow);
}

.drop-zone-icon {
    font-size: 2.5rem;
    color: var(--accent-cyan);
    margin-bottom: 0.75rem;
}

.drop-zone-text h3 {
    font-size: 1.1rem;
    color: #ffffff;
    margin-bottom: 0.25rem;
}

.drop-zone-text p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.search-and-action-row {
    display: flex;
    gap: 0.75rem;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper i {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
}

.search-input-wrapper input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.6rem;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-input-wrapper input:focus {
    border-color: var(--accent-cyan);
}

.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.file-item-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: all 0.2s ease;
}

.file-item-card:hover {
    border-color: var(--border-glow);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.file-item-card.is-selected {
    border-color: var(--accent-cyan);
    background: rgba(0, 242, 254, 0.08);
}

.file-card-select-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-right: 0.25rem;
}

.file-select-checkbox {
    width: 17px;
    height: 17px;
    accent-color: var(--accent-cyan);
    cursor: pointer;
}

.file-card-top {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.file-card-icon {
    font-size: 1.6rem;
    color: var(--accent-cyan);
}

.file-card-info {
    overflow: hidden;
    flex: 1;
}

.file-card-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-card-size {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.file-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border-subtle);
    padding-top: 0.65rem;
}

/* Modes Grid */
.modes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.mode-item-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

.mode-item-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--mode-color, var(--accent-cyan));
    box-shadow: 0 0 10px var(--mode-color, var(--accent-cyan));
}

.mode-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mode-icon-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 240, 255, 0.1);
    color: var(--mode-color, var(--accent-cyan));
    border: 1px solid var(--border-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.mode-header-text h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
}

.mode-header-text p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.mode-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    flex: 1;
}

.mode-prompt-preview {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    max-height: 75px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mode-keywords-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.mode-keyword-tag {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
}

.mode-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border-subtle);
    padding-top: 0.85rem;
}

/* Settings View Layout */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
}

.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.settings-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.settings-card-header i {
    font-size: 1.3rem;
    color: var(--accent-cyan);
}

.settings-card-header h3 {
    font-size: 1.2rem;
    color: #ffffff;
}

.diagnostic-box {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    background: rgba(0, 0, 0, 0.25);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.diag-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
}

.diag-label {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.diag-label i {
    color: var(--text-muted);
}

.diag-val {
    font-weight: 600;
    font-family: var(--font-mono);
}

.diag-val.online-text {
    color: var(--accent-emerald);
}

.diag-val.error-text {
    color: var(--accent-rose);
}

.sub-section-box {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.sub-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.sub-section-header h3 {
    font-size: 1.1rem;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.summary-history-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.summary-history-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.summary-history-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--accent-cyan);
}

.summary-history-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ==========================================================================
   Context Drawer (Right Panel)
   ========================================================================== */
.context-drawer {
    width: var(--context-width);
    height: 100%;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 60;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s ease;
}

.context-drawer-header {
    height: var(--header-height);
    padding: 0 1.25rem;
    padding-top: var(--sat);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
}

.context-drawer-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.context-drawer-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.context-box {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.context-box-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.context-box-title a {
    color: var(--accent-cyan);
    text-decoration: none;
    font-size: 0.75rem;
}

.context-mode-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-md);
}

.mode-card-details h4 {
    font-size: 0.95rem;
    color: #ffffff;
}

.mode-card-details p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.ctx-mini-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ctx-mini-item {
    padding: 0.65rem 0.85rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

/* ==========================================================================
   Buttons, Forms & Inputs
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 42px;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    touch-action: manipulation;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-cyan), #00a2ff);
    color: #04060a;
    box-shadow: 0 0 16px var(--accent-cyan-glow);
}

.btn-primary:hover, .btn-primary:active {
    filter: brightness(1.1);
    box-shadow: 0 0 24px rgba(0, 240, 255, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

.btn-secondary:hover, .btn-secondary:active {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--border-glow);
}

.btn-sm {
    min-height: 34px;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-block {
    width: 100%;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.15rem;
    min-width: 42px;
    min-height: 42px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.icon-btn:hover, .icon-btn:active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.icon-link-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    min-width: 32px;
    min-height: 32px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}
.icon-link-btn:hover {
    color: var(--accent-cyan);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.col-half {
    flex: 1;
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    min-height: 42px;
    padding: 0.7rem 1rem;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan-glow);
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

.form-range {
    width: 100%;
    height: 36px;
    accent-color: var(--accent-cyan);
}

.color-picker-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.color-picker-input {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
}

small {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.hidden-file-input {
    display: none !important;
}

/* ==========================================================================
   Modals & Popups
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    z-index: 1000;
    animation: fadeInModal 0.2s ease;
}

.modal-backdrop.hidden {
    display: none !important;
    pointer-events: none !important;
}

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

.modal-dialog {
    background: var(--bg-surface);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg), 0 0 30px var(--accent-cyan-glow);
    animation: scaleModal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.modal-dialog.modal-lg {
    max-width: 680px;
}

.modal-dialog.modal-sm {
    max-width: 400px;
}

@keyframes scaleModal {
    from { transform: scale(0.92) translateY(10px); }
    to { transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
}

.quick-modes-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.quick-mode-btn {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    min-height: 52px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    touch-action: manipulation;
}

.quick-mode-btn:hover, .quick-mode-btn:active {
    border-color: var(--accent-cyan);
    background: rgba(0, 240, 255, 0.08);
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
    color: #ffffff;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toastSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 360px;
}

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

.toast.success i { color: var(--accent-emerald); }
.toast.error i { color: var(--accent-rose); }
.toast.info i { color: var(--accent-cyan); }

/* Helpers */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.hidden { display: none !important; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.text-success { color: var(--accent-emerald) !important; }
.text-danger { color: var(--accent-rose) !important; }
.text-accent { color: var(--accent-cyan) !important; }

.loading-placeholder {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.loading-placeholder i {
    font-size: 1.75rem;
    color: var(--accent-cyan);
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state-sm {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ==========================================================================
   SISTEMA DE DISEÑO RESPONSIVO AVANZADO (DESKTOP & MULTI-DEVICE)
   Soporte completo para Pantallas Ultra-Wide, Laptops, Tablets y Pantalla Dividida
   ========================================================================== */

/* PANTALLAS ULTRA-ANCHAS (min-width: 1600px) */
@media (min-width: 1600px) {
    .module-wrapper {
        max-width: 1480px;
        padding: 2rem;
    }

    .cards-grid, .files-grid, .modes-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 1.25rem;
    }

    .message-bubble.user .message-content {
        max-width: 780px;
    }

    .message-bubble.assistant .message-content {
        max-width: 960px;
    }
}

/* LAPTOPS COMPACTAS, VENTANAS EN PANTALLA DIVIDIDA Y TABLETS EN HORIZONTAL (max-width: 1024px) */
@media (max-width: 1024px) {
    .mobile-menu-btn {
        display: inline-flex !important;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(300px, 86vw);
        max-width: 320px;
        height: 100%;
        height: 100dvh;
        transform: translateX(-100%);
        visibility: hidden;
        z-index: 90;
        box-shadow: 12px 0 40px rgba(0, 0, 0, 0.85);
        border-right: 1px solid var(--border-glow);
    }

    .sidebar.open {
        transform: translateX(0);
        visibility: visible;
    }

    .sidebar-close-btn {
        display: flex !important;
    }

    .main-content {
        width: 100%;
        flex: 1;
    }

    .summary-hud-container .hud-bar-bg {
        display: none;
    }

    .module-wrapper {
        padding: 1.25rem 1rem;
        max-width: 100%;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
        gap: 1rem;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .modal-dialog.modal-lg {
        max-width: 90vw;
    }
}

/* TABLETS EN VERTICAL, NAVEGADORES ESTRECHOS Y SMARTPHONES (max-width: 768px) */
@media (max-width: 768px) {
    .mobile-only {
        display: inline-flex !important;
    }

    .top-navbar {
        padding: 0 0.75rem;
        gap: 0.5rem;
    }

    .top-nav-left {
        gap: 0.5rem;
    }

    .view-title {
        font-size: 1.05rem;
    }

    .mode-pill-header {
        padding: 0.25rem 0.6rem;
        font-size: 0.75rem;
        max-width: 140px;
    }

    .mode-pill-header span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .summary-hud-container {
        display: none !important;
    }

    .top-nav-right {
        gap: 0.35rem;
    }

    .chat-messages-container {
        padding: 0.75rem 0.6rem;
        gap: 1rem;
    }

    .chat-welcome-box {
        padding: 1.5rem 1rem;
        margin: 0.5rem auto;
    }

    .prompt-suggestions-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .message-bubble.user .message-content {
        max-width: 90%;
        font-size: 0.92rem;
    }

    .message-bubble.assistant .message-content {
        max-width: 96%;
        font-size: 0.92rem;
    }

    .chat-input-sticky-footer {
        padding: 0.5rem 0.65rem;
        padding-bottom: calc(0.5rem + var(--sab));
    }

    .chat-textarea {
        font-size: 0.95rem;
        padding: 0.6rem 0.75rem;
    }

    .module-wrapper {
        padding: 1rem 0.75rem;
        gap: 1rem;
    }

    .module-header-row {
        gap: 0.65rem;
    }

    .module-header-title h2 {
        font-size: 1.25rem;
    }

    .module-header-title p {
        font-size: 0.82rem;
    }

    .module-header-actions {
        width: 100%;
    }

    .module-header-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .filters-bar {
        gap: 0.5rem;
    }

    .filter-chips {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2px;
    }

    .music-search-bar {
        gap: 0.5rem;
    }

    .music-search-input-box {
        flex: 1 1 100%;
        width: 100%;
    }

    .music-filter-emocion-box {
        flex: 1 1 calc(50% - 0.25rem);
    }

    .music-perpage-box {
        flex: 1 1 calc(50% - 0.25rem);
    }

    .music-alarms-btn {
        flex: 1 1 100%;
        justify-content: center;
    }

    .music-pagination-wrapper {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 0.85rem;
        padding: 1rem;
    }

    .music-pagination-info {
        width: 100%;
        text-align: center;
    }

    .music-pagination-controls {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .music-pages-chips {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 4px 2px;
    }

    .cards-grid, .files-grid, .modes-grid, .settings-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
        gap: 0.75rem;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .col-half {
        width: 100%;
        flex: none;
    }

    .modal-backdrop {
        padding: 0.5rem;
        align-items: center;
    }

    .modal-dialog {
        width: 100%;
        max-width: 100%;
        max-height: 92vh;
        max-height: 92dvh;
        border-radius: var(--radius-lg);
    }

    .modal-header {
        padding: 1rem 1.15rem;
    }

    .modal-body {
        padding: 1rem 1.15rem;
    }

    .modal-footer {
        padding: 0.85rem 1.15rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .toast-container {
        bottom: 1rem;
        right: 0.75rem;
        left: 0.75rem;
    }

    .toast {
        max-width: 100%;
    }
}

/* SMARTPHONES PEQUEÑOS Y PANTALLAS ULTRA-COMPACTAS (max-width: 480px) */
@media (max-width: 480px) {
    .view-title {
        font-size: 0.95rem;
    }

    .mode-pill-header {
        max-width: 100px;
    }

    .mode-pill-header span {
        display: none;
    }

    .chat-messages-container {
        padding: 0.6rem 0.4rem;
    }

    .cards-grid, .files-grid, .modes-grid, .settings-grid {
        grid-template-columns: 1fr;
    }

    .music-filter-emocion-box, .music-perpage-box {
        flex: 1 1 100%;
    }

    .modal-footer .btn {
        flex: 1 1 100%;
        justify-content: center;
    }

    .r2-quota-header, .r2-quota-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }
}

/* YOUTUBE EMBED PLAYER COMPONENT */
.yt-player-card {
    margin-top: 0.85rem;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    max-width: 520px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.yt-player-card:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 6px 24px var(--accent-cyan-glow);
}

.yt-player-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    background: rgba(30, 41, 59, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.yt-player-title-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
}

.yt-player-icon {
    color: #ff0000;
    font-size: 1.1rem;
}

.yt-player-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

.yt-player-link {
    color: var(--accent-cyan);
    font-size: 0.8rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.yt-player-link:hover {
    text-decoration: underline;
}

.yt-iframe-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    height: 0;
    background: #000;
}

.yt-iframe-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* MUSIC MODULE STYLES */
/* Quick Emotion Pills Row */
.music-emotion-pills-row {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.4rem;
    margin-bottom: 0.85rem;
    scrollbar-width: thin;
}

.music-pill-btn {
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    border: 1px solid var(--border-light);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    user-select: none;
}

.music-pill-btn:hover {
    background: rgba(0, 240, 255, 0.1);
    color: var(--accent-cyan);
    border-color: rgba(0, 240, 255, 0.4);
    transform: translateY(-1px);
}

.music-pill-btn.active {
    background: rgba(0, 240, 255, 0.18);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
}

.music-pill-btn.pill-alarm.active {
    background: rgba(245, 158, 11, 0.25);
    color: #fbbf24;
    border-color: #fbbf24;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
}

/* Batch Actions Bar (Paridad Desktop / Mobile) */
.music-batch-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(22, 12, 38, 0.95), rgba(12, 22, 38, 0.95));
    border: 1px solid rgba(0, 240, 255, 0.25);
    border-radius: var(--radius-md);
    padding: 0.55rem 0.95rem;
    margin-bottom: 1.25rem;
    gap: 0.75rem;
    flex-wrap: wrap;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(10px);
}

.music-batch-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.music-batch-left input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-cyan);
    cursor: pointer;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
}

.music-batch-left label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    user-select: none;
}

.music-batch-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-batch-download {
    color: #34d399 !important;
    border-color: rgba(16, 185, 129, 0.4) !important;
    background: rgba(16, 185, 129, 0.12) !important;
}

.btn-batch-download:hover {
    background: rgba(16, 185, 129, 0.25) !important;
    border-color: #34d399 !important;
    box-shadow: 0 0 10px rgba(52, 211, 153, 0.3);
}

.btn-batch-playlist {
    color: #c084fc !important;
    border-color: rgba(168, 85, 247, 0.4) !important;
    background: rgba(168, 85, 247, 0.15) !important;
}

.btn-batch-playlist:hover {
    background: rgba(168, 85, 247, 0.3) !important;
    border-color: #c084fc !important;
    box-shadow: 0 0 10px rgba(192, 132, 252, 0.35);
}

.btn-batch-delete {
    color: #f87171 !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    background: rgba(239, 68, 68, 0.12) !important;
}

.btn-batch-delete:hover {
    background: rgba(239, 68, 68, 0.25) !important;
    border-color: #f87171 !important;
    box-shadow: 0 0 10px rgba(248, 113, 113, 0.35);
}

.music-track-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.music-track-card.selected-track {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 18px rgba(0, 240, 255, 0.28);
    background: rgba(0, 240, 255, 0.04);
}

.music-track-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-cyan);
    box-shadow: 0 8px 24px rgba(0, 240, 255, 0.15);
}

.track-select-box {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10;
}

.track-select-check {
    width: 20px;
    height: 20px;
    accent-color: var(--accent-cyan);
    cursor: pointer;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.95));
    border-radius: 4px;
    transition: transform 0.15s ease;
}

.track-select-check:hover {
    transform: scale(1.15);
}

.music-thumb-box {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    overflow: hidden;
    background: #000;
}

.music-thumb-box img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.music-track-card:hover .music-thumb-box img {
    transform: scale(1.04);
}

.music-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    cursor: pointer;
}

.music-track-card:hover .music-play-overlay {
    opacity: 1;
}

.music-play-btn-circle {
    width: 44px;
    height: 44px;
    background: #ff0000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.6);
}

.music-track-info {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.music-track-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.35rem;
}

.music-track-artist {
    font-size: 0.8rem;
    color: var(--accent-cyan);
    margin-bottom: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.music-meta-tags {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: auto;
    margin-bottom: 0.85rem;
}

.music-tag-emocion {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-cyan);
    border: 1px solid rgba(56, 189, 248, 0.3);
    text-transform: capitalize;
    cursor: pointer;
    transition: all 0.2s ease;
}

.music-tag-emocion:hover {
    background: rgba(56, 189, 248, 0.3);
    border-color: var(--accent-cyan);
}

.music-track-notes {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 0.65rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.music-card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.65rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.music-actions-left {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-delete-track {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.btn-delete-track:hover {
    color: #f87171;
}

/* ==========================================================================
   Barra de Búsqueda y Filtros de Música
   ========================================================================== */
.music-search-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    width: 100%;
}

.music-search-input-box {
    flex: 2 1 240px;
    min-width: 200px;
}

.music-filter-emocion-box {
    flex: 1 1 160px;
    min-width: 140px;
}

.music-alarms-btn {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.85rem;
    white-space: nowrap;
}

.music-perpage-box {
    flex: 0 1 130px;
    min-width: 110px;
}

/* ==========================================================================
   Paginación de Hojas de Música (3 por hoja)
   ========================================================================== */
.music-pagination-wrapper {
    margin-top: 2rem;
    padding: 1.25rem 1.5rem;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    backdrop-filter: blur(10px);
}

.music-pagination-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.music-pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.music-pages-chips {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.music-page-chip {
    min-width: 34px;
    height: 34px;
    padding: 0 0.5rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.music-page-chip:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.4);
    color: var(--accent-cyan);
}

.music-page-chip.active {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
    color: #0b0f19;
    font-weight: 700;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.music-page-dots {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 0 0.25rem;
}

/* ==========================================================================
   WIDGET DE CUOTA CLOUDFLARE R2 (10 GB) & REPRODUCTOR NATIVO DE AUDIO
   ========================================================================== */
.r2-quota-widget {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.8) 0%, rgba(30, 41, 59, 0.5) 100%);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.r2-quota-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.65rem;
}

.r2-quota-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.r2-quota-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-cyan);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.r2-quota-badge.warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.4);
}

.r2-quota-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
}

.r2-quota-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), #38bdf8);
    border-radius: 4px;
    transition: width 0.4s ease;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.r2-quota-bar-fill.warning {
    background: linear-gradient(90deg, #f59e0b, #ef4444);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.r2-quota-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Reproductor de Audio HTML5 R2 (Desktop & Chat) */
.r2-audio-player-card {
    background: #0f172a;
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.r2-player-info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.r2-player-details {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
}

.r2-player-disc {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 2px solid var(--accent-cyan);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-cyan);
    font-size: 1.1rem;
    animation: r2-disc-spin 6s linear infinite;
    animation-play-state: paused;
}

.r2-player-disc.playing {
    animation-play-state: running;
}

@keyframes r2-disc-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.r2-player-text {
    overflow: hidden;
}

.r2-player-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.r2-player-artist {
    font-size: 0.8rem;
    color: var(--accent-cyan);
}

.r2-player-queue-badge {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-secondary);
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    white-space: nowrap;
}

.r2-audio-native-element {
    width: 100%;
    height: 38px;
    filter: invert(1) hue-rotate(180deg);
    border-radius: 20px;
    outline: none;
}

.r2-player-queue-list {
    margin-top: 0.5rem;
    background: rgba(0, 0, 0, 0.25);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    max-height: 240px;
    overflow-y: auto;
}

.r2-queue-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    transition: all 0.18s ease;
}

.r2-queue-item:hover {
    background: rgba(56, 189, 248, 0.12);
    color: var(--accent-cyan);
    transform: translateX(3px);
}

.r2-queue-item:active {
    transform: scale(0.98);
}

.r2-queue-item.active {
    background: rgba(56, 189, 248, 0.22);
    border-left: 3px solid var(--accent-cyan);
    color: var(--accent-cyan);
    font-weight: 700;
}

.r2-mode-toggle-btn {
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: var(--accent-cyan);
    padding: 0.25rem 0.65rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.r2-mode-toggle-btn:hover {
    background: rgba(56, 189, 248, 0.28);
    border-color: var(--accent-cyan);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.r2-nav-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-primary, #ffffff);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.18s ease;
}

.r2-nav-btn:hover {
    background: rgba(56, 189, 248, 0.25);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    transform: scale(1.08);
}

.r2-nav-btn:active {
    transform: scale(0.92);
}

.r2-player-emotions-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 0.35rem;
}

.r2-player-emotion-tag {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 9999px;
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-cyan);
    border: 1px solid rgba(56, 189, 248, 0.35);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    text-transform: capitalize;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.15);
}

.r2-queue-emotion-tag {
    font-size: 0.68rem;
    font-weight: 500;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background: rgba(56, 189, 248, 0.12);
    color: var(--accent-cyan);
    border: 1px solid rgba(56, 189, 248, 0.25);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    text-transform: capitalize;
}

/* Streaming token cursor animation */
.stream-cursor {
    display: inline-block;
    color: var(--primary, #38bdf8);
    font-weight: 700;
    margin-left: 2px;
    animation: streamBlink 0.8s infinite;
}

@keyframes streamBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.message-bubble.is-streaming .message-content {
    min-height: 1.5rem;
}

/* ==========================================================================
   MEJORAS JARVIS 4.0: VISUALIZADOR DE ONDAS, TAREAS CASUALES Y ALARMA ACTIVA
   ========================================================================== */

/* 1. Visualizador de Ondas Reactivo */
.r2-visualizer-container {
    width: 100%;
    height: 48px;
    margin-top: 0.5rem;
    background: linear-gradient(180deg, rgba(0, 15, 30, 0.6) 0%, rgba(0, 5, 15, 0.9) 100%);
    border: 1px solid rgba(0, 240, 255, 0.22);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 15px rgba(0, 240, 255, 0.08);
}

.r2-visualizer-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* 2. Tarjeta Interactiva de Sugerencia de Tarea Casual */
.task-suggestion-card {
    margin-top: 0.75rem;
    padding: 0.85rem 1.1rem;
    background: linear-gradient(135deg, rgba(14, 28, 48, 0.85) 0%, rgba(6, 14, 28, 0.95) 100%);
    border: 1px solid rgba(0, 240, 255, 0.35);
    border-left: 4px solid var(--accent-cyan);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 15px rgba(0, 240, 255, 0.1);
    animation: fadeInTaskSug 0.35s ease;
}

@keyframes fadeInTaskSug {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.task-sug-header {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.task-sug-body {
    font-size: 0.92rem;
    color: var(--text-main, #f8fafc);
    margin-bottom: 0.65rem;
}

.task-sug-body strong {
    color: #fff;
}

.task-sug-date {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: rgba(0, 240, 255, 0.12);
    border: 1px solid rgba(0, 240, 255, 0.25);
    border-radius: 4px;
    font-size: 0.78rem;
    color: var(--accent-cyan);
    margin-left: 0.4rem;
}

.task-sug-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* 3. Modal de Alarma Despertador Sonando */
.alarm-ringing-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(2, 6, 18, 0.88);
    backdrop-filter: blur(10px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: alarmPulseBg 2s infinite ease-in-out;
}

@keyframes alarmPulseBg {
    0%, 100% { background: rgba(2, 6, 18, 0.88); }
    50% { background: rgba(185, 28, 28, 0.35); }
}

.alarm-ringing-card {
    background: linear-gradient(135deg, #0d1b2a 0%, #1b263b 100%);
    border: 2px solid #ef4444;
    box-shadow: 0 0 50px rgba(239, 68, 68, 0.5), inset 0 0 20px rgba(239, 68, 68, 0.2);
    border-radius: 20px;
    padding: 2.2rem;
    max-width: 440px;
    width: 90%;
    text-align: center;
    animation: alarmCardBounce 0.5s ease;
}

@keyframes alarmCardBounce {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.alarm-icon-pulse {
    font-size: 3.5rem;
    color: #ef4444;
    margin-bottom: 1rem;
    animation: alarmBellShake 0.8s infinite ease-in-out;
}

@keyframes alarmBellShake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-15deg); }
    75% { transform: rotate(15deg); }
}

.alarm-time-display {
    font-size: 2.8rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 2px;
    font-family: monospace;
    text-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
    margin-bottom: 0.5rem;
}

.alarm-track-title {
    font-size: 0.95rem;
    color: #94a3b8;
    margin-bottom: 1.5rem;
}

.alarm-actions-grid {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-alarm-dismiss {
    background: #ef4444 !important;
    color: #fff !important;
    border: none !important;
    font-weight: 700;
    padding: 0.75rem 1.4rem;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
    transition: all 0.2s;
}

.btn-alarm-dismiss:hover {
    background: #dc2626 !important;
    transform: scale(1.04);
}

.btn-alarm-snooze {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #cbd5e1 !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    font-weight: 600;
    padding: 0.75rem 1.2rem;
    border-radius: 12px;
    cursor: pointer;
}

/* ==========================================================================
   BLOQUES DE CÓDIGO CON RESALTADO DE SINTAXIS Y BOTÓN COPIAR (v4.7)
   ========================================================================== */
.jarvis-code-block {
    margin: 0.85rem 0;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(0, 240, 255, 0.22);
    background: #0b0f17;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

.jarvis-code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.42rem 0.85rem;
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid rgba(0, 240, 255, 0.16);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.74rem;
}

.jarvis-code-lang {
    color: var(--accent-cyan, #00f0ff);
    font-weight: 600;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.jarvis-code-copy-btn {
    background: rgba(255, 255, 255, 0.06);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 6px;
    padding: 0.22rem 0.6rem;
    font-size: 0.72rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.18s ease;
}

.jarvis-code-copy-btn:hover {
    background: rgba(0, 240, 255, 0.14);
    color: #fff;
    border-color: rgba(0, 240, 255, 0.4);
}

.jarvis-code-copy-btn.copied {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.5);
}

.jarvis-code-block pre {
    margin: 0 !important;
    padding: 0.85rem 1rem !important;
    overflow-x: auto;
    background: transparent !important;
}

.jarvis-code-block pre code.hljs {
    padding: 0 !important;
    background: transparent !important;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.86rem;
    line-height: 1.55;
}



