/* ═══════════════════════════════════════════
   🔮 ORÁCULO — Tema Claro
   ═══════════════════════════════════════════ */

:root {
  --bg-main: #f4f5f9;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-input: #f0f1f6;
  --bg-hover: #eef0f5;
  --text-primary: #1e1e2f;
  --text-secondary: #5b5d72;
  --text-muted: #9496ab;
  --border: #e2e3eb;
  --border-light: #ececf2;
  --purple: #7c3aed;
  --purple-soft: rgba(124, 58, 237, 0.07);
  --purple-medium: rgba(124, 58, 237, 0.14);
  --purple-text: #6d28d9;
  --blue: #4f46e5;
  --green: #059669;
  --red: #dc2626;
  --amber: #d97706;
  --pink: #db2777;
  --gradient: linear-gradient(135deg, #7c3aed, #4f46e5);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.07);
  --shadow-purple: 0 4px 14px rgba(124, 58, 237, 0.12);
  --r: 12px;
  --r-sm: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg-main); color: var(--text-primary); height: 100vh; overflow: hidden; }
.app-container { display: flex; height: 100%; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--purple); }

/* ===== SIDEBAR ===== */
.sidebar {
  width: 260px; background: var(--bg-sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 1.25rem; box-shadow: 1px 0 6px rgba(0,0,0,0.03);
}
.sidebar-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border-light); }
.logo-icon { font-size: 1.7rem; }
.logo-text h2 { font-size: 1.05rem; font-weight: 700; color: var(--purple); }
.logo-sub { font-size: 0.72rem; color: var(--text-muted); }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-btn {
  background: none; border: none; color: var(--text-secondary); padding: 0.55rem 0.8rem;
  text-align: left; border-radius: var(--r-sm); cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; gap: 0.6rem; font-size: 0.84rem; font-family: inherit;
}
.nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-btn.active { background: var(--purple-soft); color: var(--purple); font-weight: 600; box-shadow: inset 3px 0 0 var(--purple); }
.nav-btn i { width: 18px; text-align: center; font-size: 0.88rem; }

.sessions-section { flex: 1; overflow-y: auto; margin-top: 1rem; border-top: 1px solid var(--border-light); padding-top: 0.75rem; }
.new-session-btn {
  width: 100%; padding: 0.5rem; background: var(--purple-soft); border: 1px dashed var(--purple);
  color: var(--purple); border-radius: var(--r-sm); cursor: pointer; font-size: 0.8rem;
  font-family: inherit; transition: all 0.2s; margin-bottom: 0.5rem; font-weight: 500;
}
.new-session-btn:hover { background: var(--purple); color: white; border-style: solid; }
.sessions-list { display: flex; flex-direction: column; gap: 1px; }
.session-item {
  width: 100%; padding: 0.45rem 0.6rem; background: transparent; border: none;
  color: var(--text-secondary); border-radius: var(--r-sm); cursor: pointer;
  font-size: 0.78rem; font-family: inherit; transition: all 0.12s; display: flex;
  align-items: center; justify-content: space-between; text-align: left;
}
.session-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.session-item.active { background: var(--purple-soft); color: var(--purple); font-weight: 500; }
.session-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.session-delete { background: none; border: none; color: var(--text-muted); cursor: pointer; opacity: 0; transition: 0.2s; padding: 2px 4px; font-size: 0.7rem; }
.session-item:hover .session-delete { opacity: 0.7; }
.session-delete:hover { color: var(--red); opacity: 1 !important; }

