:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-strong: #111827;
  --text: #18202f;
  --muted: #657084;
  --line: rgba(24, 32, 47, 0.12);
  --accent: #b48643;
  --accent-strong: #77511e;
  --blue: #274c77;
  --green: #2f6f5e;
  --shadow: 0 18px 50px rgba(24, 32, 47, 0.12);
  --radius: 8px;
  --nav-height: 76px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1219;
  --surface: #171d27;
  --surface-strong: #f6efe2;
  --text: #f4f0e8;
  --muted: #aab3c2;
  --line: rgba(244, 240, 232, 0.14);
  --accent: #d7ad66;
  --accent-strong: #f2cb85;
  --blue: #78a8d8;
  --green: #76b8a4;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(180, 134, 67, 0.18), transparent 26rem),
    linear-gradient(180deg, rgba(39, 76, 119, 0.08), transparent 34rem),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(0.7rem + env(safe-area-inset-top)) 1rem 0.7rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--bg);
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand small {
  display: block;
  white-space: nowrap;
}

.brand strong {
  font-size: 0.98rem;
}

.brand small {
  color: var(--muted);
  font-size: 0.76rem;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 20px rgba(24, 32, 47, 0.08);
}

main {
  width: min(100%, 1120px);
  margin: 0 auto;
}

.section {
  padding: 2.2rem 1rem;
  scroll-margin-top: 84px;
}

.hero {
  min-height: calc(100svh - 144px);
  display: grid;
  align-content: center;
  gap: 1.2rem;
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2 {
  margin: 0;
  line-height: 1.02;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.45rem, 14vw, 4.8rem);
  max-width: 12ch;
}

h2 {
  font-size: clamp(2rem, 10vw, 3.6rem);
}

h3 {
  margin: 0;
  font-size: 1rem;
}

.lead,
.section-heading p,
.feature-band p,
.timeline p,
.service-grid p,
.books-grid p,
.program-list span {
  color: var(--muted);
  line-height: 1.62;
}

.lead {
  font-size: 1.08rem;
  max-width: 38rem;
}

.hero-actions,
.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.4rem;
}

.section-jump {
  display: flex;
  gap: 0.55rem;
  overflow-x: auto;
  padding: 0.25rem 1rem 1.2rem;
  scrollbar-width: none;
}

.section-jump::-webkit-scrollbar {
  display: none;
}

.section-jump a {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  color: var(--text);
  padding: 0.62rem 0.84rem;
  font-size: 0.84rem;
  font-weight: 800;
}

.primary-action,
.secondary-action,
.contact-actions a,
.chat-form button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  padding: 0.78rem 1rem;
  font-weight: 800;
}

.primary-action,
.chat-form button {
  background: var(--surface-strong);
  color: var(--bg);
}

.secondary-action,
.contact-actions a {
  border: 1px solid var(--line);
  background: var(--surface);
}

.insight-panel,
.chat-shell,
.timeline article,
.service-grid article,
.books-grid article,
.program-list article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
}

.insight-panel {
  padding: 1.15rem;
}

.panel-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.insight-panel p {
  margin: 0.7rem 0 1rem;
  font-size: 1.5rem;
  line-height: 1.18;
  font-weight: 800;
}

.insight-panel dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  margin: 0;
}

.insight-panel div {
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

.insight-panel dt {
  color: var(--blue);
  font-size: 1.35rem;
  font-weight: 900;
}

.insight-panel dd {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.section-heading {
  max-width: 44rem;
  margin-bottom: 1.2rem;
}

.chat-shell {
  padding: 0.8rem;
}

.knowledge-status {
  display: inline-flex;
  margin-top: 0.6rem;
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 800;
}

.suggestions {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.2rem 0 0.8rem;
  scrollbar-width: none;
}

.suggestions::-webkit-scrollbar {
  display: none;
}

.suggestions button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  padding: 0.58rem 0.8rem;
  font-size: 0.88rem;
}

.messages {
  display: grid;
  gap: 0.75rem;
  min-height: 260px;
  max-height: 52svh;
  overflow-y: auto;
  padding: 0.2rem 0.1rem 0.8rem;
}

.message {
  width: min(88%, 680px);
  padding: 0.86rem 0.95rem;
  border-radius: var(--radius);
  line-height: 1.5;
}

.message p {
  margin: 0;
}

.message p + p {
  margin-top: 0.7rem;
}

.message.ai {
  justify-self: start;
  background: color-mix(in srgb, var(--green) 16%, var(--surface));
}

.message.loading {
  color: var(--muted);
}

.message-sources {
  margin-top: 0.75rem;
  border-top: 1px solid var(--line);
  padding-top: 0.6rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.message.user {
  justify-self: end;
  background: var(--surface-strong);
  color: var(--bg);
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

.chat-form input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  padding: 0.82rem 0.9rem;
}

.chat-form button {
  border: 0;
}

.timeline,
.service-grid,
.books-grid,
.program-list {
  display: grid;
  gap: 0.8rem;
}

.timeline article,
.service-grid article,
.books-grid article,
.program-list article {
  padding: 1rem;
}

.timeline span {
  display: inline-block;
  margin-bottom: 0.5rem;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.feature-band {
  display: grid;
  gap: 1rem;
  border-block: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 48%, transparent);
}

.program-list article {
  display: grid;
  gap: 0.35rem;
}

.program-list strong {
  color: var(--blue);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  min-height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding: 0.45rem 0.45rem calc(0.45rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.bottom-nav a {
  display: grid;
  place-items: center;
  gap: 0.22rem;
  min-width: 0;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.bottom-nav span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-size: 1rem;
}

.bottom-nav a.active {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--text);
}

@media (min-width: 760px) {
  .app-shell {
    padding-bottom: 0;
  }

  .topbar {
    padding-inline: 2rem;
  }

  .section {
    padding: 4.4rem 2rem;
  }

  .section-jump {
    justify-content: center;
    padding-inline: 2rem;
  }

  .hero {
    grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
    align-items: end;
  }

  .insight-panel {
    padding: 1.35rem;
  }

  .service-grid,
  .books-grid,
  .program-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .timeline {
    grid-template-columns: repeat(3, 1fr);
  }

  .feature-band {
    grid-template-columns: 0.88fr 1.12fr;
    align-items: start;
  }

  .bottom-nav {
    left: 50%;
    right: auto;
    bottom: 1rem;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 2rem));
    min-height: 64px;
    padding: 0.45rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
