@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root{
  --bg: #212121;
  --panel: #171717;
  --panel2: #2f2f2f;
  --text: #ececf1;
  --muted: #b4b4b4;
  --border: #3a3a3a;
  --hover: #2f2f2f;
  --danger: #ef4444;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --radius: 12px;
  --radius2: 18px;
  --maxw: 760px;
}

*{ box-sizing: border-box; }
html, body { height: 100%; }

body{
  margin: 0;
  height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.6;
}

.app-shell{
  height: 100vh;
  display: flex;
}


/* ----- Sidebar ----- */
.sidebar{
  width: 320px;
  background: #171717;
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  gap: 10px;
  transition: width 0.3s ease;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid #2a2a2a;
}
.sidebar-recents, .chat-list {
   flex: 1;
   overflow-y: auto;
   overflow-x: hidden;
   padding-right: 4px;
   scrollbar-width: thin;
}
.sidebar-recents::-webkit-scrollbar, .chat-list::-webkit-scrollbar {
   width: 6px;
}
.sidebar-recents::-webkit-scrollbar-thumb, .chat-list::-webkit-scrollbar-thumb {
   background: #444;
   border-radius: 999px;
}
.sidebar.is-collapsed{
  width: 60px;
  padding: 12px 8px;
}
.sidebar.is-collapsed .sidebar-section-title,
.sidebar.is-collapsed .chat-list,
.sidebar.is-collapsed .profile-meta,
.sidebar.is-collapsed .side-txt{
  display: none;
}
.sidebar.is-collapsed .sidebar-header{
  justify-content: center;
  padding-bottom: 6px;
}
.sidebar.is-collapsed .logo{
  display:none;
}
.sidebar.is-collapsed .side-item{
  justify-content: center;
  padding: 10px 8px;
}
.sidebar.is-collapsed .side-ic{
  width: 24px;
}
.sidebar.is-collapsed .profile-section{
  justify-content: center;
}

.sidebar-header{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 4px 10px 4px;
}