.sidebar-footer { border-top: 1px solid var(--border-light); padding-top: 0.75rem; margin-top: 0.5rem; }
.sidebar-user { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0 0.6rem; font-size: 0.82rem; color: var(--text-muted); }
.sidebar-user-icon { font-size: 1rem; }
.sidebar-user-name { flex: 1; font-weight: 500; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0.25rem 0.4rem; border-radius: 6px; transition: color 0.2s, background 0.2s; font-size: 0.9rem; }
.logout-btn:hover { color: var(--red); background: rgba(239,68,68,0.12); }
.admin-users-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0.25rem 0.4rem; border-radius: 6px; transition: color 0.2s, background 0.2s; font-size: 0.85rem; }
.admin-users-btn:hover { color: var(--accent); background: rgba(139,92,246,0.12); }
.connection-status { display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; color: var(--text-muted); }
.sidebar-credit { font-size: 0.65rem; color: var(--text-muted); opacity: 0.5; text-align: center; margin-top: 0.5rem; letter-spacing: 0.02em; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-dot.connected { background: var(--green); box-shadow: 0 0 6px rgba(5, 150, 105, 0.4); animation: pulse 2s infinite; }
.status-dot.disconnected { background: var(--red); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ===== MAIN ===== */
.main-content { flex: 1; position: relative; overflow: hidden; background: var(--bg-main); }
.content-section { display: none; height: 100%; padding: 1.5rem 2rem; overflow-y: auto; }
.content-section.active { display: flex; flex-direction: column; }
.section-header { margin-bottom: 1.25rem; }
.section-header h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.15rem; color: var(--text-primary); }
.section-header h2 i { color: var(--purple); }
.section-desc { color: var(--text-secondary); font-size: 0.85rem; }

/* ===== CHAT ===== */
#chat-tab { padding: 0; }
.chat-header {
  padding: 0.7rem 1.5rem; border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.92); backdrop-filter: blur(10px);
  display: flex; justify-content: space-between; align-items: center;
}
.agent-status { display: flex; align-items: center; gap: 0.7rem; }
.oracle-eye { font-size: 1.4rem; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
.agent-status h3 { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.oracle-subtitle { font-size: 0.72rem; color: var(--text-muted); }
.chat-header-right { display: flex; align-items: center; gap: 0.6rem; }
.model-badge {
  display: flex; align-items: center; gap: 0.35rem; background: var(--purple-soft);
  padding: 0.28rem 0.65rem; border-radius: 20px; font-size: 0.72rem; color: var(--purple); font-weight: 500;
}

.chat-messages { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 0.85rem; }
.message { max-width: 82%; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.message.user {
  align-self: flex-end; background: var(--gradient); color: white;
  padding: 0.7rem 1rem; border-radius: var(--r) var(--r) 4px var(--r);
  font-size: 0.88rem; line-height: 1.5; white-space: pre-wrap; box-shadow: var(--shadow-purple);
}
.message.assistant { align-self: flex-start; }
.message.assistant .content {
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 0.9rem 1.15rem; border-radius: 4px var(--r) var(--r) var(--r);
  font-size: 0.88rem; line-height: 1.6; box-shadow: var(--shadow-sm);
}
.message.assistant .content h1,.message.assistant .content h2,.message.assistant .content h3 { color: var(--purple); margin: 0.5rem 0 0.3rem; }
.message.assistant .content p { margin: 0.35rem 0; }
.message.assistant .content code { background: var(--purple-soft); padding: 0.12rem 0.3rem; border-radius: 4px; font-size: 0.84em; color: var(--purple-text); }
.message.assistant .content pre { background: #f8f9fc; border: 1px solid var(--border); padding: 0.7rem; border-radius: var(--r-sm); overflow-x: auto; margin: 0.5rem 0; }
.message.assistant .content pre code { background: none; padding: 0; color: var(--text-primary); }
.message.assistant .content blockquote { border-left: 3px solid var(--purple); padding-left: 0.75rem; color: var(--text-secondary); margin: 0.5rem 0; font-style: italic; }
.message.assistant .content ul,.message.assistant .content ol { padding-left: 1.2rem; }
.message.assistant .content table { width: 100%; border-collapse: collapse; margin: 0.5rem 0; font-size: 0.84rem; }
.message.assistant .content th,.message.assistant .content td { padding: 0.35rem 0.5rem; border: 1px solid var(--border); text-align: left; }
.message.assistant .content th { background: var(--bg-input); font-weight: 600; }
.message.assistant .content strong { color: var(--purple-text); }

.message.system.oracle-welcome { align-self: center; max-width: 540px; text-align: center; }
.message.system.oracle-welcome .content { background: var(--bg-card); border: 1px solid var(--border); padding: 1.75rem 2rem; border-radius: var(--r); box-shadow: var(--shadow); }
.oracle-welcome-icon { font-size: 2.8rem; margin-bottom: 0.6rem; }
.oracle-welcome h3 { font-size: 1.15rem; margin-bottom: 0.5rem; color: var(--purple); }
.oracle-welcome p { color: var(--text-secondary); font-size: 0.84rem; margin-bottom: 0.6rem; line-height: 1.6; }
.oracle-welcome p strong { color: var(--purple-text); }
.oracle-features, .oracle-commands { text-align: left; margin: 0.8rem 0; padding: 0.6rem 0.8rem; background: var(--bg-main); border-radius: var(--r-sm); border: 1px solid var(--border); }
.oracle-features h4, .oracle-commands h4 { font-size: 0.82rem; color: var(--purple); margin-bottom: 0.4rem; text-align: left; }
.feature-list { list-style: none; padding: 0; margin: 0; }
.feature-list li { font-size: 0.78rem; color: var(--text-secondary); padding: 0.25rem 0; line-height: 1.5; }
.feature-list li strong { color: var(--text-primary); }
.feature-list li code { background: var(--purple-soft); color: var(--purple); padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.oracle-capabilities { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: center; margin-top: 0.8rem; }
.oracle-capabilities span { background: var(--purple-soft); padding: 0.25rem 0.55rem; border-radius: 20px; font-size: 0.72rem; color: var(--purple); font-weight: 500; }
.oracle-start-hint { margin-top: 0.6rem; font-style: italic; color: var(--text-muted); font-size: 0.8rem; }

.typing { color: var(--text-muted); animation: blink 1s infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

.chat-input-area { padding: 0.7rem 1.5rem; border-top: 1px solid var(--border); background: var(--bg-card); }
.file-preview-bar { display: flex; align-items: center; justify-content: space-between; background: var(--purple-soft); padding: 0.35rem 0.7rem; border-radius: var(--r-sm); margin-bottom: 0.45rem; font-size: 0.8rem; color: var(--purple); }
.file-preview-bar button, .file-preview-cancel { background: none; border: none; color: var(--text-muted); cursor: pointer; }
#chat-form { display: flex; align-items: flex-end; gap: 0.45rem; }
.attach-btn, .upload-btn {
  background: var(--bg-input); border: 1px solid var(--border); color: var(--text-secondary);
  width: 38px; height: 38px; border-radius: var(--r-sm); display: flex;
  align-items: center; justify-content: center; cursor: pointer; transition: 0.15s; flex-shrink: 0;
}
.attach-btn:hover, .upload-btn:hover { color: var(--purple); border-color: var(--purple); background: var(--purple-soft); }
#message-input {
  flex: 1; background: var(--bg-input); border: 1px solid var(--border); color: var(--text-primary);
  padding: 0.55rem 0.8rem; border-radius: var(--r-sm); font-family: inherit; font-size: 0.88rem;
  resize: none; max-height: 120px; line-height: 1.4; transition: border-color 0.15s;
}
#message-input:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-soft); }
#message-input::placeholder { color: var(--text-muted); }
.send-btn {
  background: var(--gradient); border: none; color: white; width: 38px; height: 38px;
  border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: 0.15s; flex-shrink: 0;
}
.send-btn:hover { transform: scale(1.05); box-shadow: var(--shadow-purple); }

/* ===== CARD ===== */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r);
  padding: 1.2rem; margin-bottom: 0.85rem; box-shadow: var(--shadow-sm);
}
.card h3 { font-size: 0.95rem; margin-bottom: 0.65rem; color: var(--text-primary); }
.card h3 i { color: var(--purple); margin-right: 0.3rem; }
.card h4 { font-size: 0.88rem; margin-bottom: 0.5rem; color: var(--text-primary); }
.card h4 i { color: var(--purple); margin-right: 0.25rem; }

/* ===== FORMS ===== */
input[type="text"], input[type="number"], input[type="password"], textarea, select {
  background: var(--bg-input); border: 1px solid var(--border); color: var(--text-primary);
  padding: 0.5rem 0.7rem; border-radius: var(--r-sm); font-family: inherit; font-size: 0.84rem; transition: 0.15s; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-soft); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
.form-group { margin-bottom: 0.8rem; }
.form-group label { display: block; font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 0.25rem; font-weight: 500; }
.entry-meta-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-bottom: 0.6rem; }
.intensity-group label { font-size: 0.78rem; color: var(--text-secondary); }
input[type="range"] { appearance: none; -webkit-appearance: none; width: 100%; height: 5px; background: var(--border); border-radius: 3px; outline: none; border: none; padding: 0; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; background: var(--purple); border-radius: 50%; cursor: pointer; }
input[type="range"]:focus { box-shadow: none; }

/* ===== BUTTONS ===== */
.primary-btn {
  background: var(--gradient); border: none; color: white; padding: 0.5rem 1rem;
  border-radius: var(--r-sm); cursor: pointer; font-size: 0.84rem; font-family: inherit;
  font-weight: 500; transition: 0.15s; display: inline-flex; align-items: center; gap: 0.35rem;
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-purple); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.secondary-btn {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-secondary);
  padding: 0.5rem 1rem; border-radius: var(--r-sm); cursor: pointer; font-size: 0.84rem;
  font-family: inherit; transition: 0.15s; display: inline-flex; align-items: center; gap: 0.35rem;
}
.secondary-btn:hover { border-color: var(--purple); color: var(--purple); }
.back-btn { background: none; border: none; color: var(--purple); cursor: pointer; font-family: inherit; font-size: 0.84rem; display: flex; align-items: center; gap: 0.25rem; margin-bottom: 0.75rem; }

/* ===== PROFILE ===== */
.profile-stats { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.profile-stat-badge {
  display: inline-flex; align-items: center; gap: 0.3rem; background: var(--purple-soft);
  color: var(--purple); padding: 0.3rem 0.6rem; border-radius: 20px; font-size: 0.74rem; font-weight: 600;
}
.stat-number { font-weight: 700; }
.training-categories-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.65rem; }
.training-category-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r);
  padding: 1rem; cursor: pointer; transition: 0.2s; text-align: center; box-shadow: var(--shadow-sm);
}
.training-category-card:hover { border-color: var(--purple); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.cat-icon { font-size: 1.6rem; display: block; margin-bottom: 0.4rem; }
.cat-label { font-weight: 600; font-size: 0.84rem; margin-bottom: 0.2rem; color: var(--text-primary); }
.cat-desc { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 0.4rem; line-height: 1.4; }
.cat-count { font-size: 0.68rem; color: var(--purple); background: var(--purple-soft); padding: 0.15rem 0.45rem; border-radius: 10px; }

.guided-questions-list { display: flex; flex-direction: column; gap: 0.25rem; }
.guided-question-item {
  padding: 0.5rem 0.6rem; background: var(--bg-input); border: 1px solid var(--border-light);
  border-radius: var(--r-sm); font-size: 0.8rem; color: var(--text-secondary); cursor: pointer;
  transition: 0.15s; display: flex; gap: 0.35rem;
}
.guided-question-item:hover { border-color: var(--purple); color: var(--text-primary); background: var(--purple-soft); }

.entries-list { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.75rem; }
.entry-item { background: var(--bg-input); border: 1px solid var(--border-light); border-radius: var(--r-sm); padding: 0.7rem; }
.entry-content { font-size: 0.82rem; line-height: 1.5; white-space: pre-wrap; color: var(--text-primary); margin-bottom: 0.3rem; }
.entry-footer { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.entry-badge { font-size: 0.68rem; padding: 0.12rem 0.4rem; border-radius: 8px; background: var(--purple-soft); color: var(--purple); }
.entry-date { font-size: 0.68rem; color: var(--text-muted); margin-left: auto; }
.entry-delete-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.72rem; transition: 0.15s; opacity: 0.5; }
.entry-delete-btn:hover { color: var(--red); opacity: 1; }

/* ===== JOURNAL ===== */
.stats-badge { font-size: 0.74rem; color: var(--text-muted); }
.mood-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.7rem; }
.mood-chip {
  background: var(--bg-input); border: 1px solid var(--border); color: var(--text-secondary);
  padding: 0.3rem 0.6rem; border-radius: 20px; cursor: pointer; font-size: 0.76rem;
  font-family: inherit; transition: 0.15s;
}
.mood-chip:hover { border-color: var(--purple); color: var(--purple); }
.mood-chip.active { background: var(--purple-soft); border-color: var(--purple); color: var(--purple); font-weight: 500; }
.journal-history { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.5rem; }
.journal-entry {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r);
  padding: 0.8rem; position: relative; box-shadow: var(--shadow-sm);
}
.journal-entry-header { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.35rem; flex-wrap: wrap; }
.journal-mood-badge { font-size: 0.7rem; background: var(--purple-soft); padding: 0.12rem 0.4rem; border-radius: 10px; color: var(--purple); }
.journal-words { font-size: 0.66rem; color: var(--text-muted); }
.journal-date { font-size: 0.66rem; color: var(--text-muted); margin-left: auto; }
.journal-text { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; white-space: pre-wrap; }
.journal-delete-btn { position: absolute; top: 0.45rem; right: 0.45rem; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.68rem; opacity: 0; transition: 0.15s; }
.journal-entry:hover .journal-delete-btn { opacity: 0.7; }
.journal-delete-btn:hover { color: var(--red); opacity: 1 !important; }

