:root {
  color-scheme: dark;
  --bg: #0e1418;
  --panel: #131c22;
  --fg: #e8f4f6;
  --muted: #6f8189;
  --accent: #45e8d3;
  --accent-deep: #1f8a7e;
  --user: #9ad6e0;
  --konjo: #f5e0a8;
  --error: #ff6e6e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--panel);
  border-bottom: 1px solid #1f2a30;
}

.topbar h1 {
  flex: 1;
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

#reset-btn {
  background: transparent;
  border: 1px solid #2a3940;
  color: var(--muted);
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}

.dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent-deep);
  box-shadow: 0 0 12px var(--accent-deep);
  transition: background 200ms, box-shadow 200ms;
}
.dot.listening { background: #36c5ce; box-shadow: 0 0 16px #36c5ce; }
.dot.thinking { background: #ff9c3a; box-shadow: 0 0 14px #ff9c3a; animation: pulse 0.9s ease-in-out infinite; }
.dot.speaking { background: var(--accent); box-shadow: 0 0 18px var(--accent); animation: pulse 0.55s ease-in-out infinite; }
.dot.error { background: var(--error); box-shadow: 0 0 12px var(--error); }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

.conversation {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bubble {
  max-width: 82%;
  padding: 11px 14px;
  border-radius: 14px;
  line-height: 1.4;
  font-size: 16px;
  word-wrap: break-word;
}
.bubble.user {
  align-self: flex-end;
  background: #1a2730;
  color: var(--user);
}
.bubble.konjo {
  align-self: flex-start;
  background: #1d2620;
  color: var(--konjo);
}
.bubble.error {
  align-self: flex-start;
  background: #2a1414;
  color: var(--error);
  border: 1px solid #4a1c1c;
}

.controls {
  padding: 14px 18px 22px;
  background: var(--panel);
  border-top: 1px solid #1f2a30;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.talk {
  width: 100%;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(180deg, #1f8a7e, #136058);
  color: var(--fg);
  border: none;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.3px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  cursor: pointer;
  transition: transform 80ms;
}
.talk:active, .talk.recording {
  transform: scale(0.98);
  background: linear-gradient(180deg, #45e8d3, #1f8a7e);
}

.text-form {
  display: flex;
  gap: 8px;
}
.text-form input {
  flex: 1;
  padding: 11px 13px;
  background: #0a1014;
  border: 1px solid #1f2a30;
  border-radius: 10px;
  color: var(--fg);
  font-size: 15px;
}
.text-form input:focus {
  outline: none;
  border-color: var(--accent-deep);
}
.text-form button {
  width: 44px;
  background: #1f2a30;
  color: var(--fg);
  border: none;
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
}

.status {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  min-height: 16px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.overlay.hidden { display: none; }
.overlay-card {
  background: var(--panel);
  padding: 24px;
  border-radius: 16px;
  width: min(360px, 86vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.overlay-card h2 { margin: 0; font-size: 18px; }
.overlay-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
.overlay-card input {
  padding: 12px;
  background: #0a1014;
  border: 1px solid #2a3940;
  border-radius: 10px;
  color: var(--fg);
  font-size: 14px;
}
.overlay-card button {
  padding: 12px;
  background: var(--accent-deep);
  color: var(--fg);
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
