/* ══════════════════════════════════════════════════════════════
   PREMIUM UI — Glassmorphism Redesign
   Navbar · Sidebar · Upgrade Button
   Apple Vision Pro aesthetic, dark-first
══════════════════════════════════════════════════════════════ */

/* ── Minimal Glassmorphism Navbar ─────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  flex-shrink: 0;
  position: relative;
  z-index: 50;

  background: rgba(10, 10, 16, 0.55);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 1px 24px rgba(0, 0, 0, 0.4);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Brand link — no default anchor style */
.brand-link {
  color: inherit;
  text-decoration: none;
}

/* Hamburger icon button */
.header-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: rgba(200, 200, 220, 0.7);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}

.header-icon-btn:hover {
  background: rgba(124, 106, 247, 0.12);
  border-color: rgba(124, 106, 247, 0.35);
  color: #c4b5fd;
}

/* ── Upgrade to Premium Button — Luxury Style ─────────────── */
.upgrade-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  background: linear-gradient(135deg, rgba(124, 106, 247, 0.2) 0%, rgba(212, 175, 55, 0.15) 100%);
  border: 1px solid rgba(212, 175, 55, 0.45);
  border-radius: 10px;
  color: #e8d89b;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font, Inter, system-ui, sans-serif);
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: background 0.22s, border-color 0.22s, box-shadow 0.22s, transform 0.15s;
  box-shadow: 0 0 14px rgba(212,175,55,0.15), 0 0 0 1px rgba(212,175,55,0.1) inset;
  white-space: nowrap;
}

.upgrade-btn:hover {
  background: linear-gradient(135deg, rgba(124, 106, 247, 0.3) 0%, rgba(212, 175, 55, 0.25) 100%);
  border-color: rgba(212, 175, 55, 0.7);
  box-shadow: 0 0 22px rgba(212,175,55,0.28), 0 0 0 1px rgba(212,175,55,0.15) inset;
  transform: translateY(-1px);
}

.upgrade-btn.hidden { display: none !important; }

/* ── Sidebar Overlay ──────────────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 199;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  transition: opacity 0.25s ease;
  opacity: 0;
}

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

/* ── Floating Sidebar ─────────────────────────────────────── */
#app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 260px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  overflow-x: hidden;

  background: rgba(12, 12, 20, 0.72);
  backdrop-filter: blur(28px) saturate(1.6);
  -webkit-backdrop-filter: blur(28px) saturate(1.6);
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 4px 0 40px rgba(0, 0, 0, 0.55), 1px 0 0 rgba(124,106,247,0.08);

  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#app-sidebar.open {
  transform: translateX(0);
}

#app-sidebar::-webkit-scrollbar { width: 3px; }
#app-sidebar::-webkit-scrollbar-thumb {
  background: rgba(124, 106, 247, 0.25);
  border-radius: 3px;
}

/* Sidebar header row */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  flex-shrink: 0;
}

.sidebar-logo {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #7c6af7 0%, #c4b5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 6px;
  color: rgba(180,180,200,0.6);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.sidebar-close:hover { color: #e0e0f0; background: rgba(255,255,255,0.06); }

/* Sidebar user strip */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  margin: 4px 12px 8px;
  background: rgba(124,106,247,0.08);
  border: 1px solid rgba(124,106,247,0.15);
  border-radius: 10px;
  color: #9585f5;
  font-size: 12px;
  flex-shrink: 0;
}

.sidebar-user.visible { display: flex; }

.sidebar-user-email {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: #a090f8;
}

.sidebar-home-btn {
  background: none;
  border: none;
  color: rgba(180,180,200,0.45);
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font, Inter, system-ui, sans-serif);
  padding: 0;
  transition: color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.sidebar-home-btn:hover { color: #c4b5fd; }

/* Divider */
.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.05);
  margin: 4px 12px;
  flex-shrink: 0;
}

/* Section */
.sidebar-section {
  padding: 10px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: rgba(150,150,180,0.45);
  padding: 0 6px;
  margin-bottom: 4px;
  font-family: var(--font, Inter, system-ui, sans-serif);
}

/* Sidebar button group container */
.sidebar-btn-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Core sidebar button */
.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  color: rgba(200,200,220,0.65);
  font-size: 13px;
  font-family: var(--font, Inter, system-ui, sans-serif);
  cursor: pointer;
  text-align: left;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
  white-space: nowrap;
}

.sidebar-btn svg {
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.18s;
}

.sidebar-btn:hover {
  background: rgba(124,106,247,0.1);
  border-color: rgba(124,106,247,0.2);
  color: #c4b5fd;
}
.sidebar-btn:hover svg { opacity: 1; }

/* Active pill-toggle inside sidebar */
.sidebar-btn.pill-toggle.active {
  background: rgba(124,106,247,0.16);
  border-color: rgba(124,106,247,0.35);
  color: #c4b5fd;
}

/* Mic active state */
#mic-btn.mic-on {
  background: rgba(239,68,68,0.12);
  border-color: rgba(239,68,68,0.3);
  color: #f87171;
}

/* Unavailability notices */
.sidebar-unavail {
  display: none; /* hidden by default; shown by JS if APIs missing */
  font-size: 11px;
  color: rgba(180,100,100,0.7);
  padding: 4px 12px;
}

/* ── App shell — allow sidebar to overlay ─────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 780px;
  margin: 0 auto;
  position: relative;
}

/* ── Phase 4: Auth modal + user badge ───────────────────────────────────────── */


#auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  animation: authFadeIn 0.25s ease;
}

#auth-modal.hidden { display: none; }

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

#auth-box {
  background: #13131f;
  border: 1px solid rgba(124, 106, 247, 0.25);
  border-radius: 16px;
  padding: 36px 32px 28px;
  width: 320px;
  box-shadow: 0 0 40px rgba(124, 106, 247, 0.18);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: authSlideIn 0.25s ease;
}

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

.auth-logo {
  font-size: 22px;
  font-weight: 600;
  color: #c4b5fd;
  text-align: center;
  letter-spacing: 0.5px;
}

.auth-subtitle {
  color: #555570;
  font-size: 13px;
  text-align: center;
  margin: -8px 0 2px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: #0d0d14;
  border-radius: 10px;
  padding: 4px;
}

.auth-tab {
  flex: 1;
  padding: 7px 0;
  border: none;
  background: none;
  color: #555570;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-family: Inter, system-ui, sans-serif;
  transition: background 0.2s, color 0.2s;
}

.auth-tab.active {
  background: rgba(124, 106, 247, 0.2);
  color: #c4b5fd;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#auth-email,
#auth-password {
  padding: 10px 14px;
  background: #0d0d14;
  border: 1px solid rgba(124, 106, 247, 0.2);
  border-radius: 9px;
  color: #e0e0f0;
  font-size: 14px;
  font-family: Inter, system-ui, sans-serif;
  outline: none;
  transition: border-color 0.2s;
}

#auth-email:focus,
#auth-password:focus {
  border-color: rgba(124, 106, 247, 0.55);
}

#auth-submit {
  padding: 10px 0;
  background: #7c6af7;
  border: none;
  border-radius: 9px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: Inter, system-ui, sans-serif;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  box-shadow: 0 0 10px rgba(124, 106, 247, 0.3);
}

#auth-submit:hover   { background: #6a59e0; }
#auth-submit:disabled { opacity: 0.55; cursor: not-allowed; }

