*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --orange: #F6821F;
  --dark: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #2d3748;
  --user-bg: #1e4d8c;
  --agent-bg: #1e293b;
  --code-bg: #0d1117;
  --radius: 12px;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--dark);
  color: var(--text);
  display: flex;
  flex-direction: column;
  font-size: 14px;
  line-height: 1.6;
}

/* ── Header ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  flex-shrink: 0;
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.badge {
  font-size: 10px;
  font-weight: 600;
  background: var(--orange);
  color: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.zone-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.zone-selector label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.zone-selector select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
}

.zone-selector select:focus { border-color: var(--orange); }

/* ── Main layout ── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px 20px;
  min-height: 0;
}

/* ── Thread ── */
#thread {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.msg { display: flex; gap: 10px; max-width: 100%; }
.msg.user { flex-direction: row-reverse; }

.bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: var(--radius);
  line-height: 1.65;
  word-break: break-word;
}

.msg.user .bubble { background: var(--user-bg); border-bottom-right-radius: 4px; }
.msg.agent .bubble { background: var(--agent-bg); border-bottom-left-radius: 4px; border: 1px solid var(--border); }

/* ── Code blocks ── */
.code-block {
  position: relative;
  margin: 10px 0;
  border-radius: 8px;
  overflow: hidden;
}

.code-block pre {
  background: var(--code-bg);
  padding: 14px 16px;
  overflow-x: auto;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 12.5px;
  line-height: 1.5;
  color: #c9d1d9;
  border: 1px solid #30363d;
  border-radius: 8px;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #30363d;
  border: 1px solid #444c56;
  color: #8b949e;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.copy-btn:hover { background: #444c56; color: var(--text); }
.copy-btn.copied { background: #196a30; color: #3fb950; border-color: #238636; }

/* ── Inline code ── */
.bubble code {
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: monospace;
  font-size: 12.5px;
}

/* ── Loading indicator ── */
.msg.loading .bubble { display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); animation: bounce 1.2s infinite; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-6px)} }

/* ── Prompt chips ── */
#chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 0 12px;
}

.chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--orange); color: var(--text); }

/* ── Input form ── */
#input-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  transition: border-color 0.15s;
}
#input-form:focus-within { border-color: var(--orange); }

#user-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 140px;
  overflow-y: auto;
  padding: 4px 4px;
}
#user-input::placeholder { color: var(--text-muted); }

#send-btn {
  background: var(--orange);
  border: none;
  border-radius: 8px;
  color: #fff;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
#send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#send-btn:not(:disabled):hover { opacity: 0.85; }
