:root {
  color-scheme: light;
  --brand: #57068c;
  --ink: #21172b;
  --muted: #594d64;
  --soft: color-mix(in srgb, var(--brand) 7%, white);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: #21172b; }
button, a { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible { outline: 3px solid #e7a94c; outline-offset: 3px; }
#app {
  position: relative; isolation: isolate; width: min(100%, 540px); margin: auto;
  min-height: 100dvh; overflow: clip;
  background: var(--fallback, radial-gradient(ellipse at 28% 26%, #625568, transparent 50%), linear-gradient(155deg, #261c2a, #4e4058 50%, #1e1726));
  background-size: cover; background-position: center;
}
#camera {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 0; pointer-events: none;
  opacity: 0; transform: translateZ(0);
}
#camera[data-active] { opacity: 1; }
.entry, .experience { position: relative; z-index: 1; }
.entry {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  padding: max(28px, env(safe-area-inset-top)) 25px max(20px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 14%, #fff 15%, var(--soft) 92%);
}
.entry-content { width: min(100%, 365px); margin: auto; padding: 20px 0; text-align: center; }
.entry-brand img { width: 72px; height: 103px; object-fit: contain; }
.entry-brand strong { color: var(--brand); font-size: 34px; }
#tagline { color: var(--brand); font-weight: 650; margin: 12px 0 7px; }
h1 { margin: 0 0 18px; color: var(--brand); line-height: 1.12; font-size: clamp(26px, 7vw, 36px); letter-spacing: -.035em; }
.languages { display: grid; gap: 10px; }
.languages button { min-height: 51px; border-radius: 12px; padding: 10px 15px; display:flex; justify-content: space-between; align-items: center; border: 1px solid #d9d2df; text-align: left; font-weight: 680; }
.languages button:disabled { background: #f3eff6; color: var(--muted); }
.languages small { font-size: 12px; font-weight: 500; }
footer { text-align: center; color: var(--muted); font-size: 12px; line-height: 1.5; }
footer p { margin: 0 0 5px; }
footer a { color: var(--brand); }
.primary { background: var(--brand); color: white; border: 1px solid var(--brand) !important; font-weight: 750; border-radius: 12px; }
.experience { display: flex; flex-direction: column; min-height: 100dvh; }
header {
  display: flex; align-items: center; justify-content: space-between;
  margin: max(10px, env(safe-area-inset-top)) 12px 0; padding: 6px 10px;
  position: relative; color: white;
}
header::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: rgb(34 25 43 / .48); backdrop-filter: blur(8px);
  border-radius: 12px; border: 1px solid rgb(255 255 255 / .23);
}
/* Keep the live video out of the header's backdrop filter on iOS. */
#camera[data-active] ~ .experience header::before {
  background: rgb(34 25 43 / .64); backdrop-filter: none;
}
#header-brand, .header-actions { position: relative; z-index: 3; }
.header-actions { display: flex; align-items: center; }
#welcome-toggle, #exit {
  color: white; background: transparent; border: 0; min-height: 44px; padding: 0 12px;
}
#welcome-toggle { min-width: 44px; display: grid; place-items: center; }
#welcome-toggle svg { width: 19px; height: 19px;
}
header strong { font-size: 20px; }
header img { width: 29px; height: 34px; padding: 3px; background: white; object-fit: contain; vertical-align: middle; }
.avatar-stage { position: relative; z-index: 2; pointer-events: none; flex: 1 0 clamp(170px, 37dvh, 480px); }
#avatar, #welcome-canvas {
  position: absolute; top: -49px; left: 50%; transform: translateX(-50%);
  height: calc(100% + 49px); width: min(88%, 470px);
  object-fit: cover; object-position: center top;
}
.panel { position: relative; z-index: 3; background: #fff; border-radius: 24px 24px 0 0; padding: 16px 13px max(15px, env(safe-area-inset-bottom)); }
.menu { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.menu button, .panel .primary {
  min-height: 53px; display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 6px; text-align: center; line-height: 1.18;
}
.menu button { background: white; border: 1px solid var(--brand); border-radius: 11px; color: var(--brand); font-weight: 720; font-size: clamp(12px, 3.4vw, 16px); }
.panel .primary { width: 100%; margin-top: 11px; }
.icon { flex: 0 0 19px; width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.back { min-height: 44px; background: transparent; border: 0; color: var(--brand); font-weight: 700; padding: 0 6px; }
.topic { padding: 0 7px 10px; }
.topic h1 { margin: 5px 0 12px; }
.topic p { color: var(--muted); margin: 0 0 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.video-source { position: absolute; width: 1px; height: 1px; opacity: 0; }
/* The sheet scrolls over a stationary avatar below the header. */
.experience.show-topic {
  --avatar-reveal: clamp(135px, 28dvh, 240px);
  display: grid; height: 100dvh; grid-template-rows: auto minmax(0, 1fr);
}
.show-topic header { grid-area: 1 / 1; }
.show-topic .avatar-stage {
  grid-area: 2 / 1; align-self: start; height: var(--avatar-reveal);
}
.show-topic .panel {
  grid-area: 2 / 1; overflow-y: auto; overscroll-behavior-y: contain;
  border-radius: 0; background: transparent; padding: 0;
  scrollbar-width: none;
}
.topic-surface {
  margin-top: var(--avatar-reveal);
  min-height: calc(100% - var(--avatar-reveal));
  padding: 12px 13px max(15px, env(safe-area-inset-bottom));
  background: #fff; border-radius: 24px 24px 0 0;
}
.topic-nav { display: flex; justify-content: space-between; }
.topic-disclaimer {
  margin: 6px 7px 0; padding-top: 10px; border-top: 1px solid #e5dce9;
  color: var(--muted); font-size: 12px; line-height: 1.45;
}
.program-preview { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.program-preview small { font-size: 11px; }
.topic-action {
  display: block; width: 100%; min-height: 46px; margin: 9px 0 0; padding: 11px 13px;
  border: 1px solid var(--brand); border-radius: 10px; background: white; color: var(--brand);
  text-align: left; text-decoration: none; font-weight: 700;
}
.topic-action:disabled { color: var(--muted); border-color: #ded6e4; }
.topic-action.is-active { color: white; background: var(--brand); }
.topic-tabs { display: flex; gap: 6px; }
.topic-tabs .topic-action { flex: 1; text-align: center; font-size: 12px; padding: 6px; }
.gallery { margin-top: 12px; touch-action: pan-y; }
.gallery-frame { position: relative; }
.gallery-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 1px solid white;
  background: rgb(34 25 43 / .76); color: white; font-size: 30px; line-height: 1;
}
.gallery-arrow.previous { left: 8px; }
.gallery-arrow.next { right: 8px; }
.gallery p, .topic .photo-note { margin: 6px 0 0; font-size: 13px; }
.campus-photo, .photo-placeholder { display: block; width: 100%; aspect-ratio: 2 / 1; object-fit: cover; border-radius: 10px; }
.photo-placeholder { display: grid; place-items: center; background: var(--soft); color: var(--muted); }
.photo-trigger { display: block; width: 100%; padding: 0; border: 0; background: transparent; }
.steps { color: var(--ink); margin: 10px 0; padding-left: 22px; }
.steps li { margin: 8px 0; }
.topic-dialog { width: min(91vw, 460px); border: 0; border-radius: 14px; padding: 19px; color: var(--ink); }
.topic-dialog::backdrop { background: rgb(30 19 38 / .66); }
.topic-dialog h2 { margin-top: 0; padding-right: 32px; color: var(--brand); }
.dialog-close {
  position: absolute; top: 6px; right: 8px; width: 36px; height: 36px;
  display: grid; place-items: center; padding: 0; background: transparent; border: 0;
  color: var(--brand); font-size: 23px; line-height: 1;
}
.admissions-form label { display: block; margin: 10px 0; font-weight: 650; }
.admissions-form input, .admissions-form textarea {
  display: block; width: 100%; min-height: 44px; margin-top: 4px; padding: 8px;
  font: inherit; border: 1px solid #a997b6; border-radius: 8px;
}
.admissions-form textarea { height: 80px; resize: vertical; }

.dialog-close:focus-visible {
  outline: 2px solid var(--brand); outline-offset: -5px; border-radius: 8px;
}
#camera-toggle {
  display: grid; place-items: center; min-width: 44px; height: 44px;
  color: white; background: transparent; border: 0; padding: 0 10px;
}
#camera-toggle svg { width: 20px; height: 20px; }
#camera-toggle[data-camera-state="off"] { color: #d4cbda; }
#camera-toggle[data-camera-state="on"] .camera-slash { display: none; }

@media (orientation: landscape) {
  #app { width: 100%; }
  .experience, .experience.show-topic {
    display: grid; height: 100dvh; min-height: 0;
    grid-template-columns: minmax(0, 40fr) minmax(0, 60fr);
    grid-template-rows: auto minmax(0, 1fr);
    padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
  }
  .experience header, .show-topic header {
    grid-area: 1 / 1 / 2 / 3;
    margin: max(4px, env(safe-area-inset-top)) 8px 0;
    padding-block: 0;
  }
  .experience .avatar-stage, .show-topic .avatar-stage {
    grid-area: 2 / 1; align-self: stretch; height: auto; min-height: 0;
  }
  #avatar, #welcome-canvas {
    top: -12px; height: calc(100% + 12px); width: 100%;
    object-fit: contain; object-position: center bottom;
  }
  .experience .panel, .show-topic .panel {
    grid-area: 2 / 2; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain;
    margin: 6px 8px max(6px, env(safe-area-inset-bottom)) 0;
    border-radius: 16px; background: white; padding: 10px;
    scrollbar-width: thin;
  }
  .topic-surface { margin-top: 0; min-height: 100%; padding: 0; }
  .menu button { font-size: clamp(12px, 2.2vw, 16px); }
  .entry { padding-block: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-bottom)); }
  .entry-content { padding: 6px 0; }
  .entry-brand img { width: 42px; height: 56px; }
  .entry h1 { margin-bottom: 10px; }
  #tagline { margin: 5px 0; }
  .languages { gap: 6px; }
  .languages button { min-height: 44px; }
}

/* Give the conversation the entire area below the app header. */
.experience.show-guide {
  display: grid;
  height: var(--guide-height, 100dvh);
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
}
.show-guide header { grid-area: 1 / 1; }
.show-guide .avatar-stage { display: none; }
.show-guide .guide-screen {
  grid-area: 2 / 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-top: 6px;
  padding: 5px 10px max(6px, env(safe-area-inset-bottom));
  overflow: hidden;
}
.guide-screen .back { flex: none; align-self: flex-start; padding-inline: 10px; }
.guide-loading {
  display: grid;
  flex: 1;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 20px;
  background: var(--soft);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
}
.guide-loading p { margin: 0; }
.guide-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid color-mix(in srgb, var(--brand) 20%, white);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: guide-spin .8s linear infinite;
}
@keyframes guide-spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) {
  .guide-spinner { animation: none; }
}
.guide-chat { display: flex; flex: 1; min-height: 0; }
.embedded-ai-guide > #myai2-widget,
#guide-chat :is(#myai2-toggle-btn, #myai2-header-close-btn, #myai2-resize-handle) {
  display: none !important;
}
#guide-chat #myai2-widget {
  --primary-color: var(--brand) !important;
  --send-button-color: var(--brand) !important;
  --speech-bubble-color: var(--brand) !important;
  --launch-button-color: var(--brand) !important;
  --text-color: var(--ink);
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
  font: inherit;
}
#guide-chat #myai2-chat-window {
  position: relative !important;
  inset: auto !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  transform: none !important;
  box-shadow: none;
  transition: none;
  border: 1px solid var(--soft);
  border-radius: 14px;
}
#guide-chat .myai2-header { padding: 9px 12px; }
#guide-chat .myai2-header-subtitle { font-size: 12px; }
#guide-chat .myai2-messages { padding: 12px; background: #fff; }
#guide-chat .myai2-message.ai .myai2-message-bubble:not(.myai2-tool-bubble) {
  background: var(--soft);
  color: var(--ink);
}
#guide-chat .myai2-input-area { padding: 8px; border-color: var(--soft); }
#guide-chat #myai2-input { min-width: 0; font-size: 16px; }

@media (orientation: landscape) {
  .show-guide .guide-screen {
    margin: 6px 8px max(6px, env(safe-area-inset-bottom));
    border-radius: 16px;
    padding: 4px 8px 8px;
  }
}

@media (orientation: landscape) and (max-height: 450px) {
  .guide-screen .back { min-height: 40px; }
}