/* ===== MEMORIES / UPLOAD ===== */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--r); padding: 1.5rem;
  text-align: center; cursor: pointer; transition: 0.2s; color: var(--text-muted); margin-bottom: 0.75rem;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--purple); background: var(--purple-soft); }
.upload-zone i { font-size: 1.5rem; color: var(--purple); margin-bottom: 0.3rem; display: block; }
.upload-zone h4 { color: var(--text-primary); margin-bottom: 0.15rem; font-size: 0.9rem; }
.upload-zone p { font-size: 0.78rem; }

/* ===== MIND MAP — HUB VISUAL ===== */
.mindmap-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-bottom: 1.5rem;
}
.mm-stat {
  background: var(--bg-card); border-radius: var(--r); padding: 0.9rem 0.6rem; text-align: center;
  border: 1px solid var(--border-light); box-shadow: var(--shadow-sm); transition: 0.25s;
  cursor: default;
}
.mm-stat[data-category="insights"]  { border-bottom: 3px solid #f59e0b; }
.mm-stat[data-category="patterns"]  { border-bottom: 3px solid #8b5cf6; }
.mm-stat[data-category="summaries"] { border-bottom: 3px solid #3b82f6; }
.mm-stat[data-category="voices"]    { border-bottom: 3px solid #ef4444; }
.mm-stat-value { display: block; font-size: 1.6rem; font-weight: 800; color: var(--text-primary); line-height: 1; }
.mm-stat-label { display: block; font-size: 0.7rem; color: var(--text-muted); margin-top: 0.25rem; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }

/* Hub layout */
.mindmap-hub {
  position: relative; width: 100%; height: 320px; margin-bottom: 1rem;
  display: flex; align-items: center; justify-content: center;
}

/* Center node */
.mm-center-node {
  position: absolute; z-index: 5; width: 90px; height: 90px; border-radius: 50%;
  background: var(--gradient); display: flex; flex-direction: column;
  align-items: center; justify-content: center; box-shadow: var(--shadow-purple), 0 0 30px rgba(124,58,237,0.18);
  cursor: default; transition: transform 0.3s;
}
.mm-center-node:hover { transform: scale(1.06); }
.mm-center-pulse {
  position: absolute; width: 100%; height: 100%; border-radius: 50%;
  border: 2px solid var(--purple); animation: mmPulse 3s ease-in-out infinite; opacity: 0;
}
@keyframes mmPulse {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.7); opacity: 0; }
}
.mm-center-icon { font-size: 1.7rem; line-height: 1; }
.mm-center-text { font-size: 0.65rem; font-weight: 700; color: #fff; text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }

/* Branch wrappers */
.mm-branch {
  position: absolute; z-index: 4; transition: transform 0.3s;
}
.mm-branch-insights  { top: 20px;  left: calc(50% - 160px); }
.mm-branch-patterns  { top: 20px;  left: calc(50% + 70px); }
.mm-branch-summaries { bottom: 20px; left: calc(50% - 160px); }
.mm-branch-voices    { bottom: 20px; left: calc(50% + 70px); }

/* Connector lines via pseudo elements */
.mm-branch::before {
  content: ''; position: absolute; z-index: -1;
  background: var(--border); border-radius: 2px;
}
.mm-branch-insights::before  { width: 60px; height: 2px; bottom: -2px; right: -30px; transform: rotate(30deg); transform-origin: right center; }
.mm-branch-patterns::before  { width: 60px; height: 2px; bottom: -2px; left: -30px; transform: rotate(-30deg); transform-origin: left center; }
.mm-branch-summaries::before { width: 60px; height: 2px; top: -2px; right: -30px; transform: rotate(-30deg); transform-origin: right center; }
.mm-branch-voices::before    { width: 60px; height: 2px; top: -2px; left: -30px; transform: rotate(30deg); transform-origin: left center; }

/* Category nodes */
.mm-node {
  width: 100px; height: 100px; border-radius: 50%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; cursor: pointer;
  border: 2px solid var(--border); background: var(--bg-card); box-shadow: var(--shadow);
  transition: all 0.3s ease; position: relative;
}
.mm-node:hover { transform: scale(1.1); }
.mm-node:active { transform: scale(0.96); }
.mm-node.active { border-width: 3px; }

.mm-node-insights  { border-color: rgba(245,158,11,0.4); }
.mm-node-insights:hover, .mm-node-insights.active  { border-color: #f59e0b; box-shadow: 0 0 20px rgba(245,158,11,0.2); background: rgba(245,158,11,0.05); }
.mm-node-patterns  { border-color: rgba(139,92,246,0.4); }
.mm-node-patterns:hover, .mm-node-patterns.active  { border-color: #8b5cf6; box-shadow: 0 0 20px rgba(139,92,246,0.2); background: rgba(139,92,246,0.05); }
.mm-node-summaries { border-color: rgba(59,130,246,0.4); }
.mm-node-summaries:hover, .mm-node-summaries.active { border-color: #3b82f6; box-shadow: 0 0 20px rgba(59,130,246,0.2); background: rgba(59,130,246,0.05); }
.mm-node-voices    { border-color: rgba(239,68,68,0.4); }
.mm-node-voices:hover, .mm-node-voices.active    { border-color: #ef4444; box-shadow: 0 0 20px rgba(239,68,68,0.2); background: rgba(239,68,68,0.05); }

.mm-node-icon { font-size: 1.5rem; line-height: 1; }
.mm-node-label { font-size: 0.65rem; font-weight: 700; color: var(--text-secondary); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.3px; }
.mm-node-badge {
  position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; border-radius: 11px;
  background: var(--gradient); color: #fff; font-size: 0.65rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
  box-shadow: 0 2px 6px rgba(124,58,237,0.3);
}

/* Expanded panels */
.mm-panel {
  border-radius: var(--r); overflow: hidden; margin-bottom: 0.75rem;
  box-shadow: var(--shadow-md); border: 1px solid var(--border-light);
  animation: mmPanelIn 0.35s ease;
}
@keyframes mmPanelIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}
.mm-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem; color: #fff;
}
.mm-panel-header-insights  { background: linear-gradient(135deg, #f59e0b, #f97316); }
.mm-panel-header-patterns  { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.mm-panel-header-summaries { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.mm-panel-header-voices    { background: linear-gradient(135deg, #ef4444, #dc2626); }
.mm-panel-title { display: flex; align-items: center; gap: 0.5rem; }
.mm-panel-title span { font-size: 1.2rem; }
.mm-panel-title h3 { font-size: 0.95rem; font-weight: 700; margin: 0; color: #fff; }
.mm-panel-close {
  background: rgba(255,255,255,0.2); border: none; color: #fff; width: 28px; height: 28px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: 0.2s; font-size: 0.75rem;
}
.mm-panel-close:hover { background: rgba(255,255,255,0.35); }
.mm-panel-body {
  background: var(--bg-card); padding: 1rem;
}
.mm-voices-desc {
  font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 0.75rem; line-height: 1.4;
}

/* Memory items — improved */
.memory-list { max-height: 350px; overflow-y: auto; }
.memory-item-row {
  display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.6rem 0.65rem;
  border-radius: var(--r-sm); margin-bottom: 0.35rem; font-size: 0.82rem;
  transition: background 0.2s; background: var(--bg-input); border: 1px solid transparent;
}
.memory-item-row:hover { border-color: var(--border); background: var(--bg-hover); }
.memory-icon { flex-shrink: 0; font-size: 1rem; }
.memory-date { font-size: 0.66rem; color: var(--text-muted); margin-left: auto; white-space: nowrap; font-weight: 500; }
.add-memory-row { display: flex; gap: 0.4rem; margin-top: 0.75rem; }
.add-memory-row input { flex: 1; border-radius: var(--r-sm); }

/* ===== VOICES ===== */
.voices-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.65rem; margin-bottom: 0.75rem; }
.voice-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r);
  padding: 1rem 0.7rem; cursor: pointer; transition: all 0.25s ease; text-align: center;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.voice-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--purple), var(--pink));
  transform: scaleX(0); transition: transform 0.3s; transform-origin: left;
}
.voice-card:hover::before { transform: scaleX(1); }
.voice-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--purple); }
.voice-icon { font-size: 1.6rem; display: block; margin-bottom: 0.45rem; }
.voice-name { font-weight: 700; font-size: 0.8rem; margin-bottom: 0.2rem; color: var(--text-primary); }
.voice-desc { font-size: 0.7rem; color: var(--text-muted); line-height: 1.35; }
.voice-questions-list { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.75rem; }
.voice-question-item {
  padding: 0.6rem 0.75rem; font-size: 0.82rem; color: var(--text-secondary); cursor: pointer;
  border-radius: var(--r-sm); transition: 0.2s; background: var(--bg-input); border: 1px solid var(--border-light);
}
.voice-question-item:hover { border-color: var(--purple); color: var(--text-primary); background: var(--purple-soft); }
.voice-question-item.answered { opacity: 0.45; text-decoration: line-through; }

/* ===== FILE BROWSER ===== */
.file-browser-controls { display: flex; gap: 0.6rem; margin-bottom: 0.6rem; }
.file-root-select { flex: 1; }
.file-search-row { display: flex; gap: 0.4rem; margin-bottom: 0.6rem; }
.file-search-row input { flex: 1; }
.file-breadcrumb { font-size: 0.76rem; color: var(--text-muted); margin-bottom: 0.6rem; }
.file-breadcrumb .crumb { cursor: pointer; color: var(--purple); }
.file-breadcrumb .crumb:hover { text-decoration: underline; }
.file-breadcrumb .sep { color: var(--text-muted); }
.file-browser-list { display: flex; flex-direction: column; gap: 1px; }
.file-item {
  display: flex; align-items: center; gap: 0.55rem; padding: 0.45rem 0.55rem; cursor: pointer;
  border-radius: var(--r-sm); transition: 0.12s;
}
.file-item:hover { background: var(--purple-soft); }
.file-icon { width: 26px; text-align: center; font-size: 0.88rem; }
.file-icon.folder { color: var(--amber); }
.file-icon.pdf { color: var(--red); }
.file-icon.word { color: var(--blue); }
.file-icon.excel { color: var(--green); }
.file-icon.code { color: var(--text-secondary); }
.file-name { flex: 1; font-size: 0.84rem; }
.file-badge { font-size: 0.64rem; background: var(--green); color: white; padding: 0.08rem 0.35rem; border-radius: 8px; }
.file-meta { font-size: 0.7rem; color: var(--text-muted); }
.preview-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; }
.preview-header h4 { margin: 0; font-size: 0.88rem; }
.preview-header div { display: flex; gap: 0.4rem; }
.preview-content { padding: 0.8rem; font-size: 0.76rem; max-height: 280px; overflow-y: auto; white-space: pre-wrap; color: var(--text-secondary); background: var(--bg-input); border-radius: var(--r-sm); }

/* ===== KNOWLEDGE BASE ===== */
.kb-stats { display: flex; gap: 0.6rem; margin-bottom: 0.75rem; }
.kb-stat { display: flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; color: var(--text-secondary); }
.kb-stat i { color: var(--purple); font-size: 0.75rem; }
.kb-stat span { font-weight: 700; color: var(--purple); }
.kb-search-row { display: flex; gap: 0.4rem; margin-bottom: 0.5rem; }
.kb-search-row input { flex: 1; }
.kb-search-result { padding: 0.65rem; margin-top: 0.35rem; background: var(--bg-input); border-radius: var(--r-sm); border: 1px solid var(--border-light); }
.kb-search-result .result-source { font-size: 0.7rem; color: var(--purple); margin-bottom: 0.15rem; }
.kb-search-result .result-text { font-size: 0.78rem; color: var(--text-secondary); }
.kb-documents-list { list-style: none; padding: 0; margin: 0; }
.kb-documents-list li { display: flex; justify-content: space-between; align-items: center; padding: 0.55rem 0; border-bottom: 1px solid var(--border-light); }
.kb-documents-list li:last-child { border-bottom: none; }
.doc-info strong { font-size: 0.84rem; }
.doc-info small { display: block; font-size: 0.7rem; color: var(--text-muted); }
.delete-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; opacity: 0.5; transition: 0.15s; }
.delete-btn:hover { color: var(--red); opacity: 1; }

/* ===== LIBRARY / APOIO TEÓRICO ===== */
.library-card { border-left: 3px solid var(--purple); }
.library-card h3 { color: var(--purple); }
.library-card h3 i { margin-right: 0.3rem; }
.library-upload-zone { background: linear-gradient(135deg, rgba(139,92,246,0.04), rgba(139,92,246,0.08)); border: 2px dashed rgba(139,92,246,0.25); }
.library-upload-zone:hover { border-color: var(--purple); background: linear-gradient(135deg, rgba(139,92,246,0.06), rgba(139,92,246,0.12)); }
.library-upload-zone i { color: var(--purple); }
.library-list { margin-top: 0.75rem; }
.library-item { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0; border-bottom: 1px solid var(--border-light); }
.library-item:last-child { border-bottom: none; }
.library-item .doc-info { display: flex; align-items: center; gap: 0.5rem; flex: 1; min-width: 0; }
.library-item .doc-info > div { min-width: 0; }
.library-item .doc-info strong { font-size: 0.84rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-item .doc-info small { display: block; font-size: 0.68rem; color: var(--text-muted); }
.library-icon { font-size: 1.2rem; flex-shrink: 0; }

/* ===== KB DOC CLICKABLE ===== */
.kb-doc-row { display: flex; justify-content: space-between; align-items: center; padding: 0.55rem 0; border-bottom: 1px solid var(--border-light); }
.kb-doc-row:last-child { border-bottom: none; }
.kb-doc-clickable .doc-info-clickable { cursor: pointer; transition: opacity 0.15s; }
.kb-doc-clickable .doc-info-clickable:hover { opacity: 0.75; }
.kb-doc-clickable .doc-info-clickable:hover strong { color: var(--purple); text-decoration: underline; }
.doc-info-clickable { display: flex; align-items: center; gap: 0.5rem; flex: 1; min-width: 0; }
.doc-info-clickable > div { min-width: 0; }
.doc-type-icon { font-size: 1.15rem; flex-shrink: 0; }
.doc-badge { font-size: 0.6rem; padding: 0.1rem 0.35rem; border-radius: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; vertical-align: middle; margin-left: 0.3rem; }
.doc-badge-generated { background: rgba(139,92,246,0.12); color: var(--purple); }

/* ===== KB PREVIEW PANEL ===== */
.kb-preview-card { border-left: 3px solid var(--purple); animation: slideDown 0.25s ease; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.kb-preview-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.75rem; gap: 0.5rem; }
.kb-preview-title-row { display: flex; align-items: center; gap: 0.6rem; flex: 1; min-width: 0; }
.kb-preview-title-row h3 { margin: 0; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-preview-icon { font-size: 1.5rem; flex-shrink: 0; }
.kb-preview-meta { font-size: 0.7rem; color: var(--text-muted); display: block; margin-top: 0.1rem; }
.kb-preview-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }
.kb-preview-actions .secondary-btn { padding: 0.3rem 0.5rem; font-size: 0.75rem; }
.kb-preview-body { background: var(--bg-input); border-radius: var(--r-sm); padding: 1rem 1.1rem; max-height: 60vh; overflow-y: auto; font-size: 0.82rem; line-height: 1.65; border: 1px solid var(--border-light); }
.kb-preview-body h1, .kb-preview-body h2, .kb-preview-body h3, .kb-preview-body h4 { margin-top: 1rem; margin-bottom: 0.4rem; color: var(--text-primary); }
.kb-preview-body h1 { font-size: 1.1rem; }
.kb-preview-body h2 { font-size: 1rem; border-bottom: 1px solid var(--border-light); padding-bottom: 0.3rem; }
.kb-preview-body h3 { font-size: 0.92rem; }
.kb-preview-body p { margin-bottom: 0.5rem; }
.kb-preview-body ul, .kb-preview-body ol { padding-left: 1.3rem; margin-bottom: 0.5rem; }
.kb-preview-body li { margin-bottom: 0.2rem; }
.kb-preview-body strong { color: var(--text-primary); }
.kb-preview-body hr { border: none; border-top: 1px solid var(--border-light); margin: 0.75rem 0; }
.kb-preview-body pre { background: rgba(0,0,0,0.15); padding: 0.6rem; border-radius: var(--r-sm); overflow-x: auto; }
.kb-preview-body code { font-size: 0.78rem; background: rgba(0,0,0,0.1); padding: 0.1rem 0.3rem; border-radius: 3px; }
.kb-preview-body blockquote { border-left: 3px solid var(--purple); padding-left: 0.7rem; margin: 0.5rem 0; color: var(--text-secondary); font-style: italic; }

/* ===== CONFIG ===== */
.api-status-row { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.65rem; padding: 0.45rem 0.6rem; background: var(--bg-input); border-radius: var(--r-sm); font-size: 0.8rem; }
.api-key-row { display: flex; gap: 0.4rem; align-items: center; }
.api-key-row input { flex: 1; }
.models-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 0.45rem; }
.model-card {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 0.7rem; cursor: pointer; transition: 0.15s; text-align: center; position: relative;
}
.model-card:hover { border-color: var(--purple); }
.model-card.selected { border-color: var(--purple); background: var(--purple-soft); }
.model-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.25rem; }
.model-card-icon { font-size: 1.1rem; }
.model-check { display: none; color: var(--purple); }
.model-card.selected .model-check { display: block; }
.model-card-name { font-weight: 600; font-size: 0.8rem; margin-bottom: 0.1rem; color: var(--text-primary); }
.model-card-desc { font-size: 0.68rem; color: var(--text-muted); line-height: 1.3; margin-bottom: 0.25rem; }
.model-card-tags { display: flex; flex-wrap: wrap; gap: 0.15rem; justify-content: center; }
.model-tag { font-size: 0.6rem; background: var(--bg-main); padding: 0.08rem 0.28rem; border-radius: 6px; color: var(--text-muted); }
.model-tag.highlight { background: var(--purple-soft); color: var(--purple); }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; padding: 0.6rem 1rem; border-radius: var(--r-sm);
  font-size: 0.82rem; color: white; z-index: 10000; animation: slideUp 0.3s, fadeOut 0.3s 3s forwards;
  display: flex; align-items: center; gap: 0.35rem; box-shadow: var(--shadow-md);
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.warning { background: var(--amber); color: white; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-10px); } }

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

