:root {
  --bg: #0a0a0a;
  --bg-elev: #141414;
  --kb: #22c55e;
  --kb-dim: #16a34a;
  --user: #38bdf8;
  --text: #f5f5f5;
  --muted: #888;
  --danger: #ef4444;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  height: 100%;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  max-width: 600px;
  margin: 0 auto;
  gap: 14px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 1px;
  color: var(--kb);
  font-weight: 700;
}

.dot {
  display: inline-block;
  font-size: 14px;
  color: var(--kb);
  animation: pulse 2s infinite;
  vertical-align: middle;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

#setup-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  padding: 6px 10px;
}

.bubble {
  background: var(--bg-elev);
  border-radius: var(--radius);
  padding: 14px 18px;
  line-height: 1.4;
  min-height: 56px;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.bubble.user {
  border-left: 3px solid var(--user);
  color: #d4d4d4;
  font-style: italic;
}

.bubble.kb {
  border-left: 3px solid var(--kb);
  font-size: 18px;
  flex: 1;
}

.bubble.kb:empty::before {
  content: "...";
  color: var(--muted);
}

.status {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
}

.status.err { color: var(--danger); }
.status.ok  { color: var(--kb); }

.mic {
  align-self: center;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 0;
  background: var(--kb);
  color: #0a0a0a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(34, 197, 94, 0.4);
  transition: transform 0.08s, background 0.2s;
  margin-top: auto;
  margin-bottom: 30px;
  -webkit-tap-highlight-color: transparent;
}

.mic:active { transform: scale(0.96); }

.mic.listening {
  background: var(--danger);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
  animation: ring 1.4s infinite;
}

.mic.busy {
  background: var(--kb-dim);
  cursor: not-allowed;
}

@keyframes ring {
  0%   { box-shadow: 0 0 0 0   rgba(239, 68, 68, 0.5); }
  100% { box-shadow: 0 0 0 28px rgba(239, 68, 68, 0); }
}

dialog {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid #333;
  border-radius: var(--radius);
  padding: 20px;
  max-width: 90%;
  width: 360px;
}

dialog::backdrop { background: rgba(0, 0, 0, 0.7); }

dialog h2 { margin: 0 0 12px; color: var(--kb); font-size: 18px; }

dialog label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 8px;
}

dialog input {
  width: 100%;
  padding: 10px 12px;
  margin-top: 6px;
  background: #0a0a0a;
  border: 1px solid #333;
  border-radius: 8px;
  color: var(--text);
  font-family: monospace;
  font-size: 13px;
}

.hint { font-size: 12px; color: var(--muted); }
.hint code { background: #000; padding: 1px 5px; border-radius: 4px; }

.actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}

.actions button {
  padding: 8px 16px;
  border-radius: 8px;
  border: 0;
  background: #333;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}

.actions button[value="save"] {
  background: var(--kb);
  color: #0a0a0a;
  font-weight: 600;
}
