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

:root {
  --bg: #0b0f17;
  --panel: #141a26;
  --line: #222b3b;
  --text: #e6ebf5;
  --muted: #8a94a8;
  --accent: #3fa9ff;
  --user: #1f6feb;
  --error: #e5534b;
}

html, body { height: 100%; }

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

svg {
  width: 20px; height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
svg .fill { fill: currentColor; stroke: none; }

/* header */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.brand { min-width: 0; }
.brand .name { font-size: 12px; letter-spacing: 3px; color: var(--accent); font-weight: 600; }
.brand .greet { font-size: 18px; font-weight: 600; margin-top: 2px; }
.actions { display: flex; gap: 6px; flex-shrink: 0; }

.icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--panel);
  display: flex; align-items: center; justify-content: center;
}
.icon.lang { font-size: 13px; font-weight: 700; letter-spacing: 0.5px; color: var(--accent); }

/* events */
.events {
  max-height: 20vh;
  overflow-y: auto;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
}
.events h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 4px;
}
.events ul { list-style: none; }
.events li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.events li:last-child { border-bottom: none; }
.events .when { color: var(--accent); white-space: nowrap; font-size: 13px; }
.events .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.events .del { color: var(--muted); padding: 4px; display: flex; }
.events .del svg { width: 16px; height: 16px; }
.events .empty { color: var(--muted); }

/* big mic */
.mic-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 0 10px;
  border-bottom: 1px solid var(--line);
}
.mic {
  width: 104px; height: 104px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 35% 30%, #6cc0ff, var(--accent) 45%, #1d6fd1);
  color: #fff;
  box-shadow: 0 0 0 6px rgba(63, 169, 255, 0.12), 0 8px 30px rgba(63, 169, 255, 0.35);
  transition: transform 0.15s, background 0.2s;
}
.mic:active { transform: scale(0.95); }
.mic svg { width: 44px; height: 44px; }
.mic.rec {
  background: radial-gradient(circle at 35% 30%, #ff8a84, var(--error) 50%, #b8322b);
  animation: ring 1.4s infinite;
}
.mic.busy { background: var(--panel); box-shadow: 0 0 0 6px rgba(63, 169, 255, 0.08); }
.mic-status { font-size: 13px; color: var(--muted); text-align: center; padding: 0 16px; min-height: 18px; }

.spinner {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes ring {
  0%   { box-shadow: 0 0 0 0 rgba(229, 83, 75, 0.55); }
  100% { box-shadow: 0 0 0 26px rgba(229, 83, 75, 0); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.4; } }

/* chat */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 18px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border-bottom-left-radius: 4px; }
.msg.thinking { color: var(--muted); animation: pulse 1.2s infinite; }
.msg.error { align-self: flex-start; color: var(--error); border: 1px solid var(--error); }

/* composer */
.composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.composer input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 16px; /* 16px stops iPhone from zooming in */
  outline: none;
}
.composer input:focus { border-color: var(--accent); }
.send {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.send svg { width: 18px; height: 18px; }
.send:disabled { opacity: 0.5; }