:root {
  --panel: rgba(8, 19, 31, 0.66);
  --panel-strong: rgba(8, 19, 31, 0.82);
  --text: #f7f4eb;
  --muted: rgba(247, 244, 235, 0.72);
  --accent: #ffb84d;
  --accent-2: #73d2de;
  --border: rgba(255, 255, 255, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(4, 9, 15, 0.24), rgba(4, 9, 15, 0.66)),
    url("img/bg.jpg")
      center/cover no-repeat fixed;
}

.page {
  min-height: 100vh;
  padding: 28px 18px 36px;
  backdrop-filter: blur(4px);
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 0.35fr 0.65fr;
  gap: 22px;
  align-items: stretch;
}

.hero, .chat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.hero {
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: max(640px, min(90vh, calc(100vh - 64px)));
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 44px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  color: #08131f;
  font-size: 20px;
  font-weight: 700;
}

.brand-text strong {
  display: block;
  font-size: 14px;
  letter-spacing: 0.24em;
}

.brand-text span {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 12px;
}

h1 {
  margin: 12px 0 16px;
  max-width: 10ch;
  font-size: clamp(32px, 5vw, 48px);
  line-height: 1.08;
}

.lead {
  max-width: 30rem;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
}

.stats {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 28px;
}

.stat {
  width: 100%;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat strong {
  display: block;
  font-size: 24px;
  margin-bottom: 6px;
}

.stat span {
  color: var(--muted);
  font-size: 14px;
}

.chat-card {
  height: max(640px, min(90vh, calc(100vh - 64px)));
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--panel-strong);
}

.chat-top {
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 19, 31, 0.88);
}

.chat-top h2 {
  margin: 0 0 8px;
  font-size: 26px;
}

.chat-top p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.preset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  max-height: 105px;
  overflow: hidden;
  transition: max-height 220ms ease;
}

.preset-list.expanded {
  max-height: 320px;
}

.preset {
  border: 1px solid rgba(255, 184, 77, 0.28);
  background: linear-gradient(135deg, rgba(255, 184, 77, 0.22), rgba(115, 210, 222, 0.14));
  color: var(--text);
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.preset:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, rgba(255, 184, 77, 0.3), rgba(115, 210, 222, 0.2));
  border-color: rgba(255, 184, 77, 0.44);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.2);
}

.preset-toggle {
  margin-top: 12px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  padding: 0;
  cursor: pointer;
}

.messages {
  min-height: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 184, 77, 0.82) rgba(255, 255, 255, 0.08);
}

.messages::-webkit-scrollbar {
  width: 12px;
}

.messages::-webkit-scrollbar-track {
  margin: 10px 0;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(8, 19, 31, 0.2);
}

.messages::-webkit-scrollbar-thumb {
  border-radius: 999px;
  border: 2px solid transparent;
  background:
    linear-gradient(180deg, rgba(255, 184, 77, 0.96), rgba(115, 210, 222, 0.92)) padding-box,
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.04)) border-box;
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.24),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.messages::-webkit-scrollbar-thumb:hover {
  background:
    linear-gradient(180deg, rgba(255, 198, 112, 1), rgba(135, 224, 232, 0.96)) padding-box,
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.06)) border-box;
}

.messages::-webkit-scrollbar-corner {
  background: transparent;
}

.message {
  max-width: 84%;
  padding: 14px 16px;
  border-radius: 18px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #0f766e, #155e75);
}

.message.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.message.assistant.loading {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 110px;
  color: var(--muted);
}

.working-icon {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(115, 210, 222, 0.22);
  border-top-color: var(--accent-2);
  border-right-color: var(--accent);
  animation: spin 900ms linear infinite;
  flex: 0 0 auto;
}

.working-icon::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 184, 77, 0.95), rgba(115, 210, 222, 0.18));
  animation: pulse 1100ms ease-in-out infinite;
}

.working-label {
  font-size: 14px;
  letter-spacing: 0.02em;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { transform: scale(0.72); opacity: 0.55; }
  50% { transform: scale(1); opacity: 1; }
}

.composer {
  padding: 16px 18px 18px;
  border-top: 1px solid var(--border);
  background: rgba(8, 19, 31, 0.92);
}

.composer form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

textarea {
  min-height: 64px;
  resize: vertical;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 14px 16px;
  font: inherit;
}

textarea::placeholder {
  color: rgba(247, 244, 235, 0.46);
}

.send {
  min-width: 108px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), #ff7a18);
  color: #08131f;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.send:disabled {
  opacity: 0.72;
  cursor: wait;
}

.footer-note {
  text-align: center;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .hero { min-height: auto; }
  .chat-card {
    height: auto;
    min-height: 560px;
    grid-template-rows: auto auto auto;
  }
  .messages {
    min-height: auto;
    overflow: visible;
  }
  h1 { max-width: none; }
}

@media (max-width: 640px) {
  .chat-card {
    min-height: 520px;
  }
  .composer form { grid-template-columns: 1fr; }
  .send { min-height: 52px; }
  .message { max-width: 100%; }
  .preset {
    font-size: 14px;
    padding: 11px 16px;
  }
}
