:root {
  --bg: #0a0b10;
  --surface: #12141b;
  --surface-2: #181b24;
  --border: #232734;
  --text: #e8eaf0;
  --muted: #8b90a0;
  --faint: #5d6273;
  --accent: #46d3e0;
  --accent-ink: #062126;
  --ok: #3ccf8e;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
  height: 100dvh; overflow: hidden;
}
button { font: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- top bar ---------- */
.topbar {
  flex: none;
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding: 0 24px;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  object-fit: cover; object-position: 50% 38%;
  border: 1px solid var(--border);
}
.brand-name { font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.actions { display: flex; gap: 8px; flex: none; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 12px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 9px;
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { color: var(--text); border-color: #343a4b; background: var(--surface); }

.ca {
  display: inline-flex; align-items: center; gap: 8px; min-width: 0;
  height: 34px; padding: 0 12px; margin: 0 16px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  font-size: 13px; cursor: pointer;
  transition: border-color .15s;
}
.ca:hover { border-color: #3a4052; }
.ca-label { color: var(--accent); font-weight: 600; flex: none; }
.ca-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; letter-spacing: .01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.ca svg { width: 15px; height: 15px; flex: none; color: var(--muted); }
.ca .ca-done { display: none; color: var(--ok); }
.ca.copied .ca-copy { display: none; }
.ca.copied .ca-done { display: inline; }

/* ---------- layout ---------- */
.layout {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 520px);
  gap: 20px;
  padding: 20px 24px 24px;
  max-width: 1440px; width: 100%; margin: 0 auto;
}

.portrait {
  position: relative; overflow: hidden; min-height: 0;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: #06040f;
}
#avatar { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.status-chip {
  position: absolute; left: 16px; bottom: 16px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 10px; border-radius: 999px;
  background: rgba(10, 11, 16, .72);
  border: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 13px; color: var(--text);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
body.thinking .status-dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
body.speaking .status-dot { background: var(--accent); }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- chat ---------- */
.chat {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
}
.log {
  list-style: none; margin: 0; padding: 24px 22px 8px;
  flex: 1; overflow-y: auto; min-height: 0;
  display: flex; flex-direction: column; gap: 18px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.msg { white-space: pre-wrap; overflow-wrap: anywhere; animation: rise .2s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }
.msg.user {
  align-self: flex-end; max-width: 82%;
  padding: 9px 14px; border-radius: 14px 14px 4px 14px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.msg.alien { align-self: flex-start; max-width: 92%; display: flex; gap: 12px; }
.msg.alien img {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  object-fit: cover; object-position: 50% 38%; margin-top: 1px;
}
.msg.alien .body { padding-top: 3px; }
.msg.alien.err .body { color: #f08a9b; }
.typing { display: inline-flex; gap: 4px; padding-top: 9px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); opacity: .4; animation: blip 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blip { 40% { opacity: 1; } }

.starters { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 22px 12px; }
.starters[hidden] { display: none; }
.chip {
  padding: 7px 12px; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); font-size: 13.5px;
  transition: color .15s, border-color .15s;
}
.chip:hover { color: var(--text); border-color: #3a4052; }

.composer {
  display: flex; gap: 6px; align-items: center;
  margin: 0 16px; padding: 6px 6px 6px 16px;
  background: var(--bg);
  border: 1px solid var(--border); border-radius: 14px;
  transition: border-color .15s;
}
.composer:focus-within { border-color: #3d4458; }
.composer input {
  flex: 1; min-width: 0; height: 38px;
  background: none; border: 0; outline: none;
  color: var(--text); font: inherit; font-size: 15px;
}
.composer input::placeholder { color: var(--faint); }
.icon-btn {
  width: 38px; height: 38px; flex: none; border-radius: 10px;
  display: grid; place-items: center; cursor: pointer;
  background: transparent; color: var(--muted); border: 0;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.rec { color: #f0657d; }
.send {
  width: 38px; height: 38px; flex: none; border-radius: 10px;
  display: grid; place-items: center; cursor: pointer; border: 0;
  background: var(--accent); color: var(--accent-ink);
  transition: opacity .15s;
}
.send svg { width: 18px; height: 18px; stroke-width: 2.2; }
.send:disabled { opacity: .35; cursor: default; }
.fineprint { margin: 10px 0 14px; text-align: center; font-size: 12px; color: var(--faint); }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .topbar { height: 54px; padding: 0 16px; }
  .btn span, .brand-name { display: none; }
  .ca { margin: 0 10px; padding: 0 10px; }
  .btn { width: 34px; padding: 0; justify-content: center; }
  .layout { grid-template-columns: 1fr; grid-template-rows: 38dvh minmax(0, 1fr); gap: 12px; padding: 12px 16px 16px; }
  .portrait, .chat { border-radius: 16px; }
  .log { padding: 16px 14px 6px; }
  .starters { padding: 2px 14px 10px; }
  .composer { margin: 0 10px; }
  .fineprint { margin: 8px 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .msg, .status-dot, .typing i { animation: none !important; }
}