.auth-error {
  color: #f87171;
  font-size: 12.5px;
  text-align: center;
  background: rgba(248, 113, 113, 0.08);
  border-radius: 7px;
  padding: 7px 10px;
}

.auth-guest {
  text-align: center;
  margin-top: -4px;
}

.auth-guest button {
  background: none;
  border: none;
  color: #444460;
  font-size: 12px;
  cursor: pointer;
  font-family: Inter, system-ui, sans-serif;
  text-decoration: underline;
  padding: 0;
  transition: color 0.15s;
}

.auth-guest button:hover { color: #777790; }

/* ── Auth consent section (register mode only) ──────────────────────────── */
#auth-consent-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(124, 106, 247, 0.12);
}

#auth-privacy-summary {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(124, 106, 247, 0.12);
  border-radius: 8px;
  padding: 10px 12px;
  max-height: 82px;
  overflow-y: auto;
  font-size: 11px;
  line-height: 1.6;
  color: #454560;
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 106, 247, 0.25) transparent;
}

#auth-privacy-summary strong {
  color: #585878;
}

#auth-privacy-summary a {
  color: #7060c0;
  text-decoration: none;
}

#auth-privacy-summary a:hover {
  text-decoration: underline;
}

.auth-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  cursor: pointer;
  font-size: 11.5px;
  line-height: 1.5;
  color: #7878a0;
  user-select: none;
}

.auth-check input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: #7c6af7;
}

.auth-check a {
  color: #9585f5;
  text-decoration: none;
}

.auth-check a:hover {
  text-decoration: underline;
}

/* auth-box puede crecer en modo registro — evitar que salga de pantalla */
#auth-box {
  max-height: 92vh;
  overflow-y: auto;
}

/* ── User badge in header (shown when logged in) ──────────────────────────── */
#user-badge {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: #9585f5;
  background: rgba(124, 106, 247, 0.1);
  border: 1px solid rgba(124, 106, 247, 0.2);
  border-radius: 20px;
  padding: 3px 10px 3px 8px;
  white-space: nowrap;
}

#user-badge.visible { display: flex; }

#user-badge-email {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#user-logout-btn {
  background: none;
  border: none;
  color: #444460;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  font-family: Inter, system-ui, sans-serif;
  transition: color 0.15s;
}

#user-logout-btn:hover { color: #f87171; }

/* ── Week 19: pill toggle buttons for Autonomy / Roam */
.pill-toggle {
  background: none;
  border: 1px solid var(--border, #2a2a3e);
  color: var(--muted, #777790);
  border-radius: 14px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 11px;
  font-family: Inter, system-ui, sans-serif;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  white-space: nowrap;
  user-select: none;
}

.pill-toggle.active {
  border-color: var(--accent, #7c6af7);
  color: var(--accent, #c4b5fd);
  background: rgba(124, 106, 247, 0.12);
}

/* Week 20: Focus mode — hide chat, avatar fills full screen */
body.focus-mode #chat-panel {
  display: none !important;
}

body.focus-mode #avatar-panel {
  width: 100vw !important;
  flex: 1 !important;
  min-width: 0 !important;
}

body.focus-mode #avatar-3d {
  width: 100vw !important;
  height: 100vh !important;
}

body.focus-mode #avatar-3d canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ══════════════════════════════════════════════════════════════
   Week 21: Avatar-First Mode — fullscreen avatar + floating chat
   Activated by body.avatar-first (set via #avatar-mode-btn)
══════════════════════════════════════════════════════════════ */

/* Hide normal chat panel in avatar-first mode */
body.avatar-first #chat-panel {
  display: none !important;
}

/* Hide orb/sphere UI in avatar-first mode */
body.avatar-first #avatar-panel,
body.avatar-first #avatar-orb,
body.avatar-first #avatar-label {
  display: none !important;
}

/* Make 3D avatar fill the full viewport (fixed so it escapes flex-row layout) */
body.avatar-first #avatar-3d {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  z-index: 1;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  min-width: 0 !important;
  border-right: none !important;
}

/* Header stays readable above the fullscreen avatar */
body.avatar-first header {
  position: relative;
  z-index: 10;
  background: rgba(13, 13, 13, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

/* Session bar is redundant when avatar fills the screen */
body.avatar-first #session-bar {
  display: none !important;
}

body.avatar-first #avatar-3d canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Show the FAB only in avatar-first mode */
#chat-fab {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 900;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent, #7c6af7);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 0 0 0 rgba(124, 106, 247, 0.5),
    0 4px 20px rgba(124, 106, 247, 0.45);
  transition: transform 0.18s, box-shadow 0.18s;
  line-height: 1;
}

body.avatar-first #chat-fab {
  display: flex;
  align-items: center;
  justify-content: center;
}

#chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 6px rgba(124, 106, 247, 0.2),
    0 6px 24px rgba(124, 106, 247, 0.55);
}

#chat-fab:active {
  transform: scale(0.95);
}

/* Floating chat drawer */
#chat-float {
  position: fixed;
  bottom: 90px;
  right: 20px;
  z-index: 901;
  width: 360px;
  height: 55vh;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(20, 20, 30, 0.82);
  backdrop-filter: blur(18px) saturate(1.6);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(124, 106, 247, 0.15);
  overflow: hidden;
}

#chat-float.hidden {
  display: none !important;
}

/* Float header */
#chat-float-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(124, 106, 247, 0.12);
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent, #c4b5fd);
  letter-spacing: 0.03em;
}

#chat-float-close {
  background: none;
  border: none;
  color: var(--muted, #666);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}

#chat-float-close:hover {
  color: var(--ai-text, #e0e0e0);
  background: rgba(255, 255, 255, 0.08);
}

/* Float messages list */
#chat-float-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#chat-float-messages::-webkit-scrollbar {
  width: 3px;
}

#chat-float-messages::-webkit-scrollbar-thumb {
  background: rgba(124, 106, 247, 0.3);
  border-radius: 3px;
}

/* Float input area */
#chat-float-input {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  background: rgba(10, 10, 18, 0.5);
}

#float-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--ai-text, #e0e0e0);
  font-family: var(--font, Inter, system-ui, sans-serif);
  font-size: 14px;
  padding: 8px 12px;
  resize: none;
  min-height: 38px;
  max-height: 96px;
  outline: none;
  transition: border-color 0.2s;
}

#float-input:focus {
  border-color: var(--accent, #7c6af7);
}

#float-input::placeholder {
  color: var(--muted, #666);
}

#float-send {
  background: var(--accent, #7c6af7);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
}

#float-send:hover {
  background: var(--accent-hover, #9b8df9);
}

#float-send:active {
  transform: scale(0.94);
}

/* Float message bubbles (compact variant) */
#chat-float-messages .msg {
  max-width: 90%;
  gap: 3px;
}

#chat-float-messages .msg-label {
  font-size: 10px;
}

#chat-float-messages .bubble {
  font-size: 13px;
  padding: 8px 11px;
}

/* Active state of avatar-mode-btn */
#avatar-mode-btn.avatar-first-on {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(124, 106, 247, 0.14);
}

/* Responsive: mobile float panel */
@media (max-width: 700px) {
  #chat-float {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 82px;
    height: 65vh;
  }

  #chat-fab {
    bottom: 16px;
    right: 16px;
  }
}


