:root {
  /* Brand Colors — Inspiro + Fuse */
  --accent: #F21582;           /* Fuse magenta — kept as primary accent */
  --brand-navy: #081F3D;       /* Inspiro navy — sidebar / dark structure */
  --secondary: #7092A7;        /* Inspiro blue — borders / secondary */
  --highlight: #FDC4BB;        /* Inspiro salmon — soft callouts */
  --cream: #DFD6CA;            /* Inspiro cream — warm secondary text */
  --neutral: #858085;          /* Inspiro grey — faint dividers */

  /* Dark UI */
  --bg-main: #1a1a1d;
  --bg-sidebar: #141416;
  --bg-input: #242429;
  --bg-panel: #2a2a2e;
  --bg-panel-hover: #36363c;
  --hover-dark: rgba(242, 21, 130, 0.15);   /* Fuse magenta tint */

  --border-pill: rgba(112, 146, 167, 0.22); /* Inspiro blue at low alpha */
  --border-pill-hover: rgba(112, 146, 167, 0.55);
  --border-panel: rgba(112, 146, 167, 0.18);

  --text-primary: #ffffff;
  --text-secondary: var(--cream);           /* warm cream for body secondary */
  --text-muted: #a8a49a;                    /* muted cream */
  --text-faint: var(--neutral);

  --sidebar-w: 56px;
  --sidebar-expanded: 260px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Averta', 'Quicksand', 'Segoe UI', sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  font-size: 15px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.app { display: flex; height: 100vh; width: 100vw; position: relative; }

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 14px;
  flex-shrink: 0;
  transition: width 0.18s ease;
  z-index: 15;
  position: relative;
}
.sidebar.expanded { width: var(--sidebar-expanded); align-items: stretch; padding: 10px 8px 14px; }
.sidebar.expanded .side-btn { width: 100%; justify-content: flex-start; gap: 12px; padding: 0 12px; }
.sidebar.expanded .side-btn::after { display: none; }
.sidebar.expanded .side-label { display: inline; }
.sidebar.expanded .sidebar-top { gap: 2px; }
.sidebar.expanded .user-avatar { width: 100%; border-radius: 8px; padding: 8px 10px; gap: 10px; justify-content: flex-start; height: auto; }
.sidebar.expanded .user-name-label { display: inline; }
.sidebar.expanded .chat-history { display: block; }
.sidebar.expanded .sidebar-bottom { align-items: stretch; }

.sidebar-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.side-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer; transition: background 0.15s, color 0.15s;
  position: relative;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
}
.side-btn:hover { background: var(--hover-dark); color: var(--text-primary); }
.side-label { display: none; }

/* Tooltip */
.side-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  background: #000;
  color: #f5f4ef;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 9px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.side-btn:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
  transition-delay: 0.4s;
}

/* Chat history */
.chat-history {
  display: none;
  margin-top: 16px;
  padding: 0 4px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.chat-history::-webkit-scrollbar { width: 5px; }
.chat-history::-webkit-scrollbar-thumb { background: #3d3d3a; border-radius: 3px; }
.history-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-faint);
  padding: 10px 10px 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.history-item {
  display: block;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}
.history-item:hover { background: var(--hover-dark); color: var(--text-primary); }
.history-item.active {
  background: rgba(242, 21, 130, 0.15);
  color: var(--accent);
  font-weight: 600;
}

.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #3d3d3a;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 10.5px; font-weight: 600;
  cursor: pointer; border: none;
  letter-spacing: 0.02em;
  transition: background 0.15s;
  font-family: inherit;
}
.user-avatar:hover { background: #4a4a46; }
.user-avatar .avatar-circle {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #3d3d3a;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 10.5px; font-weight: 600;
  flex-shrink: 0;
}
.user-name-label { display: none; color: var(--text-primary); font-size: 13.5px; font-weight: 500; }

/* ============ MAIN ============ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  min-width: 0;
  position: relative;
  overflow: hidden;
}
.center-wrap {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: -60px;
}
.greeting {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
  font-family: 'Averta', 'Quicksand', sans-serif;
  font-size: 34px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  text-align: center;
}
.greeting-text {
  display: inline-block;
  line-height: 1.1;
}

.brand-logo-img {
  height: 40px;
  width: auto;
  object-fit: contain;
}

/* ============ INPUT ============ */
.input-box {
  width: 100%;
  background: var(--bg-input);
  border-radius: 16px;
  padding: 18px 20px 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  border: 1px solid var(--border-panel);
}
.input-area {
  width: 100%;
  background: transparent;
  border: none; outline: none; resize: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  min-height: 24px;
  max-height: 200px;
}
.input-area::placeholder { color: var(--neutral); font-size: 14px; }

.input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }

