/* =========================================
   RESET
========================================= */

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Helvetica,
    Arial,
    sans-serif;

  background: #212121;
  color: #ececec;

  overflow: hidden;
}

button,
textarea,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}


/* =========================================
   ACCESSIBILITY
========================================= */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* =========================================
   APP
========================================= */

.app {
  display: flex;
  width: 100%;
  height: 100vh;
}


/* =========================================
   SIDEBAR
========================================= */

.sidebar {
  width: 260px;
  flex-shrink: 0;

  display: flex;
  flex-direction: column;

  padding: 12px;

  background: #171717;
}

.new-chat {
  width: 100%;

  display: flex;
  align-items: center;
  gap: 12px;

  padding: 10px 12px;

  border: 0;
  border-radius: 8px;

  background: transparent;
  color: #ececec;

  font-size: 14px;

  cursor: pointer;

  transition:
    background 0.15s ease;
}

.new-chat:hover {
  background: #2a2a2a;
}

.new-chat-icon {
  width: 28px;
  height: 28px;

  display: flex;
  align-items: center;
  justify-content: center;

  border: 1px solid #555;
  border-radius: 7px;

  font-size: 19px;
  font-weight: 300;
}

.sidebar-spacer {
  flex: 1;
}

.sidebar-brand {
  padding: 8px 12px;

  color: #555;
  font-size: 11px;
}


/* =========================================
   MAIN
========================================= */

.main {
  min-width: 0;
  flex: 1;

  display: flex;
  flex-direction: column;
}


/* =========================================
   HEADER
========================================= */

.header {
  height: 56px;
  flex-shrink: 0;

  display: flex;
  align-items: center;

  padding: 0 16px;

  border-bottom: 1px solid #303030;

  background: #212121;
}

.brand {
  padding: 6px 8px;

  border-radius: 8px;

  font-size: 17px;
  font-weight: 500;
}

.brand-chevron {
  margin-left: 5px;

  color: #666;
  font-size: 13px;
}

.mobile-menu {
  display: none;

  margin-right: 10px;

  border: 0;
  background: transparent;

  color: #aaa;

  font-size: 18px;

  cursor: pointer;
}


/* =========================================
   CHAT
========================================= */

.chat {
  flex: 1;

  overflow-y: auto;

  scroll-behavior: smooth;
}

.chat:empty {
  display: block;
}


/* =========================================
   MESSAGES
========================================= */

.message {
  width: 100%;
}

.message-inner {
  width: 100%;
  max-width: 800px;

  display: flex;
  gap: 16px;

  margin: 0 auto;
  padding: 24px 20px;
}

.user-message {
    justify-content: flex-end;
}

.user-bubble {
    max-width: min(680px, 78%);
    padding: 11px 16px;
    border-radius: 20px 20px 5px 20px;
    background: #2f2f2f;
    color: #fff;
}

.ai-avatar {
  width: 30px;
  height: 30px;
  flex-shrink: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  margin-top: 1px;

  border-radius: 50%;

  background: #fff;
  color: #111;

  font-size: 9px;
  font-weight: 700;
}

.ai-content {
  min-width: 0;
  flex: 1;

  font-size: 15px;
  line-height: 1.65;
}

.ai-content p {
  margin: 0 0 14px;
}

.ai-content p:last-child {
  margin-bottom: 0;
}


/* =========================================
   TYPING
========================================= */

.typing {
  display: flex;
  align-items: center;
  gap: 4px;

  color: #8b8b8b;
}

.typing-label {
  margin-right: 1px;
}

.typing-dot {
  animation: typing 1.2s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    opacity: 0.25;
  }

  30% {
    opacity: 1;
  }
}


/* =========================================
   SEARCH CARDS
========================================= */

.search-card {
  width: 100%;
  max-width: 520px;

  display: flex;
  align-items: center;
  gap: 12px;

  margin-top: 18px;
  padding: 12px;

  border: 1px solid #414141;
  border-radius: 12px;

  background: #292929;

  color: inherit;
  text-decoration: none;

  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}