/* ═══════════════════════════════════════════════════════
   AI Companion — Chat UI  (chat.css)
   Pure CSS, no framework. Dark mode default.
═══════════════════════════════════════════════════════ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0d0d0d;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #2e2e2e;
  --accent: #7c6af7;
  --accent-hover: #9b8df9;
  --user-bg: #2a2250;
  --user-text: #e8e0ff;
  --ai-bg: #1e1e1e;
  --ai-text: #e0e0e0;
  --muted: #666;
  --error-bg: #3b1414;
  --error-text: #ff7b7b;
  --radius: 12px;
  --radius-sm: 6px;
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--ai-text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* #app — see PREMIUM UI section at top of file */

#chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* header — see PREMIUM UI section at top of file */

header h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #555;
  transition: background 0.4s, box-shadow 0.4s;
  flex-shrink: 0;
}

.status-dot.connected {
  background: #4caf86;
  box-shadow: 0 0 5px #4caf8688;
}

.status-dot.reconnecting {
  background: #f0b429;
  box-shadow: 0 0 5px #f0b42988;
}

.status-dot.error {
  background: #e05252;
  box-shadow: 0 0 5px #e0525288;
}

#status-badge {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  transition: all 0.3s;
}

#status-badge.connected {
  color: #4caf86;
  border-color: #2a5e47;
}

#status-badge.reconnecting {
  color: #f0b429;
  border-color: #7a5e1a;
}

#status-badge.error {
  color: var(--error-text);
  border-color: #5c2020;
}

/* ── Messages area ────────────────────────────────────── */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

#messages::-webkit-scrollbar {
  width: 4px;
}

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

#messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ── Message bubbles ──────────────────────────────────── */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  gap: 4px;
  animation: fadeUp 0.18s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg.user {
  align-self: flex-end;
  align-items: flex-end;
}

.msg.ai {
  align-self: flex-start;
  align-items: flex-start;
}

.msg.error {
  align-self: flex-start;
  max-width: 90%;
}

.bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}

.msg.user .bubble {
  background: var(--user-bg);
  color: var(--user-text);
  border-bottom-right-radius: 3px;
}

.msg.ai .bubble {
  background: var(--ai-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}

.msg.error .bubble {
  background: var(--error-bg);
  color: var(--error-text);
  font-size: 13px;
}

/* command output — monospaced */
.msg.ai .bubble.cmd {
  font-family: var(--mono);
  font-size: 13px;
}

.msg-label {
  font-size: 11px;
  color: var(--muted);
  padding: 0 4px;
}

/* ── Typing indicator ─────────────────────────────────── */
#typing {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  background: var(--ai-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: fit-content;
  color: var(--muted);
  font-size: 13px;
}

#typing.visible {
  display: flex;
}

#typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s infinite;
}

#typing span:nth-child(2) {
  animation-delay: 0.2s;
}

#typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {

  0%,
  80%,
  100% {
    opacity: 0.2;
    transform: scale(0.8);
  }

  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── Input bar ────────────────────────────────────────── */
#input-bar {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

#user-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ai-text);
  font-family: var(--font);
  font-size: 15px;
  padding: 10px 14px;
  resize: none;
  min-height: 44px;
  max-height: 144px;
  transition: border-color 0.2s;
  outline: none;
}

#user-input:focus {
  border-color: var(--accent);
}

#user-input::placeholder {
  color: var(--muted);
}

#send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 18px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
  height: 44px;
}

#send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

#send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

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

/* ── Session info bar ─────────────────────────────────── */
#session-bar {
  display: none; /* hidden — uncomment below to show */
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 4px;
  letter-spacing: 0.03em;
}

/* ── Diary modal ──────────────────────────────────────── */
.diary-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.diary-overlay.hidden { display: none; }

.diary-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: min(580px, 94vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.diary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}
.diary-header button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
}

#diary-list-view, #diary-detail-view {
  overflow-y: auto;
  padding: 14px 18px;
  flex: 1;
}

.diary-status {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px 0;
}

.diary-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.diary-card:hover { border-color: var(--accent); background: rgba(124,106,247,0.06); }
.diary-card.entry-dream { border-color: #4a3a6e; }

.diary-card-date  { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.diary-card-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.diary-card-preview { font-size: 12px; color: var(--muted); line-height: 1.5; }

.diary-card.mood-positive { border-left: 3px solid #4caf86; }
.diary-card.mood-negative  { border-left: 3px solid #e05252; }
.diary-card.mood-neutral   { border-left: 3px solid var(--border); }

.diary-back-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
  margin-bottom: 14px;
}
.diary-detail-date    { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.diary-detail-title   { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 12px; }
.diary-detail-content { font-size: 13px; color: var(--text); line-height: 1.7; white-space: pre-wrap; }
.diary-detail-meta    { font-size: 11px; color: var(--muted); margin-top: 14px; }

/* ── Admin token modal ────────────────────────────────── */
#admin-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

#admin-modal.open {
  display: flex;
}

#admin-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: min(360px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#admin-box h2 {
  font-size: 15px;
  color: var(--accent);
}

#admin-box p {
  font-size: 13px;
  color: var(--muted);
}

#admin-token-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ai-text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--mono);
  width: 100%;
  outline: none;
}

#admin-token-input:focus {
  border-color: var(--accent);
}

#admin-save-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  font-size: 14px;
  align-self: flex-end;
}

#admin-save-btn:hover {
  background: var(--accent-hover);
}

/* ── TTS Controls (hidden — voz muy robótica, se activará más adelante) ── */
#auto-voice-btn,
#stop-voice-btn,
#tts-unavailable,
.speak-btn {
  display: none !important;
}

.voice-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

#auto-voice-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

#auto-voice-btn:hover {
  border-color: var(--accent);
  color: var(--ai-text);
}

#auto-voice-btn.voice-on {
  background: #1e1a40;
  border-color: var(--accent);
  color: var(--accent);
}

#stop-voice-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

#stop-voice-btn:hover {
  border-color: #e05555;
  color: #e05555;
}

/* ── Week 17: per-message token/cost info ──────────────────────────────── */
.token-info {
  display: none; /* hidden — uncomment below to show */
  font-size: 10px;
  color: var(--muted);
  padding: 1px 4px;
  opacity: 0.65;
  font-family: var(--mono);
  letter-spacing: 0.02em;
  user-select: none;
}

/* Per-bubble speak button */
.speak-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  align-self: flex-start;
  margin-top: 2px;
  line-height: 1;
}

.speak-btn:hover {
  color: var(--accent);
  background: rgba(124, 106, 247, 0.1);
}

/* TTS unavailable note */
#tts-unavailable {
  display: none;
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

/* ── STT Mic Button ───────────────────────────────────── */
#mic-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}

#mic-btn:hover {
  border-color: var(--accent);
  color: var(--ai-text);
}

/* Pulsing red ring when mic is ON */
#mic-btn.mic-on {
  border-color: #e05555;
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(224, 85, 85, 0.5);
  }

  50% {
    box-shadow: 0 0 0 5px rgba(224, 85, 85, 0);
  }
}

/* STT unavailable note */
#stt-unavailable {
  display: none;
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════
   ── Avatar Panel (Week 13) ────────────────────────────
   States applied on #avatar-orb[data-state]:
     idle | thinking | speaking | speaking_stream | listening
═══════════════════════════════════════════════════════ */

#avatar-panel {
  display: none;
}

/* ── Orb container ──────────────────────────────────── */
#avatar-orb {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Core SVG glyph ─────────────────────────────────── */
#avatar-glyph {
  width: 70px;
  height: 70px;
  filter: drop-shadow(0 0 10px rgba(124, 106, 247, 0.5));
  transition: filter 0.4s;
}