.tool-btn {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer; transition: all 0.15s;
}
.tool-btn:hover:not(:disabled) { background: var(--hover-dark); color: var(--accent); }
.tool-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Phosphor icon sizing inside tool buttons and sidebar */
.tool-btn i,
.side-btn i {
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Send button — magenta bubble with white paper-plane icon */
.send-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s;
  box-shadow: 0 2px 6px rgba(242, 21, 130, 0.35);
}
.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(242, 21, 130, 0.45);
  background: #ff2a99;
}
.send-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(242, 21, 130, 0.35);
}
.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.send-btn i {
  font-size: 18px;
  line-height: 1;
  color: #fff;
  /* Tilt the paper-plane slightly for motion */
  transform: translateX(1px);
}

/* Model selector */
.model-wrap { position: relative; }
.model-selector {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 6px;
  background: transparent; border: none;
  border-radius: 6px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer; transition: all 0.15s;
  letter-spacing: 0.01em;
}
.model-selector:hover { background: var(--hover-dark); color: var(--text-primary); }

.dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-panel);
  border-radius: 12px;
  padding: 6px;
  min-width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 50;
}
.dropdown.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.dropdown-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}
.dropdown-item:hover { background: var(--bg-panel-hover); }
.dropdown-item-main { flex: 1; }
.dropdown-item-title {
  font-size: 13.5px; color: var(--text-primary); font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.dropdown-item-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }
.dropdown-check { color: var(--accent); opacity: 0; margin-top: 2px; }
.dropdown-item.selected .dropdown-check { opacity: 1; }
.badge {
  font-size: 10px; color: var(--text-muted);
  background: rgba(112, 146, 167, 0.1);
  padding: 1px 6px; border-radius: 4px;
  font-weight: 600; letter-spacing: 0.02em;
  border: 1px solid var(--border-pill);
}

/* User menu */
.user-menu {
  position: absolute;
  left: calc(100% + 6px);
  bottom: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-panel);
  border-radius: 12px;
  padding: 6px;
  min-width: 240px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateX(-6px);
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 50;
}
.sidebar.expanded .user-menu { left: 8px; right: 8px; bottom: calc(100% + 6px); min-width: 0; transform: translateY(6px); }
.sidebar.expanded .user-menu.open { transform: translateY(0); }
.user-menu.open { opacity: 1; transform: translateX(0); pointer-events: auto; }
.user-menu-header {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border-panel);
  margin-bottom: 4px;
}
.user-menu-name { font-size: 13.5px; color: var(--text-primary); font-weight: 600; }
.user-menu-email { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.user-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.12s;
}
.user-menu-item:hover { background: var(--bg-panel-hover); color: var(--text-primary); }
.user-menu-sep { height: 1px; background: var(--border-panel); margin: 4px 0; }

/* Pills */
.pills {
  display: flex; gap: 8px;
  margin-top: 16px; flex-wrap: wrap;
  justify-content: center;
}
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--border-pill);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.pill:hover {
  background: var(--hover-dark);
  border-color: var(--accent);
  color: var(--text-primary);
}

/* ============ CHAT AREA ============ */
.chat-area {
  display: none;
  width: 100%;
  max-width: 760px;
  flex: 1;
  overflow-y: auto;
  padding: 40px 20px 20px;
  flex-direction: column;
  min-height: 0;
}
.chat-area.active { display: flex; }
.main.has-chat {
  justify-content: flex-start;
  padding-top: 20px;
}
.main.has-chat .center-wrap {
  margin-top: 0;
  max-width: 760px;
  flex-shrink: 0;
}
.main.has-chat .greeting { display: none; }
.main.has-chat .pills { display: none; }
.main.has-chat .input-box { box-shadow: 0 -4px 20px rgba(0,0,0,0.2); }

.chat-area::-webkit-scrollbar { width: 8px; }
.chat-area::-webkit-scrollbar-thumb { background: #36363c; border-radius: 4px; }

.message { margin-bottom: 24px; }
.message-user { display: flex; justify-content: flex-end; }
.message-user .bubble {
  background: rgba(112, 146, 167, 0.15);
  border: 1px solid rgba(112, 146, 167, 0.3);
  padding: 12px 16px;
  border-radius: 18px;
  max-width: 80%;
  white-space: pre-wrap;
  line-height: 1.5;
  color: var(--text-primary);
}
.message-assistant {
  font-family: 'Averta', 'Quicksand', sans-serif;
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-primary);
}
.message-assistant p { margin-bottom: 14px; }
.message-assistant p:last-child { margin-bottom: 0; }
.message-assistant h1, .message-assistant h2, .message-assistant h3 {
  font-weight: 700;
  margin-top: 18px;
  margin-bottom: 10px;
  color: var(--text-primary);
}
.message-assistant h1 { font-size: 22px; }
.message-assistant h2 { font-size: 19px; }
.message-assistant h3 { font-size: 17px; }
.message-assistant ul, .message-assistant ol {
  margin: 0 0 14px 0;
  padding-left: 24px;
}
.message-assistant li { margin-bottom: 6px; }
.message-assistant code {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.9em;
  background: rgba(242, 21, 130, 0.1);
  color: var(--highlight);
  padding: 2px 5px;
  border-radius: 4px;
}
.message-assistant pre {
  background: #121212;
  border: 1px solid var(--border-panel);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  margin-bottom: 14px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13.5px;
  line-height: 1.5;
}
.message-assistant pre code { background: none; padding: 0; font-size: inherit; color: var(--text-primary); }
.message-assistant strong { font-weight: 700; color: var(--accent); }
.message-assistant em { font-style: italic; color: var(--highlight); }
.message-assistant a {
  color: var(--secondary);
  text-decoration: none;
  border-bottom: 1px dashed var(--secondary);
  transition: color 0.2s;
}
.message-assistant a:hover {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
}

