:root {
  --bg: #0d0f14;
  --bg-elevated: #131722;
  --bg-soft: #171c29;
  --sidebar: #0b0d12;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #eef2ff;
  --muted: #97a1b7;
  --muted-strong: #c7d0e2;
  --accent: #10a37f;
  --accent-strong: #0c7e62;
  --assistant-bubble: #161b27;
  --user-bubble: #1d2433;
  --warning: #f0c36c;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  --button-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top, rgba(16, 163, 127, 0.14), transparent 24rem),
    linear-gradient(180deg, #10131a, #0d0f14);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

button {
  color: inherit;
  transition:
    transform 140ms ease,
    background-color 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    color 140ms ease,
    opacity 140ms ease;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.22);
}

button:active {
  transform: translateY(1px) scale(0.99);
}

a {
  color: inherit;
  text-decoration: none;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px 16px;
  border-right: 1px solid var(--border);
  background: rgba(11, 13, 18, 0.96);
}

.sidebar-top {
  display: grid;
  gap: 14px;
}

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

.brand-mark,
.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  font-weight: 800;
}

.brand-mark {
  background: linear-gradient(135deg, var(--accent), #3e6dff);
  color: #fff;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-action,
.ghost-button,
.send-button,
.thread-item,
.starter-card,
.context-chip,
.mini-tag-button {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  cursor: pointer;
}

.sidebar-action {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    var(--bg-soft);
  color: var(--text);
  text-align: left;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.sidebar-action::before {
  content: "+";
  margin-right: 10px;
  color: var(--muted-strong);
}

.sidebar-section {
  display: grid;
  gap: 10px;
}

.sidebar-label,
.eyebrow,
.select-field span,
.message-role {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.thread-list {
  display: grid;
  gap: 8px;
}

.thread-item {
  display: grid;
  gap: 4px;
  padding: 13px 12px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  background: rgba(255, 255, 255, 0.015);
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.thread-item strong {
  font-size: 14px;
}

.thread-item span {
  color: var(--muted);
  font-size: 12px;
}

.thread-item.is-active,
.thread-item:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: var(--button-shadow);
}

.thread-item.is-active {
  background:
    linear-gradient(90deg, rgba(16, 163, 127, 0.14), transparent 70%),
    rgba(255, 255, 255, 0.05);
}

.thread-item.is-active strong {
  color: #f6fbff;
}

.mini-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-tag-button,
.context-chip {
  min-height: 34px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  color: var(--muted-strong);
  font-size: 13px;
}

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

.chat-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 24px clamp(16px, 4vw, 36px) 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 15, 20, 0.82);
  backdrop-filter: blur(14px);
}

.chat-header h1 {
  margin: 6px 0 0;
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.05;
  letter-spacing: 0;
}

.header-controls {
  display: flex;
  gap: 12px;
}

.select-field {
  display: grid;
  gap: 6px;
}

.select-field select {
  min-width: 190px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
}

.chat-thread {
  overflow: auto;
  padding: 28px clamp(14px, 5vw, 72px) 24px;
}

.chat-thread::-webkit-scrollbar {
  width: 10px;
}

.chat-thread::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.message {
  display: grid;
  grid-template-columns: 44px minmax(0, 860px);
  justify-content: center;
  gap: 14px;
  margin: 0 auto 24px;
}

.message.user {
  grid-template-columns: minmax(0, 860px) 44px;
}

.message.user .avatar {
  order: 2;
  background: #20304f;
}

.message.user .bubble {
  order: 1;
  background: var(--user-bubble);
}

.message.assistant .avatar {
  background: linear-gradient(135deg, var(--accent), #3e6dff);
}

.bubble {
  padding: 18px 18px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--assistant-bubble);
  box-shadow: var(--shadow);
}

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

.bubble h2 {
  margin-bottom: 10px;
  font-size: clamp(24px, 3vw, 30px);
  line-height: 1.08;
}

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

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

.starter-card {
  display: grid;
  align-items: center;
  min-height: 72px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.025)),
    rgba(255, 255, 255, 0.03);
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.starter-card strong {
  font-size: 15px;
}

.starter-card strong::after {
  content: "";
  color: var(--muted);
}

.welcome-lead,
.analysis-block li,
.analysis-meta span,
.composer-actions p,
.disclaimer {
  color: var(--muted);
}

.welcome-lead {
  margin-bottom: 0;
  color: var(--muted-strong);
}

.welcome-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.welcome-tab {
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
}

.welcome-tab.is-active {
  background: rgba(16, 163, 127, 0.14);
  border-color: rgba(16, 163, 127, 0.28);
  color: #f2fbf8;
}

.welcome-panels {
  margin-top: 14px;
}

.welcome-panel {
  display: none;
  padding: 14px 0 2px;
  border-top: 1px solid var(--border);
}

.welcome-panel.is-active {
  display: block;
}

.welcome-panel p,
.welcome-panel li {
  color: var(--muted);
}

.welcome-panel ul {
  margin: 0;
  padding-left: 18px;
}

.welcome-panel li + li {
  margin-top: 6px;
}

.starter-card:hover,
.context-chip:hover,
.mini-tag-button:hover,
.sidebar-action:hover,
.ghost-button:hover {
  transform: translateY(-1px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.035)),
    rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: var(--button-shadow);
}

