:root {
  color-scheme: light;
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-soft: #eef6f1;
  --line: #dce5df;
  --line-strong: #bfd0c7;
  --text: #17211d;
  --muted: #63716b;
  --faint: #8b9892;
  --brand: #0f8f68;
  --brand-strong: #087557;
  --brand-soft: #dff5ea;
  --warn: #b7791f;
  --danger: #b42318;
  --shadow: 0 16px 42px rgba(23, 33, 29, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(223, 245, 234, 0.72), transparent 360px),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 36px);
  border-bottom: 1px solid rgba(191, 208, 199, 0.72);
  background: rgba(246, 248, 247, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--brand);
  font-weight: 800;
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.25;
}

.top-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--brand);
}

.chat-page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 48px) clamp(14px, 4vw, 28px) 44px;
}

.chat-shell,
.results-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.chat-shell {
  display: grid;
  gap: 18px;
  min-height: calc(100vh - 150px);
  align-content: center;
  padding: clamp(20px, 5vw, 42px);
}

.chat-heading h2 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1.1;
}

.chat-heading p:not(.section-kicker),
.chat-boundary {
  max-width: 780px;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.75;
}

.conversation {
  display: grid;
  gap: 12px;
}

.message {
  width: min(760px, 100%);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.message.user {
  justify-self: end;
  border-color: #cce7d9;
  background: #f3fbf7;
}

.message.assistant.loading {
  border-color: #ead6a7;
  background: #fffaf0;
}

.message span {
  display: block;
  margin-bottom: 6px;
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 900;
}

.message p {
  margin: 0;
  line-height: 1.7;
  white-space: pre-line;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.prompt-chip {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  color: var(--brand-strong);
  background: var(--brand-soft);
  font-weight: 800;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.composer textarea {
  width: 100%;
  min-height: 116px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 14px;
  color: var(--text);
  background: #fff;
  line-height: 1.6;
  outline: none;
}

.composer textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 143, 104, 0.14);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  font-weight: 850;
}

.primary-button {
  color: #fff;
  background: var(--brand);
}

.primary-button:hover {
  background: var(--brand-strong);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.secondary-button {
  color: var(--brand-strong);
  border-color: var(--line-strong);
  background: #fff;
}

.chat-boundary {
  color: var(--faint);
  font-size: 13px;
}

.results-shell {
  margin-top: 22px;
  padding: clamp(16px, 3vw, 24px);
  scroll-margin-top: 88px;
}

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

.result-header h2,
.sources-panel h3 {
  margin: 0;
}

.summary-box {
  padding: 14px;
  border: 1px solid #cce7d9;
  border-radius: 8px;
  background: #f3fbf7;
  line-height: 1.7;
}

.summary-box p {
  white-space: pre-line;
}

.query-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.query-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.cards-grid {
  display: grid;
  gap: 14px;
}

.school-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand);
  border-radius: 8px;
  background: #fff;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-top h3 {
  margin: 0;
  font-size: 21px;
}

.card-meta {
  margin: 5px 0 0;
  color: var(--muted);
}

.confidence {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--brand-strong);
  background: var(--brand-soft);
  font-size: 12px;
  font-weight: 900;
}

.card-section {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.card-section strong {
  display: block;
  margin-bottom: 6px;
}

.card-section p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.card-section ul {
  margin: 0;
  padding-left: 18px;
}

.card-section li {
  margin: 4px 0;
  line-height: 1.6;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-links a,
.sources-list a {
  color: var(--brand-strong);
  font-weight: 850;
  text-decoration: none;
}

.sources-panel {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.sources-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.source-item {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.55;
}

.source-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.source-item span {
  display: block;
  color: var(--faint);
  font-size: 12px;
}

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

  .chat-shell {
    min-height: auto;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .composer .primary-button,
  .result-header .secondary-button {
    width: 100%;
  }

  .result-header,
  .card-top {
    flex-direction: column;
  }
}