/* Block types from response composer */
.block-steps {
  border-left: 2px solid var(--accent);
  padding-left: 14px;
  margin: 10px 0 14px;
}
.block-tip {
  background: rgba(112, 146, 167, 0.08);
  border-left: 3px solid var(--secondary);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  margin: 12px 0;
  font-size: 14px;
}
.block-tip::before {
  content: "💡 ";
}
.block-warning {
  background: rgba(237, 168, 162, 0.08);
  border-left: 3px solid var(--highlight);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  margin: 12px 0;
  font-size: 14px;
}
.block-warning::before {
  content: "⚠️ ";
}
.block-context {
  font-size: 14px;
  font-style: italic;
  color: var(--text-muted);
  margin-top: 10px;
}
.block-subheader {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 16px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-subtle);
}
.block-clarify {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(242, 21, 130, 0.08);
  border-radius: 8px;
  font-weight: 600;
  color: var(--accent);
}
.block-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.action-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  font-family: inherit;
}
.action-link:hover {
  background: var(--accent);
  color: #fff;
  border-bottom-color: var(--accent);
}

/* Thinking stream */
.thinking-stream {
  color: var(--text-muted);
  font-style: italic;
  font-size: 14px;
  margin-bottom: 12px;
  min-height: 20px;
  opacity: 0.8;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 0.9; } }

/* Streaming cursor */
.streaming-cursor {
  display: inline-block;
  width: 8px;
  height: 18px;
  background: var(--accent);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 1s steps(2) infinite;
  border-radius: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

.fade-in { animation: fade 0.25s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.overlay {
  position: fixed; inset: 0; z-index: 40;
  display: none;
}
.overlay.active { display: block; }

/* Toast for memory reset etc */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--border-panel);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  font-size: 13px;
  z-index: 200;
  animation: toastIn 0.2s ease-out, toastOut 0.3s ease-in 2.5s forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toastOut { to { opacity: 0; transform: translate(-50%, 10px); } }

/* ============ RESPONSIVE — MOBILE ============ */

/* Tablets and small laptops */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.expanded {
    transform: translateX(0);
  }
  .main {
    margin-left: 0;
    width: 100%;
  }
  .center-wrap {
    max-width: 100%;
    padding: 0 16px;
  }
  .greeting {
    font-size: 28px;
    gap: 12px;
  }
  .brand-logo-img {
    height: 36px;
  }
}

/* Phones */
@media (max-width: 640px) {
  .greeting {
    flex-direction: column;
    gap: 10px;
    margin-bottom: 22px;
    font-size: 20px;
    text-align: center;
  }
  .greeting-text {
    font-size: 20px;
    display: block;
    max-width: 100%;
    word-wrap: break-word;
  }
  .brand-logo-img {
    height: 32px;
  }
  .center-wrap {
    margin-top: -20px;
    padding: 0 12px;
  }
  .input-box {
    padding: 14px 14px 10px;
    border-radius: 12px;
  }
  .input-area {
    font-size: 16px;  /* 16px prevents iOS zoom-on-focus */
  }
  .input-area::placeholder {
    font-size: 14px;
  }
  .input-toolbar {
    margin-top: 16px;
  }
  .send-btn {
    width: 40px;
    height: 40px;
  }
  .send-btn i {
    font-size: 20px;
  }
  .pills {
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
  }
  .pill {
    font-size: 12px;
    padding: 8px 12px;
  }
  /* Messages: tighter on mobile */
  .message {
    padding: 12px 14px;
    font-size: 14px;
  }
  .message-assistant,
  .message-user {
    max-width: 100%;
  }
  /* Chat area padding */
  .chat-area {
    padding: 16px 12px;
  }
  /* Actions: wrap on phone */
  .action-buttons,
  .actions {
    flex-wrap: wrap;
    gap: 6px;
  }
  .action-link {
    font-size: 12px;
    padding: 6px 10px;
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .greeting-text {
    font-size: 18px;
  }
  .brand-logo-img {
    height: 28px;
  }
  .pill {
    font-size: 11px;
    padding: 7px 10px;
  }
}