:root {
  color-scheme: dark;
  --bg: #101418;
  --panel: #171d24;
  --panel-2: #202833;
  --text: #ecf1f8;
  --muted: #9cadc2;
  --accent: #5d8bff;
  --danger: #ff5d6b;
  --border: #2a3443;
  --user-bubble: #3a3f48;
  --bot-font: Inter, Segoe UI, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: Inter, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.conversation-search-wrap {
  position: relative;
}

.conversation-search-wrap i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 13px;
}

.conversation-search-wrap input {
  width: 100%;
  border: 1px solid var(--border);
  background: #121920;
  color: var(--text);
  border-radius: 10px;
  height: 38px;
  padding: 0 10px 0 34px;
  outline: none;
}

.sidebar-helper {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
  margin-top: -6px;
}

.profile-footer {
  margin-top: auto;
  border: 1px solid var(--border);
  background: #1a212c;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.profile-footer-text {
  min-width: 0;
}

.profile-footer .username,
.profile-footer .plan {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-footer .plan {
  white-space: normal;
  line-height: 1.25;
}

.brand {
  font-size: 24px;
  font-weight: 700;
}

.conversations {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conversation-item {
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 8px 8px 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.conversation-item.active {
  border-color: #4a6dbd;
  background: #152031;
}

.conversation-title {
  flex: 1;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 6px;
}

.conversation-item:hover .conversation-title {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.menu-wrap {
  position: relative;
}

.menu-btn {
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  opacity: 0;
  padding: 0;
  width: 18px;
  height: 18px;
}

.conversation-item:hover .menu-btn {
  opacity: 1;
}

.empty-conversation {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.menu {
  position: absolute;
  top: 34px;
  right: 0;
  width: 140px;
  background: #101720;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  z-index: 5;
}

.menu button {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 10px;
  cursor: pointer;
}

.menu button:hover {
  background: #1b2533;
}

.chat-area {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
  position: relative;
}

.chat-topbar {
  position: sticky;
  top: 0;
  z-index: 7;
  display: flex;
  justify-content: flex-start;
  padding: 8px min(7vw, 84px);
  background: linear-gradient(to bottom, rgba(16, 20, 24, 0.98), rgba(16, 20, 24, 0.76));
}

.model-picker-wrap {
  position: relative;
  display: inline-block;
  padding-bottom: 170px;
  margin-bottom: -170px;
}

.model-picker {
  border: 1px solid var(--border);
  background: #151e29;
  border-radius: 12px;
  color: var(--text);
  text-align: left;
  padding: 8px 12px;
  cursor: pointer;
}

.model-picker-name {
  font-weight: 700;
  font-size: 13px;
}

.model-picker-desc {
  font-size: 11px;
  color: var(--muted);
}

.model-hover-panel {
  position: absolute;
  left: 0;
  top: 100%;
  width: 260px;
  border: 1px solid var(--border);
  background: #121a25;
  border-radius: 12px;
  padding: 8px;
  display: none;
  z-index: 15;
}

.model-picker-wrap:hover .model-hover-panel {
  display: block;
}

.model-hover-title {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 4px 6px;
}

.model-hover-option {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f1620;
  color: var(--text);
  text-align: left;
  padding: 8px;
  font-size: 12px;
  cursor: pointer;
}

.model-hover-option + .model-hover-option {
  margin-top: 6px;
}

.model-hover-option.active {
  border-color: var(--accent);
}

.messages {
  flex: 1;
  overflow-y: auto;
  width: 100%;
  margin: 0;
  padding: 10px min(7vw, 84px) 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-thread {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 900px;
}

.message-thread .message.user {
  align-self: flex-end;
  margin-bottom: 1px;
}

.message-thread .message.assistant {
  align-self: flex-start;
}

.message {
  max-width: 900px;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.45;
  white-space: normal;
}

.message.user {
  align-self: flex-end;
  background: var(--user-bubble);
  color: #f1f4f8;
}

.message.assistant {
  align-self: flex-start;
  background: #1f2836;
  font-family: var(--bot-font);
}

.message.system {
  align-self: center;
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--border);
}

.typing-message {
  align-self: flex-start;
  background: rgba(21, 31, 43, 0.72);
  padding: 10px 12px;
}

.message-meta {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
}

.message-credits {
  font-size: 11px;
  color: var(--muted);
  margin-right: auto;
}

.copy-wrap {
  position: relative;
}

.copy-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: #c8d4e6;
  cursor: pointer;
}

.copy-menu {
  position: absolute;
  right: 0;
  top: 32px;
  min-width: 190px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #111922;
  overflow: hidden;
  z-index: 20;
}

.copy-menu button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 10px;
  cursor: pointer;
}

.copy-menu button:hover {
  background: #1a2534;
}

.typing-dots {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
}

.assistant-status {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.input-bar {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  display: flex;
  gap: 10px;
  background: rgba(18, 25, 32, 0.92);
  backdrop-filter: blur(8px);
  align-items: flex-end;
}

.composer-shell {
  width: 100%;
  padding: 10px 20px 14px;
  border-top: 1px solid rgba(42, 52, 67, 0.5);
  background: linear-gradient(to top, rgba(16, 20, 24, 1), rgba(16, 20, 24, 0.86));
}

.composer-helper {
  width: min(100%, 900px);
  margin: 8px auto 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.jump-bottom {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 108px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #152031;
  color: #d9e7fb;
  cursor: pointer;
  z-index: 8;
}

.overlay-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.54);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 70;
}

.overlay-dialog {
  width: min(92vw, 720px);
  background: #171d25;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
}

.search-dialog {
  padding: 0;
  overflow: hidden;
}

.search-header {
  display: grid;
  grid-template-columns: 18px 1fr 30px;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.search-header i {
  color: var(--muted);
}

.search-header input {
  border: none;
  background: transparent;
  color: var(--text);
  outline: none;
  font-size: 15px;
}

.overlay-close {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.search-results {
  max-height: 62vh;
  overflow-y: auto;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.search-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #141b25;
  padding: 10px;
  cursor: pointer;
}

.search-item-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.search-item-sub {
  font-size: 12px;
  color: var(--muted);
}

.delete-dialog h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

.delete-text {
  color: var(--muted);
  margin-bottom: 16px;
}

.delete-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.model-title {
  font-weight: 700;
  margin-bottom: 10px;
}

.model-options {
  display: grid;
  gap: 8px;
}

.model-option {
  width: 100%;
  border: 1px solid var(--border);
  background: #111923;
  color: var(--text);
  border-radius: 10px;
  text-align: left;
  padding: 10px;
  cursor: pointer;
}

.model-option.active {
  border-color: var(--accent);
}

.model-option small {
  color: var(--muted);
  display: block;
  margin-top: 2px;
}

textarea {
  flex: 1;
  border-radius: 14px;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 12px 10px;
  resize: none;
  outline: none;
  min-height: 56px;
  max-height: 260px;
  font-size: 15px;
  line-height: 1.45;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.icon-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 999px;
  flex-shrink: 0;
}

.attach-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #1a2330;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.attachment-preview {
  width: min(100%, 900px);
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #151d28;
  color: var(--muted);
  font-size: 13px;
}

.attachment-remove {
  margin-left: auto;
  border: none;
  background: transparent;
  color: #c7d3e3;
  cursor: pointer;
}

.msg-content {
  display: block;
}

.assistant-heading {
  font-size: 20px;
  font-weight: 800;
  margin: 4px 0 6px;
}

.assistant-subtitle {
  font-size: 16px;
  font-weight: 700;
  margin: 4px 0 6px;
}

.assistant-paragraph {
  margin: 3px 0;
  line-height: 1.5;
}

.assistant-list {
  list-style: disc;
  margin: 4px 0 4px 18px;
  padding: 0;
}

.assistant-list li {
  position: static;
  padding-left: 0;
  margin: 2px 0;
}

.assistant-pre {
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0f141c;
  overflow-x: auto;
}

.assistant-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  padding: 12px;
}

.welcome {
  margin: auto;
  text-align: center;
  color: #dbe9ff;
  opacity: 0.9;
  font-size: 22px;
  font-weight: 600;
}

.btn.secondary {
  background: #1a2330;
  color: var(--text);
  border-color: var(--border);
}

.btn.discord {
  display: inline-block;
  background: #5865f2;
  color: #fff;
}

.btn.danger {
  background: rgba(255, 93, 107, 0.1);
  color: #ff8e97;
  border-color: rgba(255, 93, 107, 0.25);
}

.account,
.login-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: #121920;
}

.account-top {
  display: flex;
  gap: 10px;
  align-items: center;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  object-fit: cover;
  background: #0d131a;
}

.username {
  font-weight: 700;
}

.plan,
.usage {
  color: var(--muted);
  font-size: 13px;
}

.usage {
  margin: 10px 0 14px;
}

.prefs-section {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: grid;
  gap: 8px;
}

.settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.settings-dialog {
  width: min(95vw, 980px);
  height: min(88vh, 760px);
  background: #191f29;
  border: 1px solid var(--border);
  border-radius: 18px;
  display: grid;
  grid-template-columns: 220px 1fr;
  overflow: hidden;
}

.settings-nav {
  background: #141a22;
  border-right: 1px solid var(--border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-close {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  margin-bottom: 8px;
}

.settings-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 10px;
  border-radius: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  text-align: left;
}

.settings-tab.active {
  background: #2c333e;
}

.settings-content {
  padding: 18px;
  overflow: auto;
}

.settings-panel h2 {
  margin-top: 0;
  margin-bottom: 14px;
}

.settings-panel {
  display: grid;
  gap: 10px;
}

.plan-options {
  display: grid;
  gap: 10px;
}

.plan-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #141b25;
  padding: 12px;
}

.plan-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.plan-card-title {
  font-weight: 700;
}

.plan-card-price {
  color: var(--muted);
  font-size: 13px;
}

.plan-card-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.settings-actions {
  position: sticky;
  bottom: 0;
  padding-top: 12px;
  background: linear-gradient(to top, rgba(25, 31, 41, 1), rgba(25, 31, 41, 0.1));
}

.account-actions {
  display: flex;
  gap: 8px;
}

.prefs-gear {
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 10px;
}

.prefs-title {
  margin: 0 0 4px;
  font-size: 14px;
}

.prefs-label {
  font-size: 12px;
  color: var(--muted);
}

.prefs-select {
  width: 100%;
  border: 1px solid var(--border);
  background: #0f151d;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
}

.prefs-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}

.prefs-switch input {
  accent-color: var(--accent);
}

.prefs-save {
  margin-top: 4px;
  width: 100%;
}

.hidden {
  display: none !important;
}

@media (max-width: 920px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .messages {
    width: 100%;
    padding: 16px 12px 10px;
  }

  .composer-shell {
    padding: 10px 10px 14px;
  }
}
