@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=IBM+Plex+Sans:wght@400;500;600&family=VT323&display=swap");

* {
  box-sizing: border-box;
}

:root {
  --bg-0: #0f1113;
  --bg-1: #15181c;
  --bg-2: #1c2026;
  --panel: rgba(18, 21, 26, 0.92);
  --panel-stroke: #2e343c;
  --text: #e3e7ec;
  --muted: #9aa2ad;
  --primary: #6c727a;
  --primary-strong: #8a919b;
  --accent: #c2c6cc;
  --danger: #c45252;
  --title: "Space Grotesk", sans-serif;
  --body: "IBM Plex Sans", sans-serif;
  --pixel: "VT323", monospace;
}

:root[data-theme="mono"] {
  --bg-0: #0f1113;
  --bg-1: #15181c;
  --bg-2: #1c2026;
  --panel: rgba(18, 21, 26, 0.92);
  --panel-stroke: #2e343c;
  --text: #e3e7ec;
  --muted: #9aa2ad;
  --primary: #6c727a;
  --primary-strong: #8a919b;
  --accent: #c2c6cc;
}

:root[data-theme="neon"] {
  --bg-0: #0b0f16;
  --bg-1: #0e1622;
  --bg-2: #141f2d;
  --panel: rgba(12, 20, 30, 0.9);
  --panel-stroke: #2c3a55;
  --text: #e8f1ff;
  --muted: #93a8c0;
  --primary: #2e8bc0;
  --primary-strong: #45b1f2;
  --accent: #e0a938;
}

:root[data-theme="sunset"] {
  --bg-0: #1a1416;
  --bg-1: #24161a;
  --bg-2: #2e1b1e;
  --panel: rgba(30, 20, 22, 0.9);
  --panel-stroke: #4a2c33;
  --text: #f3e8e4;
  --muted: #c9a9a1;
  --primary: #d06c4e;
  --primary-strong: #e58a5a;
  --accent: #f0c766;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text);
  font-family: var(--body);
  background:
    radial-gradient(1200px 420px at 10% -8%, rgba(110, 120, 135, 0.2), transparent 65%),
    radial-gradient(900px 380px at 92% 0%, rgba(196, 200, 208, 0.08), transparent 62%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 36%, var(--bg-2));
}

.hero {
  padding: 22px 26px 18px;
  border-bottom: 1px solid rgba(120, 146, 173, 0.24);
  background: linear-gradient(180deg, rgba(13, 18, 24, 0.82), rgba(19, 25, 32, 0.42));
  backdrop-filter: blur(8px);
}

.heroTop {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

h1 {
  margin: 0;
  font-family: var(--title);
  font-size: 26px;
  letter-spacing: 0.5px;
}

.heroSub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.ghostLink {
  color: #a8c8df;
  text-decoration: none;
  border: 1px solid #42617f;
  padding: 7px 11px;
  border-radius: 999px;
  transition: 140ms ease;
  font-size: 13px;
}

.heroActions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.themeRow {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #3a424d;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(18, 24, 32, 0.6);
}

.themeLabel {
  font-size: 11px;
  color: var(--muted);
  margin-right: 4px;
}

.themeBtn {
  border: 1px solid #4a5664;
  background: transparent;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.themeBtn.active {
  border-color: var(--primary-strong);
  color: #f1f6ff;
  box-shadow: 0 0 0 2px rgba(120, 160, 200, 0.16);
}

.ghostLink:hover {
  border-color: #62a1d2;
  color: #c6e6ff;
  transform: translateY(-1px);
}

.layout {
  padding: 18px 22px 24px;
  max-width: 1180px;
  margin: 0 auto;
}

.panel {
  border: 1px solid var(--panel-stroke);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 22px 32px rgba(0, 0, 0, 0.2);
}

.configPanel {
  padding: 14px;
}

.chatPanel {
  margin-top: 14px;
  padding: 14px;
}

label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  color: #b8c5d4;
  letter-spacing: 0.2px;
}

textarea,
input {
  width: 100%;
  border: 1px solid #35465b;
  border-radius: 12px;
  background: rgba(15, 21, 30, 0.92);
  color: var(--text);
  padding: 11px 12px;
  font-family: inherit;
  outline: none;
  transition: 130ms ease;
}

textarea:focus,
input:focus {
  border-color: #5da0d0;
  box-shadow: 0 0 0 3px rgba(71, 142, 189, 0.2);
}

.controlsRow {
  margin-top: 10px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.miniControl {
  width: 170px;
}

.ttsToggle input {
  width: auto;
  transform: translateY(2px) scale(1.05);
}

.ttsVolume input[type="range"] {
  padding: 0;
  height: 40px;
}

button {
  border: 1px solid #425a74;
  background: #233345;
  color: #dbe7f5;
  border-radius: 11px;
  padding: 10px 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: #6fa8d7;
}

button.primary {
  border-color: var(--primary-strong);
  background: linear-gradient(180deg, var(--primary-strong), var(--primary));
}

button.secondary {
  background: #1f2a36;
}

button.mic {
  border-color: #ba9452;
  background: linear-gradient(180deg, #9c814e, #7f673f);
  min-width: 122px;
}

button.mic.micOn {
  animation: micPulse 1400ms ease-in-out infinite;
}

button:disabled {
  opacity: 0.64;
  cursor: not-allowed;
}

@keyframes micPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(213, 165, 78, 0.35);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(213, 165, 78, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(213, 165, 78, 0);
  }
}

.status {
  margin-left: auto;
  padding: 8px 11px;
  border-radius: 999px;
  border: 1px solid #415264;
  font-size: 12px;
  color: #c4d1de;
  background: rgba(21, 30, 39, 0.78);
}

.chatlog {
  height: 500px;
  overflow: auto;
  border: 1px solid #334457;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(12, 16, 20, 0.88), rgba(17, 20, 24, 0.9));
  padding: 10px;
}

.msg {
  padding: 10px 12px;
  border-radius: 12px;
  margin: 8px 0;
  line-height: 1.35;
  white-space: pre-wrap;
  animation: msgIn 180ms ease;
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg.user {
  background: rgba(62, 146, 195, 0.22);
  border: 1px solid rgba(74, 170, 229, 0.35);
}

.msg.assistant {
  background: rgba(169, 184, 199, 0.14);
  border: 1px solid rgba(174, 192, 209, 0.24);
}

.msg.assistant.streaming::after {
  content: "▍";
  display: inline-block;
  margin-left: 4px;
  opacity: 0.8;
  animation: caretBlink 1.05s step-end infinite;
}

@keyframes caretBlink {
  50% {
    opacity: 0;
  }
}

.msg.sys {
  background: rgba(216, 166, 70, 0.12);
  border: 1px dashed rgba(216, 166, 70, 0.35);
  color: #d9e5f2;
}

.micRow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
}

.meterTrack {
  height: 12px;
  border-radius: 999px;
  border: 1px solid #42566f;
  background: rgba(22, 31, 41, 0.9);
  flex: 1;
  overflow: hidden;
}

.meterFill {
  height: 100%;
  width: 2%;
  background: linear-gradient(90deg, #3f8fbc, #5fb2de 60%, #b5d8f2);
  transition: width 90ms linear;
}

.composer {
  display: flex;
  gap: 9px;
  margin-top: 9px;
}

.composer input {
  flex: 1;
}

.hint {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 800px) {
  .layout {
    padding: 14px;
  }

  .hero {
    padding: 16px 14px 13px;
  }

  h1 {
    font-size: 22px;
  }

  .chatlog {
    height: 420px;
  }

  .status {
    margin-left: 0;
  }
}