/* Glow boost for active states */
#avatar-orb[data-state="speaking"] #avatar-glyph,
#avatar-orb[data-state="speaking_stream"] #avatar-glyph {
  filter: drop-shadow(0 0 18px rgba(124, 106, 247, 0.85));
  animation: orb-bob 0.6s ease-in-out infinite alternate;
}

#avatar-orb[data-state="thinking"] #avatar-glyph {
  filter: drop-shadow(0 0 8px rgba(124, 106, 247, 0.4));
  animation: orb-breathe 2s ease-in-out infinite;
}

#avatar-orb[data-state="listening"] #avatar-glyph {
  filter: drop-shadow(0 0 12px rgba(224, 85, 85, 0.6));
}

@keyframes orb-bob {
  from {
    transform: translateY(0) scale(1);
  }

  to {
    transform: translateY(-4px) scale(1.04);
  }
}

@keyframes orb-breathe {

  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }

  50% {
    transform: scale(1.06);
    opacity: 1;
  }
}

/* ── Speaking waves ─────────────────────────────────── */
#avatar-waves {
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 18px;
  opacity: 0;
  transition: opacity 0.3s;
}

#avatar-orb[data-state="speaking"] #avatar-waves,
#avatar-orb[data-state="speaking_stream"] #avatar-waves {
  opacity: 1;
}

.wave {
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
  animation: wave-bar 0.9s ease-in-out infinite;
}

.wave:nth-child(1) {
  height: 6px;
  animation-delay: 0s;
}

.wave:nth-child(2) {
  height: 14px;
  animation-delay: 0.1s;
}

.wave:nth-child(3) {
  height: 18px;
  animation-delay: 0.2s;
}

.wave:nth-child(4) {
  height: 14px;
  animation-delay: 0.3s;
}

.wave:nth-child(5) {
  height: 6px;
  animation-delay: 0.4s;
}

@keyframes wave-bar {

  0%,
  100% {
    transform: scaleY(0.4);
    opacity: 0.6;
  }

  50% {
    transform: scaleY(1);
    opacity: 1;
  }
}

/* ── Listening ring ─────────────────────────────────── */
#avatar-listen-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid #e05555;
  opacity: 0;
  transition: opacity 0.3s;
}

#avatar-orb[data-state="listening"] #avatar-listen-ring {
  opacity: 1;
  animation: listen-ring 1.4s ease-in-out infinite;
}

@keyframes listen-ring {

  0%,
  100% {
    transform: scale(1);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.12);
    opacity: 0.3;
  }
}

/* ── State label ────────────────────────────────────── */
#avatar-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  min-height: 16px;
}

/* ── Thinking dots ──────────────────────────────────── */
#avatar-dots {
  display: none;
  gap: 3px;
  align-items: center;
}

#avatar-orb[data-state="thinking"]~#avatar-label #avatar-dots,
/* workaround: JS also shows/hides directly */
#avatar-dots.visible {
  display: flex;
}

#avatar-dots span {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s infinite;
}

#avatar-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

#avatar-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

/* ═══════════════════════════════════════════════════════
   ── Avatar Mode: fullscreen avatar + floating chat ──────
   body.avatar-mode — activated by #avatar-toggle-btn
═══════════════════════════════════════════════════════ */

/* #avatar-3d is the Three.js mount — hidden by default */
#avatar-3d {
  display: none;
}

/* Avatar fills the full viewport */
body.avatar-mode {
  display: block;
  height: 100vh;
  overflow: hidden;
  background: #07070f;
}

body.avatar-mode #avatar-3d {
  display: block;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: #07070f;
  z-index: 1;
  overflow: hidden;
}

body.avatar-mode #avatar-3d canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ── Avatar Loading Screen ────────────────────────────────────────────────── */
#avatar-loading-screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #07070f;
  opacity: 1;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

#avatar-loading-screen.loaded {
  opacity: 0;
}

.avatar-loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.avatar-loading-spinner {
  width: 40px;
  height: 40px;
  border: 2px solid rgba(124, 106, 247, 0.18);
  border-top-color: #7c6af7;
  border-radius: 50%;
  animation: avatarSpinnerRotate 0.9s linear infinite;
}

@keyframes avatarSpinnerRotate {
  to { transform: rotate(360deg); }
}

.avatar-loading-text {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: rgba(196, 181, 253, 0.6);
  letter-spacing: 0.06em;
  margin: 0;
}

/* Header: fixed full-width bar above the avatar */
body.avatar-mode header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 20;
  padding: 10px 20px;
  background: rgba(10, 10, 18, 0.75);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 0;
  flex-shrink: 0;
}

body.avatar-mode #session-bar-container {
  display: none !important;
}

/* Chat bubble: messages + input only, no header inside.
   NOTE: backdrop-filter intentionally on #chat-panel, not here —
   backdrop-filter on a position:fixed ancestor would make child
   position:fixed (the header) relative to it instead of the viewport. */
body.avatar-mode #app {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: min(380px, calc(100vw - 40px));
  height: 52vh;
  min-height: 260px;
  max-width: none;
  margin: 0;
  z-index: 10;
  background: transparent;
  border-radius: 16px;
  overflow: visible;
}

body.avatar-mode #chat-panel {
  position: relative;
  background: rgba(10, 10, 18, 0.82);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.55),
              0 0 0 1px rgba(124, 106, 247, 0.12);
  overflow: visible;
}

/* Clip the inner content (messages + input) but allow X button to bleed outside */
body.avatar-mode #messages,
body.avatar-mode #input-bar {
  border-radius: 0;
}

body.avatar-mode #messages {
  border-radius: 16px 16px 0 0;
  overflow-y: auto;
}

body.avatar-mode #input-bar {
  border-radius: 0 0 16px 16px;
}

/* Chat close button — floats on top-right corner of the bubble (avatar mode only) */
#chat-minimize-btn {
  display: none;
}

body.avatar-mode #chat-minimize-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: -12px;
  right: -12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(124, 106, 247, 0.75);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  z-index: 12;
  transition: background 0.15s, transform 0.15s;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

body.avatar-mode #chat-minimize-btn:hover {
  background: rgba(124, 106, 247, 1);
  transform: scale(1.1);
}

/* ── Chat starts collapsed by default ────────────────────────────────────────
   These rules apply as soon as <body class="chat-collapsed"> is parsed,
   before avatar-mode is added by JS — prevents any flash of open chat panel. */
body.chat-collapsed #chat-panel {
  display: none !important;
}
body.chat-collapsed #chat-bubble-btn {
  display: flex !important;
}

/* Chat bubble FAB — shown when chat is collapsed in avatar mode */
#chat-bubble-btn {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 15;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid rgba(124, 106, 247, 0.5);
  background: rgba(124, 106, 247, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(124, 106, 247, 0.55),
              0 0 0 0 rgba(124, 106, 247, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  line-height: 1;
}

body.avatar-mode.chat-collapsed #chat-bubble-btn {
  display: flex;
}

#chat-bubble-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(124, 106, 247, 0.7);
}

/* Hide ONLY the chat bubble when collapsed — header stays visible */
body.avatar-mode.chat-collapsed #chat-panel {
  display: none !important;
}

/* Avatar toggle button active state */
#avatar-toggle-btn.avatar-on {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(124, 106, 247, 0.12);
}