/* ═══════════════════════════════════════════
   📱 MOBILE / RESPONSIVE
   ═══════════════════════════════════════════ */

/* Mobile topbar — hidden on desktop */
.mobile-topbar {
  display: none;
}
.sidebar-overlay {
  display: none;
}

/* ===== TABLET (≤ 900px) ===== */
@media (max-width: 900px) {
  .sidebar { width: 220px; padding: 1rem 0.75rem; }
  .content-section { padding: 1.25rem 1.5rem; }
  .mindmap-hub { height: 290px; }
  .mm-branch-insights  { left: calc(50% - 140px); }
  .mm-branch-patterns  { left: calc(50% + 50px); }
  .mm-branch-summaries { left: calc(50% - 140px); }
  .mm-branch-voices    { left: calc(50% + 50px); }
  .chat-header { padding: 0.6rem 1rem; }
  .chat-messages { padding: 1rem; }
  .chat-input-area { padding: 0.6rem 1rem; }
}

/* ===== MOBILE (≤ 768px) ===== */
@media (max-width: 768px) {
  /* App container */
  .app-container {
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* dynamic viewport height for mobile browsers */
  }

  /* Mobile top bar */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 1rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    z-index: 1001;
    flex-shrink: 0;
    min-height: 48px;
  }
  .hamburger-btn {
    background: none; border: none; color: var(--text-primary);
    font-size: 1.15rem; cursor: pointer; padding: 0.35rem;
    border-radius: var(--r-sm); transition: 0.15s;
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px;
  }
  .hamburger-btn:hover { background: var(--bg-hover); }
  .hamburger-btn:active { background: var(--purple-soft); }
  .mobile-topbar-title {
    display: flex; align-items: center; gap: 0.4rem;
    font-weight: 700; font-size: 1rem; color: var(--purple);
  }
  .mobile-topbar-title span:first-child { font-size: 1.2rem; }
  .mobile-topbar-spacer { flex: 1; }

  /* Sidebar — off-canvas drawer */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 280px; max-width: 85vw;
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    padding: 1.25rem;
    overflow-y: auto;
  }
  .sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }

  /* Overlay */
  .sidebar-overlay {
    display: block;
    position: fixed; inset: 0; z-index: 1050;
    background: rgba(0,0,0,0.4);
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s;
  }
  .sidebar-overlay.active {
    opacity: 1; pointer-events: auto;
  }

  /* Sidebar internals — show full content in drawer */
  .logo-text, .nav-btn span, .sessions-section, .sidebar-footer { display: revert; }
  .sidebar-footer span:not(.status-dot) { display: revert; }
  .nav-btn { justify-content: flex-start; padding: 0.6rem 0.8rem; font-size: 0.88rem; }
  .nav-btn i { margin: 0; width: 22px; }

  /* Main content — full width */
  .main-content {
    flex: 1; min-height: 0; overflow: hidden;
  }
  .content-section {
    padding: 1rem;
    height: 100%;
  }

  /* Chat adjustments */
  #chat-tab { padding: 0; }
  .chat-header { padding: 0.5rem 0.75rem; }
  .chat-header-right { gap: 0.35rem; }
  .model-badge { font-size: 0.65rem; padding: 0.2rem 0.45rem; }
  .compile-btn { font-size: 0.78rem; padding: 0.3rem 0.45rem; }
  .chat-messages { padding: 0.75rem; gap: 0.65rem; }
  .message { max-width: 92%; }
  .message.user { padding: 0.6rem 0.85rem; font-size: 0.84rem; }
  .message.assistant .content { padding: 0.7rem 0.9rem; font-size: 0.84rem; }
  .message.system.oracle-welcome { max-width: 100%; }
  .message.system.oracle-welcome .content { padding: 1.2rem 1rem; }
  .oracle-welcome-icon { font-size: 2.2rem; }
  .oracle-welcome h3 { font-size: 1rem; }
  .oracle-capabilities { gap: 0.25rem; }
  .oracle-capabilities span { font-size: 0.66rem; padding: 0.2rem 0.4rem; }
  .oracle-features, .oracle-commands { padding: 0.5rem 0.65rem; }

  .chat-input-area { padding: 0.5rem 0.75rem; }
  #chat-form { gap: 0.35rem; }
  .attach-btn, .send-btn { width: 36px; height: 36px; }
  #message-input { font-size: 0.86rem; padding: 0.5rem 0.7rem; }

  /* Section headers */
  .section-header h2 { font-size: 1.1rem; }
  .section-desc { font-size: 0.8rem; }

  /* Cards */
  .card { padding: 0.9rem; margin-bottom: 0.7rem; }
  .card h3 { font-size: 0.9rem; }

  /* Forms */
  input[type="text"], input[type="number"], input[type="password"], textarea, select {
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  /* Profile */
  .profile-stats { flex-wrap: wrap; }
  .training-categories-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.5rem; }
  .entry-meta-row { grid-template-columns: 1fr; }

  /* Journal */
  .mood-chips { gap: 0.25rem; }
  .mood-chip { font-size: 0.72rem; padding: 0.25rem 0.5rem; }

  /* Mind Map */
  .mindmap-stats { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .mm-stat { padding: 0.7rem 0.5rem; }
  .mm-stat-value { font-size: 1.3rem; }
  .mindmap-hub { height: 260px; }
  .mm-center-node { width: 68px; height: 68px; }
  .mm-center-icon { font-size: 1.3rem; }
  .mm-center-text { font-size: 0.55rem; }
  .mm-node { width: 78px; height: 78px; }
  .mm-node-icon { font-size: 1.2rem; }
  .mm-node-label { font-size: 0.55rem; }
  .mm-node-badge { min-width: 18px; height: 18px; font-size: 0.58rem; }
  .mm-branch-insights  { top: 12px; left: calc(50% - 115px); }
  .mm-branch-patterns  { top: 12px; left: calc(50% + 42px); }
  .mm-branch-summaries { bottom: 12px; left: calc(50% - 115px); }
  .mm-branch-voices    { bottom: 12px; left: calc(50% + 42px); }
  .mm-panel-header { padding: 0.6rem 0.75rem; }
  .mm-panel-title h3 { font-size: 0.88rem; }
  .mm-panel-body { padding: 0.75rem; }

  /* Voices */
  .voices-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .voice-card { padding: 0.75rem 0.5rem; }
  .voice-icon { font-size: 1.3rem; }
  .voice-name { font-size: 0.75rem; }
  .voice-desc { font-size: 0.65rem; }

  /* File browser */
  .file-browser-controls { flex-direction: column; gap: 0.4rem; }
  .file-search-row { flex-direction: column; gap: 0.4rem; }

  /* Knowledge base */
  .kb-stats { flex-wrap: wrap; gap: 0.4rem; }
  .kb-search-row { flex-direction: column; gap: 0.4rem; }

  /* Config */
  .models-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.4rem; }
  .api-key-row { flex-direction: column; gap: 0.4rem; }
  .api-key-row input { width: 100%; }

  /* Lessons */
  .entries-list .entry-item { padding: 0.6rem; }
  .entry-footer { flex-wrap: wrap; }

  /* Toast — centered on mobile */
  .toast {
    left: 1rem; right: 1rem; bottom: 1rem;
    text-align: center; justify-content: center;
  }

  /* Modals */
  .modal-overlay .modal-card,
  .modal-card {
    max-width: 95vw; margin: 0.5rem;
    max-height: 90vh;
  }
  .onboarding-card { max-width: 95vw; }

  /* Compile doc */
  .compile-dropdown-menu {
    right: -1rem; min-width: 200px;
  }

  /* Library / KB */
  .library-item { flex-direction: column; align-items: flex-start; gap: 0.35rem; }
  .kb-doc-row { flex-direction: column; align-items: flex-start; gap: 0.35rem; }

  /* Password */
  .password-requirements { gap: 0.15rem; }
}