.logo{
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.icon-btn{
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 16px;
  transition: background 0.2s, color 0.2s;
}
.icon-btn:hover{ background: var(--hover); color: var(--text); }

.sidebar-toggle{
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

/* Sidebar nav (ChatGPT-like) */
.side-nav{
  display:flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 2px 2px 2px;
}
.side-item{
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}
.side-item:hover{ background: var(--hover); }
.side-item.is-active{ background: var(--hover); color: #fff; }
.side-item-primary{ background: #ececf1; color: #171717; }
.side-item-primary:hover{ background: #d1d1d6; }
.side-ic{
  width: 18px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  opacity: .8;
}
.side-txt{ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-section-title{
  color: var(--muted);
  font-size: 11px;
  padding: 12px 8px 6px 8px;
  font-weight: 600;
}

.chat-list{
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-item{
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  color: #ececf1;
  font-size: 14px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.2s ease;
  flex-shrink: 0;
  min-height: 40px;
}
.chat-item:hover{ background: rgba(255,255,255,0.08); }
.chat-item.is-active{
  background: rgba(255,255,255,0.1);
  font-weight: 500;
}

.profile-section{
  margin-top: auto;
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.profile-section:hover{ background: var(--hover); }

.profile-avatar{
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.profile-meta{
  min-width: 0;
  display:flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.upload-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  margin-bottom: 0px;
  padding: 0 4px;
}

.upload-preview {
  width: 90px;
  height: 90px;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  border: 1px solid #3a3a3a;
  background: #2b2b2b;
}

.upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.generating-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: #2a2a2a;
    border-radius: 14px;
    border: 1px solid #3a3a3a;
    position: relative;
    overflow: hidden;
    max-width: 300px;
    color: #ececf1;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.shimmer-icon {
    animation: pulse 1.5s infinite;
}
.loading-gradient {
    position: absolute;
    bottom: 0; left: 0; height: 3px; width: 30%;
    background: linear-gradient(90deg, transparent, #10a37f, transparent);
    animation: slideGradient 1.5s infinite ease-in-out;
}
@keyframes slideGradient {
    0% { left: -30%; }
    100% { left: 100%; }
}
@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.streaming-cursor::after {
    content: '▋';
    animation: blink 1s step-start infinite;
    color: #10a37f;
    margin-left: 2px;
}
@keyframes blink {
    50% { opacity: 0; }
}

.generated-image {
  max-width: 640px;
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  background: #222;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.generated-image img {
  width: 100%;
  display: block;
}

.profile-email{
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-sub{
  font-size: 11px;
  color: var(--muted);
}

.profile-menu-btn{
  font-size: 18px;
  padding: 6px;
}

.settings-menu{
  display: none;
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 60px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 20;
}
.settings-menu a{
  display:block;
  text-decoration: none;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  transition: background 0.2s;
}
.settings-menu a:hover{ background: var(--hover); }
.settings-menu .danger{ color: var(--danger); }
.settings-sep{
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

/* ----- Main ----- */
.chat-container{
  flex: 1;
  display:flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.topbar{
  height: 56px;
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg);
}

.topbar-left{
  display:flex;
  align-items:center;
  gap: 10px;
}
.topbar-title{
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.topbar-pill{
  font-size: 12px;
  color: var(--muted);
  background: var(--hover);
  padding: 4px 10px;
  border-radius: 999px;
}

.chat-scroll{
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 0 16px;
  scroll-behavior: smooth;
}

.welcome{
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  animation: fadeIn 0.5s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.welcome-title{
  font-size: 36px;
  font-weight: 600;
  margin-bottom: 30px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.welcome-sub{
  margin: 0 auto 18px auto;
  max-width: 56ch;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}
.welcome-cards{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-width: 600px;
  width: 100%;
}
.welcome-card{
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 12px;
  padding: 16px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.welcome-card:hover{ background: var(--hover); transform: translateY(-2px); }
.welcome-card-title{ font-weight: 500; margin-bottom: 4px; font-size: 14px; }
.welcome-card-sub{ color: var(--muted); font-size: 13px; }

.chat-box{
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 24px 60px;
  display:flex;
  flex-direction: column;
}

.user, .ai{
  width: 100%;
  line-height: 1.75;
  font-size: 15px;
  color: #ececec;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.user{
  display:flex;
  justify-content: flex-end;
  color: var(--text);
}

.ai{
  color: var(--text);
}

/* Assistant rows with avatar (ChatGPT-like) */
.assistant-row{
  display:flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 28px;
  max-width: 760px;
  margin: 0 auto 28px auto;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}
.assistant-avatar{
  width: 30px;
  height: 30px;
  border-radius: 4px;
  background: #10a37f;
  display:flex;
  align-items:center;
  justify-content:center;
  flex: 0 0 auto;
  overflow:hidden;
}
.assistant-avatar img{
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* AI message bubble */
.assistant-content {
  background: transparent;
  color: var(--text);
  padding: 0 0 10px 0;
  flex: 1;
  min-width: 0;
}
.assistant-content p {
  margin: 0 0 1em 0;
}
.assistant-content p:last-child {
  margin-bottom: 0;
}

.status-dots{
  opacity: .7;
  font-style: italic;
  color: var(--muted);
}

/* Code */
.code-box{
  background: #111;
  border: 1px solid #262626;
  padding: 12px 12px 10px 12px;
  border-radius: 12px;
  position: relative;
}
.code-box pre{
  margin: 0;
  overflow-x: auto;
}
.copy-btn{
  position: absolute;
  right: 10px;
  top: 10px;
  cursor: pointer;
  background: #222;
  border: 1px solid #333;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 10px;
}

/* ----- Composer ----- */
.composer-wrap{
  position: sticky;
  bottom: 0;
  padding: 20px;
  background: linear-gradient(to top, #171717 70%, transparent);
  z-index: 10;
}

.composer{
  max-width: 900px;
  margin: 0 auto;
}

.composer-row{
  display:flex;
  align-items: flex-end;
  gap: 12px;
  background: #2b2b2b;
  border: 1px solid #3a3a3a;
  border-radius: 28px;
  min-height: 58px;
  padding: 14px 18px;
  position: relative;
  box-shadow: 0 0 15px rgba(0,0,0,0.1);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.composer-row:focus-within{
  border-color: #555;
  box-shadow: 0 0 20px rgba(0,0,0,0.15);
}

.icon-btn#toolsBtn{
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid transparent;
  font-size: 18px;
  color: var(--muted);
  flex-shrink: 0;
  margin-bottom: 2px;
}
.icon-btn#toolsBtn:hover{ background: var(--hover); color: var(--text); }

.icon-btn#micBtn, .icon-btn#speakBtn{
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.composer-input{
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  resize: none;
  outline: none;
  font-size: 15px;
  line-height: 1.5;
  padding: 8px 4px;
  max-height: 200px;
  font-family: inherit;
}
.composer-input::placeholder {
  color: var(--muted);
}

.send-btn{
  background: #fff;
  color: #000;
  border: none;
  border-radius: 50%;
  height: 32px;
  width: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
  transition: transform 0.2s, filter 0.2s;
}
.send-btn:hover{ filter: brightness(.9); transform: scale(1.05); }

.composer-hint{
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* Quick actions under composer (ChatGPT home) */
.quick-actions{
  display:none;
  max-width: var(--maxw);
  margin: 12px auto 0 auto;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.quick-action{
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  display:flex;
  align-items:center;
  gap: 8px;
  transition: background 0.2s, transform 0.1s;
}
.quick-action:hover{ background: var(--hover); transform: translateY(-1px); }
.qa-ic{ opacity: .8; font-size: 14px; }

/* Image tray (Image/Auto + Explore ideas) */
.image-tray{
  max-width: var(--maxw);
  margin: 14px auto 0 auto;
}
.image-tray-top{
  display:flex;
  gap: 8px;
  align-items:center;
  padding: 0 4px;
}
.tray-chip{
  display:flex;
  gap: 6px;
  align-items:center;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  cursor:pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s;
}
.tray-chip:hover{ background: var(--hover); }
.tray-caret{ opacity: .7; }

.image-explore{
  margin-top: 16px;
  padding: 0 4px 6px 4px;
}
.image-explore-header{
  display:flex;
  align-items:center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.image-explore-title{
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.image-explore-nav{ display:flex; gap: 8px; }
.nav-btn{
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition: background 0.2s;
}
.nav-btn:hover{ background: var(--hover); }

.explore-row{
  display:flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-behavior: smooth;
}
.explore-card{
  min-width: 150px;
  height: 170px;
  border-radius: 16px;
  border: 1px solid #2f2f2f;
  background: #1b1b1b;
  color: var(--text);
  cursor:pointer;
  position: relative;
  overflow:hidden;
  display:flex;
  align-items:flex-end;
  justify-content:flex-start;
  padding: 10px;
}
.explore-card:hover{ filter: brightness(1.05); }
.explore-card.outline{
  border: 1px dashed #4a4a4a;
  align-items:center;
  justify-content:center;
  flex-direction: column;
  gap: 8px;
}
.explore-plus{
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 24px;
}
.explore-label{ color: var(--muted); font-size: 13px; }
.explore-caption{
  width: 100%;
  font-weight: 600;
  font-size: 13px;
  background: linear-gradient(to top, rgba(0,0,0,.75), rgba(0,0,0,0));
  padding: 10px;
  border-radius: 0 0 16px 16px;
  position:absolute;
  left: 0;
  bottom: 0;
}
.explore-card.bg1{ background-image: url("https://images.unsplash.com/photo-1620641788421-7a1c342ea42e?w=400&auto=format&fit=crop"); background-size: cover; background-position: center; }
.explore-card.bg2{ background-image: url("https://images.unsplash.com/photo-1542204165-65bf26472b9b?w=400&auto=format&fit=crop"); background-size: cover; background-position: center; }
.explore-card.bg3{ background-image: url("https://images.unsplash.com/photo-1526481280695-3c687fd5432c?w=400&auto=format&fit=crop"); background-size: cover; background-position: center; }.explore-card.bg4{ background-image: url("https://images.unsplash.com/photo-1550684848-fac1c5b4e853?w=400&auto=format&fit=crop"); background-size: cover; background-position: center; }

/* Tools menu */
.tools-menu {
  display: none;
  position: absolute;
  bottom: 54px;
  left: 10px;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 14px;
  padding: 6px;
  min-width: 200px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 30;
  flex-direction: column;
}
.tools-menu.show {
  display: flex;
  animation: fadeIn 0.2s ease;
}
.tools-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}
.tools-item:hover { background: #3a3a3a; }
.tool-ic { font-size: 16px; }

/* Premium Image Toolbar */
.image-toolbar-premium {
  display: flex;
  gap: 12px;
  margin-top: 14px;
  justify-content: flex-start;
}
.img-tool-premium {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 8px 16px;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.img-tool-premium:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

/* Centered state for composer */
.chat-container.is-empty {
  justify-content: center;
}
.chat-container.is-empty .chat-scroll {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.chat-container.is-empty .composer-wrap {
  background: transparent;
  border-top: none;
  padding-bottom: 10vh;
}
.chat-container.is-empty .composer-row {
  box-shadow: 0 0 20px rgba(0,0,0,0.2);
}

@media (max-width: 960px){
  .welcome-cards{ grid-template-columns: 1fr; }
  .sidebar{ position: absolute; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.is-open{ transform: translateX(0); }
}

/* -------- Settings modal (ChatGPT-like) -------- */
.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 1000;
}
.settings-modal{
  width: min(980px, calc(100vw - 40px));
  height: min(680px, calc(100vh - 40px));
  background: #1f1f1f;
  border: 1px solid #2a2a2a;
  border-radius: 18px;
  box-shadow: var(--shadow);
  display:flex;
  overflow:hidden;
  position: relative;
}
.modal-close{
  position:absolute;
  left: 16px;
  top: 14px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid #2a2a2a;
  background: #2a2a2a;
  color: var(--text);
  cursor:pointer;
}
.modal-close:hover{ background:#333; }
.settings-nav{
  width: 240px;
  background: #222;
  border-right: 1px solid #2a2a2a;
  padding: 60px 10px 12px 10px;
  overflow-y:auto;
}
.settings-nav-item{
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text);
  opacity: .9;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap: 10px;
}
.settings-nav-item:hover{ background:#2a2a2a; }
.settings-nav-item.active{
  background:#2a2a2a;
  outline: 1px solid #333;
}
.settings-body{
  flex: 1;
  padding: 22px 22px 22px 22px;
  overflow-y:auto;
}
.settings-title{
  margin: 0 0 16px 0;
  text-align:center;
  font-size: 22px;
  font-weight: 600;
}
.settings-card{
  background: #0f0f0f;
  border: 1px solid #2a2a2a;
  border-radius: 16px;
  padding: 16px;
  position: relative;
  margin: 0 0 18px 0;
}
.settings-card-head{
  display:flex;
  gap: 12px;
  align-items:flex-start;
  margin-bottom: 14px;
}
.settings-card-ic{
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid #2a2a2a;
  background:#111;
  display:flex;
  align-items:center;
  justify-content:center;
}
.settings-card-title{ font-weight: 700; margin-bottom: 6px; }
.settings-card-sub{ color: var(--muted); line-height: 1.4; }
.settings-btn{
  background: transparent;
  border: 1px solid #3a3a3a;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  cursor:pointer;
}
.settings-btn:hover{ background:#1a1a1a; }
.settings-card-x{
  position: absolute;
  right: 12px;
  top: 12px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor:pointer;
}
.settings-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 14px 0;
  border-bottom: 1px solid #2a2a2a;
}
.settings-row-title{ font-weight: 500; margin-bottom: 4px; }
.settings-row-sub{ font-size: 13px; color: var(--muted); }

.toggle{
  display: inline-block;
  position: relative;
  width: 42px;
  height: 24px;
}
.toggle input{ opacity: 0; width: 0; height: 0; }
.toggle-ui{
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #333;
  transition: .2s;
  border-radius: 24px;
}
.toggle-ui:before{
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  transition: .2s;
  border-radius: 50%;
}
input:checked + .toggle-ui{ background: #22c55e; }
input:checked + .toggle-ui:before{ transform: translateX(18px); }

@media (max-width: 992px) {
  .sidebar { width: 280px; }
}
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .sidebar-section-title,
  .sidebar .chat-list,
  .sidebar .profile-meta,
  .sidebar .side-txt { display: none; }
  .sidebar .sidebar-header { justify-content: center; padding-bottom: 6px; }
  .sidebar .logo { display: none; }
  .sidebar .side-item { justify-content: center; padding: 10px 8px; }
  .sidebar .side-ic { width: 24px; }
  .sidebar .profile-section { justify-content: center; }
}

/* ================================================================
   MARKDOWN PROSE — assistant-content rich rendering
   ================================================================ */

.assistant-content {
  font-size: 15px;
  line-height: 1.85;
  color: #ececec;
  word-break: break-word;
}

/* Paragraphs */
.assistant-content p {
  margin: 0 0 14px 0;
}
.assistant-content p:last-child {
  margin-bottom: 0;
}

/* Headings */
.assistant-content h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 28px 0 12px 0;
  color: #ffffff;
  letter-spacing: -0.01em;
  border-bottom: 1px solid #2f2f2f;
  padding-bottom: 6px;
}
.assistant-content h2 {
  font-size: 19px;
  font-weight: 650;
  margin: 24px 0 10px 0;
  color: #f0f0f0;
  letter-spacing: -0.01em;
}
.assistant-content h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 18px 0 8px 0;
  color: #e0e0e0;
}
.assistant-content h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 14px 0 6px 0;
  color: #d0d0d0;
}

/* Lists */
.assistant-content ul,
.assistant-content ol {
  padding-left: 24px;
  margin: 10px 0 14px 0;
}
.assistant-content li {
  margin-bottom: 7px;
  line-height: 1.75;
}
.assistant-content li:last-child {
  margin-bottom: 0;
}
.assistant-content ul li { list-style-type: disc; }
.assistant-content ol li { list-style-type: decimal; }

/* Nested lists */
.assistant-content ul ul,
.assistant-content ol ol,
.assistant-content ul ol,
.assistant-content ol ul {
  margin: 4px 0 4px 0;
}

/* Blockquotes */
.assistant-content blockquote {
  border-left: 3px solid #4a4a4a;
  padding: 8px 16px;
  margin: 14px 0;
  color: #b4b4b4;
  background: #1e1e1e;
  border-radius: 0 8px 8px 0;
}

/* Horizontal rule */
.assistant-content hr {
  border: none;
  border-top: 1px solid #2f2f2f;
  margin: 20px 0;
}

/* Inline code */
.assistant-content code:not(pre code) {
  background: #2a2a2a;
  color: #e8c07d;
  padding: 2px 6px;
  border-radius: 5px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
  font-size: 13.5px;
  border: 1px solid #3a3a3a;
}

/* Code blocks — wrapper */
.assistant-content pre {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  margin: 16px 0;
  overflow: hidden;
  position: relative;
}

/* Code block inner */
.assistant-content pre code {
  display: block;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.65;
  background: transparent;
  color: #e6edf3;
  border: none;
}

/* Code block header bar (language label + copy button) */
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #21262d;
  border-bottom: 1px solid #30363d;
  padding: 7px 14px;
}
.code-block-lang {
  font-size: 12px;
  font-weight: 600;
  color: #8b949e;
  font-family: 'JetBrains Mono', Consolas, monospace;
  text-transform: lowercase;
}
.code-copy-btn {
  background: transparent;
  border: 1px solid #30363d;
  color: #8b949e;
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.code-copy-btn:hover {
  background: #30363d;
  color: #e6edf3;
}

/* Formula highlight pill */
.assistant-content .formula,
.formula-block {
  background: #1e2433;
  border: 1px solid #2d3555;
  padding: 10px 16px;
  border-radius: 10px;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 14px;
  color: #79c0ff;
  display: block;
  margin: 14px 0;
  overflow-x: auto;
  white-space: pre;
}

/* Tables */
.assistant-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
  border-radius: 10px;
  overflow: hidden;
}
.assistant-content th {
  background: #21262d;
  color: #e6edf3;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid #30363d;
}
.assistant-content td {
  padding: 9px 14px;
  border-bottom: 1px solid #2a2a2a;
  color: #cdd9e5;
}
.assistant-content tr:last-child td {
  border-bottom: none;
}
.assistant-content tr:nth-child(even) td {
  background: #161b22;
}

/* Strong / em */
.assistant-content strong { color: #fff; font-weight: 650; }
.assistant-content em { color: #cdd9e5; font-style: italic; }

/* Links */
.assistant-content a {
  color: #58a6ff;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}
.assistant-content a:hover {
  border-bottom-color: #58a6ff;
}

/* KaTeX display math */
.assistant-content .katex-display {
  background: #1e2433;
  border: 1px solid #2d3555;
  border-radius: 10px;
  padding: 14px 18px;
  margin: 14px 0;
  overflow-x: auto;
}

/* Streaming cursor */
.streaming-cursor::after {
  content: '▋';
  animation: blink 0.7s step-end infinite;
  color: #22c55e;
  font-size: 14px;
}
@keyframes blink {
  50% { opacity: 0; }
}

/* ================================================================
   TAXINA AI v4.0 — ADDITIONS
   Dark/Light themes, Personality, Memory, Voice, Message Actions,
   Image Toolbar, Document mode, Streaming UX improvements
   ================================================================ */

/* LIGHT THEME */
[data-theme="light"] {
  --bg: #f5f5f5;
  --panel: #ffffff;
  --panel2: #ebebeb;
  --text: #1a1a1a;
  --muted: #666666;
  --border: #d0d0d0;
  --hover: #e8e8e8;
  --danger: #dc2626;
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
}
[data-theme="light"] body { background: #f5f5f5; color: #1a1a1a; }
[data-theme="light"] .sidebar { background: #ffffff; border-right: 1px solid #d0d0d0; }
[data-theme="light"] .topbar { background: #f5f5f5; }
[data-theme="light"] .chat-container { background: #f5f5f5; }
[data-theme="light"] .composer-wrap { background: linear-gradient(to top, #f5f5f5 70%, transparent); }
[data-theme="light"] .composer-row { background: #ffffff; border-color: #d0d0d0; }
[data-theme="light"] .chat-item { color: #1a1a1a; }
[data-theme="light"] .chat-item:hover { background: rgba(0,0,0,0.06); }
[data-theme="light"] .chat-item.is-active { background: rgba(0,0,0,0.08); }
[data-theme="light"] .side-item { color: #1a1a1a; }
[data-theme="light"] .side-item-primary { background: #1a1a1a; color: #fff; }
[data-theme="light"] .assistant-content { color: #1a1a1a; }
[data-theme="light"] .assistant-content pre { background: #f6f8fa; border-color: #e1e4e8; }
[data-theme="light"] .assistant-content code:not(pre code) { background: #f0f0f0; color: #c7254e; border-color: #ddd; }
[data-theme="light"] .tools-menu { background: #fff; border-color: #d0d0d0; }
[data-theme="light"] .settings-modal { background: #fff; border-color: #d0d0d0; }
[data-theme="light"] .settings-nav { background: #f9f9f9; border-right-color: #d0d0d0; }
[data-theme="light"] .settings-menu { background: #fff; border-color: #d0d0d0; }
[data-theme="light"] .welcome-title { color: #1a1a1a; }
[data-theme="light"] .composer-input { color: #1a1a1a; }
[data-theme="light"] .topbar-pill { background: #e8e8e8; color: #666; }
[data-theme="light"] .icon-btn { color: #666; }
[data-theme="light"] .icon-btn:hover { background: #e8e8e8; color: #1a1a1a; }
[data-theme="light"] .send-btn { background: #1a1a1a; color: #fff; }
[data-theme="light"] .streaming-cursor::after { color: #16a34a; }
[data-theme="light"] .sidebar-section-title { color: #666; }
[data-theme="light"] .profile-email { color: #1a1a1a; }
[data-theme="light"] .profile-sub { color: #666; }
[data-theme="light"] .quick-action { background: #f5f5f5; border-color: #d0d0d0; color: #1a1a1a; }
[data-theme="light"] .code-block-header { background: #e8e8e8; border-bottom-color: #d0d0d0; }
[data-theme="light"] .code-block-lang { color: #555; }

/* LOGIN PAGE */
.login-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 60% 40%, #1a2e1a 0%, #0d0d0d 70%);
}
.login-card {
  text-align: center;
  background: rgba(23,23,23,0.95);
  padding: 48px 40px;
  border-radius: 20px;
  border: 1px solid #2a2a2a;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  max-width: 380px;
  width: 90vw;
}
.login-logo img { width: 56px; height: 56px; border-radius: 50%; margin-bottom: 16px; }
.login-title { font-size: 28px; font-weight: 700; color: #22c55e; margin: 0 0 8px; letter-spacing: -0.02em; }
.login-sub { color: #888; margin-bottom: 28px; font-size: 14px; }

/* THEME TOGGLE */
.theme-toggle-btn { width: 36px; height: 36px; border-radius: 8px; transition: background 0.2s, transform 0.2s; }
.theme-toggle-btn:hover { transform: scale(1.1); }

/* DOC MODE BADGE */
.doc-mode-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(34,197,94,0.12);
  border: 1px solid rgba(34,197,94,0.3);
  color: #22c55e;
  border-radius: 999px;
  padding: 4px 10px 4px 8px;
  font-size: 12px;
  font-weight: 500;
}
.doc-mode-badge span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.doc-mode-badge button { background: transparent; border: none; color: #22c55e; cursor: pointer; font-size: 12px; padding: 0 2px; opacity: 0.7; transition: opacity 0.2s; }
.doc-mode-badge button:hover { opacity: 1; }

/* MESSAGE ACTIONS */
.message-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
  margin-top: 8px;
  flex-wrap: wrap;
}
.assistant-row:hover .message-actions { opacity: 1; }
.msg-action-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.msg-action-btn:hover { background: var(--hover); color: var(--text); border-color: var(--border); }

/* IMAGE TOOLBAR */
.image-toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 4px 0;
}
.img-tool-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}
.img-tool-btn:hover { background: var(--hover); transform: translateY(-1px); }

/* SETTINGS TABS */
.settings-tab { display: none; }
.settings-tab.active { display: block; }
.settings-desc { color: var(--muted); font-size: 13px; margin-bottom: 20px; line-height: 1.5; }

/* THEME PICKER */
.theme-picker { display: flex; gap: 6px; }
.theme-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: background 0.15s;
}
.theme-btn:hover { background: var(--hover); }
.theme-btn.active { border-color: #22c55e; color: #22c55e; background: rgba(34,197,94,0.08); }

/* PERSONALITY GRID */
.personality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}
.personality-card {
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 16px 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  font-family: inherit;
  color: var(--text);
}
.personality-card:hover { background: var(--hover); transform: translateY(-2px); }
.personality-card.active { border-color: #22c55e; background: rgba(34,197,94,0.08); }
.pc-icon { font-size: 28px; margin-bottom: 8px; }
.pc-name { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.pc-desc { color: var(--muted); font-size: 11px; line-height: 1.4; }
.save-feedback { font-size: 13px; color: #22c55e; margin-left: 10px; opacity: 0; transition: opacity 0.3s; }
.save-feedback.show { opacity: 1; }

/* MEMORY MODAL */
.memory-modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: min(680px, calc(100vw - 40px));
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
  overflow: hidden;
}
.memory-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--border);
}
.memory-modal-header h2 { margin: 0; font-size: 18px; font-weight: 600; }
.modal-close-inline {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}
.modal-close-inline:hover { background: var(--hover); color: var(--text); }
.memory-add-row { display: flex; gap: 8px; padding: 16px 24px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.mem-input {
  flex: 1;
  min-width: 120px;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.mem-input:focus { border-color: #22c55e; }
.mem-select {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.memory-list { flex: 1; overflow-y: auto; padding: 12px 24px 20px; display: flex; flex-direction: column; gap: 8px; }
.memory-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}
.memory-type-badge {
  background: rgba(34,197,94,0.15);
  color: #22c55e;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.memory-key { font-weight: 600; font-size: 13px; min-width: 0; flex-shrink: 0; max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.memory-value { color: var(--muted); font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memory-del-btn { background: transparent; border: none; color: var(--danger); cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 4px; opacity: 0.6; transition: opacity 0.2s; flex-shrink: 0; }
.memory-del-btn:hover { opacity: 1; }
.memory-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 32px; }

/* VOICE OVERLAY */
.voice-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.2s ease;
}
.voice-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 48px;
  text-align: center;
  min-width: 320px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
}
.voice-title { font-size: 18px; font-weight: 600; margin-bottom: 32px; color: var(--text); }
.voice-status { color: var(--muted); font-size: 14px; margin-top: 24px; height: 20px; }
.voice-transcript { color: var(--text); font-size: 15px; margin-top: 12px; min-height: 40px; max-width: 400px; word-wrap: break-word; line-height: 1.5; }
.voice-actions { margin-top: 32px; }
.voice-stop-btn {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 28px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  font-family: inherit;
}
.voice-stop-btn:hover { opacity: 0.85; transform: scale(1.04); }
.voice-waveform { display: flex; align-items: center; justify-content: center; gap: 5px; height: 60px; }
.wave-bar { width: 5px; background: #22c55e; border-radius: 999px; height: 10px; animation: wavePulse 1.2s ease-in-out infinite; }
.wave-bar:nth-child(1) { animation-delay: 0s;   height: 14px; }
.wave-bar:nth-child(2) { animation-delay: 0.1s; height: 24px; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; height: 40px; }
.wave-bar:nth-child(4) { animation-delay: 0.3s; height: 54px; }
.wave-bar:nth-child(5) { animation-delay: 0.2s; height: 40px; }
.wave-bar:nth-child(6) { animation-delay: 0.1s; height: 24px; }
.wave-bar:nth-child(7) { animation-delay: 0s;   height: 14px; }
.voice-overlay.is-speaking .wave-bar { background: #3b82f6; }
.voice-overlay.is-idle .wave-bar { animation-play-state: paused; background: var(--muted); }
@keyframes wavePulse {
  0%, 100% { transform: scaleY(0.4); opacity: 0.6; }
  50%       { transform: scaleY(1);   opacity: 1; }
}
#micBtn.is-recording { color: #ef4444 !important; animation: micPulse 1s ease-in-out infinite; }
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50%       { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

/* IMPROVED STREAMING */
.assistant-content.is-streaming > *:last-child::after {
  content: '▋';
  animation: blink 0.7s step-end infinite;
  color: #22c55e;
  font-size: 14px;
  margin-left: 2px;
}
@keyframes chunkFade { from { opacity: 0.5; } to { opacity: 1; } }
.assistant-content p, .assistant-content li, .assistant-content pre { animation: chunkFade 0.2s ease; }

/* DOC UPLOAD PILL */
.doc-upload-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text);
}
.doc-upload-pill .doc-icon { font-size: 22px; }
.doc-upload-pill .doc-info { flex: 1; min-width: 0; }
.doc-upload-pill .doc-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-upload-pill .doc-meta { color: var(--muted); font-size: 11px; margin-top: 2px; }
.doc-remove-btn { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 2px 6px; border-radius: 4px; transition: color 0.2s; }
.doc-remove-btn:hover { color: var(--danger); }

/* CHAT ITEM WITH TIMESTAMP */
.chat-item-inner { display: flex; flex-direction: column; min-width: 0; }
.chat-item-title { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.chat-item-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* PREMIUM SCROLLBARS */
.chat-scroll::-webkit-scrollbar,
.memory-list::-webkit-scrollbar,
.settings-body::-webkit-scrollbar { width: 5px; }
.chat-scroll::-webkit-scrollbar-thumb,
.memory-list::-webkit-scrollbar-thumb,
.settings-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 999px; }
[data-theme="light"] .chat-scroll::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); }

/* RESPONSIVE */
@media (max-width: 600px) {
  .personality-grid { grid-template-columns: repeat(2, 1fr); }
  .memory-add-row { flex-direction: column; }
  .voice-panel { padding: 32px 24px; min-width: 280px; }
  .image-toolbar { gap: 4px; }
  .img-tool-btn { padding: 4px 8px; font-size: 11px; }
}

/* ================================================================
   UI FIX BLOCK v4.1 — Alignment, Animations, Polish
   ================================================================ */

/* ── Message smooth entry animations ── */
@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes imgFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

/* Apply entry animation to every message row */
.assistant-row {
  animation: msgSlideIn 0.25s ease forwards;
}
.user {
  animation: msgSlideIn 0.2s ease forwards;
}

/* ── Fix assistant-row alignment ── */
/* Remove double-centering: chat-box already constrains width */
.assistant-row {
  max-width: 100% !important;
  margin: 0 0 24px 0 !important;
  align-items: flex-start;
  gap: 12px;
}

/* Avatar stays fixed top-aligned with first line of text */
.assistant-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  margin-top: 2px;        /* aligns with first text line */
  object-fit: cover;
}

/* Content area never shifts left/right */
.assistant-content {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  line-height: 1.7;
  font-size: 15px;
  color: var(--text);
  padding-top: 2px;       /* baseline align with avatar */
}

/* ── Status dots (Thinking…) alignment ── */
.status-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 14px;
  padding-top: 4px;
}
.status-dots::after {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: dotPulse 1.2s ease-in-out infinite;
}
@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40%           { opacity: 1;   transform: scale(1); }
}

/* ── User bubble ── */
.user {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
  padding: 0;
}
.bubble {
  background: #2f2f2f !important;
  color: #ececf1 !important;
  border-radius: 18px !important;
  padding: 12px 18px !important;
  max-width: 72% !important;
  font-size: 15px !important;
  line-height: 1.6 !important;
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
[data-theme="light"] .bubble {
  background: #e8e8e8 !important;
  color: #1a1a1a !important;
}

/* ── Generated image — centered, max width ── */
.generated-image {
  position: relative;
  max-width: 520px;
  margin: 10px auto;           /* center the image in the content area */
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  animation: imgFadeIn 0.5s ease;
}
.generated-image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 16px;
}

/* Image toolbar below image — centered */
.image-toolbar {
  max-width: 520px;
  margin: 8px auto 0;
  justify-content: center;
}

/* ── Uploaded image preview — centered ── */
.preview-box {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 0 4px;
}
.upload-preview {
  display: flex;
  justify-content: center;
}
.upload-preview img {
  max-width: 160px;
  max-height: 120px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* ── Sidebar New Chat button — premium look ── */
.side-item-primary {
  background: #22c55e !important;
  color: #000 !important;
  font-weight: 600;
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(34,197,94,0.25);
}
.side-item-primary:hover {
  background: #16a34a !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(34,197,94,0.35);
}
.side-item-primary .side-ic { font-size: 16px; }

/* ── Sidebar chat item — improved ── */
.chat-item {
  border-radius: 8px;
  padding: 8px 10px;
  transition: background 0.15s;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text);
  opacity: 0.85;
}
.chat-item:hover { background: rgba(255,255,255,0.06); opacity: 1; }
.chat-item.is-active { background: rgba(255,255,255,0.09); opacity: 1; font-weight: 500; }

/* ── Smooth streaming text ── */
.assistant-content p,
.assistant-content li,
.assistant-content h1,
.assistant-content h2,
.assistant-content h3 {
  animation: msgSlideIn 0.2s ease;
}

/* ── Code blocks ── */
.assistant-content pre {
  border-radius: 10px;
  margin: 12px 0;
  overflow-x: auto;
}

/* ── Topbar cleaner ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  height: 52px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: var(--bg);
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-title { font-weight: 600; font-size: 15px; }
.topbar-pill {
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
}

/* ── Welcome screen ── */
.welcome { text-align: center; padding: 60px 20px 20px; }
.welcome-title {
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 24px;
  letter-spacing: -0.02em;
}

/* ── Quick actions ── */
.quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0 4px 8px;
}
.quick-action {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.15s, transform 0.15s;
  white-space: nowrap;
}
.quick-action:hover { background: var(--hover); transform: translateY(-1px); }
.qa-ic { font-size: 14px; }

/* ── Composer row clean ── */
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 14px;
  transition: border-color 0.2s;
}
.composer-row:focus-within { border-color: rgba(255,255,255,0.2); }
.composer-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  resize: none;
  max-height: 200px;
  line-height: 1.6;
}
.composer-input::placeholder { color: var(--muted); }

/* ── Consistent icon button ── */
.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }

/* Light mode overrides for new elements */
[data-theme="light"] .bubble { background: #e8e8e8 !important; color: #1a1a1a !important; }
[data-theme="light"] .side-item-primary { color: #fff !important; }
[data-theme="light"] .generated-image { box-shadow: 0 8px 32px rgba(0,0,0,0.15); }
[data-theme="light"] .chat-item:hover { background: rgba(0,0,0,0.05); }
[data-theme="light"] .chat-item.is-active { background: rgba(0,0,0,0.08); }
[data-theme="light"] .composer-row:focus-within { border-color: rgba(0,0,0,0.25); }
[data-theme="light"] .quick-action:hover { background: var(--hover); }