:root {
  color-scheme: dark;
  --bg: #08090d;
  --panel: #0b0d13;
  --panel-2: #11141d;
  --line: #202637;
  --text: #f3f7ff;
  --muted: #98a2b8;
  --soft: #c8d1e6;
  --accent: #35d0ff;
  --accent-2: #8b5cf6;
  --danger: #ff647c;
  --good: #54e3a6;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
  --font-scale: 1;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(53, 208, 255, 0.09), transparent 32rem),
    linear-gradient(160deg, #030407 0%, #06070b 52%, #090d15 100%);
  color: var(--text);
  font-size: calc(16px * var(--font-scale));
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(20, 24, 36, 0.78), rgba(6, 8, 13, 0.82)),
    rgba(8, 10, 15, 0.72);
  backdrop-filter: blur(20px);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.04);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
}

.logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(53, 208, 255, 0.24), rgba(139, 92, 246, 0.32)),
    #0d111a;
  box-shadow: 0 0 24px rgba(53, 208, 255, 0.18);
  color: var(--text);
  font-weight: 800;
}

.brand h1,
.auth-card h1 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0;
}

.brand p,
.auth-card p,
.muted {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn,
.chip,
.danger-btn {
  min-height: 40px;
  border-radius: 8px;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease,
    color 0.16s ease;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #051018;
  font-weight: 800;
  box-shadow: 0 10px 28px rgba(53, 208, 255, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.secondary-btn,
.ghost-btn,
.chip,
.icon-btn,
.danger-btn {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.055);
  color: var(--soft);
}

.secondary-btn,
.danger-btn {
  padding: 0 14px;
}

.danger-btn {
  color: #ffd7de;
  border-color: rgba(255, 100, 124, 0.32);
}

.ghost-btn {
  padding: 0 12px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--muted);
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.chip:hover,
.icon-btn:hover,
.danger-btn:hover {
  transform: translateY(-1px);
}

.chat-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.chat-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--soft);
  text-align: left;
  position: relative;
  overflow: hidden;
}

.chat-item.active,
.chat-item:hover {
  border-color: rgba(53, 208, 255, 0.22);
  background: rgba(53, 208, 255, 0.08);
}

.chat-item::before {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  transform: translateX(-120%);
  transition: transform 0.5s ease;
}

.chat-item:hover::before {
  transform: translateX(120%);
}

.chat-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.chat-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.sidebar-footer {
  display: grid;
  gap: 8px;
}

.main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 10, 15, 0.55);
  backdrop-filter: blur(20px);
}

.topbar h2 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
}

.top-actions,
.mode-row,
.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-select,
.input,
.textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  outline: none;
}

.custom-select {
  position: relative;
  width: 100%;
}

.custom-select.compact {
  width: 190px;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04)),
    rgba(255, 255, 255, 0.05);
  color: var(--text);
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.custom-select .chevron {
  color: var(--accent);
  transition: transform 0.18s ease;
}

.custom-select.open .chevron {
  transform: rotate(180deg);
}

.custom-options {
  position: absolute;
  right: 0;
  left: 0;
  z-index: 25;
  display: grid;
  gap: 5px;
  min-width: 190px;
  max-height: 260px;
  overflow: auto;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(12, 15, 23, 0.96);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(20px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px) scale(0.98);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.custom-select.open .custom-options {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.custom-option {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 7px;
  background: transparent;
  color: var(--soft);
  text-align: left;
}

.custom-option:hover,
.custom-option.selected {
  background: rgba(53, 208, 255, 0.12);
  color: var(--text);
}

.mode-select,
.input {
  height: 40px;
  padding: 0 12px;
}

.textarea {
  min-height: 90px;
  padding: 12px;
  resize: vertical;
}

.messages {
  overflow: auto;
  padding: 28px min(6vw, 72px);
}

.welcome {
  display: grid;
  place-items: center;
  min-height: 100%;
}

.welcome-inner {
  width: min(780px, 100%);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.welcome h2 {
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 4.8rem);
  line-height: 1;
}

.welcome p {
  max-width: 620px;
  margin: 18px 0 28px;
  color: var(--soft);
  font-size: 1.08rem;
  line-height: 1.6;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.suggestion {
  min-height: 88px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03)),
    rgba(13, 16, 24, 0.74);
  color: var(--text);
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.suggestion:hover {
  transform: translateY(-2px);
  border-color: rgba(53, 208, 255, 0.32);
  background:
    linear-gradient(135deg, rgba(53, 208, 255, 0.12), rgba(139, 92, 246, 0.08)),
    rgba(13, 16, 24, 0.78);
}

.suggestion strong {
  display: block;
  margin-bottom: 5px;
}

.suggestion span {
  color: var(--muted);
  font-size: 0.9rem;
}

.message {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 14px;
  width: min(900px, 100%);
  margin: 0 auto 24px;
  animation: rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent);
  font-weight: 800;
}

.message.user .avatar {
  color: var(--text);
  background: rgba(139, 92, 246, 0.22);
}

.bubble {
  min-width: 0;
  padding-top: 6px;
  color: var(--soft);
  line-height: 1.65;
}

.bubble h1,
.bubble h2,
.bubble h3 {
  margin: 1.2em 0 0.45em;
  color: var(--text);
  line-height: 1.2;
}

.bubble h1:first-child,
.bubble h2:first-child,
.bubble h3:first-child,
.bubble p:first-child {
  margin-top: 0;
}

.bubble p {
  margin: 0.75em 0;
}

.bubble ul,
.bubble ol {
  padding-left: 1.4em;
}

.bubble table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.bubble th,
.bubble td {
  padding: 8px 10px;
  border: 1px solid var(--line);
}

.inline-code {
  padding: 0.16em 0.38em;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #d7f5ff;
}

.code-wrap {
  overflow: hidden;
  margin: 14px 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: #070911;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.8rem;
}

.code-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.copy-code,
.run-code {
  min-height: 28px;
  padding: 0 9px;
  border-radius: 7px;
  background: rgba(53, 208, 255, 0.12);
  color: var(--accent);
}

.run-code {
  background: rgba(84, 227, 166, 0.12);
  color: var(--good);
}

.run-code:disabled {
  cursor: progress;
  opacity: 0.7;
}

pre {
  margin: 0;
  overflow: auto;
  padding: 14px;
}

code {
  font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  font-size: 0.92em;
}

.message-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.message-actions button {
  min-height: 30px;
  padding: 0 9px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.composer {
  padding: 16px min(6vw, 72px) 22px;
  background: linear-gradient(180deg, transparent, rgba(8, 9, 13, 0.86) 26%);
}

.composer-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(14, 17, 25, 0.92);
  box-shadow: var(--shadow), 0 0 0 1px rgba(53, 208, 255, 0.04);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.attach-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--accent);
  cursor: pointer;
  font-weight: 900;
}

