.chat-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 22px;
}

.chat-sidebar,
.chat-main {
  border-radius: var(--radius-xl);
}

.chat-sidebar {
  display: grid;
  gap: 18px;
}

.chat-main {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-height: 720px;
  overflow: hidden;
}

.chat-header,
.chat-welcome,
.chat-body,
.chat-sources,
.chat-composer {
  padding: 24px;
}

.chat-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.chat-header-copy .section-title {
  margin-bottom: 0;
}

.chat-header-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.chat-state,
.chat-sync-badge,
.composer-status,
.prompt-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(55, 207, 134, 0.18);
  background: rgba(7, 11, 7, 0.82);
}

.chat-state::before,
.composer-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--secondary);
  box-shadow: 0 0 12px rgba(213, 255, 99, 0.7);
}

.chat-state.is-thinking::before,
.composer-status.is-thinking::before {
  background: var(--primary);
  box-shadow: 0 0 12px rgba(55, 207, 134, 0.7);
}

.chat-sync-badge {
  color: var(--muted);
}

.chat-welcome {
  display: grid;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at top right, rgba(55, 207, 134, 0.08), transparent 32%),
    linear-gradient(180deg, rgba(9, 14, 10, 0.84), rgba(7, 11, 7, 0.72));
}

.chat-welcome h3 {
  margin-bottom: 12px;
  font-size: 1.4rem;
}

.chat-welcome .muted {
  margin-bottom: 0;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.prompt-chip {
  color: var(--accent);
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease;
}

.prompt-chip:hover {
  transform: translateY(-1px);
  background: rgba(55, 207, 134, 0.1);
  border-color: rgba(55, 207, 134, 0.3);
}

.chat-body {
  display: grid;
  gap: 14px;
  align-content: start;
  max-height: 520px;
  overflow-y: auto;
  background:
    radial-gradient(circle at top right, rgba(55, 207, 134, 0.08), transparent 28%),
    rgba(7, 11, 7, 0.64);
}

.chat-sources {
  display: grid;
  gap: 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(10, 15, 10, 0.8), rgba(7, 11, 7, 0.7)),
    rgba(7, 11, 7, 0.64);
}

.chat-sources-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.chat-sources-head .eyebrow {
  margin-bottom: 0;
}

.chat-sources-state {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(55, 207, 134, 0.18);
  background: rgba(7, 11, 7, 0.8);
  color: var(--muted);
  font-size: 0.88rem;
}

.chat-sources-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.source-card {
  min-height: 132px;
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(55, 207, 134, 0.14);
  background:
    radial-gradient(circle at top right, rgba(55, 207, 134, 0.08), transparent 36%),
    rgba(7, 11, 7, 0.78);
}

.source-card strong {
  display: block;
  margin-bottom: 10px;
}

.source-card p {
  margin-bottom: 0;
}

.source-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.source-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(55, 207, 134, 0.08);
  border: 1px solid rgba(55, 207, 134, 0.14);
  color: var(--accent);
  font-size: 0.84rem;
}

.source-card-placeholder {
  grid-column: 1 / -1;
}

.message {
  max-width: min(78%, 560px);
  padding: 16px 18px;
  border-radius: 20px;
  border: 1px solid rgba(55, 207, 134, 0.12);
}

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

.message-ai {
  background:
    linear-gradient(180deg, rgba(16, 24, 15, 0.84), rgba(8, 12, 8, 0.82)),
    rgba(7, 11, 7, 0.72);
  border-top-left-radius: 8px;
}

.message-user {
  margin-left: auto;
  background: linear-gradient(135deg, rgba(55, 207, 134, 0.16), rgba(213, 255, 99, 0.08));
  border-top-right-radius: 8px;
}

.message-meta {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.chat-composer {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 14px;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.composer-label {
  color: var(--accent);
  font-size: 0.95rem;
}

.chat-input {
  width: 100%;
  min-height: 136px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  color: var(--text);
  background: rgba(7, 11, 7, 0.92);
}

.chat-input::placeholder {
  color: rgba(145, 163, 181, 0.62);
}

.chat-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.prompt-list {
  display: grid;
  gap: 12px;
}

.prompt-button {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(55, 207, 134, 0.16);
  background: rgba(7, 11, 7, 0.74);
  color: var(--text);
  cursor: pointer;
}

.prompt-button:hover {
  background: rgba(55, 207, 134, 0.08);
}

.chat-note {
  color: var(--muted);
  line-height: 1.7;
}

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

.chat-body::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(55, 207, 134, 0.24);
}

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

  .chat-main {
    min-height: 640px;
  }

  .chat-header,
  .composer-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-header-status {
    justify-content: flex-start;
  }

  .chat-sources-head {
    flex-direction: column;
    align-items: stretch;
  }

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