:root {
  --bg: #0a0e1a;
  --bg-2: #0d1428;
  --fg: #d8e4ff;
  --muted: #6f7d9b;
  --accent: #3da9ff;
  --user: #6cd4ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(ellipse at center, var(--bg-2) 0%, var(--bg) 75%);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#orb {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

#ui {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  z-index: 1;
  pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#transcript {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 0;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

#transcript::-webkit-scrollbar { width: 6px; }
#transcript::-webkit-scrollbar-thumb { background: rgba(108, 212, 255, 0.2); border-radius: 3px; }

.msg {
  max-width: 80%;
  padding: 10px 16px;
  border-radius: 16px;
  font-size: 17px;
  line-height: 1.4;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  white-space: pre-wrap;
  word-wrap: break-word;
  user-select: text;
  -webkit-user-select: text;
}

.msg.user {
  align-self: flex-end;
  background: rgba(108, 212, 255, 0.16);
  color: var(--user);
  border: 1px solid rgba(108, 212, 255, 0.3);
}

.msg.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.msg.tool {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
  font-family: "SF Mono", Menlo, ui-monospace, monospace;
  background: rgba(0, 0, 0, 0.3);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  padding: 4px 10px;
  border-radius: 6px;
  max-width: 70%;
  letter-spacing: 0.5px;
}

#status-line {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  height: 16px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 4px 0;
  opacity: 0.7;
}

#controls {
  padding: 16px 24px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
}

#control-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

#mic-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1a2548, #0f1830);
  border: 1px solid rgba(108, 212, 255, 0.3);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
#mic-btn:active, #mic-btn.recording {
  background: linear-gradient(145deg, #3da9ff, #1a76e0);
  color: #fff;
  transform: scale(0.94);
  box-shadow: 0 0 36px rgba(61, 169, 255, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

#auto-btn {
  min-width: 84px;
  height: 56px;
  border-radius: 28px;
  border: 1px solid rgba(108, 212, 255, 0.24);
  background: rgba(10, 14, 26, 0.72);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: inherit;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

#auto-btn:active {
  transform: scale(0.96);
}

#auto-btn.active {
  background: linear-gradient(145deg, rgba(61, 169, 255, 0.32), rgba(108, 212, 255, 0.16));
  border-color: rgba(108, 212, 255, 0.72);
  color: #e9f6ff;
  box-shadow: 0 0 28px rgba(61, 169, 255, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

#hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 12px;
  text-align: center;
  letter-spacing: 0.5px;
  opacity: 0.6;
}

#text-form {
  width: min(560px, calc(100vw - 32px));
  height: 46px;
  display: grid;
  grid-template-columns: 1fr 46px;
  gap: 8px;
  margin-top: 12px;
  pointer-events: auto;
}

#text-input {
  min-width: 0;
  height: 46px;
  border-radius: 23px;
  border: 1px solid rgba(108, 212, 255, 0.22);
  background: rgba(10, 14, 26, 0.72);
  color: var(--fg);
  padding: 0 16px;
  font: inherit;
  font-size: 16px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

#text-input::placeholder {
  color: rgba(111, 125, 155, 0.74);
}

#text-input:focus {
  border-color: rgba(108, 212, 255, 0.62);
  box-shadow: 0 0 0 3px rgba(61, 169, 255, 0.12);
}

#text-send {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(108, 212, 255, 0.32);
  background: rgba(61, 169, 255, 0.18);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#text-send:active {
  background: var(--accent);
  color: #fff;
  transform: scale(0.96);
}

#auth-dialog {
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid rgba(108, 212, 255, 0.2);
  border-radius: 16px;
  padding: 28px;
  max-width: 360px;
  width: calc(100% - 48px);
}
#auth-dialog::backdrop {
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
}
#auth-dialog h2 { margin: 0 0 8px; font-weight: 500; }
#auth-dialog p { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
#auth-dialog input {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  background: rgba(0,0,0,0.3);
  color: var(--fg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
}
#auth-dialog button {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
#auth-dialog button:hover { background: #2d8de0; }
