:root {
  font-family: Inter, system-ui, sans-serif;
  color: #142033;
  background: #f5f7fb;
  --active-school-accent: #163a63;
  --active-school-accent-text: #ffffff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #eef4fb 0, #fff 100%);
}

main {
  width: min(760px, calc(100% - 28px));
  margin: auto;
  padding: 46px 0;
}

.brand {
  display: flex;
  gap: 13px;
  align-items: center;
  margin-bottom: 28px;
}

.mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: #163a63;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 27px;
}

.brand p {
  margin: 2px 0;
  color: #5b6675;
  font-size: 14px;
}

.card {
  background: #fff;
  border: 1px solid #dde5ef;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 14px 40px #24344d12;
}

.intro {
  font-size: 18px;
  line-height: 1.5;
}

.school-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.school-button {
  min-height: 220px;
  border: 1px solid #d7e0eb;
  border-radius: 18px;
  background: var(--school-card-tint, #f8fbff);
  color: #142033;
  padding: 18px 14px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(36, 52, 77, 0.05);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.school-button:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--school-accent, #9fb6d2);
  box-shadow: 0 12px 26px rgba(36, 52, 77, 0.12);
}

.school-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--school-accent, #1f4e8c) 30%, transparent);
  outline-offset: 3px;
}

.school-button:disabled {
  cursor: default;
  opacity: 0.6;
}

.school-icon-wrap {
  width: 116px;
  height: 116px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background: var(--school-accent, #1f4e8c);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), 0 8px 18px rgba(20,32,51,.12);
  overflow: hidden;
}

.school-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.school-title {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
  margin-top: 2px;
}

.school-state,
.school-loading,
.eyebrow {
  color: #667085;
  font-size: 12px;
}

.school-state {
  margin-top: auto;
  font-weight: 700;
}

.school-loading { margin: 0; }

.assistant-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e7edf4;
}

.assistant-school-icon {
  width: 58px;
  height: 58px;
  border-radius: 15px;
  object-fit: cover;
  flex: 0 0 auto;
  box-shadow: 0 6px 16px rgba(20, 32, 51, 0.14);
}

.assistant-head > div {
  margin-right: auto;
}

.assistant-head h2 {
  margin: 3px 0 0;
  color: var(--active-school-accent);
  font-size: 22px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 800;
}

.askrow {
  display: flex;
  gap: 10px;
}

textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  border: 1px solid #cdd7e4;
  border-radius: 14px;
  padding: 14px;
  font: inherit;
}

button {
  border: 0;
  border-radius: 13px;
  background: var(--active-school-accent, #163a63);
  color: var(--active-school-accent-text, white);
  font-weight: 700;
  padding: 0 20px;
  min-width: 94px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.secondary-button {
  min-width: 0;
  min-height: 38px;
  padding: 9px 13px;
  background: #edf3f9;
  color: var(--active-school-accent, #163a63);
  white-space: nowrap;
}

.answer {
  display: none;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e7edf4;
  line-height: 1.55;
}

.answer.show { display: block; }

#answer > strong {
  display: none;
}

#answerText {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 84%;
}

.chat-message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-message.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-label {
  margin: 0 6px 4px;
  color: #667085;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.chat-bubble {
  padding: 11px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-message.user .chat-bubble {
  background: var(--active-school-accent, #163a63);
  color: var(--active-school-accent-text, #fff);
  border-bottom-right-radius: 5px;
}

.chat-message.assistant .chat-bubble {
  background: #f1f4f8;
  color: #142033;
  border: 1px solid #e1e7ef;
  border-bottom-left-radius: 5px;
}

.status,
.note,
.last-checked {
  font-size: 12px;
  color: #667085;
}

.status { margin-top: 14px; }

.last-checked {
  margin: 14px 4px 0;
  text-align: center;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ba7b5;
  margin-right: 7px;
}

.dot.ready { background: #2c9d62; }

@media (max-width: 700px) {
  .school-grid { grid-template-columns: 1fr; }
  .school-button {
    min-height: 0;
    display: grid;
    grid-template-columns: 92px 1fr;
    grid-template-rows: auto auto;
    column-gap: 16px;
    row-gap: 4px;
    text-align: left;
    align-items: center;
    padding: 14px;
  }

  .school-icon-wrap {
    width: 92px;
    height: 92px;
    grid-row: 1 / 3;
  }

  .school-title {
    align-self: end;
    font-size: 18px;
  }

  .school-state {
    margin-top: 0;
    align-self: start;
  }
}

@media (max-width: 600px) {
  main { padding: 28px 0; }
  .askrow { display: block; }

  #ask {
    width: 100%;
    height: 48px;
    margin-top: 10px;
  }

  .assistant-head {
    align-items: center;
    flex-wrap: wrap;
  }

  .assistant-school-icon {
    width: 52px;
    height: 52px;
  }

  .assistant-head h2 {
    font-size: 20px;
  }

  .secondary-button {
    margin-left: 0;
  }

  #changeSchool {
    margin-left: auto;
  }

  .chat-message {
    max-width: 92%;
  }
}