/* ===== SMALL MOBILE (≤ 400px) ===== */
@media (max-width: 400px) {
  .mobile-topbar { padding: 0.45rem 0.7rem; }
  .content-section { padding: 0.75rem; }
  .chat-messages { padding: 0.6rem; }
  .chat-input-area { padding: 0.4rem 0.6rem; }
  .message { max-width: 96%; }
  .mindmap-hub { height: 240px; }
  .mm-center-node { width: 60px; height: 60px; }
  .mm-center-icon { font-size: 1.1rem; }
  .mm-node { width: 68px; height: 68px; }
  .mm-node-icon { font-size: 1rem; }
  .mm-branch-insights  { top: 10px; left: calc(50% - 100px); }
  .mm-branch-patterns  { top: 10px; left: calc(50% + 36px); }
  .mm-branch-summaries { bottom: 10px; left: calc(50% - 100px); }
  .mm-branch-voices    { bottom: 10px; left: calc(50% + 36px); }
  .mindmap-stats { grid-template-columns: repeat(2, 1fr); gap: 0.4rem; }
  .voices-grid { grid-template-columns: 1fr 1fr; }
  .training-categories-grid { grid-template-columns: 1fr 1fr; }
  .models-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== SAFE AREA (notch devices) ===== */
@supports (padding: env(safe-area-inset-bottom)) {
  .chat-input-area { padding-bottom: calc(0.5rem + env(safe-area-inset-bottom)); }
  .sidebar { padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
  .mobile-topbar { padding-top: calc(0.55rem + env(safe-area-inset-top)); }
}

/* ═══════════════════════════════════════════
   📋 COMPILAR CONVERSA — Dropdown & Doc
   ═══════════════════════════════════════════ */

/* Dropdown */
.compile-dropdown {
  position: relative;
}
.compile-btn {
  background: var(--purple-soft);
  border: 1px solid var(--border);
  color: var(--purple);
  padding: 0.35rem 0.55rem;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.compile-btn:hover {
  background: var(--purple-medium);
  border-color: var(--purple);
}
.compile-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
  min-width: 220px;
  z-index: 100;
  overflow: hidden;
}
.compile-dropdown-menu.show {
  display: block;
  animation: slideUp 0.2s ease;
}
.compile-dropdown-header {
  padding: 0.55rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-light);
}
.compile-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.compile-option:hover {
  background: var(--purple-soft);
  color: var(--purple-text);
}
.compile-option span {
  font-size: 1rem;
}
.compile-dropdown-hint {
  padding: 0.4rem 0.75rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
  font-style: italic;
}
.compile-dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: 0.2rem 0;
}
.finalize-option {
  font-weight: 600 !important;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.06), rgba(34, 197, 94, 0.06)) !important;
}
.finalize-option:hover {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(34, 197, 94, 0.15)) !important;
}
.lesson-category-badge {
  padding: 0.12rem 0.45rem;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--purple-soft);
  color: var(--purple-text);
}
.lesson-emotion-tag {
  padding: 0.12rem 0.4rem;
  border-radius: 10px;
  font-size: 0.62rem;
  background: linear-gradient(135deg, #fce4ec, #f3e5f5);
  color: #7b1fa2;
}

/* Documento compilado */
.compiled-doc-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--purple-medium);
  flex-wrap: wrap;
}
.compiled-doc-badge {
  background: var(--gradient);
  color: white;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.compiled-doc-saved {
  font-size: 0.72rem;
  color: var(--green);
  font-weight: 500;
}
.compiled-doc-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}
.compiled-action-btn {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.76rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.2s;
}
.compiled-action-btn:hover {
  background: var(--purple-soft);
  border-color: var(--purple);
  color: var(--purple-text);
}

