:root {
  --bg: #07111f;
  --bg-2: #0b1830;
  --panel: rgba(13, 24, 47, 0.82);
  --panel-strong: rgba(10, 19, 38, 0.96);
  --line: rgba(122, 162, 255, 0.16);
  --line-strong: rgba(122, 162, 255, 0.28);
  --text: #edf3ff;
  --muted: #9db0d2;
  --accent: #74a7ff;
  --accent-2: #4c86ff;
  --user: linear-gradient(180deg, #4d82ff, #376df0);
  --bot: rgba(20, 34, 64, 0.96);
  --success: #73d39c;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(76, 134, 255, 0.24), transparent 50%),
    radial-gradient(900px 600px at 110% 10%, rgba(116, 167, 255, 0.18), transparent 40%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
}

button, textarea, select { font: inherit; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.app-shell {
  width: min(1480px, calc(100% - 24px));
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  padding: 18px 0;
}

.glass {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.sidebar, .chat-area {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.brand-card, .panel, .chat-header, .chat-card {
  border-radius: var(--radius);
}

.brand-card {
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(116, 167, 255, 0.28), rgba(76, 134, 255, 0.12));
  border: 1px solid var(--line-strong);
  font-size: 1.2rem;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 700;
}

h1, h2, p { margin: 0; }
.brand-card h1, .chat-header h2 { font-size: 1.3rem; }

.panel {
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

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

.status-item {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
}

.label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.status-item strong {
  font-size: 0.95rem;
}

.field-label {
  display: block;
  margin: 10px 0 8px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.input {
  width: 100%;
  border: 1px solid rgba(125, 154, 215, 0.22);
  background: rgba(7, 15, 30, 0.92);
  color: var(--text);
  border-radius: 16px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(116, 167, 255, 0.12);
}

.select {
  padding: 12px 14px;
}

.sidebar-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

.session-actions {
  margin-top: 10px;
}

.chat-header {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  border-radius: 999px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-size: 0.78rem;
}

.chat-card {
  padding: 16px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  min-height: calc(100vh - 54px);
}

.messages {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
}

.message-row {
  display: flex;
}

.message-row.user { justify-content: flex-end; }
.message-row.assistant { justify-content: flex-start; }

.message-bubble {
  max-width: min(780px, 88%);
  border-radius: 22px;
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,0.06);
}

.message-row.user .message-bubble {
  background: var(--user);
  border-color: rgba(255,255,255,0.1);
}

.message-row.assistant .message-bubble {
  background: var(--bot);
}

.message-meta {
  font-size: 0.74rem;
  color: rgba(237,243,255,0.68);
  margin-bottom: 7px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.message-text {
  white-space: pre-wrap;
  line-height: 1.62;
  word-break: break-word;
}

.typing {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  padding: 10px 6px 2px;
}

.typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
.typing em { font-style: normal; font-size: 0.9rem; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin-top: 12px;
}

.composer-input {
  resize: none;
  min-height: 58px;
  max-height: 180px;
  padding: 17px 18px;
}

.btn, .icon-btn {
  border: none;
  cursor: pointer;
  border-radius: 16px;
  color: white;
  transition: transform .18s ease, opacity .18s ease, background .18s ease;
}

.btn:hover, .icon-btn:hover { transform: translateY(-1px); }
.btn:active, .icon-btn:active { transform: translateY(0); }

.btn {
  padding: 13px 18px;
  font-weight: 700;
}

.btn-sm { padding: 9px 12px; border-radius: 12px; font-size: 0.86rem; }

.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.btn-secondary, .icon-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
}

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
}

.send-btn {
  min-width: 108px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(900px, calc(100% - 18px));
    padding: 10px 0 18px;
  }

  .chat-card {
    min-height: auto;
    height: calc(100vh - 292px);
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: calc(100% - 12px);
    gap: 12px;
  }

  .brand-card, .panel, .chat-header, .chat-card {
    border-radius: 18px;
  }

  .chat-header {
    padding: 15px 16px;
    align-items: flex-start;
    flex-direction: column;
  }

  .header-badges {
    width: 100%;
  }

  .chat-card {
    padding: 12px;
    height: calc(100vh - 318px);
    min-height: 520px;
  }

  .message-bubble {
    max-width: 94%;
    padding: 13px 14px;
  }

  .composer {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .send-btn {
    width: 100%;
  }

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