:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #162033;
  --muted: #667085;
  --line: #d9e0eb;
  --primary: #3157d5;
  --primary-dark: #2442a4;
  --soft-primary: #edf2ff;
  --danger: #c0392b;
  --danger-bg: #fff1f0;
  --shadow: 0 18px 45px rgba(25, 39, 80, 0.10);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(49, 87, 213, 0.12), transparent 34%),
    linear-gradient(135deg, #f8fbff 0%, var(--bg) 58%, #eef2fb 100%);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1040px, calc(100% - 32px));
  margin: 32px auto;
}

.hero-card,
.panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(217, 224, 235, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 34px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.03em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.2rem;
}

.subtitle {
  max-width: 850px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.8;
}

.panel {
  padding: 24px;
  margin-bottom: 18px;
}

.key-panel {
  display: grid;
  gap: 12px;
}

.muted {
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 0;
}

.input-label {
  display: block;
  margin: 12px 0 8px;
  color: #344054;
  font-weight: 700;
}

.key-row {
  display: flex;
  gap: 10px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

input {
  height: 46px;
  padding: 0 14px;
}

textarea {
  resize: vertical;
  min-height: 160px;
  padding: 14px;
  line-height: 1.7;
}

input:focus,
textarea:focus {
  border-color: rgba(49, 87, 213, 0.72);
  box-shadow: 0 0 0 4px rgba(49, 87, 213, 0.12);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.example-chip,
.ghost-btn,
.secondary-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: #344054;
  border-radius: 999px;
  padding: 9px 13px;
  transition: transform 0.15s ease, border 0.15s ease, background 0.15s ease;
}

.example-chip:hover,
.ghost-btn:hover,
.secondary-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(49, 87, 213, 0.45);
  background: var(--soft-primary);
}

.secondary-btn {
  flex: 0 0 auto;
  border-radius: 12px;
}

.chat-box {
  min-height: 260px;
  max-height: 560px;
  overflow-y: auto;
  padding: 18px;
  background: #f8faff;
  border: 1px solid var(--line);
  border-radius: 18px;
  margin-bottom: 18px;
}

.empty-state {
  height: 220px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.message {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.message:last-child {
  margin-bottom: 0;
}

.message-meta {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--muted);
}

.bubble {
  width: fit-content;
  max-width: min(780px, 100%);
  padding: 13px 15px;
  border-radius: 16px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user {
  justify-items: end;
}

.message.user .bubble {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 6px;
}

.message.assistant {
  justify-items: start;
}

.message.assistant .bubble {
  background: white;
  color: var(--text);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}

.primary-btn {
  min-width: 150px;
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  background: var(--primary);
  color: white;
  font-weight: 800;
  box-shadow: 0 12px 22px rgba(49, 87, 213, 0.24);
  transition: transform 0.15s ease, background 0.15s ease;
}

.primary-btn:hover {
  transform: translateY(-1px);
  background: var(--primary-dark);
}

.primary-btn:disabled,
.ghost-btn:disabled,
.secondary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.status-text {
  color: var(--muted);
}

.error-box {
  display: none;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(192, 57, 43, 0.22);
  line-height: 1.6;
}

.error-box.show {
  display: block;
}

.footer-note {
  color: var(--muted);
  text-align: center;
  font-size: 0.92rem;
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1040px);
    margin: 16px auto;
  }

  .hero-card,
  .panel {
    padding: 20px;
  }

  .section-header,
  .key-row,
  .action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .primary-btn,
  .secondary-btn,
  .ghost-btn {
    width: 100%;
  }
}
