:root {
  --bg: #f5f8fc;
  --card: rgba(255,255,255,.88);
  --text: #162033;
  --muted: #66768a;
  --line: rgba(102,204,255,.28);
  --brand: #66ccff;
  --shadow: 0 18px 50px rgba(33, 88, 130, .13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(102,204,255,.36), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(169,139,255,.20), transparent 32rem),
    var(--bg);
}

button,
textarea {
  font: inherit;
}

.ai-page {
  width: min(980px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.ai-hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.ai-kicker {
  margin: 0 0 8px;
  color: #228fc6;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.6rem);
  letter-spacing: -.04em;
}

.ai-hero p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.8;
}

.ai-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ai-nav a {
  display: inline-flex;
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  background: rgba(255,255,255,.50);
  font-weight: 800;
}

.ai-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.ai-messages {
  height: min(620px, calc(100vh - 330px));
  min-height: 360px;
  overflow: auto;
  padding: 20px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.ai-msg {
  max-width: 88%;
  padding: 13px 15px;
  border-radius: 18px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-msg.user {
  justify-self: end;
  color: #062133;
  background: linear-gradient(135deg, #66ccff, #b8ecff);
  border-bottom-right-radius: 6px;
}

.ai-msg.assistant {
  justify-self: start;
  background: rgba(255,255,255,.68);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}

.ai-msg.error {
  justify-self: start;
  color: #8a1f1f;
  background: rgba(255, 220, 220, .8);
  border: 1px solid rgba(255, 120, 120, .35);
}

.ai-form {
  border-top: 1px solid var(--line);
  padding: 16px;
  background: rgba(255,255,255,.36);
}

.ai-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  outline: none;
  color: var(--text);
  background: rgba(255,255,255,.76);
  line-height: 1.7;
}

.ai-form textarea:focus {
  border-color: rgba(102,204,255,.86);
  box-shadow: 0 0 0 4px rgba(102,204,255,.18);
}

.ai-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.ai-thinking {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.ai-buttons {
  display: flex;
  gap: 10px;
}

.ai-buttons button {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 900;
}

#aiClear {
  color: var(--text);
  background: rgba(255,255,255,.72);
  border: 1px solid var(--line);
}

#aiSend {
  color: #062133;
  background: linear-gradient(135deg, #66ccff, #b8ecff);
}

#aiSend:disabled {
  opacity: .55;
  cursor: not-allowed;
}

@media (max-width: 720px) {
  .ai-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .ai-nav {
    justify-content: flex-start;
  }

  .ai-msg {
    max-width: 96%;
  }

  .ai-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .ai-buttons {
    justify-content: flex-end;
  }
}