/* ── Responsive: mobile — full-width bottom sheet ─────── */
@media (max-width: 700px) {
  body.avatar-mode header {
    padding: 8px 14px;
  }
  body.avatar-mode #app {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 50vh;
    border-radius: 16px 16px 0 0;
  }
}

/* ══════════════════════════════════════════════════════════════
   Avatar Debug Panel (Frontend Only)
══════════════════════════════════════════════════════════════ */
#avatar-debug-panel {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 9999;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  /* overridden by script inline style if hidden */
  flex-direction: column;
  gap: 8px;
  width: 260px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Hide if not in avatar mode */
body:not(.avatar-mode) #avatar-debug-panel {
  display: none !important;
}

#avatar-debug-panel .debug-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent, #c4b5fd);
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#avatar-debug-panel .hotkey {
  font-size: 10px;
  color: var(--muted, #666);
  font-weight: normal;
}

#avatar-debug-panel .debug-status {
  font-size: 11px;
  font-family: var(--mono, monospace);
  color: #aaa;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#avatar-debug-panel .debug-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#avatar-debug-panel button {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ddd;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

#avatar-debug-panel button:hover {
  background: rgba(124, 106, 247, 0.3);
  border-color: rgba(124, 106, 247, 0.5);
  color: #fff;
}

#avatar-debug-panel button:active {
  transform: scale(0.95);
}

#avatar-debug-panel button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ═══════════════════════════════════════════════════════
   Bubble Aesthetic Refresh
═══════════════════════════════════════════════════════ */

/* ── AI bubble: acento morado en borde izquierdo ────── */
.msg.ai .bubble {
  background: linear-gradient(160deg, #1c1c28 0%, #181820 100%);
  border: 1px solid rgba(124, 106, 247, 0.22);
  border-left: 2px solid rgba(124, 106, 247, 0.55);
  border-bottom-left-radius: 3px;
}

/* ── User bubble: gradiente con profundidad ──────────── */
.msg.user .bubble {
  background: linear-gradient(135deg, #2a2250 0%, #36296e 100%);
  box-shadow: inset 0 1px 0 rgba(196, 181, 253, 0.09);
}

/* ── Labels: más pequeños y discretos ───────────────── */
.msg-label {
  font-size: 10px;
  opacity: 0.5;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 500;
}

/* ── Typing indicator: más refinado ─────────────────── */
#typing {
  background: linear-gradient(160deg, #1c1c28 0%, #181820 100%);
  border: 1px solid rgba(124, 106, 247, 0.2);
  border-left: 2px solid rgba(124, 106, 247, 0.5);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 12px;
  color: rgba(180, 170, 220, 0.65);
}

/* ── Send button: brillo sutil ───────────────────────── */
#send-btn {
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(124, 106, 247, 0.35);
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

#send-btn:hover:not(:disabled) {
  box-shadow: 0 4px 18px rgba(124, 106, 247, 0.55);
}

/* ── Avatar mode: panel de cristal mejorado ──────────── */
body.avatar-mode #chat-panel {
  background: rgba(7, 7, 15, 0.91);
  backdrop-filter: blur(32px) saturate(1.9);
  -webkit-backdrop-filter: blur(32px) saturate(1.9);
  border: 1px solid rgba(124, 106, 247, 0.2);
  box-shadow:
    0 18px 64px rgba(0, 0, 0, 0.72),
    0 0 0 1px rgba(124, 106, 247, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

/* ── Avatar mode: área de mensajes ──────────────────── */
body.avatar-mode #messages {
  gap: 10px;
  padding: 14px 14px 8px;
}

/* ── Avatar mode: burbujas más compactas ────────────── */
body.avatar-mode .bubble {
  font-size: 14px;
  padding: 9px 13px;
}

/* ── Avatar mode: barra de input ─────────────────────── */
body.avatar-mode #input-bar {
  background: rgba(6, 6, 14, 0.7);
  border-top: 1px solid rgba(124, 106, 247, 0.13);
  padding: 10px 14px;
}

body.avatar-mode #user-input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  font-size: 14px;
}

body.avatar-mode #user-input:focus {
  border-color: rgba(124, 106, 247, 0.55);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 3px rgba(124, 106, 247, 0.11);
}

body.avatar-mode #send-btn {
  border-radius: 10px;
}


/* ── Memorias modal ────────────────────────────────────── */
.memoria-section-title {
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 10px;
  opacity: 0.9;
}

.memoria-summary {
  font-size: 13px;
  color: var(--ai-text);
  line-height: 1.65;
  background: var(--surface2);
  border-radius: 10px;
  padding: 12px 14px;
  border-left: 2px solid rgba(124, 106, 247, 0.4);
  font-style: italic;
  margin-bottom: 4px;
}

.memoria-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  transition: border-color 0.2s, background 0.2s;
}

.memoria-card:hover {
  border-color: rgba(124, 106, 247, 0.38);
  background: rgba(124, 106, 247, 0.05);
}

.memoria-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.memoria-card-type {
  font-size: 11px;
  color: var(--muted);
  text-transform: capitalize;
}

.memoria-card-weight {
  font-size: 10px;
  color: rgba(196, 181, 253, 0.55);
  font-family: var(--mono);
}

.memoria-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ai-text);
  margin-bottom: 4px;
}

.memoria-card-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.memoria-card-meta {
  font-size: 10px;
  color: rgba(124, 106, 247, 0.55);
  margin-top: 6px;
  font-family: var(--mono);
}

/* ── Category tree (migration 015) ─────────────────────────────────────── */

.memoria-category-group {
  margin-bottom: 16px;
}

.memoria-category-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}

.mem-cat-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(124, 106, 247, 0.18);
  color: rgba(196, 181, 253, 0.8);
  border-radius: 20px;
  font-family: var(--mono);
}

.memoria-category-cards {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Sensitive revealed group — subtle purple-red tint */
.memoria-category-group--sensitive .memoria-category-header {
  color: rgba(248, 163, 211, 0.7);
  border-bottom-color: rgba(248, 100, 148, 0.2);
}
.memoria-card--sensitive {
  border-color: rgba(248, 100, 148, 0.25);
}
.memoria-card--sensitive:hover {
  border-color: rgba(248, 100, 148, 0.45);
  background: rgba(248, 100, 148, 0.04);
}

/* Delete button on each card */
.memoria-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mem-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  opacity: 0.35;
  padding: 0 2px;
  line-height: 1;
  transition: opacity 0.15s;
  color: inherit;
}
.mem-delete-btn:hover { opacity: 0.85; }

/* Sensitive section title */
.mem-sensitive-title { color: rgba(248, 163, 211, 0.9) !important; }

/* Locked placeholder block */
.mem-sensitive-locked {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  background: rgba(248, 100, 148, 0.04);
  border: 1px dashed rgba(248, 100, 148, 0.22);
  border-radius: 10px;
  text-align: center;
  margin-bottom: 8px;
}

.mem-lock-icon { font-size: 28px; opacity: 0.7; }

