:root {
  color-scheme: dark;
  --bg: #080b12;
  --panel: rgba(18, 24, 38, 0.82);
  --panel-strong: #121827;
  --text: #eef4ff;
  --muted: #9aa8bd;
  --line: rgba(148, 163, 184, 0.22);
  --accent: #7c3aed;
  --accent-2: #06b6d4;
  --danger: #fb7185;
  --ok: #34d399;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(124, 58, 237, 0.26), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(6, 182, 212, 0.18), transparent 34rem),
    var(--bg);
  color: var(--text);
}

button, input, textarea { font: inherit; }

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

.sidebar {
  padding: 24px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.92), rgba(15, 23, 42, 0.62));
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.orb {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: conic-gradient(from 130deg, var(--accent), var(--accent-2), #22c55e, var(--accent));
  box-shadow: 0 0 32px rgba(124, 58, 237, 0.52);
}

h1, h2, p { margin: 0; }
h1 { font-size: 1.25rem; }
h2 { font-size: clamp(1.45rem, 4vw, 2.25rem); }
.brand p, .eyebrow, .meta { color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.74rem; margin-bottom: 6px; }

.panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

label {
  display: block;
  color: #dbeafe;
  font-size: 0.88rem;
  margin: 12px 0 8px;
}
label:first-child { margin-top: 0; }

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  background: rgba(2, 6, 23, 0.66);
  color: var(--text);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus {
  border-color: rgba(6, 182, 212, 0.72);
  box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.12);
}

.status-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  margin-bottom: 14px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot-ok { background: var(--ok); box-shadow: 0 0 16px rgba(52, 211, 153, 0.8); }
.dot-bad { background: var(--danger); box-shadow: 0 0 16px rgba(251, 113, 133, 0.7); }
.alpha-status-row { margin-bottom: 8px; }
.alpha-counts {
  margin: -2px 0 14px 19px;
  color: #a7f3d0;
  font-size: 0.78rem;
  line-height: 1.35;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.12s, opacity 0.12s, filter 0.12s;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.secondary { width: 100%; background: rgba(148, 163, 184, 0.16); color: #dbeafe; border: 1px solid var(--line); }

.chat-area {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  max-height: 100vh;
  padding: 28px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.badge {
  border: 1px solid rgba(6, 182, 212, 0.42);
  border-radius: 999px;
  padding: 8px 12px;
  color: #cffafe;
  background: rgba(6, 182, 212, 0.12);
}
.hidden { display: none !important; }

.messages {
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  background: rgba(2, 6, 23, 0.34);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

.message {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.message.user { grid-template-columns: minmax(0, 1fr) 42px; }
.message.user .avatar { grid-column: 2; background: linear-gradient(135deg, #0ea5e9, #2563eb); }
.message.user .bubble { grid-column: 1; grid-row: 1; justify-self: end; background: rgba(37, 99, 235, 0.18); }

.avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  font-size: 0.78rem;
  font-weight: 800;
}

.bubble {
  max-width: 920px;
  width: fit-content;
  min-width: min(100%, 220px);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px 15px;
  background: var(--panel-strong);
}
.meta { font-size: 0.76rem; margin-bottom: 8px; }
.content { white-space: pre-wrap; line-height: 1.58; word-wrap: break-word; }
.content pre {
  white-space: pre-wrap;
  overflow-x: auto;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(0, 0, 0, 0.34);
}
.content code, .content pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.error {
  margin: 14px 0 0;
  border: 1px solid rgba(251, 113, 133, 0.45);
  border-radius: 16px;
  padding: 12px 14px;
  color: #ffe4e6;
  background: rgba(127, 29, 29, 0.35);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(15, 23, 42, 0.84);
  box-shadow: var(--shadow);
}
.composer textarea { min-height: 56px; max-height: 220px; }
.composer button { align-self: end; min-width: 104px; min-height: 52px; }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .chat-area { max-height: none; min-height: 70vh; padding: 18px; }
  .composer { grid-template-columns: 1fr; }
  .composer button { width: 100%; }
}