.attach-btn input {
  display: none;
}

.pending-files,
.message-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: min(900px, 100%);
  margin: 0 auto 8px;
}

.message-files {
  width: 100%;
  margin: 0 0 10px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid rgba(53, 208, 255, 0.2);
  border-radius: 8px;
  background: rgba(53, 208, 255, 0.08);
  color: var(--soft);
  font-size: 0.84rem;
}

.file-chip small {
  color: var(--muted);
}

.file-chip button {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.artifact-generating {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 8px 0;
  padding: 9px 12px;
  border: 1px solid rgba(53, 208, 255, 0.18);
  border-radius: 8px;
  background: rgba(53, 208, 255, 0.06);
  color: var(--soft);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(53, 208, 255, 0.22);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.composer-box:focus-within {
  border-color: rgba(53, 208, 255, 0.36);
  box-shadow: var(--shadow), 0 0 34px rgba(53, 208, 255, 0.12);
  transform: translateY(-1px);
}

.composer textarea {
  min-height: 54px;
  max-height: 180px;
  border: 0;
  background: transparent;
  color: var(--text);
  outline: none;
  resize: none;
  line-height: 1.5;
}

.status-line {
  width: min(900px, 100%);
  min-height: 22px;
  margin: 8px auto 0;
  color: var(--muted);
  font-size: 0.84rem;
}

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

.typing i {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 0.9s infinite alternate;
}

.typing i:nth-child(2) {
  animation-delay: 0.16s;
}

.typing i:nth-child(3) {
  animation-delay: 0.32s;
}

.thinking-bubble {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(53, 208, 255, 0.14);
  border-radius: 8px;
  background: rgba(53, 208, 255, 0.06);
  color: var(--muted);
}

.run-result {
  margin: 0 14px 14px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.run-result.ok {
  border-color: rgba(84, 227, 166, 0.28);
}

.run-result.fail {
  border-color: rgba(255, 100, 124, 0.34);
}

.run-result strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
}

.run-result pre {
  max-height: 220px;
  margin: 8px 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--soft);
  white-space: pre-wrap;
}

.run-result .stderr {
  color: #ffd7de;
}

.run-muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.artifact-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.artifact-item {
  display: grid;
  gap: 8px;
}

.artifact-image {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 160px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(53, 208, 255, 0.08), rgba(139, 92, 246, 0.08)),
    rgba(0, 0, 0, 0.22);
  color: var(--muted);
  cursor: pointer;
}

.artifact-image img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.03);
}

.artifact-download {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(53, 208, 255, 0.24);
  border-radius: 8px;
  background: rgba(53, 208, 255, 0.1);
  color: var(--text);
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.artifact-download:hover {
  transform: translateY(-1px);
  border-color: rgba(53, 208, 255, 0.42);
  background: rgba(53, 208, 255, 0.16);
}

.artifact-download span {
  color: var(--muted);
  font-size: 0.82rem;
}

.auth-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card,
.modal {
  width: min(440px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(13, 16, 24, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.auth-card {
  padding: 26px;
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 18px;
}

.auth-tabs button.active,
.chip.active {
  border-color: rgba(53, 208, 255, 0.42);
  background: rgba(53, 208, 255, 0.14);
  color: var(--text);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.55);
}

.modal {
  max-height: min(720px, calc(100vh - 40px));
  overflow: auto;
  padding: 22px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.modal h3 {
  margin: 0;
}

.settings-grid {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--soft);
  font-weight: 700;
  font-size: 0.9rem;
}

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.memory-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.memory-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.empty {
  padding: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(12, 15, 23, 0.94);
  color: var(--text);
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes pulse {
  from {
    opacity: 0.35;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 15;
    width: min(320px, 88vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    max-height: none;
    min-height: 100vh;
  }

  .messages {
    padding: 22px 16px;
  }

  .composer {
    padding: 14px 14px 18px;
  }

  .suggestions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 12px;
  }

  .top-actions {
    gap: 6px;
  }

  .mode-select {
    max-width: 128px;
  }

  .custom-select.compact {
    width: 132px;
  }

  .custom-select.compact .custom-options {
    right: 0;
    left: auto;
  }

  .composer-box {
    grid-template-columns: auto 1fr;
  }

  .composer-box .primary-btn {
    grid-column: 1 / -1;
  }

  .message {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 10px;
  }

  .avatar {
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }
}
