body, .matrix-ai-chat-root, .matrix-chat-messages {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto;
  line-height: 1.55;
  color: #e4e4e4;
  margin: 0;
}

/* --- Layout Container (Sidebar + Content) --- */
.matrix-ai-chat-root {
  display: flex;
  flex-direction: row;
  height: 85vh;
  width: 100%;
  background-color: #1e1f23;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  padding: 0;
}

/* --- Sidebar Styling --- */
.matrix-chat-sidebar {
  width: 260px;
  min-width: 260px;
  background-color: #15161a;
  border-right: 1px solid #2a2c31;
  display: flex;
  flex-direction: column;
  padding: 16px;
  z-index: 2;
}

.matrix-new-chat-btn {
  width: 100%;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #2a2c31;
  background-color: rgba(255, 255, 255, 0.03);
  color: #fff;
  cursor: pointer;
  text-align: left;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  font-weight: 500;
  transition: all 0.2s ease;
}

  .matrix-new-chat-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: #3a3b42;
  }

  .matrix-new-chat-btn span {
    font-size: 18px;
    margin-right: 10px;
    line-height: 1;
    color: #4fd2ff;
  }

.matrix-sidebar-label {
  font-size: 11px;
  font-weight: 700;
  color: #6c727c;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.matrix-session-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.matrix-session-item {
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  color: #9da1a8;
  transition: background 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

  .matrix-session-item:hover, .matrix-session-item.active {
    background-color: rgba(255, 255, 255, 0.05);
    color: #e4e4e4;
  }

.session-info {
  flex: 1;
  overflow: hidden;
}

.session-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.session-date {
  font-size: 11px;
  color: #666;
  margin-top: 2px;
}

.session-actions {
  display: none;
}

.matrix-session-item:hover .session-actions {
  display: block;
}

.delete-btn {
  font-size: 12px;
  padding: 4px;
  border-radius: 4px;
  color: #666;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

  .delete-btn:hover {
    color: #ff4d4d;
    background-color: rgba(255, 77, 77, 0.1);
  }

/* --- Main Content Area --- */
.matrix-chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: #1e1f23;
}

.matrix-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  border-bottom: 1px solid #2a2c31;
  background-color: #1e1f23;
}

  .matrix-chat-header h2 {
    color: #4fd2ff;
    font-weight: 600;
    margin: 0;
    font-size: 18px;
    letter-spacing: -0.01em;
    text-shadow: 0 0 10px rgba(79, 210, 255, 0.15);
  }

.matrix-prompt-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

  .matrix-prompt-wrapper span {
    font-size: 13px;
    color: #6c727c;
  }

.matrix-chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column; 
  background: transparent;
  padding: 24px 10%;
  overflow-y: auto;
  scroll-behavior: smooth;
  gap: 12px;
}

/* --- Message Bubbles --- */
.matrix-msg {
  padding: 12px 16px;
  margin: 4px 0;
  border-radius: 12px;
  max-width: 75%;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.6;
}

