:root {
  --bg: #050a12;
  --panel: rgba(14, 24, 40, 0.78);
  --line: rgba(120, 190, 255, 0.16);
  --text: #e8f3ff;
  --muted: #8fa8c4;
  --accent: #4fd1ff;
  --accent-2: #7c6cff;
  --danger: #ff6b8a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  overflow-x: hidden;
  padding: env(safe-area-inset-top) 12px env(safe-area-inset-bottom);
}

.glow {
  position: fixed;
  width: 60vw;
  height: 60vw;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.22;
  pointer-events: none;
  z-index: 0;
}
.glow-a { top: -20vw; left: -15vw; background: #2a7fff; }
.glow-b { bottom: -25vw; right: -20vw; background: #7c4dff; }

.app {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 4px 32px;
}

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

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 14px;
  font-weight: 800; font-size: 20px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #04101c;
  box-shadow: 0 8px 28px rgba(79, 209, 255, 0.28);
}
h1 { font-size: 20px; margin: 0; letter-spacing: 0.4px; }
.sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 16, 28, 0.7);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 10px var(--danger); }
.pill.online .dot { background: #4be08f; box-shadow: 0 0 10px #4be08f; }
.pill.listening .dot { background: var(--accent); box-shadow: 0 0 12px var(--accent); animation: pulse 1s infinite; }

.stage { text-align: center; padding: 8px 0 12px; }

.orb {
  position: relative;
  width: 168px;
  height: 168px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
}
.orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(79, 209, 255, 0.28);
  animation: spin 14s linear infinite;
}
.orb-ring::after {
  content: "";
  position: absolute;
  top: -4px; left: 50%;
  width: 8px; height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
}
.ring-2 { inset: 18px; animation-duration: 9s; animation-direction: reverse; border-color: rgba(124, 108, 255, 0.3); }
.ring-2::after { background: var(--accent-2); box-shadow: 0 0 14px var(--accent-2); }

.mic {
  position: relative;
  width: 104px; height: 104px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #04101c;
  background: linear-gradient(145deg, #7ee6ff, #4f9dff 55%, #7c6cff);
  box-shadow: 0 10px 40px rgba(79, 209, 255, 0.35), inset 0 2px 6px rgba(255,255,255,0.5);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.mic:active { transform: scale(0.95); }
.mic svg { width: 44px; height: 44px; fill: currentColor; }
.orb.active .mic { box-shadow: 0 0 0 10px rgba(79,209,255,0.12), 0 0 55px rgba(79,209,255,0.6); }
.orb.active .orb-ring { animation-duration: 3s; }

.listen-label { margin: 0; font-size: 14px; color: var(--muted); min-height: 20px; }
.transcript {
  margin: 12px auto 0;
  max-width: 460px;
  min-height: 22px;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
}

.reply-card {
  margin: 14px 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 14px;
  background: var(--panel);
  backdrop-filter: blur(10px);
}
.reply-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--accent); }
.reply-card p { margin: 6px 0 0; font-size: 14px; line-height: 1.5; }

.toggles { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.track {
  position: relative; width: 38px; height: 22px; border-radius: 999px;
  background: rgba(255,255,255,0.12); border: 1px solid var(--line);
  transition: background 0.2s ease;
}
.track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #c6d8ea; transition: transform 0.2s ease;
}
.switch input:checked + .track { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.switch input:checked + .track::after { transform: translateX(16px); background: #fff; }

.text-form { display: flex; gap: 8px; margin-bottom: 22px; }
.text-form input {
  flex: 1; min-width: 0;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(8,16,28,0.75);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.text-form input:focus { border-color: var(--accent); }
.text-form button {
  width: 50px; border: none; border-radius: 12px; cursor: pointer;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #04101c; font-size: 18px; font-weight: 700;
}

.quick, .history { margin-top: 20px; }
.quick h2, .history h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.6px; color: var(--muted); margin: 0 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(14, 24, 40, 0.6);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.chip:active { border-color: var(--accent); }

.history-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.link-btn { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(14,24,40,0.5);
  border: 1px solid rgba(120,190,255,0.08);
  font-size: 13px;
}
.history-item .said { color: var(--text); }
.history-item .when { color: var(--muted); font-size: 11px; white-space: nowrap; }
.history-item.failed .said::before { content: "⚠ "; color: var(--danger); }
.empty { color: var(--muted); font-size: 13px; margin: 0; }

footer { margin-top: 26px; text-align: center; color: var(--muted); font-size: 11px; line-height: 1.5; }

.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: rgba(2, 6, 12, 0.86);
  backdrop-filter: blur(8px);
  padding: 20px;
}
.panel {
  width: 100%; max-width: 360px;
  padding: 24px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  text-align: center;
}
.panel h2 { margin: 0 0 8px; font-size: 19px; }
.panel p { color: var(--muted); font-size: 13px; line-height: 1.5; }
.panel input {
  width: 100%; padding: 12px; margin: 8px 0 12px;
  border-radius: 10px; border: 1px solid var(--line);
  background: #07111f; color: var(--text); text-align: center;
  font-size: 15px; outline: none;
}
.primary {
  width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #04101c; font-weight: 700; cursor: pointer;
}
.error { color: var(--danger) !important; min-height: 18px; }

.toast {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 30; max-width: 92vw;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--accent);
  background: rgba(8, 22, 38, 0.96);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

.hidden { display: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.75); } }

@media (min-width: 520px) {
  .app { padding-top: 30px; }
  .orb { width: 190px; height: 190px; }
  .mic { width: 118px; height: 118px; }
}
