:root {
  --background: 30 15% 12%;
  --foreground: 40 30% 90%;
  --primary: 40 65% 55%;
  --secondary: 30 10% 22%;
  --muted-foreground: 30 10% 55%;
  --border: 30 10% 25%;
  --gold: 40 65% 55%;
  --gold-glow: 40 80% 65%;
  --radius: 0.75rem;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: hsl(var(--foreground));
  background: hsl(30 18% 8%);
  line-height: 1.5;
}

.font-serif-cn {
  font-family: "Songti SC", "STSong", "SimSun", "PingFang TC", serif;
}

.page {
  max-width: 36rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.page__header {
  text-align: center;
}

.page__title {
  margin: 0 0 0.25rem;
  color: hsl(var(--gold));
  font-size: 1.5rem;
}

.page__sub {
  margin: 0;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
}

.page__status {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.page__status.is-ok {
  color: hsl(140 45% 55%);
}

.page__status.is-warn {
  color: hsl(35 80% 60%);
}

.gate-chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  border-radius: var(--radius);
  border: 1px solid hsla(40, 65%, 55%, 0.28);
  background: hsl(30 12% 14%);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  min-height: 20rem;
  max-height: min(85vh, 40rem);
}

.gate-chat__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--gold));
  font-size: 0.8rem;
  font-weight: 600;
}

.gate-chat__model {
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  font-size: 0.72rem;
}

.gate-chat__messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.65rem;
  font-size: 0.8rem;
}

.gate-chat__msg {
  margin-bottom: 0.52rem;
}

.gate-chat__msg--user {
  color: hsl(var(--gold-glow));
}

.gate-chat__form {
  border-top: 1px solid hsl(var(--border));
  padding: 0.5rem;
}

.gate-chat__row {
  display: flex;
  gap: 0.4rem;
}

.gate-chat__row input {
  flex: 1;
  min-width: 0;
  border-radius: 0.5rem;
  border: 1px solid hsl(var(--border));
  background: hsl(30 15% 10%);
  color: hsl(var(--foreground));
  padding: 0.45rem 0.6rem;
  font-size: 1rem;
}

.btn {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  border-radius: 0.5rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.gate-chat__mic {
  min-width: 2.3rem;
  height: 2.3rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid hsla(40, 65%, 55%, 0.5);
  background: radial-gradient(
    circle at 28% 24%,
    hsla(42, 90%, 78%, 0.95) 0%,
    hsla(34, 66%, 48%, 0.88) 56%,
    hsla(24, 58%, 32%, 0.86) 100%
  );
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.gate-chat__mic-icon {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: hsl(26 32% 12%);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gate-chat__mic.is-recording {
  animation: gateMicNudge 0.9s ease-in-out infinite;
}

.gate-chat__mic.is-recording .gate-chat__mic-icon {
  stroke: #fff7ed;
}

.gate-chat__thinking {
  margin: 0.4rem 0 0;
  font-size: 0.72rem;
  color: hsl(var(--muted-foreground));
}

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