.mem-lock-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.mem-unlock-btn {
  padding: 7px 18px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(248, 100, 148, 0.12);
  border: 1px solid rgba(248, 100, 148, 0.35);
  border-radius: 8px;
  color: rgba(248, 163, 211, 0.9);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.mem-unlock-btn:hover {
  background: rgba(248, 100, 148, 0.22);
  border-color: rgba(248, 100, 148, 0.6);
}

/* ════════════════════════════════════════════════════════
   PHASE 5 — Cosmetics Modal (avatar + background selection)
   ════════════════════════════════════════════════════════ */

/* ── Overlay base (shared with auth-modal pattern) ────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.18s ease;
}
.modal-overlay.hidden { display: none; }

/* ── Cosmetics box ─────────────────────────────────────── */
#cosmetics-box {
  background: var(--surface, #0d0d1a);
  border: 1px solid var(--border, #1e1e30);
  border-radius: 16px;
  width: min(560px, 96vw);
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(124, 106, 247, 0.08);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ── Header ────────────────────────────────────────────── */
.cosmetics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.cosmetics-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--ai-text, #c4b5fd);
  margin: 0;
}
.modal-close-btn {
  background: none;
  border: 1px solid var(--border, #1e1e30);
  color: var(--muted, #555570);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}
.modal-close-btn:hover { color: #fff; border-color: #555570; }

/* ── 5.5 Fallback banner ───────────────────────────────── */
.fallback-banner {
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.30);
  border-radius: 8px;
  color: #fbbf24;
  font-size: 12px;
  padding: 10px 14px;
  margin-bottom: 18px;
  line-height: 1.5;
}
.fallback-banner.hidden { display: none; }

/* ── Section ────────────────────────────────────────────── */
.cosmetics-section {
  margin-bottom: 28px;
}
.cosmetics-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ai-text, #c4b5fd);
  margin: 0 0 4px;
}
.cosmetics-section-hint {
  font-size: 11px;
  color: var(--muted, #555570);
  margin: 0 0 14px;
}

/* ── Asset grid ─────────────────────────────────────────── */
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.asset-loading,
.asset-empty,
.asset-error {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--muted, #555570);
  padding: 12px 0;
  text-align: center;
}
.asset-error { color: #f87171; }

/* ── Asset card ─────────────────────────────────────────── */
.asset-card {
  position: relative;
  border-radius: 10px;
  border: 2px solid var(--border, #1e1e30);
  background: var(--surface2, #111124);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
  user-select: none;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 8px;
}
.asset-card:hover { transform: translateY(-2px); border-color: rgba(124, 106, 247, 0.45); }

/* 5.1 — Selected state: purple ring */
.asset-card.selected {
  border-color: #7c6af7;
  box-shadow: 0 0 0 2px rgba(124, 106, 247, 0.35), 0 4px 16px rgba(124, 106, 247, 0.20);
}
.asset-card.selected::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 6px;
  background: #7c6af7;
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 18px;
  text-align: center;
}

/* 5.1 — Locked state: dimmed + lock badge */
.asset-card[data-access="locked"] {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}
.asset-card[data-access="locked"]:hover { transform: none; border-color: var(--border, #1e1e30); }

/* 5.1 — Unavailable state: heavily dimmed + X badge */
.asset-card[data-access="unavailable"] {
  opacity: 0.30;
  cursor: not-allowed;
  pointer-events: none;
}

/* Access badges */
.asset-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 13px;
  line-height: 1;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  padding: 2px 4px;
}
.asset-badge.locked     { color: #fbbf24; }
.asset-badge.unavailable{ color: #f87171; }

/* Thumbnail */
.asset-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}
.asset-thumb-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: rgba(124, 106, 247, 0.35);
  background: linear-gradient(135deg, rgba(124,106,247,0.08) 0%, rgba(10,10,20,0) 100%);
}

/* Card name label */
.asset-name {
  position: relative;
  z-index: 1;
  font-size: 11px;
  font-weight: 600;
  color: #e2e0ff;
  text-align: center;
  padding: 0 6px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.asset-lock-hint {
  position: relative;
  z-index: 1;
  font-size: 9px;
  color: #fbbf24;
  margin-top: 2px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

/* ── Footer / status ───────────────────────────────────── */
.cosmetics-footer {
  border-top: 1px solid var(--border, #1e1e30);
  padding-top: 14px;
  min-height: 32px;
  display: flex;
  align-items: center;
}
.cosmetics-status {
  font-size: 12px;
  color: var(--muted, #555570);
  transition: color 0.2s;
}
.cosmetics-status.saving { color: #a78bfa; }
.cosmetics-status.ok     { color: #34d399; }
.cosmetics-status.error  { color: #f87171; }

/* ── Pricing / Paywall Modal ─────────────────────────────────────────────────── */

#pricing-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 950;
  animation: authFadeIn 0.3s ease;
}

#pricing-modal.hidden { display: none; }

#pricing-box {
  background: #0d0d18;
  border: 1px solid rgba(124, 106, 247, 0.22);
  border-radius: 20px;
  padding: 40px 36px 32px;
  width: min(740px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 0 60px rgba(124, 106, 247, 0.14), 0 4px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 28px;
  animation: authSlideIn 0.3s ease;
}

.pricing-header {
  text-align: center;
}

.pricing-logo {
  font-size: 26px;
  font-weight: 700;
  color: #c4b5fd;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.pricing-subtitle {
  color: #666680;
  font-size: 14px;
  margin: 0;
}

.pricing-plans {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.plan-card {
  background: #13131f;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.plan-card.plan-premium {
  border-color: rgba(124, 106, 247, 0.38);
  background: linear-gradient(145deg, #13131f 0%, #1a1530 100%);
  box-shadow: 0 0 24px rgba(124, 106, 247, 0.1);
}

.plan-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #555570;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  padding: 3px 8px;
  display: inline-block;
  align-self: flex-start;
}

.plan-badge-premium {
  color: #c4b5fd;
  background: rgba(124, 106, 247, 0.15);
  border: 1px solid rgba(124, 106, 247, 0.25);
}

.plan-price {
  font-size: 34px;
  font-weight: 700;
  color: #e0e0f5;
  line-height: 1;
}

.plan-price span {
  font-size: 14px;
  font-weight: 400;
  color: #555570;
}

.plan-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.plan-features li {
  font-size: 13px;
  color: #a0a0c0;
}

.plan-features li.plan-limit {
  color: #3a3a50;
}

.btn-free {
  padding: 11px 0;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  color: #555570;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  margin-top: auto;
}

.btn-free:hover {
  border-color: rgba(255, 255, 255, 0.22);
  color: #9090b0;
}

.btn-premium {
  padding: 14px 0;
  background: linear-gradient(135deg, #7c6af7 0%, #9b5de5 100%);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.2s, box-shadow 0.2s, transform 0.15s;
  box-shadow: 0 0 20px rgba(124, 106, 247, 0.38);
  margin-top: auto;
}

.btn-premium:hover {
  opacity: 0.9;
  box-shadow: 0 0 32px rgba(124, 106, 247, 0.55);
  transform: translateY(-1px);
}

.btn-premium:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ── Premium upgrade button in header ────────────────────────────────────────── */

#upgrade-btn {
  background: linear-gradient(135deg, rgba(124, 106, 247, 0.12) 0%, rgba(155, 93, 229, 0.12) 100%);
  border: 1px solid rgba(124, 106, 247, 0.38);
  border-radius: 20px;
  color: #c4b5fd;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  padding: 4px 12px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

#upgrade-btn:hover {
  background: linear-gradient(135deg, rgba(124, 106, 247, 0.28) 0%, rgba(155, 93, 229, 0.28) 100%);
  box-shadow: 0 0 14px rgba(124, 106, 247, 0.3);
}

#upgrade-btn.hidden { display: none !important; }

/* Responsive pricing */
@media (max-width: 620px) {
  .pricing-plans {
    grid-template-columns: 1fr;
  }

  #pricing-box {
    padding: 28px 18px 22px;
    gap: 20px;
  }

  .plan-price {
    font-size: 28px;
  }
}

/* ── fadeUp animation: más vivo ──────────────────────── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ══════════════════════════════════════════════════════════════
   MODALES: Memorias & Diario
   Glassmorphism — z-index superior al canvas 3D (z:1) y al sidebar (z:200)
   Añadido para reconectar la UI del sidebar tras el refactor.
══════════════════════════════════════════════════════════════ */

/* ── Utility: .hidden ─────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Modal Overlay (backdrop) ─────────────────────────────── */
.diary-overlay {
  position: fixed;
  inset: 0;
  z-index: 820;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  animation: modalFadeIn 0.22s ease;
}

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

/* ── Modal Box ────────────────────────────────────────────── */
.diary-box {
  background: rgba(13, 13, 22, 0.90);
  backdrop-filter: blur(28px) saturate(1.7);
  -webkit-backdrop-filter: blur(28px) saturate(1.7);
  border: 1px solid rgba(124, 106, 247, 0.18);
  border-radius: 18px;
  box-shadow:
    0 8px 48px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 40px rgba(124, 106, 247, 0.06);
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalSlideUp 0.25s cubic-bezier(0.22, 0.9, 0.36, 1);
}

@keyframes modalSlideUp {
  from { transform: translateY(16px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

/* ── Modal Header ─────────────────────────────────────────── */
.diary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  background: rgba(124, 106, 247, 0.07);
}

.diary-header > span {
  font-size: 14px;
  font-weight: 600;
  color: #c4b5fd;
  letter-spacing: 0.03em;
}

.diary-header > button {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  color: rgba(180, 180, 200, 0.55);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: color 0.18s, background 0.18s, border-color 0.18s;
}

.diary-header > button:hover {
  color: #e0e0f0;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

/* ── Status text (loading / empty) ───────────────────────── */
.diary-status {
  padding: 32px 20px;
  text-align: center;
  color: rgba(180, 180, 210, 0.45);
  font-size: 13px;
  font-style: italic;
  line-height: 1.7;
}

/* ── List view scroll container ──────────────────────────── */
#diary-list-view,
#diary-detail-view {
  overflow-y: auto;
  padding: 14px 16px;
  flex: 1;
  min-height: 0;
}

#diary-list-view::-webkit-scrollbar,
#diary-detail-view::-webkit-scrollbar,
#memorias-content::-webkit-scrollbar { width: 3px; }

#diary-list-view::-webkit-scrollbar-thumb,
#diary-detail-view::-webkit-scrollbar-thumb,
#memorias-content::-webkit-scrollbar-thumb {
  background: rgba(124, 106, 247, 0.25);
  border-radius: 3px;
}

/* ── Diary Entry Cards ────────────────────────────────────── */
.diary-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-left: 3px solid rgba(124, 106, 247, 0.4);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.15s, box-shadow 0.18s;
}

.diary-card:hover {
  background: rgba(124, 106, 247, 0.08);
  border-color: rgba(124, 106, 247, 0.22);
  border-left-color: #7c6af7;
  transform: translateX(3px);
  box-shadow: 0 4px 18px rgba(124, 106, 247, 0.12);
}

/* Mood variants */
.diary-card.mood-positive { border-left-color: #4caf86; }
.diary-card.mood-negative  { border-left-color: #e05252; }
.diary-card.mood-neutral   { border-left-color: rgba(124, 106, 247, 0.4); }

.diary-card.mood-positive:hover { border-left-color: #6bd6a8; }
.diary-card.mood-negative:hover  { border-left-color: #f87171; }

/* Dream variant */
.diary-card.entry-dream {
  background: rgba(80, 55, 120, 0.12);
  border-color: rgba(120, 80, 180, 0.2);
  border-left-color: #a07fd0;
}
.diary-card.entry-dream:hover {
  background: rgba(80, 55, 120, 0.2);
  border-left-color: #c4b5fd;
}

.diary-card-date {
  font-size: 11px;
  color: rgba(180, 170, 210, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 6px;
}

.diary-card-title {
  font-size: 14px;
  font-weight: 600;
  color: rgba(220, 215, 240, 0.9);
  margin-bottom: 6px;
  line-height: 1.4;
}

.diary-card-preview {
  font-size: 12.5px;
  color: rgba(180, 175, 210, 0.5);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Detail View ──────────────────────────────────────────── */
.diary-back-btn {
  background: none;
  border: 1px solid rgba(124, 106, 247, 0.25);
  border-radius: 8px;
  color: rgba(196, 181, 253, 0.7);
  font-size: 12px;
  font-family: var(--font, Inter, system-ui, sans-serif);
  padding: 5px 12px;
  cursor: pointer;
  margin-bottom: 16px;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}
.diary-back-btn:hover {
  background: rgba(124, 106, 247, 0.12);
  color: #c4b5fd;
  border-color: rgba(124, 106, 247, 0.45);
}

.diary-detail-date {
  font-size: 11px;
  color: rgba(180, 170, 210, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}

.diary-detail-title {
  font-size: 18px;
  font-weight: 600;
  color: #c4b5fd;
  line-height: 1.4;
  margin-bottom: 14px;
}

.diary-detail-content {
  font-size: 14px;
  color: rgba(224, 220, 245, 0.8);
  line-height: 1.8;
  white-space: pre-line;
}

.diary-detail-meta {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 11.5px;
  color: rgba(180, 170, 210, 0.38);
  letter-spacing: 0.04em;
}

/* ─────────────────────────────────────────────────────────
   MEMORIAS MODAL — Cards de recuerdos / memory anchors
───────────────────────────────────────────────────────── */

.memoria-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(196, 181, 253, 0.5);
  margin-bottom: 12px;
  padding: 0 2px;
}

.memoria-summary {
  background: rgba(124, 106, 247, 0.07);
  border: 1px solid rgba(124, 106, 247, 0.15);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: rgba(220, 215, 240, 0.75);
  line-height: 1.7;
  margin-bottom: 4px;
}

.memoria-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s;
}

.memoria-card:hover {
  background: rgba(124, 106, 247, 0.07);
  border-color: rgba(124, 106, 247, 0.2);
  box-shadow: 0 4px 18px rgba(124, 106, 247, 0.1);
}

.memoria-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.memoria-card-type {
  font-size: 11.5px;
  font-weight: 600;
  color: rgba(196, 181, 253, 0.7);
  letter-spacing: 0.03em;
}

.memoria-card-weight {
  font-size: 10.5px;
  color: rgba(180, 170, 210, 0.38);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 20px;
  padding: 2px 8px;
  letter-spacing: 0.02em;
}

.memoria-card-title {
  font-size: 14px;
  font-weight: 600;
  color: rgba(224, 220, 245, 0.88);
  margin-bottom: 6px;
  line-height: 1.4;
}

.memoria-card-desc {
  font-size: 12.5px;
  color: rgba(180, 175, 210, 0.52);
  line-height: 1.65;
}

.memoria-card-meta {
  margin-top: 8px;
  font-size: 11px;
  color: rgba(196, 181, 253, 0.38);
  letter-spacing: 0.03em;
}

/* ── Sidebar button loading state ─────────────────────────── */
.sidebar-btn.loading {
  opacity: 0.65;
  pointer-events: none;
  cursor: wait;
}

/* ── Responsive: smaller screens ─────────────────────────── */
@media (max-width: 640px) {
  .diary-box {
    max-height: 90vh;
    border-radius: 14px;
  }
  .diary-overlay {
    padding: 12px 8px;
    align-items: flex-end;
  }
}

/* ═══════════════════════════════════════════════════════════════
   DELETE ACCOUNT — Danger Zone (sidebar) + Confirmation Modal
   ═══════════════════════════════════════════════════════════════ */

/* ── Sidebar danger zone section ── */
.sidebar-danger-zone {
  padding-bottom: 4px;
}

.sidebar-btn-danger {
  color: #f87171 !important;
  border-color: rgba(248, 113, 113, 0.2) !important;
}
.sidebar-btn-danger:hover {
  background: rgba(239, 68, 68, 0.1) !important;
  border-color: rgba(239, 68, 68, 0.45) !important;
  color: #fca5a5 !important;
}

/* ── Delete account modal overlay ── */
#delete-account-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#delete-account-modal.hidden { display: none; }

/* ── Delete account modal box ── */
#delete-account-box {
  background: #0c0c18;
  border: 1px solid rgba(239, 68, 68, 0.22);
  border-radius: 16px;
  padding: 28px 28px 24px;
  max-width: 440px;
  width: 100%;
  box-shadow:
    0 0 0 1px rgba(239, 68, 68, 0.08) inset,
    0 28px 72px rgba(0, 0, 0, 0.75);
  animation: deleteModalIn 0.18s ease;
}

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

/* ── Header ── */
.delete-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.delete-modal-icon {
  font-size: 24px;
  flex-shrink: 0;
}
.delete-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #fca5a5;
  margin: 0;
  letter-spacing: -0.01em;
}

/* ── Warning block ── */
.delete-modal-warning {
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.16);
  border-left: 3px solid rgba(239, 68, 68, 0.55);
  border-radius: 0 10px 10px 0;
  padding: 14px 16px;
  margin-bottom: 22px;
}
.delete-modal-warning p {
  font-size: 13px;
  color: #9090b0;
  margin: 0 0 8px;
  line-height: 1.7;
}
.delete-modal-warning p:last-child { margin-bottom: 0; }
.delete-modal-warning strong { color: #fca5a5; font-weight: 600; }

/* ── Form ── */
.delete-modal-form { margin-bottom: 22px; }
.delete-modal-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #6868a0;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
#delete-account-password {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(239, 68, 68, 0.18);
  border-radius: 8px;
  padding: 10px 12px;
  color: #e0e0e0;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#delete-account-password:focus {
  border-color: rgba(239, 68, 68, 0.5);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.08);
}
#delete-account-password::placeholder { color: #444460; }

.delete-modal-error {
  margin-top: 8px;
  font-size: 12px;
  color: #f87171;
  line-height: 1.4;
}

/* ── Action buttons ── */
.delete-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.delete-modal-cancel {
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #6868a0;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.delete-modal-cancel:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #a0a0c0;
  border-color: rgba(255, 255, 255, 0.18);
}
.delete-modal-confirm {
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.38);
  color: #f87171;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.delete-modal-confirm:hover {
  background: rgba(239, 68, 68, 0.24);
  border-color: rgba(239, 68, 68, 0.65);
  color: #fca5a5;
}
.delete-modal-confirm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Farewell screen ── */
.delete-farewell {
  text-align: center;
  padding: 12px 0 8px;
}
.delete-farewell-emoji { font-size: 34px; margin-bottom: 16px; }
.delete-farewell-title {
  font-size: 16px;
  font-weight: 700;
  color: #c4b5fd;
  margin: 0 0 12px;
}
.delete-farewell-text {
  font-size: 13px;
  color: #6868a0;
  line-height: 1.75;
  margin: 0;
}

/* ── Pensamientos — sidebar badge dot ───────────────────────────────────────── */
.pensamientos-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a78bfa;
  box-shadow: 0 0 6px #a78bfa88;
  animation: badge-pulse 2s ease-in-out infinite;
  pointer-events: none;
  font-size: 0;
  line-height: 0;
}
@keyframes badge-pulse {
  0%, 100% { opacity: 1;   transform: scale(1);    }
  50%       { opacity: 0.6; transform: scale(1.25); }
}

/* ── Pensamientos panel (overlay reuses .diary-overlay .diary-box) ──────────── */
.pensam-box {
  background: linear-gradient(160deg, #0d0d1a 0%, #0e0a1f 100%);
  border: 1px solid #2d1f4e;
}
.pensam-header {
  background: transparent;
  border-bottom: 1px solid #2d1f4e;
  color: #c4b5fd;
}
.pensam-subtitle {
  font-size: 12px;
  color: #6b6b99;
  line-height: 1.6;
  margin: 0 0 16px;
  padding: 12px 20px 0;
  font-style: italic;
}
.pensam-empty-msg {
  color: #5a5a80;
  font-style: italic;
  line-height: 1.8;
}
.pensam-empty-msg small {
  font-size: 11px;
  color: #44446a;
}

/* ── Reflection cards ───────────────────────────────────────────────────────── */
.pensam-card {
  background: rgba(167,139,250,0.04);
  border: 1px solid rgba(167,139,250,0.12);
  border-left: 3px solid var(--emo-color, #7c3aed);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 0 16px 12px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.18s;
  animation: pensam-fade-in 0.35s ease both;
}
.pensam-card:hover {
  background: rgba(167,139,250,0.09);
  border-color: rgba(167,139,250,0.28);
  transform: translateY(-1px);
}
@keyframes pensam-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.pensam-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.pensam-card-emo {
  font-size: 11px;
  font-weight: 600;
  text-transform: lowercase;
  letter-spacing: 0.03em;
}
.pensam-card-time {
  font-size: 11px;
  color: #5a5a80;
  margin-left: auto;
}
.pensam-new-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a78bfa;
  box-shadow: 0 0 5px #a78bfa99;
  flex-shrink: 0;
}
.pensam-card-text {
  font-size: 13px;
  color: #9d9dc0;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Detail view ────────────────────────────────────────────────────────────── */
.pensam-detail-content {
  font-size: 14px;
  color: #bdbde8;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 8px 20px 0;
  font-style: italic;
}

/* ── Reflection toast ───────────────────────────────────────────────────────── */
.reflection-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(17, 10, 35, 0.94);
  border: 1px solid rgba(167,139,250,0.28);
  border-radius: 10px;
  padding: 9px 12px 9px 14px;
  margin: 0 12px 8px;
  font-size: 13px;
  color: #c4b5fd;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  backdrop-filter: blur(12px);
  box-shadow: 0 2px 16px rgba(124,58,237,0.18);
  pointer-events: all;
}
.reflection-toast.visible {
  opacity: 1;
  transform: none;
}
.reflection-toast-icon {
  font-size: 15px;
  flex-shrink: 0;
}
.reflection-toast-text {
  flex: 1;
  line-height: 1.4;
  color: #a09abf;
}
.reflection-toast-text em {
  font-style: normal;
  color: #c4b5fd;
}
.reflection-toast-btn {
  background: rgba(124,58,237,0.28);
  border: 1px solid rgba(167,139,250,0.4);
  border-radius: 6px;
  color: #c4b5fd;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.reflection-toast-btn:hover {
  background: rgba(124,58,237,0.5);
}
.reflection-toast-close {
  background: none;
  border: none;
  color: #5a5a80;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.15s;
}
.reflection-toast-close:hover {
  color: #a09abf;
}