/* User Bubble: Blue Gradient + Right Aligned */
.matrix-msg-user {
  background: linear-gradient(135deg, #05b5ff, #03c8ff);
  color: white;
  align-self: flex-end; 
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  border-bottom-right-radius: 2px;
}

/* AI Bubble: Dark Grey + Left Aligned */
.matrix-msg-ai {
  background: #25262b;
  color: #e4e4e4;
  align-self: flex-start; 
  border: 1px solid #2a2c31;
  border-bottom-left-radius: 2px;
}

.matrix-msg-system {
  background: rgba(3, 200, 255, 0.05);
  color: #a0aab8;
  border-left: 3px solid #4fd2ff;
  align-self: center;
  max-width: 90%;
}

/* --- Input Area --- */
.matrix-input-container {
  padding: 20px 10% 30px 10%;
  background-color: #1e1f23;
}

.matrix-input-wrapper {
  position: relative;
  display: flex;
  align-items: flex-end;
  background-color: #25262b;
  border: 1px solid #3a3b42;
  border-radius: 12px;
  padding: 0;
  transition: border-color 0.2s;
}

  .matrix-input-wrapper:focus-within {
    border-color: #4fd2ff;
  }

.matrix-chat-input {
  flex: 1;
  min-height: 55px;
  max-height: 200px;
  resize: none;
  padding: 14px;
  border: none;
  background: transparent;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.matrix-send-btn {
  width: 36px;
  height: 36px;
  margin: 0 10px 10px 0;
  border: none;
  border-radius: 50%;
  background-color: #03c8ff;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
}

  .matrix-send-btn:hover {
    background-color: #35c9ff;
    transform: scale(1.05);
  }

/* --- Markdown Styling --- */
.matrix-chat-messages a {
  color: #35c9ff !important;
  text-decoration: none;
  font-weight: 500;
}

  .matrix-chat-messages a:hover {
    text-decoration: underline;
  }

.matrix-chat-messages pre {
  background: #111;
  padding: 12px;
  border-radius: 8px;
  color: #ccc;
  overflow-x: auto;
  border: 1px solid #2a2c31;
}

/* --- AI Response Headers --- */
.matrix-msg-ai h2 {
  color: #4fd2ff;
  font-weight: 600;
  margin-top: 22px;
  margin-bottom: 10px;
  font-size: 1.5rem;
  border-bottom: 1px solid rgba(79,210,255,0.35);
  padding-bottom: 6px;
}

.matrix-msg-ai h3 {
  color: #35c9ff;
  font-weight: 600;
  margin-top: 18px;
  margin-bottom: 8px;
  font-size: 1.25rem;
}

.matrix-msg-ai ul, .matrix-msg-ai ol {
  margin-top: 8px;
  margin-bottom: 12px;
  padding-left: 22px;
  color: #d1d5db;
}

/* --- Mermaid Diagrams --- */
.matrix-chat-messages .mermaid {
  padding: 16px;
  background: #15161a;
  border-radius: 8px;
  margin: 12px 0;
  cursor: zoom-in;
  border: 1px solid #2a2c31;
}

  .matrix-chat-messages .mermaid svg {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
    max-height: 70vh;
  }

.mermaid .node circle.central,
.mermaid .node ellipse.central {
  fill: #5ad68a !important;
  stroke: #2f8f58 !important;
  stroke-width: 2px !important;
}

.mermaid-expanded-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

  .mermaid-expanded-overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }

.mermaid-expanded {
  min-width: 95vw;
  max-height: 90vh;
  overflow: auto;
  background: #111;
  padding: 24px;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
}

  .mermaid-expanded svg {
    width: 100% !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
  }

.matrix-prompt-dropdown {
  appearance: none;
  border: 1px solid #3a3b42;
  background-color: #2a2c31;
  color: #e4e4e4;
  padding: 6px 32px 6px 12px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  height: 32px;
  min-width: 180px;
  background-image: url("data:image/svg+xml;utf8,<svg width='10' height='10' viewBox='0 0 20 20' fill='%236c727c' xmlns='http://www.w3.org/2000/svg'><path d='M5 7l5 5 5-5H5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px;
}

  .matrix-prompt-dropdown:hover {
    border-color: #555;
  }

  .matrix-prompt-dropdown:focus {
    outline: none;
    border-color: #4fd2ff;
  }

  .matrix-prompt-dropdown option {
    background-color: #2a2c31;
    color: #fff;
  }

.matrix-search-wrapper {
  margin-bottom: 20px;
  position: relative;
}

.matrix-sidebar-search {
  width: 100%;
  padding: 10px 16px;
  border-radius: 20px; 
  border: 1px solid #2a2c31;
  background-color: #25262b;
  color: #e4e4e4;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, background-color 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236c727c'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z' /%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

  .matrix-sidebar-search:focus {
    border-color: #4fd2ff;
    background-color: #1e1f23;
  }

  .matrix-sidebar-search::placeholder {
    color: #6c727c;
  }