:root {
  font-family:
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  color: #18251e;
  background: #f6f8f5;
  font-size: 16px;
  --line: #dfe7df;
  --muted: #66756b;
  --panel: #fff;
  --accent: #226344;
  --text: #18251e;
  --soft: #edf4ef;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  position: fixed;
  left: 0;
  right: 0;
  top: var(--cps-visible-top, 0px);
  height: min(var(--cps-visible-height, 100dvh), 100dvh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
button,
select {
  font: inherit;
}
button {
  cursor: pointer;
}
a {
  color: inherit;
}
button:focus-visible,
a:focus-visible,
select:focus-visible {
  outline: 3px solid #63a780;
  outline-offset: 3px;
}
.site-header {
  height: calc(80px + env(safe-area-inset-top, 0px));
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 40px;
  padding: env(safe-area-inset-top, 0px) max(36px, env(safe-area-inset-right, 0px)) 0
    max(36px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.5px;
}
.brand img {
  border-radius: 8px;
}
.site-header nav {
  display: flex;
  gap: 28px;
}
.site-header nav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 15px;
}
.site-header nav [aria-current] {
  color: var(--accent);
  font-weight: 600;
}
.site-header select {
  margin-left: auto;
  border: 1px solid var(--line);
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel);
  color: inherit;
  font-size: 14px;
}
.chat-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  max-width: 1500px;
  width: 100%;
  margin: auto;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.sidebar {
  position: relative;
  padding: 35px 20px 20px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  overflow: auto;
}
.sidebar h2 {
  font-size: 20px;
  font-weight: 650;
  margin: 0 12px 20px;
  color: var(--text);
}
.faq {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.faq button {
  text-align: left;
  border: 0;
  background: none;
  padding: 12px;
  border-radius: 10px;
  color: inherit;
  line-height: 1.5;
  font-size: 15px;
}
.faq button:hover {
  background: #e7eee7;
}
.privacy {
  margin: auto 12px 0;
  padding-top: 30px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}
.conversation {
  min-width: 0;
  min-height: 0;
}
@media (max-width: 760px) {
  .site-header {
    height: calc(66px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0
      max(16px, env(safe-area-inset-left, 0px));
    gap: 16px;
  }
  .brand {
    font-size: 17px;
    gap: 8px;
  }
  .brand img {
    width: 28px;
    height: 28px;
  }
  .site-header nav {
    gap: 15px;
  }
  .site-header nav a {
    font-size: 14px;
  }
  .site-header nav a:nth-child(2) {
    display: none;
  }
  .site-header select {
    max-width: 84px;
    padding: 7px;
    font-size: 14px;
  }
  .chat-layout {
    display: flex;
    flex-direction: column;
  }
  .sidebar {
    padding: 12px 16px;
    border: 0;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
    overflow: hidden;
  }
  .sidebar .privacy {
    display: none;
  }
  .faq {
    flex-direction: row;
    overflow: auto;
    gap: 8px;
    padding-bottom: 3px;
    scrollbar-width: none;
  }
  .faq button {
    white-space: nowrap;
    border: 1px solid var(--line);
    border-radius: 20px;
    font-size: 14px;
    padding: 8px 12px;
    background: var(--panel);
  }
  .conversation {
    flex: 1;
  }
}
body[data-chat-compact] .sidebar {
  display: none;
}
body[data-chat-compact] .chat-layout {
  grid-template-columns: minmax(0, 1fr);
}
body[data-chat-compact] .site-header {
  height: calc(52px + env(safe-area-inset-top, 0px));
}
body[data-chat-compact] .wa-chat .conversation-header {
  padding: 4px 16px 0;
}
body[data-chat-tiny] .site-header {
  display: none;
}
body[data-chat-tiny] .wa-chat .conversation-header {
  padding-top: max(4px, env(safe-area-inset-top, 0px));
}
@media (prefers-color-scheme: dark) {
  :root {
    color: #e1ebe3;
    background: #111a14;
    --line: #2e4033;
    --muted: #a2b5a7;
    --panel: #17221b;
    --text: #e1ebe3;
    --soft: #293d2f;
    --accent: #8dd3a5;
  }
  .faq button:hover {
    background: #293d2f;
  }
}

.student-context {
  flex-shrink: 0;
  display: flex;
  gap: 16px;
  padding: 0 36px 12px;
  position: relative;
  z-index: 3;
}
.student-context label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}
.student-context .grade-field {
  flex: 0 0 132px;
}
.school-field {
  flex: 1;
  min-width: 0;
  position: relative;
}
.school-input {
  position: relative;
  margin-top: 6px;
}
.student-context select,
.student-context input {
  width: 100%;
  height: 38px;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 7px 10px;
}
.student-context input {
  padding-right: 34px;
}
.clear-school {
  position: absolute;
  right: 4px;
  top: 2px;
  height: 34px;
  width: 30px;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 22px;
  cursor: pointer;
}
.school-options {
  --school-safe-bottom: env(safe-area-inset-bottom, 0px);
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: min(320px, 40vh);
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px #0002;
  padding: 4px;
}
.school-options [role='option'],
.school-options [role='status'] {
  padding: 10px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
.school-options [role='option']:hover,
.school-options [aria-selected='true'] {
  background: var(--soft);
}
@media (max-width: 760px) {
  .student-context {
    padding: 0 16px 10px;
    gap: 10px;
  }
  .student-context .grade-field {
    flex-basis: 108px;
  }
  .student-context input,
  .student-context select {
    font-size: 16px;
  }
}
body[data-chat-compact] .student-context {
  display: none;
}

.faq-panel > summary {
  display: none;
}
.faq-group > summary {
  font-size: 14px;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
}
.faq-group button {
  display: block;
  width: 100%;
}
@media (max-width: 760px) {
  .sidebar {
    max-height: 40dvh;
    overflow: auto;
  }
  .sidebar h2 {
    font-size: 18px;
    margin: 0 44px 0 0;
    line-height: 44px;
  }
  .faq-panel > summary {
    display: grid;
    place-items: center;
    position: absolute;
    right: 16px;
    top: 12px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    border-radius: 8px;
    color: var(--accent);
    list-style: none;
    font-size: 24px;
  }
  .faq-panel > summary::-webkit-details-marker {
    display: none;
  }
  .faq-panel[open] > summary span {
    transform: rotate(180deg);
  }
  .faq {
    flex-direction: column;
    overflow: visible;
    padding-top: 8px;
  }
  .faq button {
    white-space: normal;
    border: 0;
    border-radius: 8px;
    text-align: left;
  }
}

.student-context .grade-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

body[data-school-search] .site-header,
body[data-school-search] .sidebar,
body[data-school-search] .wa-chat .conversation-header,
body[data-school-search] .wa-chat .composer-area,
body[data-school-search] .student-context .grade-field {
  display: none;
}
body[data-school-search] .chat-layout {
  grid-template-columns: minmax(0, 1fr);
}
body[data-school-search] .student-context {
  padding: max(8px, env(safe-area-inset-top, 0px)) 16px 8px;
}
body[data-school-search] .student-context input {
  font-size: 16px;
}

@media (pointer: coarse) {
  .student-context input,
  .student-context select {
    font-size: 16px;
  }
}

.student-context input[data-selected] {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.faq-launcher,
.drawer-support {
  display: none;
}
.faq-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  border: 0;
  background: #0006;
}
@media (max-width: 760px) {
  .site-header {
    gap: 8px;
  }
  .site-header .brand img {
    display: none;
  }
  .faq-launcher {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
  }
  .sidebar {
    position: fixed;
    z-index: 100;
    left: 0;
    top: var(--cps-visible-top, 0px);
    width: min(86vw, 340px);
    height: var(--cps-visible-height, 100dvh);
    max-height: none;
    padding: max(16px, env(safe-area-inset-top)) 16px 24px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    overflow-y: auto;
    transform: translateX(-100%);
    visibility: hidden;
  }
  body[data-faq-open] .sidebar {
    transform: translateX(0);
    visibility: visible;
  }
  .sidebar .privacy,
  .drawer-support {
    display: block;
    margin: 12px;
    padding-top: 0;
    color: var(--muted);
    font-size: 14px;
    text-decoration: none;
  }
  .drawer-support {
    margin-top: 28px;
  }
  .faq-panel > summary {
    top: max(16px, env(safe-area-inset-top));
  }
  .faq-panel[open] > summary span {
    transform: none;
  }
}
@media (max-width: 380px) {
  .site-header nav a:last-child {
    display: none;
  }
}

.mobile-brand-title,
.drawer-app {
  display: none;
}
@media (max-width: 760px) {
  .site-header {
    height: calc(56px + env(safe-area-inset-top, 0px));
  }
  .site-header .brand {
    flex: 1;
    min-width: 0;
    font-size: 16px;
  }
  .desktop-brand-title,
  .site-header nav {
    display: none;
  }
  .mobile-brand-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .drawer-app {
    display: block;
    margin: 28px 12px 12px;
    color: var(--muted);
    font-size: 14px;
    text-decoration: none;
  }
  .drawer-support {
    margin-top: 12px;
  }
  .wa-chat .conversation-header {
    display: none;
  }
  .student-context {
    align-items: center;
    padding: 8px 16px;
    gap: 8px;
  }
  .student-context label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .student-context .grade-field {
    flex: 0 0 90px;
  }
  .student-context .school-input {
    margin-top: 0;
  }
  .student-context .chat-toolbar {
    flex: 0 0 44px;
  }
  .student-context .chat-toolbar .icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  body[data-school-search] .student-context .chat-toolbar {
    display: none;
  }
}

@media (min-width: 761px) {
  .student-context {
    padding: 8px 36px;
    align-items: center;
  }
  .student-context .grade-field {
    flex: 0 0 200px;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .student-context label {
    white-space: nowrap;
  }
  .student-context .grade-field select {
    flex: 1;
    min-width: 0;
  }
  .student-context .school-field {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .student-context .school-input {
    flex: 1;
    min-width: 0;
    margin-top: 0;
  }
  .student-context .school-options {
    top: auto;
    bottom: calc(100% + 8px);
  }
}

@media (min-width: 761px) {
  .student-context .grade-field {
    flex-direction: row;
  }
}
body[data-school-search] .student-context {
  order: -1;
}
body[data-school-search] .student-context label {
  display: none;
}
body[data-school-search] .student-context .school-options {
  top: 100%;
  bottom: auto;
}

/* Site typography: compact UI, readable text, native-size touch inputs. */
body .wa-chat .message {
  font-size: 0.9375rem;
  line-height: 1.65;
}
body .wa-chat :is(.source, .activity, .status) {
  font-size: 0.8125rem;
}
body .sidebar h2 {
  font-size: 1.0625rem;
  font-weight: 600;
}
body .faq button,
body .faq-group > summary {
  font-size: 0.875rem;
  line-height: 1.55;
}
body .brand {
  font-size: 1.125rem;
}
body .wa-chat h1 {
  font-size: 1rem;
}
@media (max-width: 760px) {
  body .wa-chat .conversation-header {
    display: none;
  }
  body .site-header .brand {
    font-size: 1rem;
  }
}
@media (max-width: 760px) {
  body .wa-chat textarea:placeholder-shown {
    min-height: 68px;
  }
}