/* ═══════════════════════════════════════════
   🌱 LIÇÕES APRENDIDAS
   ═══════════════════════════════════════════ */

.lessons-stats-bar {
  margin-bottom: 1rem;
}
.lessons-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border-radius: var(--r);
  border: 1px solid var(--border-light);
}
.lesson-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
.lesson-stat .stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.lesson-stat .stat-label,
.lesson-stat-tags .stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}
.lesson-stat-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.lesson-stat-tag {
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.7rem;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}

/* Controls */
.lessons-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.lessons-search-row {
  display: flex;
  gap: 0.5rem;
}
.lessons-search-row input {
  flex: 1;
}
.lessons-filters {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.lessons-filter-select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.8rem;
  flex: 1;
}
#lessons-fav-filter.active {
  background: #fef3cd;
  border-color: #f5a623;
  color: #f5a623;
}

/* Add lesson */
.lessons-add-row h4 {
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}
.lesson-add-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* Lesson cards */
.lessons-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.lesson-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg, 12px);
  padding: 1rem 1.1rem;
  transition: all 0.2s;
  position: relative;
}
.lesson-card:hover {
  border-color: var(--purple);
  box-shadow: 0 2px 12px rgba(139, 92, 246, 0.08);
}
.lesson-card.lesson-favorite {
  border-left: 3px solid #f5a623;
}
.lesson-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.lesson-card-actions {
  display: flex;
  gap: 0.3rem;
}
.lesson-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  transition: all 0.2s;
}
.lesson-action-btn:hover {
  background: var(--bg-input);
}
.lesson-delete-btn:hover {
  color: var(--red);
}
.lesson-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}
.lesson-description {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}
.lesson-emotions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
}
.emotion-tag {
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.68rem;
  background: linear-gradient(135deg, #fce4ec, #f3e5f5);
  color: #7b1fa2;
  font-weight: 500;
  border: 1px solid rgba(123, 31, 162, 0.15);
}
.lesson-strength {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-secondary);
  padding: 0.4rem 0.6rem;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.05), rgba(59, 130, 246, 0.05));
  border-radius: 8px;
  margin-bottom: 0.5rem;
  border-left: 2px solid var(--purple);
}
.lesson-category-tag {
  padding: 0.15rem 0.55rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}
