  * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
  }

  :root {
      --bg: #343541;
      --sidebar-bg: #202123;
      --surface: #444654;
      --border: rgba(255, 255, 255, 0.08);
      --text-primary: #ECECF1;
      --text-secondary: #ACACBE;
      --accent: #10A37F;
      --accent-hover: #0d8a6b;
      --shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
      --radius: 8px;
      --transition: 0.2s ease;
  }

  html,
  body {
      height: 100%;
      font-family: Verdana, Geneva, Tahoma, sans-serif;
      background: var(--sidebar-bg);
      color: var(--text-primary);
      overflow: hidden;
  }

  #app {
      display: flex;
      height: 100vh;
  }

  /* === SIDEBAR === */
  #sidebar {
      width: 260px;
      min-width: 260px;
      background: var(--sidebar-bg);
      display: flex;
      flex-direction: column;
      height: 100vh;
      overflow: hidden;

      transition: transform 0.3s ease, width 0.3s ease;
      position: relative;
      z-index: 20;
  }

  #sidebar-header {
      padding: 16px;

      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 8px;
      height: 56px;
      margin-bottom: 1rem;
  }

  #sidebar-header h1 {
      font-size: 18px;
      font-weight: 600;
      color: var(--text-primary);
      letter-spacing: -0.02em;
  }

  .sidebar-logo {
      width: 28px;
      height: 28px;
      background: var(--surface);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 14px;
      font-weight: 700;
      color: #fff;
  }

  #new-chat-btn {


      display: flex;
      align-items: center;
      gap: 6px;
      background: transparent;
      border: none;
      border-radius: var(--radius);
      color: var(--text-primary);
      font-size: 12px;
      cursor: pointer;
      font-weight: bold;
      transition: background var(--transition), border-color var(--transition);
  }


  #new-chat-btn svg {
      height: 18px;
      width: 18px;
  }


  #new-chat-btn:hover {
      background: rgba(255, 255, 255, 0.05);
      border-color: rgba(255, 255, 255, 0.2);
  }

  #chat-list {
      flex: 1;
      overflow-y: auto;
      padding: 4px 8px;
  }

  #chat-list::-webkit-scrollbar {
      width: 4px;
  }

  #chat-list::-webkit-scrollbar-track {
      background: transparent;
  }

  #chat-list::-webkit-scrollbar-thumb {
      background: rgba(255, 255, 255, 0.2);
      border-radius: 4px;
  }

  .chat-item {
      padding: 10px 12px;
      margin: 2px 0;
      border-radius: var(--radius);
      font-size: 13px;

      cursor: pointer;
      transition: background var(--transition), color var(--transition);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
  }

  .chat-item:hover {
      background: rgba(255, 255, 255, 0.04);
      color: var(--text-primary);
  }

  .chat-item.active {
      background: rgba(255, 255, 255, 0.07);
      color: var(--text-primary);
  }

  #sidebar-footer {
      padding: 12px 16px;

      font-size: 12px;
      color: var(--text-secondary);
  }

  .sidebar-toggle-btn {
      display: none;
      background: none;
      border: none;
      color: var(--text-primary);
      font-size: 22px;
      cursor: pointer;
      padding: 4px 8px;
      border-radius: 4px;
      transition: background var(--transition);
  }

  .sidebar-toggle-btn:hover {
      background: rgba(255, 255, 255, 0.05);
  }

  /* === MAIN CHAT AREA === */
  #main {
      flex: 1;
      display: flex;
      flex-direction: column;
      height: 100vh;
      min-width: 0;
      position: relative;
  }

  #chat-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 12px 20px;


      z-index: 10;
      height: 56px;
  }

  #chat-header .sidebar-toggle-btn {
      display: none;
  }

  #model-selector {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 6px 12px;
      background: var(--sidebar-bg);

      border-radius: 20px;
      font-size: 13px;
      color: var(--text-primary);
      cursor: default;
      border: 1px solid var(--border);
  }

  #chat-title {
      font-size: 14px;
      font-weight: 500;
      color: var(--text-primary);
      flex: 1;
      text-align: center;
  }

  /* === MESSAGES === */
  #messages-container {
      flex: 1;
      overflow-y: auto;
      padding: 0;
      scroll-behavior: smooth;
  }

  #messages-container::-webkit-scrollbar {
      width: 6px;
  }

  #messages-container::-webkit-scrollbar-track {
      background: transparent;
  }

  #messages-container::-webkit-scrollbar-thumb {
      background: rgba(255, 255, 255, 0.15);
      border-radius: 4px;
  }

  #messages {
      max-width: 768px;
      margin: 0 auto;
      padding: 20px 24px 0;
  }

  .message {
      display: flex;
      flex-direction: column;
      margin-bottom: 20px;
      animation: messageFadeIn 0.3s ease;
  }

  @keyframes messageFadeIn {
      from {
          opacity: 0;
          transform: translateY(8px);
      }

      to {
          opacity: 1;
          transform: translateY(0);
      }
  }

  .message.user {
      align-items: flex-end;
  }

  .message.assistant {
      align-items: flex-start;
  }

  .message-bubble {
      max-width: 85%;
      padding: 14px 18px;
      border-radius: 18px;
      font-size: 14px;
      line-height: 1.6;
      word-wrap: break-word;
      position: relative;
  }

  .message-bubble ul,
  .message-bubble ol {
      padding-inline: 2rem;
  }

  .message.user .message-bubble {
      background: var(--bg);
      color: #fff;
      border-bottom-right-radius: 4px;
  }

  .message.assistant .message-bubble {
      background: transparent;
      color: var(--text-primary);
      border-bottom-left-radius: 4px;
      padding: 0;
  }

  .message-actions {
      display: flex;
      gap: 6px;
      margin-top: 1rem;
      opacity: 0;
      transition: opacity var(--transition);
  }

  .message:hover .message-actions {
      opacity: 1;
  }

  .message-actions button {
      background: rgba(255, 255, 255, 0.05);
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--text-secondary);
      padding: 4px 10px;
      font-size: 12px;
      cursor: pointer;
      transition: background var(--transition), color var(--transition);
  }

  .message-actions button:hover {
      background: rgba(255, 255, 255, 0.1);
      color: var(--text-primary);
  }

  /* Code blocks inside assistant messages */
  .code-block-wrapper {
      background: #1e1e2e;
      border-radius: 10px;
      margin: 10px 0;
      overflow: hidden;
      border: 1px solid var(--border);
  }

  .code-block-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 6px 14px;
      background: rgba(255, 255, 255, 0.03);
      border-bottom: 1px solid var(--border);
      font-size: 12px;
      color: var(--text-secondary);
  }

  .code-block-header .copy-code-btn {
      background: none;
      border: 1px solid var(--border);
      border-radius: 4px;
      color: var(--text-secondary);
      padding: 2px 10px;
      font-size: 12px;
      cursor: pointer;
      transition: background var(--transition), color var(--transition);
  }

  .code-block-header .copy-code-btn:hover {
      background: rgba(255, 255, 255, 0.08);
      color: var(--text-primary);
  }

  .code-block-wrapper pre {
      margin: 0;
      padding: 14px;
      overflow-x: auto;
      font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
      font-size: 13px;
      line-height: 1.5;
      color: #e0e0e0;
  }

  .code-block-wrapper pre::-webkit-scrollbar {
      height: 4px;
  }

  .code-block-wrapper pre::-webkit-scrollbar-thumb {
      background: rgba(255, 255, 255, 0.2);
      border-radius: 4px;
  }

  .inline-code {
      background: rgba(255, 255, 255, 0.07);
      border-radius: 4px;
      padding: 2px 6px;
      font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
      font-size: 13px;
      color: #e6e6e6;
  }

  /* Empty state */
  #empty-state {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      height: 100%;
      text-align: center;
      padding: 40px 24px;
      animation: messageFadeIn 0.4s ease;
  }



  #empty-state .logo img {
      inline-size: 320px;
      object-fit: cover;
  }

  #empty-state .logo {
      width: 56px;
      height: 56px;
      background: var(--surface);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 28px;
      font-weight: 700;
      color: #fff;
      margin-bottom: 80px;
  }

  #empty-state h2 {
      font-size: 22px;
      font-weight: 600;
      color: var(--text-primary);
      margin-bottom: 8px;
  }

  #empty-state p {
      font-size: 14px;
      color: var(--text-secondary);
      margin-bottom: 28px;
  }

  .example-prompts {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      justify-content: center;
  }

  .example-prompt {
      background: var(--border);
      border: 1px solid var(--border);
      border-radius: 50px;
      padding: 12px 20px;
      font-size: 13px;
      color: var(--text-secondary);
      cursor: pointer;
      transition: background var(--transition), color var(--transition), border-color var(--transition);
  }

  .example-prompt:hover {
      background: rgba(255, 255, 255, 0.05);
      color: var(--text-primary);
      border-color: rgba(255, 255, 255, 0.15);
  }

  /* === INPUT AREA === */
  #input-area {
      padding: 12px 20px 20px;


  }

  #composer {
      max-width: 768px;
      margin: 0 auto;
      display: flex;
      justify-content: center;
      gap: 8px;
      align-items: center;
      background: var(--border);
      border-radius: 50px;
      padding: 8px 12px;
      border: 1px solid var(--border);
      transition: border-color var(--transition);
  }

  #composer:focus-within {
      border-color: rgba(255, 255, 255, 0.15);
  }

  #message-input {
      flex: 1;
      background: transparent;
      border: none;
      outline: none;
      color: var(--text-primary);
      font-size: 14px;
      line-height: 1.5;
      padding: 6px 4px;
      resize: none;
      max-height: 200px;
      font-family: inherit;
  }

  #message-input::placeholder {
      color: var(--text-secondary);
  }

  #message-input::-webkit-scrollbar {
      width: 4px;
  }

  #message-input::-webkit-scrollbar-thumb {
      background: rgba(255, 255, 255, 0.2);
      border-radius: 4px;
  }

  #char-count {
      font-size: 11px;
      color: var(--text-secondary);
      white-space: nowrap;
      padding: 2px 4px;
      display: none;
  }

  #send-btn {
      background: #fff;
      border: none;
      border-radius: 50px;

      color: var(--bg);
      font-size: 14px;
      cursor: pointer;
      transition: background var(--transition), opacity var(--transition);
      display: flex;
      align-items: center;
      justify-content: center;
      min-width: 44px;
      min-height: 38px;
  }

  #send-btn:hover:not(:disabled) {
      background: var(--text-secondary);
  }

  #send-btn:disabled {
      opacity: 0.5;
      cursor: not-allowed;
  }



  @keyframes dots {

      0%,
      20% {
          opacity: 0;
      }

      40% {
          opacity: 0.5;
      }

      60%,
      100% {
          opacity: 1;
      }
  }

  /* === TOAST === */
  #toast {
      position: fixed;
      bottom: 80px;
      right: 20px;
      background: var(--surface);
      color: var(--text-primary);
      padding: 12px 20px;
      border-radius: 10px;
      border: 1px solid var(--border);
      font-size: 13px;
      box-shadow: var(--shadow);
      z-index: 100;
      transform: translateY(20px);
      opacity: 0;
      transition: transform 0.3s ease, opacity 0.3s ease;
      pointer-events: none;
  }

  #toast.show {
      transform: translateY(0);
      opacity: 1;
  }

  #toast.error {
      border-color: #e74c3c;
  }

  #toast.success {
      border-color: var(--accent);
  }

  /* === SCROLL TO BOTTOM === */
  #scroll-to-bottom {
      position: absolute;
      bottom: 80px;
      right: 24px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 50%;
      width: 40px;
      height: 40px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 18px;
      color: var(--text-primary);
      cursor: pointer;
      box-shadow: var(--shadow);
      opacity: 0;
      transform: translateY(10px);
      transition: opacity 0.3s ease, transform 0.3s ease, background var(--transition);
      z-index: 5;
  }

  #scroll-to-bottom.visible {
      opacity: 1;
      transform: translateY(0);
  }

  #scroll-to-bottom:hover {
      background: rgba(255, 255, 255, 0.08);
  }

  /* === TYPING INDICATOR === */
  .typing-indicator {
      display: flex;
      gap: 4px;
      padding: 4px 8px;
      align-items: center;
  }

  .typing-indicator span {
      width: 8px;
      height: 8px;
      background: var(--text-secondary);
      border-radius: 50%;
      animation: typingBounce 1.4s infinite ease-in-out;
  }

  .typing-indicator span:nth-child(1) {
      animation-delay: 0s;
  }

  .typing-indicator span:nth-child(2) {
      animation-delay: 0.2s;
  }

  .typing-indicator span:nth-child(3) {
      animation-delay: 0.4s;
  }

  @keyframes typingBounce {

      0%,
      60%,
      100% {
          transform: translateY(0);
      }

      30% {
          transform: translateY(-6px);
      }
  }

  /* === OVERLAY === */
  #sidebar-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.5);
      backdrop-filter: blur(4px);
      z-index: 15;
  }

  /* === RESPONSIVE === */
  @media (max-width: 768px) {
      #sidebar {
          position: fixed;
          left: 0;
          top: 0;
          bottom: 0;
          width: 280px;
          transform: translateX(-100%);
          z-index: 25;
          border-right: none;
          box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
      }

      #sidebar.open {
          transform: translateX(0);
      }

      #sidebar-overlay.active {
          display: block;
      }

      #chat-header .sidebar-toggle-btn {
          display: flex;
      }

      #chat-title {
          font-size: 13px;
      }

      #messages {
          padding: 16px 16px 0;
      }

      .message-bubble {
          max-width: 95%;
          padding: 12px 14px;
          font-size: 13px;
      }

      #input-area {
          padding: 8px 12px 16px;
      }

      #composer {
          padding: 6px 10px;
      }

      #send-btn {
          padding: 6px 12px;
          min-width: 38px;
          min-height: 34px;
      }

      #scroll-to-bottom {
          bottom: 70px;
          right: 12px;
          width: 36px;
          height: 36px;
          font-size: 16px;
      }

      #empty-state .logo {
          width: 48px;
          height: 48px;
          font-size: 22px;
      }

      #empty-state h2 {
          font-size: 18px;
      }

      .example-prompt {
          font-size: 12px;
          padding: 10px 14px;
      }
  }

  @media (min-width: 769px) {
      #chat-header .sidebar-toggle-btn {
          display: none;
      }
  }














  .code-block-wrapper {
      margin: 12px 0;
      border: 1px solid rgba(255, 255, 255, 0.12);
      border-radius: 12px;
      overflow: hidden;
      background: #0f172a;
  }

  .code-block-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 8px 12px;
      background: rgba(255, 255, 255, 0.06);
      font-size: 13px;
      color: #cbd5e1;
      border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .code-block-header span {
      font-weight: 600;
      text-transform: lowercase;
  }

  .copy-code-btn {
      border: none;
      background: #1e293b;
      color: #e2e8f0;
      padding: 6px 10px;
      border-radius: 8px;
      cursor: pointer;
      font-size: 12px;
  }

  .copy-code-btn:hover {
      background: #334155;
  }

  .code-block-wrapper pre {
      margin: 0;
      padding: 14px;
      overflow-x: auto;
      overflow-y: hidden;
      /* cleaner horizontal scroll */
      background: #0b1220;

      /* Smooth scrolling */
      scroll-behavior: smooth;

      /* Firefox scrollbar */
      scrollbar-width: thin;
      scrollbar-color: #334155 transparent;
  }

  /* Chrome, Edge, Safari */
  .code-block-wrapper pre::-webkit-scrollbar {
      height: 8px;
      /* horizontal scrollbar height */
  }

  .code-block-wrapper pre::-webkit-scrollbar-track {
      background: transparent;
      /* transparent background */
  }

  .code-block-wrapper pre::-webkit-scrollbar-thumb {
      background-color: #334155;
      /* scrollbar handle */
      border-radius: 999px;
      /* fully rounded */
      border: 2px solid #0b1220;
      /* creates padding effect */
  }

  .code-block-wrapper pre::-webkit-scrollbar-thumb:hover {
      background-color: #475569;
      /* lighter on hover */
  }


  .code-block-wrapper code {
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
      font-size: 14px;
      line-height: 1.6;
  }



















  /* Typography for Assistant Responses */
  .message.assistant .message-bubble {
      line-height: 1.6;
      color: #ececec;
      /* Adjust based on your theme */
      font-size: 15px;
      word-wrap: break-word;
  }

  /* Headings */
  .message-bubble h1,
  .message-bubble h2,
  .message-bubble h3,
  .message-bubble h4 {
      margin-top: 24px;
      margin-bottom: 12px;
      font-weight: 600;
      line-height: 1.25;
      color: #fff;
  }

  .message-bubble h1 {
      font-size: 1.5em;
      border-bottom: 1px solid #3e3f4b;
      padding-bottom: 0.3em;
  }

  .message-bubble h2 {
      font-size: 1.25em;
      border-bottom: 1px solid #3e3f4b;
      padding-bottom: 0.3em;
  }

  .message-bubble h3 {
      font-size: 1.1em;
  }

  /* Paragraphs and Spacing */
  .message-bubble p {
      margin-top: 0;
      margin-bottom: 16px;
  }

  .message-bubble p:last-child {
      margin-bottom: 0;
  }

  /* Lists */
  .message-bubble ul,
  .message-bubble ol {
      margin-top: 0;
      margin-bottom: 16px;
      padding-left: 2em;
  }

  .message-bubble li {
      margin-bottom: 4px;
  }

  .message-bubble li>ul,
  .message-bubble li>ol {
      margin-top: 4px;
      margin-bottom: 0;
  }

  /* Inline Code */
  .message-bubble :not(pre)>code {
      background-color: rgba(255, 255, 255, 0.1);
      padding: 0.2em 0.4em;
      border-radius: 6px;
      font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
      font-size: 85%;
  }

  /* Blockquotes */
  .message-bubble blockquote {
      margin: 0 0 16px 0;
      padding: 0 1em;
      color: #9ca3af;
      border-left: 0.25em solid #4b5563;
  }

  /* Tables */
  .message-bubble table {
      border-collapse: collapse;
      width: 100%;
      margin-bottom: 16px;
      font-size: 14px;
  }

  .message-bubble th,
  .message-bubble td {
      border: 1px solid #3e3f4b;
      padding: 8px 12px;
  }

  .message-bubble th {
      background-color: rgba(255, 255, 255, 0.05);
      font-weight: 600;
  }

  /* Horizontal Rule */
  .message-bubble hr {
      height: 1px;
      background-color: #3e3f4b;
      border: none;
      margin: 24px 0;
  }

  /* Links */
  .message-bubble a {
      color: #10a37f;
      text-decoration: none;
  }

  .message-bubble a:hover {
      text-decoration: underline;
  }

















  /* Share button in header */
  .header-icon-btn {
      padding: 6px;
      border-radius: 6px;
      cursor: pointer;
      display: flex;
      align-items: center;
  }

  .header-icon-btn:hover {
      background: rgba(255, 255, 255, 0.06);
  }

  /* Modal overlay */
  #share-modal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.6);
      backdrop-filter: blur(4px);
      z-index: 200;
  }

  /* Modal container */
  #share-modal {
      display: none;
      position: fixed;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);

      width: 90%;
      max-width: 420px;
      background: var(--surface);
      border-radius: 12px;
      padding: 20px;
      border: 1px solid var(--border);
      z-index: 201;
  }

  /* Modal header */
  .share-modal-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 14px;
  }

  .share-modal-header h3 {
      font-size: 18px;
      color: var(--text-primary);
  }

  #share-modal-close {
      background: none;
      border: none;
      cursor: pointer;
      color: var(--text-secondary);
  }

  #share-modal-close:hover {
      color: var(--text-primary);
  }

  /* Link box */
  .share-link-box {
      display: flex;
      gap: 10px;
      margin: 10px 0 16px;
  }

  #share-link-input {
      flex: 1;
      padding: 8px 10px;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--text-primary);
  }

  #share-link-copy {
      padding: 8px 12px;
      border: 1px solid var(--border);
      border-radius: 6px;
      background: rgba(255, 255, 255, 0.05);
      color: var(--text-secondary);
      cursor: pointer;
  }

  #share-link-copy:hover {
      background: rgba(255, 255, 255, 0.1);
      color: var(--text-primary);
  }












  .edit-wrap {
      width: 100%;
  }

  .edit-textarea {
      width: 100%;
      min-height: 80px;
      resize: vertical;
      padding: 10px;
      border-radius: 10px;
      border: 1px solid rgba(255, 255, 255, 0.15);
      background: rgba(0, 0, 0, 0.25);
      color: inherit;
      outline: none;
      font: inherit;
  }

  .edit-actions {
      display: flex;
      gap: 8px;
      margin-top: 8px;
      justify-content: flex-end;
  }

  .edit-actions button {
      padding: 8px 12px;
      border-radius: 10px;
      border: 1px solid rgba(255, 255, 255, 0.15);
      background: rgba(255, 255, 255, 0.06);
      color: inherit;
      cursor: pointer;
  }

  .edit-actions button:hover {
      background: rgba(255, 255, 255, 0.10);
  }