:root {
  --bg0: #1a2332;
  --bg1: #243044;
  --panel: #f7f3eb;
  --ink: #1c2430;
  --muted: #5c6778;
  --accent: #c45c26;
  --accent-ink: #fff8f3;
  --line: #d9d0c3;
  --bot: #ffffff;
  --you: #e8eef6;
  --ok: #2f6b4f;
  --bad: #9b2c2c;
}

* { box-sizing: border-box; }

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

body {
  font-family: "Figtree", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #3a4d6b 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #5a3a28 0%, transparent 45%),
    linear-gradient(160deg, var(--bg0), var(--bg1));
}

.page {
  max-width: 820px;
  height: 100dvh;
  margin: 0 auto;
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.header {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  color: #f4efe6;
  padding-bottom: 2px;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  opacity: 0.75;
}

h1 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 700;
  line-height: 1.15;
}

.sub {
  margin: 6px 0 0;
  max-width: 46ch;
  color: #d7d0c4;
  font-size: 0.9rem;
  line-height: 1.4;
}

.status {
  flex-shrink: 0;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.1);
  color: #eee7db;
  white-space: nowrap;
}

.status.ok { background: rgba(47, 107, 79, 0.35); color: #d8f0e4; }
.status.bad { background: rgba(155, 44, 44, 0.4); color: #ffd7d7; }

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.you-are {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.12);
  color: #f0e8dc;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.you-are.set {
  background: rgba(196, 92, 38, 0.35);
  color: #ffe8d8;
}

.identity-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 0;
}

.identity-bar label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.identity-bar select {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.chat-shell {
  flex: 1;
  min-height: 0;
  background: var(--panel);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.messages {
  flex: 1;
  min-height: 0;
  padding: 18px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.chat-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  background: #efe9df;
}

.bubble {
  max-width: 92%;
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 0.95rem;
  white-space: pre-wrap;
  animation: bubble-in 0.28s ease-out;
}

.bubble.md {
  white-space: normal;
}

.bubble.md .section-title {
  margin: 14px 0 8px;
  font-size: 0.98rem;
  font-weight: 700;
  color: #1a2332;
  letter-spacing: 0.01em;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}

.bubble.md .section-title:first-child {
  margin-top: 0;
}

.bubble.md p {
  margin: 0 0 10px;
  color: #2a3340;
}

.bubble.md ul,
.bubble.md ol {
  margin: 0 0 12px;
  padding-left: 1.15rem;
}

.bubble.md li {
  margin: 0 0 6px;
}

.bubble.md .member-card {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 0 10px;
  box-shadow: 0 1px 0 rgba(28, 36, 48, 0.04);
}

.bubble.md .member-card h4 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.bubble.md .member-card ul {
  margin: 0;
  padding-left: 1rem;
}

.bubble.md .member-card li {
  margin: 0 0 4px;
  font-size: 0.88rem;
  color: #3a4452;
}

.bubble.md strong {
  color: #1a2332;
}

.bubble.md code {
  font-size: 0.85em;
  background: #f0ebe3;
  padding: 1px 5px;
  border-radius: 4px;
}

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

.bubble.bot {
  align-self: flex-start;
  background: var(--bot);
  border: 1px solid var(--line);
}

.bubble.you {
  align-self: flex-end;
  background: var(--you);
  border: 1px solid #c9d5e6;
}

.bubble.meta {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  border: none;
  padding: 4px 8px;
}

.bubble.thinking {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
  white-space: normal;
  background: linear-gradient(120deg, #fff 0%, #f3ebe0 45%, #fff 100%);
  background-size: 200% 100%;
  animation: bubble-in 0.28s ease-out, shimmer 1.6s ease-in-out infinite;
  border-color: #e0c9b0;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.thinking-dots {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  height: 14px;
}

.thinking-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 1s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.thinking-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.thinking-label {
  font-weight: 600;
  color: var(--ink);
  animation: fade-swap 0.35s ease;
}

.thinking-hint {
  font-size: 0.78rem;
  color: var(--muted);
}

@keyframes fade-swap {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.composer.busy {
  opacity: 0.85;
}

.composer.busy button {
  position: relative;
  overflow: hidden;
}

.composer.busy button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.28), transparent);
  animation: btn-shine 1.2s linear infinite;
}

@keyframes btn-shine {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px 0;
}

.suggestions button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.suggestions button:hover { border-color: var(--accent); color: var(--accent); }

.composer {
  display: flex;
  gap: 10px;
  padding: 12px 16px 14px;
}

.composer input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.composer input:focus {
  outline: 2px solid rgba(196, 92, 38, 0.35);
  border-color: var(--accent);
}

.composer button {
  border: none;
  border-radius: 12px;
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

.composer button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .page { padding: 10px 10px 8px; gap: 10px; }
  .header { flex-direction: column; gap: 8px; }
  .sub { display: none; }
  .bubble { max-width: 100%; }
  .suggestions { padding-top: 10px; }
}