.lesson-category-tag[data-category="autoestima"] { background: #fef3cd; color: #856404; border-color: #ffc107; }
.lesson-category-tag[data-category="relacionamentos"] { background: #d4edda; color: #155724; border-color: #28a745; }
.lesson-category-tag[data-category="medos"] { background: #f8d7da; color: #721c24; border-color: #dc3545; }
.lesson-category-tag[data-category="crescimento"] { background: #d1ecf1; color: #0c5460; border-color: #17a2b8; }
.lesson-category-tag[data-category="valores"] { background: #e2d5f1; color: #4a148c; border-color: #7b1fa2; }
.lesson-category-tag[data-category="limites"] { background: #ffe0b2; color: #e65100; border-color: #ff9800; }
.lesson-category-tag[data-category="vulnerabilidade"] { background: #fce4ec; color: #880e4f; border-color: #e91e63; }
.lesson-category-tag[data-category="coragem"] { background: #fff9c4; color: #f57f17; border-color: #fbc02d; }
.lesson-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border-light);
}

/* Lessons section in compiled doc */
.compiled-lessons-section {
  margin-top: 1.25rem;
  padding: 1rem;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.04), rgba(34, 197, 94, 0.04));
  border-radius: var(--r-lg, 12px);
  border: 1px solid rgba(139, 92, 246, 0.15);
}
.compiled-lessons-section h4 {
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  font-size: 0.9rem;
}
.compiled-lessons-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
.compiled-lesson-card {
  padding: 0.65rem 0.85rem;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-light);
}
.compiled-lesson-card strong {
  display: block;
  margin: 0.3rem 0 0.2rem;
  font-size: 0.85rem;
}
.compiled-lesson-card p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin: 0 0 0.3rem;
}
.lessons-saved-hint {
  font-size: 0.76rem;
  color: var(--text-muted);
  text-align: center;
}

/* ═══ FINALIZAR SESSÃO ═══ */
.finalize-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.finalize-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-light);
}
.finalize-badge {
  background: linear-gradient(135deg, var(--purple), #22c55e);
  color: white;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.finalize-section {
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg, 12px);
  overflow: hidden;
  transition: all 0.3s;
}
.finalize-section.collapsed .finalize-section-content {
  display: none;
}
.finalize-section.collapsed .finalize-section-tab i {
  transform: rotate(-90deg);
}
.finalize-section-tab {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  user-select: none;
  transition: background 0.2s;
}
.finalize-section-tab:hover {
  background: var(--purple-soft);
}
.finalize-section-tab i {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.finalize-section-content {
  padding: 1rem 1.2rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.88rem;
  line-height: 1.65;
}
.finalize-section-content h1 { font-size: 1.2rem; margin-bottom: 0.5rem; }
.finalize-section-content h2 { font-size: 1rem; margin: 1rem 0 0.4rem; color: var(--purple-text); }
.finalize-section-content h3 { font-size: 0.9rem; margin: 0.75rem 0 0.3rem; }

.finalize-lessons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.finalize-lesson-card {
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.05), rgba(139, 92, 246, 0.05));
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 10px;
}
.finalize-lesson-title {
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 0.3rem;
}
.finalize-lesson-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.finalize-lesson-strength {
  font-size: 0.78rem;
  color: var(--purple-text);
  font-style: italic;
  margin-top: 0.35rem;
}
.finalize-lesson-meta {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}
.finalize-disclaimer {
  padding: 0.65rem 0.9rem;
  background: rgba(234, 179, 8, 0.08);
  border: 1px solid rgba(234, 179, 8, 0.25);
  border-radius: 8px;
  font-size: 0.76rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.4;
}

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; width: 100%; max-width: 520px; max-height: 85vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border-light);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); margin: 0; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1.1rem; padding: 0.25rem;
  border-radius: 6px; transition: color 0.2s, background 0.2s;
}
.modal-close:hover { color: var(--red); background: rgba(239,68,68,0.1); }
.modal-body { padding: 1.25rem 1.5rem; }

