:root {
  --page: #f5f6f1;
  --panel: #ffffff;
  --panel-soft: #f8faf7;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d8ded6;
  --teal: #137b74;
  --teal-dark: #0f5f5a;
  --gold: #b98318;
  --red: #b8443f;
  --green: #2f7d46;
  --shadow: 0 16px 34px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 340px;
  height: 100vh;
  min-height: 620px;
}

.sidebar,
.sources {
  background: var(--panel-soft);
  border-color: var(--line);
  overflow-y: auto;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 22px 18px;
}

.sources {
  border-left: 1px solid var(--line);
  padding: 22px 18px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border: 2px solid var(--teal);
  background: #e8f3ef;
  color: var(--teal-dark);
  font-weight: 800;
  font-size: 24px;
}

.brand-text {
  min-width: 0;
}

.school-name,
.eyebrow,
.metric-label {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

h1,
h2 {
  margin: 0;
  font-weight: 760;
  letter-spacing: 0;
}

h1 {
  font-size: 17px;
  line-height: 1.35;
}

h2 {
  font-size: 20px;
  line-height: 1.25;
}

.status-band,
.quick-panel,
.scope-panel {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  font-size: 14px;
  font-weight: 700;
}

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

.status-ok {
  background: var(--green);
}

.status-error {
  background: var(--red);
}

.status-waiting {
  background: var(--gold);
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.status-grid > div {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 10px;
  min-height: 62px;
}

.status-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
}

.section-title {
  margin-bottom: 10px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.sample {
  display: block;
  width: 100%;
  min-height: 42px;
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  padding: 9px 10px;
  line-height: 1.35;
}

.sample:hover,
.sample:focus-visible {
  border-color: var(--teal);
  outline: none;
}

.scope-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scope-tags span {
  border: 1px solid #cbd8d1;
  background: #eef5f0;
  color: #315d4c;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
}

.conversation {
  display: grid;
  grid-template-rows: 78px minmax(0, 1fr) auto;
  min-width: 0;
  background: var(--panel);
}

.topbar,
.sources-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.topbar {
  padding: 16px 22px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.send-button {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  font-size: 18px;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--teal);
  color: var(--teal-dark);
  outline: none;
}

.chat-log {
  overflow-y: auto;
  padding: 20px 22px 24px;
  background:
    linear-gradient(180deg, rgba(19, 123, 116, 0.04), rgba(255, 255, 255, 0) 220px),
    var(--panel);
}

.message {
  display: grid;
  gap: 6px;
  max-width: 880px;
  margin-bottom: 16px;
}

.message.user {
  margin-left: auto;
  justify-items: end;
}

.message.assistant {
  margin-right: auto;
}

.message-label {
  color: var(--muted);
  font-size: 12px;
}

.bubble {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.68;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 8px 22px rgba(31, 41, 51, 0.05);
}

.user .bubble {
  background: #e7f3ef;
  border-color: #bed6cf;
}

.assistant .bubble {
  background: var(--panel);
}

.bubble.pending {
  color: var(--muted);
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.feedback-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  color: var(--muted);
  font-size: 12px;
}

.feedback-button {
  min-width: 52px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  color: #475467;
  padding: 4px 9px;
  font-size: 12px;
}

.feedback-button:hover:not(:disabled),
.feedback-button:focus-visible:not(:disabled) {
  border-color: var(--teal);
  color: var(--teal-dark);
  outline: none;
}

.feedback-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 7px;
  color: #344054;
  background: #f7f8f5;
  font-size: 12px;
}

.badge.answered {
  border-color: #b9d7ca;
  background: #edf7f2;
  color: #1f6b4b;
}

.badge.refused {
  border-color: #efc1bd;
  background: #fff0ef;
  color: var(--red);
}

.badge.no-evidence {
  border-color: #e5d0a2;
  background: #fff8e8;
  color: #805a12;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 12px;
  padding: 16px 22px 18px;
  border-top: 1px solid var(--line);
  background: #fbfcfa;
}

#queryInput {
  width: 100%;
  min-height: 76px;
  max-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: var(--panel);
  line-height: 1.55;
}

#queryInput:focus {
  border-color: var(--teal);
  outline: 3px solid rgba(19, 123, 116, 0.14);
}

.send-button {
  width: 48px;
  height: 48px;
  align-self: end;
  border-radius: 8px;
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
  font-size: 22px;
  font-weight: 800;
}

.send-button:disabled,
.icon-button:disabled,
.sample:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.send-button:hover:not(:disabled),
.send-button:focus-visible:not(:disabled) {
  background: var(--teal-dark);
  outline: none;
}

.sources-header {
  padding-bottom: 16px;
}

.latency {
  min-width: 68px;
  text-align: right;
  color: var(--muted);
  font-size: 12px;
}

.answer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 30px;
  margin: 14px 0;
}

.source-list,
.evidence-list {
  display: grid;
  gap: 10px;
}

.source-item,
.evidence-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
}

.source-item strong,
.evidence-item strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  line-height: 1.45;
}

.source-item p,
.evidence-item p {
  margin: 0;
  color: #475467;
  font-size: 12px;
  line-height: 1.55;
}

.evidence-title {
  margin: 18px 0 10px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.empty-state {
  border: 1px dashed #cbd5cf;
  border-radius: 8px;
  color: var(--muted);
  padding: 16px 12px;
  text-align: center;
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 11px 13px;
  box-shadow: var(--shadow);
  font-size: 14px;
  z-index: 20;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .sources {
    display: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    order: 2;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .conversation {
    order: 1;
    height: 100vh;
    min-height: 620px;
  }

  .sources {
    display: block;
    order: 3;
    border-left: none;
    border-top: 1px solid var(--line);
  }

  .topbar {
    align-items: flex-start;
    padding: 14px;
  }

  .topbar h2 {
    font-size: 18px;
  }

  .toolbar {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .chat-log {
    padding: 16px 14px;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) 46px;
    padding: 12px 14px;
  }

  .sidebar {
    padding: 18px 14px;
  }
}
