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

:root {
  --gold: #c9a96e;
  --gold-dim: #7a6340;
  --bg: #0f0f0f;
  --bg2: #1a1a1a;
  --bg3: #242424;
  --text: #f0f0f0;
  --text-dim: #888;
  --radius: 18px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: env(safe-area-inset-top, 16px) 0 env(safe-area-inset-bottom, 0) 0;
}

/* TOP BAR */
.top-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  flex-shrink: 0;
}

.avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.avatar {
  width: 52px;
  height: 52px;
  background: var(--bg3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  position: relative;
  z-index: 1;
}

.pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  opacity: 0;
  transition: opacity 0.3s;
}
.pulse.active {
  opacity: 1;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.12); opacity: 0.3; }
}

.title-wrap h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.status {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}
.status.connected { color: #5cd65c; }
.status.listening { color: var(--gold); }
.status.speaking  { color: #6eb5ff; }

/* CANVAS */
#canvas {
  width: 100%;
  height: 60px;
  flex-shrink: 0;
  display: block;
}

/* TRANSCRIPT */
.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.45;
  word-break: break-word;
}

.msg.system {
  align-self: center;
  background: var(--bg3);
  color: var(--text-dim);
  font-size: 13px;
  border-radius: 10px;
}

.msg.user {
  align-self: flex-end;
  background: var(--gold-dim);
  color: #fff;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid #2e2e2e;
}

.msg.tool {
  align-self: center;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid #2e2e2e;
  border-radius: 20px;
}

/* BOTTOM BAR */
.bottom-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}

.mic-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: none;
  background: var(--bg3);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  -webkit-user-select: none;
  user-select: none;
}

.mic-btn svg {
  width: 32px;
  height: 32px;
}

.mic-btn:active {
  transform: scale(0.94);
}

.mic-btn.active {
  background: var(--gold);
  color: #0f0f0f;
  box-shadow: 0 4px 30px rgba(201, 169, 110, 0.5);
  animation: mic-glow 1.6s ease-in-out infinite;
}

@keyframes mic-glow {
  0%, 100% { box-shadow: 0 4px 30px rgba(201,169,110,0.4); }
  50% { box-shadow: 0 4px 50px rgba(201,169,110,0.8); }
}
