:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: rgba(18, 24, 42, 0.82);
  --line: rgba(148, 163, 184, 0.18);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --bot: rgba(30, 41, 59, 0.95);
  --user: rgba(56, 189, 248, 0.16);
  --shadow: 0 24px 80px rgba(2, 6, 23, 0.45);
  font-family: "SF Pro Text", "PingFang TC", "Noto Sans TC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 20%, rgba(56, 189, 248, 0.18), transparent 32%),
    radial-gradient(circle at 80% 10%, rgba(129, 140, 248, 0.16), transparent 28%),
    linear-gradient(180deg, #070b16 0%, var(--bg) 100%);
}

.shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
  display: grid;
  gap: 24px;
}

.hero {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.05;
}

.lede {
  margin: 12px 0 0;
  color: var(--muted);
  max-width: 62ch;
  line-height: 1.6;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.chip {
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.chip:hover {
  border-color: rgba(56, 189, 248, 0.55);
  transform: translateY(-1px);
}

.chat {
  display: grid;
  gap: 16px;
}

.messages {
  display: grid;
  gap: 12px;
  min-height: 280px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.55);
}

.msg {
  max-width: 88%;
  padding: 14px 16px;
  border-radius: 18px;
  line-height: 1.65;
}

.msg.user {
  white-space: pre-wrap;
}

.msg.bot {
  white-space: normal;
}

.msg.bot > *:first-child {
  margin-top: 0;
}

.msg.bot > *:last-child {
  margin-bottom: 0;
}

.msg.bot h1,
.msg.bot h2,
.msg.bot h3 {
  margin: 0.85em 0 0.4em;
  line-height: 1.3;
  color: var(--text);
}

.msg.bot h2 {
  font-size: 1.15em;
}

.msg.bot h3 {
  font-size: 1.05em;
}

.msg.bot p {
  margin: 0.55em 0;
}

.msg.bot ul,
.msg.bot ol {
  margin: 0.45em 0;
  padding-left: 1.25em;
}

.msg.bot li {
  margin: 0.25em 0;
}

.msg.bot code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  color: var(--accent);
  background: rgba(2, 6, 23, 0.35);
  padding: 0.1em 0.35em;
  border-radius: 6px;
}

.msg.bot strong {
  color: #f8fafc;
}

.msg.bot a {
  color: var(--accent);
}

.msg.bot {
  background: var(--bot);
  border: 1px solid var(--line);
}

.msg.user {
  margin-left: auto;
  background: var(--user);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.msg.pending {
  color: var(--muted);
  font-style: italic;
}

.composer {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(2, 6, 23, 0.55);
  color: var(--text);
  padding: 14px 16px;
  font: inherit;
}

textarea:focus {
  outline: 2px solid rgba(56, 189, 248, 0.35);
  border-color: rgba(56, 189, 248, 0.45);
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  cursor: pointer;
}

#send {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #041018;
  font-weight: 700;
}

#send:disabled {
  opacity: 0.55;
  cursor: wait;
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.foot {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.gate-card h1 {
  margin: 0;
  font-size: 1.8rem;
}

.gate-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(2, 6, 23, 0.55);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
}

.gate-card button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #041018;
  font-weight: 700;
}

.gate-error {
  margin: 0;
  color: #fca5a5;
  font-size: 14px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 640px) {
  .shell {
    width: min(100%, calc(100% - 20px));
    padding-top: 16px;
  }

  .hero,
  .messages,
  .composer {
    border-radius: 18px;
  }

  .msg {
    max-width: 100%;
  }
}
