:root {
  --bg: #0b1220;
  --panel: #111a2c;
  --panel-2: #16223a;
  --line: #22304d;
  --ink: #e6edf7;
  --muted: #8fa3c4;
  --accent: #22d3ee;
  --accent-2: #0891b2;
  --user: #1d4ed8;
  --ok: #34d399;
  --warn: #fbbf24;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: radial-gradient(1200px 600px at 20% -10%, #14213d 0%, var(--bg) 55%);
  color: var(--ink);
  font: 15.5px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 18, 32, 0.85);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 5;
}

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

.logo {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06202a;
  font-weight: 800;
  letter-spacing: -1px;
}

.top h1 { margin: 0; font-size: 17px; letter-spacing: -0.2px; }
.top p { margin: 0; font-size: 12px; color: var(--muted); }

.status { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.busy .dot { background: var(--warn); box-shadow: 0 0 8px var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 26px 18px 10px;
  scroll-behavior: smooth;
}

.welcome, .msg { max-width: 880px; margin: 0 auto; }

.welcome { padding: 10px 6px 20px; }
.welcome h2 { margin: 6px 0 8px; font-size: 24px; letter-spacing: -0.4px; }
.welcome p { color: var(--muted); max-width: 640px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chips button {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.chips button:hover { border-color: var(--accent); transform: translateY(-1px); }

.msg { display: flex; margin: 14px auto; gap: 10px; }
.msg .avatar {
  flex: 0 0 32px; width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  background: var(--panel-2); color: var(--accent);
  border: 1px solid var(--line);
}
.msg .bubble {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  overflow-x: auto;
}
.msg.user .bubble { background: var(--user); border-color: transparent; }
.msg.user .avatar { background: var(--user); color: #fff; border-color: transparent; }

.bubble p { margin: 0.4em 0; }
.bubble h3, .bubble h4 { margin: 0.6em 0 0.3em; }
.bubble code {
  background: #0a101d;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  font: 13px ui-monospace, SFMono-Regular, Menlo, monospace;
}
.bubble pre { background: #0a101d; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
.bubble pre code { border: none; padding: 0; }
.bubble table { border-collapse: collapse; margin: 8px 0; font-size: 14px; width: 100%; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
.bubble th { background: var(--panel-2); }
.bubble a { color: var(--accent); }
.bubble ul { margin: 0.4em 0; padding-left: 20px; }
.attachment-img { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); margin-top: 10px; display: block; }
.deck-btn {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06202a !important;
  font-weight: 700;
  text-decoration: none;
  border-radius: 9px;
  padding: 9px 14px;
}

.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

.composer {
  border-top: 1px solid var(--line);
  background: rgba(11, 18, 32, 0.92);
  padding: 12px 18px 8px;
  position: sticky;
  bottom: 0;
}
.composer form {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 160px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  outline: none;
}
.composer textarea:focus { border-color: var(--accent); }
.composer button {
  width: 46px; height: 46px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06202a;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}
.composer button:disabled { opacity: 0.5; cursor: not-allowed; }
.hint { max-width: 880px; margin: 8px auto 0; font-size: 11.5px; color: var(--muted); text-align: center; }

@media (max-width: 640px) {
  .top p { display: none; }
  .chat { padding: 16px 10px 6px; }
  .msg .avatar { display: none; }
}
