:root {
  --bg: #04070a;
  --panel: #0a1118;
  --cyan: #4ad9ff;
  --cyan-dim: #1c5a73;
  --text: #cdeefb;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Consolas', 'Courier New', monospace;
  overflow: hidden;
}
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(74, 217, 255, 0.03) 0px,
    rgba(74, 217, 255, 0.03) 1px,
    transparent 1px,
    transparent 3px
  );
  z-index: 5;
}
main {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px;
}
header { text-align: center; }
h1 {
  letter-spacing: 6px;
  font-weight: 400;
  color: var(--cyan);
  text-shadow: 0 0 12px var(--cyan);
  margin: 8px 0 4px;
}
#statusLine {
  color: var(--cyan-dim);
  margin: 0 0 12px;
  text-transform: lowercase;
  letter-spacing: 2px;
}

.core { position: relative; width: 90px; height: 90px; margin: 0 auto; }
.ring {
  position: absolute;
  border: 1.5px solid var(--cyan);
  border-radius: 50%;
  opacity: 0.5;
  animation: spin linear infinite;
}
.r1 { inset: 0; animation-duration: 6s; }
.r2 { inset: 14px; animation-duration: 4s; animation-direction: reverse; border-style: dashed; }
.r3 { inset: 28px; animation-duration: 8s; }
.dot {
  position: absolute;
  inset: 38px;
  background: var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 20px var(--cyan);
}
.core.thinking .ring { animation-duration: 1.2s; }
.core.thinking .dot { animation: pulse 0.6s ease-in-out infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

#log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 4px;
  line-height: 1.4;
  white-space: pre-wrap;
  border: 1px solid var(--cyan-dim);
}
.bubble.user { align-self: flex-end; background: rgba(74, 217, 255, 0.08); border-color: var(--cyan); }
.bubble.assistant { align-self: flex-start; background: rgba(74, 217, 255, 0.04); }
.bubble.system { align-self: center; color: var(--cyan-dim); font-size: 0.85em; border: none; }

footer {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--cyan-dim);
}
#micBtn {
  font-size: 22px;
  background: var(--panel);
  border: 1px solid var(--cyan-dim);
  color: var(--cyan);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  cursor: pointer;
  flex-shrink: 0;
}
#micBtn.listening { background: var(--cyan); color: #04070a; box-shadow: 0 0 16px var(--cyan); }
#micBtn:disabled { opacity: 0.3; cursor: not-allowed; }
#textForm { flex: 1; display: flex; gap: 8px; }
#textInput {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--cyan-dim);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 4px;
  font-family: inherit;
}
#textInput:focus { outline: none; border-color: var(--cyan); }
#textForm button {
  background: transparent;
  border: 1px solid var(--cyan-dim);
  color: var(--cyan);
  padding: 10px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}
#textForm button:hover { border-color: var(--cyan); }