.context-chip {
  font-weight: 600;
}

.mini-tag-button {
  font-weight: 600;
}

.context-chip:hover {
  color: #f2f7ff;
}

.mini-tag-button:hover {
  color: #f2f7ff;
}

.analysis-layout {
  display: grid;
  gap: 14px;
}

.analysis-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.analysis-meta span {
  min-height: 34px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 13px;
}

.analysis-block {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.analysis-block h3 {
  margin-bottom: 10px;
  font-size: 17px;
}

.analysis-block ul {
  margin: 0;
  padding-left: 20px;
}

.analysis-block li + li {
  margin-top: 6px;
}

.disclaimer {
  padding: 12px 14px;
  border-left: 3px solid var(--warning);
  border-radius: 8px;
  background: rgba(240, 195, 108, 0.08);
  font-size: 13px;
}

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

.typing span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
  animation: blink 1s infinite ease-in-out;
}

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

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

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.28;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.composer-shell {
  position: sticky;
  bottom: 0;
  display: grid;
  gap: 12px;
  padding: 14px clamp(14px, 4vw, 28px) 18px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(13, 15, 20, 0.2), rgba(13, 15, 20, 0.95) 20%);
  backdrop-filter: blur(18px);
}

.context-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.composer {
  width: min(940px, 100%);
  margin: 0 auto;
  padding: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: rgba(19, 23, 34, 0.96);
  box-shadow: var(--shadow);
}

.composer textarea {
  width: 100%;
  min-height: 34px;
  max-height: 220px;
  resize: none;
  border: 0;
  background: transparent;
  color: var(--text);
  outline: none;
}

.composer textarea::placeholder {
  color: var(--muted);
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
}

.composer-actions p {
  margin: 0;
  font-size: 13px;
}

.action-group {
  display: flex;
  gap: 10px;
}

.ghost-button,
.send-button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  font-weight: 700;
}

.ghost-button {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--muted-strong);
}

.send-button {
  padding-inline: 18px;
  background: linear-gradient(135deg, #12b48b, #0c8f70);
  color: #fff;
  box-shadow:
    0 12px 26px rgba(16, 163, 127, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.send-button::after {
  content: " ->";
  margin-left: 8px;
  color: rgba(255, 255, 255, 0.88);
}

.send-button:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #18bf94, #0d9a77);
  box-shadow:
    0 16px 30px rgba(16, 163, 127, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.26);
}

.send-button:disabled,
.ghost-button:disabled,
.sidebar-action:disabled,
.context-chip:disabled,
.mini-tag-button:disabled,
.starter-card:disabled,
.thread-item:disabled {
  cursor: default;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}

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

  .sidebar {
    display: none;
  }

  .chat-shell {
    min-height: 100vh;
  }
}

@media (max-width: 820px) {
  .chat-header,
  .composer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .header-controls {
    flex-direction: column;
  }

  .select-field select {
    min-width: 0;
    width: 100%;
  }

  .message,
  .message.user {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .message.user .avatar,
  .message.user .bubble {
    order: initial;
  }

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

  .action-group {
    width: 100%;
  }

  .ghost-button,
  .send-button {
    flex: 1;
  }
}

@media (max-width: 520px) {
  .chat-thread {
    padding-inline: 12px;
  }

  .bubble {
    padding: 16px 14px 14px;
  }

  .bubble h2 {
    font-size: 22px;
  }
}
