:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-2: #18212e;
  --border: #243041;
  --text: #e6edf5;
  --muted: #93a4b8;
  --accent: #22d3ee;
  --accent-2: #10b981;
  --danger: #f87171;
  --warn: #fbbf24;
  --user-bg: #163244;
  --bot-bg: #141c27;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.app {
  max-width: 860px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, #0d1219 0%, #0b0f14 100%);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
  color: #06131a;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  flex-shrink: 0;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.14);
  color: var(--accent);
  border: 1px solid rgba(34, 211, 238, 0.3);
}

.status-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot.online { background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); }
.dot.busy { background: var(--warn); }
.dot.offline { background: var(--danger); }

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

select, button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
}

button {
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.disclaimer {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(24, 33, 46, 0.65);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.disclaimer strong {
  color: var(--text);
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-state {
  margin: auto 0;
  text-align: center;
  padding: 24px 12px;
}

.empty-state h1 {
  margin: 0 0 8px;
  font-size: 24px;
  background: linear-gradient(90deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.empty-state p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.prompts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.chip {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px;
  color: var(--text);
}

.msg {
  max-width: 85%;
  padding: 11px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  font-size: 14.5px;
  word-wrap: break-word;
}

.msg.user {
  align-self: flex-end;
  background: var(--user-bg);
  border-color: rgba(34, 211, 238, 0.28);
}

.msg.assistant {
  align-self: flex-start;
  background: var(--bot-bg);
}

.msg-role {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.msg.user .msg-role {
  color: var(--accent);
}

.msg-body p {
  margin: 0 0 8px;
}
.msg-body p:last-child {
  margin-bottom: 0;
}

.msg-body pre {
  background: #090d12;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 13px;
  margin: 8px 0;
}

.msg-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 4px;
  border-radius: 4px;
}

.msg-body pre code {
  background: none;
  padding: 0;
}

.cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  background: var(--accent);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.alert-bar {
  margin: 0 16px 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.hidden {
  display: none !important;
}

.composer-wrap {
  padding: 10px 16px 14px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.composer:focus-within {
  border-color: var(--accent);
}

textarea {
  width: 100%;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  max-height: 140px;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.char-count {
  margin-right: auto;
  font-size: 12px;
  color: var(--muted);
}

.btn-send {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #051318;
  border: none;
  font-weight: 700;
  padding: 7px 16px;
}

.btn-stop {
  background: rgba(248, 113, 113, 0.16);
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
  font-weight: 600;
}

@media (max-width: 640px) {
  .app { border-left: none; border-right: none; }
  .topbar { flex-wrap: wrap; }
  .msg { max-width: 94%; }
}