.search-card:hover {
  background: #333;
  border-color: #555;

  transform: translateY(-1px);
}

.source-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 9px;

  background: #3a3a3a;

  color: #eee;

  font-size: 17px;
  font-weight: 600;
}

.source-copy {
  min-width: 0;
  flex: 1;
}

.source-title {
  color: #eee;

  font-size: 13px;
  font-weight: 500;
}

.source-description {
  margin-top: 2px;

  overflow: hidden;

  color: #777;

  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-arrow {
  flex-shrink: 0;

  color: #777;

  font-size: 16px;
}


/* =========================================
   SNIPPET
========================================= */

.snippet {
  max-width: 600px;

  margin-top: 16px;
  padding: 13px 15px;

  border-left: 2px solid #555;

  background: #282828;

  color: #aaa;

  font-size: 13px;
  line-height: 1.6;
}

.snippet-label {
  margin-bottom: 5px;

  color: #777;

  font-size: 10px;
  font-weight: 600;

  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.snippet a {
  color: #aaa;
}


/* =========================================
   SOURCE LINKS
========================================= */

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;

  margin-top: 10px;
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  padding: 6px 9px;

  border: 1px solid #3d3d3d;
  border-radius: 7px;

  background: #292929;

  color: #aaa;

  font-size: 11px;
  text-decoration: none;

  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.source-link:hover {
  background: #343434;
  color: #eee;
}


/* =========================================
   DEEP RESEARCH
========================================= */

.deep-research {
  display: inline-flex;
  align-items: center;
  gap: 7px;

  margin-top: 16px;
  padding: 8px 11px;

  border-radius: 8px;

  background: #fff;
  color: #111;

  font-size: 11px;
  font-weight: 600;

  text-decoration: none;

  transition:
    background 0.15s ease,
    transform 0.15s ease;
}

.deep-research:hover {
  background: #e5e5e5;
  transform: translateY(-1px);
}


/* =========================================
   COMPOSER
========================================= */

.composer-area {
  width: 100%;
}

.composer-container {
  width: 100%;
  max-width: 800px;

  margin: 0 auto;
  padding: 0 20px 12px;
}


/* =========================================
   PROMPTS
========================================= */

.suggestions {
  margin-bottom: 12px;
}

.suggestions-heading {
  margin: 0 0 7px 2px;

  color: #666;

  font-size: 11px;
}

.prompt-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.prompt-card {
  padding: 10px 12px;

  border: 1px solid #383838;
  border-radius: 10px;

  background: #272727;

  color: #ddd;

  text-align: left;

  cursor: pointer;

  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

.prompt-card:hover {
  background: #303030;
  border-color: #505050;
}

.prompt-title {
  font-size: 12px;
}

.prompt-description {
  margin-top: 2px;

  color: #666;

  font-size: 10px;
}


/* =========================================
   COMPOSER
========================================= */

.composer {
  position: relative;

  border: 1px solid #424242;
  border-radius: 16px;

  background: #2f2f2f;

  box-shadow:
    0 8px 30px rgba(0, 0, 0, 0.18);
}

.message-input {
  width: 100%;

  display: block;

  min-height: 52px;
  max-height: 190px;

  padding: 15px 15px 48px;

  border: 0;
  outline: 0;

  resize: none;

  background: transparent;

  color: #eee;

  font-size: 14px;
  line-height: 1.5;
}

.message-input::placeholder {
  color: #666;
}


/* =========================================
   TOOLBAR
========================================= */

.composer-toolbar {
  position: absolute;

  left: 9px;
  right: 9px;
  bottom: 8px;

  display: flex;
  align-items: center;
  justify-content: space-between;
}

.source-control {
  position: relative;
}

.source-select {
  appearance: none;

  padding: 7px 28px 7px 10px;

  border: 1px solid #4d4d4d;
  border-radius: 7px;

  outline: 0;

  background: #3a3a3a;

  color: #ccc;

  font-size: 11px;

  cursor: pointer;
}

.select-arrow {
  position: absolute;

  top: 50%;
  right: 9px;

  pointer-events: none;

  color: #777;

  font-size: 9px;

  transform: translateY(-50%);
}


/* =========================================
   SEND
========================================= */

.send-button {
  width: 30px;
  height: 30px;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0;

  border: 0;
  border-radius: 8px;

  background: #fff;
  color: #111;

  cursor: pointer;

  transition:
    background 0.15s ease,
    transform 0.15s ease;
}

.send-button:hover:not(:disabled) {
  background: #ddd;
}

.send-button:active:not(:disabled) {
  transform: scale(0.95);
}

.send-button:disabled {
  background: #676767;
  color: #303030;

  cursor: default;
}


/* =========================================
   FOOTER
========================================= */

.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  min-height: 31px;

  color: #555;

  font-size: 10px;
  text-align: center;
}

.footer a {
  color: #555;
  text-decoration: none;
}

.footer a:hover {
  color: #999;
}

.footer-divider {
  color: #444;
}

.help-button {
  width: 18px;
  height: 18px;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0;

  border: 1px solid #555;
  border-radius: 50%;

  background: transparent;

  color: #777;

  font-size: 10px;
  font-weight: 600;

  cursor: pointer;

  transition:
    color 0.15s ease,
    border-color 0.15s ease;
}

.help-button:hover {
  border-color: #888;
  color: #ddd;
}


/* =========================================
   MODAL
========================================= */

.modal {
  position: fixed;

  inset: 0;

  z-index: 100;

  display: none;

  align-items: center;
  justify-content: center;

  padding: 20px;
}

.modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;

  inset: 0;

  background: rgba(0, 0, 0, 0.72);

  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;

  width: 100%;
  max-width: 500px;

  overflow: hidden;

  border: 1px solid #444;
  border-radius: 16px;

  background: #292929;

  box-shadow:
    0 25px 80px rgba(0, 0, 0, 0.45);

  animation: modal-in 0.18s ease-out;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 15px 18px;

  border-bottom: 1px solid #404040;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title h2 {
  margin: 0;

  color: #eee;

  font-size: 14px;
  font-weight: 600;
}

.modal-icon {
  width: 27px;
  height: 27px;

  display: flex;
  align-items: center;
  justify-content: center;

  border: 1px solid #555;
  border-radius: 50%;

  color: #bbb;

  font-size: 11px;
  font-weight: 600;
}

.close-button {
  width: 30px;
  height: 30px;

  border: 0;
  border-radius: 7px;

  background: transparent;

  color: #777;

  font-size: 21px;

  cursor: pointer;
}

.close-button:hover {
  background: #383838;
  color: #eee;
}

.modal-content {
  padding: 21px;

  color: #bbb;

  font-size: 13px;
  line-height: 1.7;
}

.modal-content p {
  margin: 0 0 14px;
}

.modal-content strong {
  color: #eee;
}

.history-box {
  margin: 18px 0;

  padding: 13px 15px;

  border: 1px solid #414141;
  border-radius: 10px;

  background: #222;

  color: #888;

  font-style: italic;
}

.history-box p {
  margin: 0 0 5px;
}

.history-box p:last-child {
  margin-bottom: 0;
}

.modal-small {
  color: #666;

  font-size: 10px;
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 12px 18px;

  border-top: 1px solid #404040;

  color: #555;

  font-size: 10px;
}

.modal-footer a {
  color: #666;
  text-decoration: none;
}

.modal-footer a:hover {
  color: #aaa;
}


/* =========================================
   MOBILE
========================================= */

@media (max-width: 700px) {

  .sidebar {
    display: none;
  }

  .mobile-menu {
    display: block;
  }

  .message-inner {
    padding: 18px 14px;
  }

  .user-bubble {
    max-width: 85%;
  }

  .composer-container {
    padding: 0 10px 8px;
  }

  .prompt-list {
    grid-template-columns: 1fr;
  }

  .footer {
    padding: 3px 10px 0;
  }

  .footer > span:first-child {
    max-width: 260px;
  }

}


/* =========================================
   REDUCED MOTION
========================================= */

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

}