/* Admin: user management */
.add-user-form { margin-bottom: 0.5rem; }
.add-user-form h4 { font-size: 0.9rem; margin-bottom: 0.75rem; color: var(--text-primary); }
.admin-user-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 0; border-bottom: 1px solid var(--border-light);
  gap: 0.5rem;
}
.admin-user-item:last-child { border-bottom: none; }
.admin-user-info { display: flex; align-items: center; gap: 0.6rem; flex: 1; min-width: 0; }
.admin-user-icon { font-size: 1.25rem; }
.admin-user-info strong { display: block; font-size: 0.88rem; color: var(--text-primary); }
.admin-user-info small { display: block; font-size: 0.72rem; color: var(--text-muted); }
.admin-user-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.small-btn { padding: 0.3rem 0.6rem !important; font-size: 0.72rem !important; }
.danger-btn { color: var(--red) !important; border-color: rgba(239,68,68,0.3) !important; }
.danger-btn:hover { background: rgba(239,68,68,0.15) !important; }
.admin-badge {
  font-size: 0.72rem; color: var(--accent); background: rgba(139,92,246,0.12);
  padding: 0.2rem 0.6rem; border-radius: 6px; font-weight: 600;
}

/* Onboarding modal */
.onboarding-card { max-width: 480px; }
.onboarding-icon { font-size: 2.5rem; text-align: center; margin-bottom: 0.5rem; }
.onboarding-step h4 { font-size: 1.05rem; color: var(--text-primary); margin-bottom: 0.3rem; text-align: center; }
.onboarding-step p { font-size: 0.82rem; color: var(--text-secondary); text-align: center; margin-bottom: 1rem; line-height: 1.5; }
.onboarding-step .primary-btn { width: 100%; margin-top: 0.75rem; }

/* Password change section */
.password-input-wrapper { position: relative; display: flex; align-items: center; }
.password-input-wrapper input { flex: 1; padding-right: 2.5rem; }
.password-toggle-btn {
  position: absolute; right: 0.5rem; background: none; border: none;
  color: var(--text-muted); cursor: pointer; padding: 0.3rem;
  font-size: 0.85rem; transition: color 0.2s;
}
.password-toggle-btn:hover { color: var(--text-primary); }

.password-strength { margin-top: 0.4rem; }
.strength-bar {
  height: 4px; background: var(--bg-input); border-radius: 4px;
  overflow: hidden; margin-bottom: 0.3rem;
}
.strength-fill {
  height: 100%; width: 0%; border-radius: 4px;
  transition: width 0.3s ease, background 0.3s ease;
}
.strength-label { font-size: 0.72rem; font-weight: 600; }

.password-requirements { margin-top: 0.4rem; display: flex; flex-direction: column; gap: 0.2rem; }
.password-requirements .req {
  font-size: 0.72rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 0.35rem;
  transition: color 0.2s;
}
.password-requirements .req i { font-size: 0.45rem; }
.password-requirements .req.met { color: var(--green); }
.password-requirements .req.met i::before { content: "\f00c"; font-weight: 900; font-size: 0.65rem; }
.password-requirements .req.unmet { color: var(--text-muted); }

.password-match-hint { font-size: 0.72rem; margin-top: 0.3rem; display: block; }
.password-match-hint.match { color: var(--green); }
.password-match-hint.no-match { color: var(--red); }
