/* ============================================================
   Lab-on-a-Book — brand stylesheet (v2)
   ============================================================ */

/* --- Tokens --------------------------------------------------- */
:root {
  --bg:          #3B3154;
  --bg-deep:     #2E2543;
  --purple:      #6E4FA0;
  --yellow:      #F2C200;
  --cyan:        #29B6D8;
  --ink:         #111111;
  --paper:       #FAF8F4;
  --paper-deep:  #E9E4DC;
  --rule:        rgba(255,255,255,0.10);

  --font:         'Space Grotesk', system-ui, sans-serif;
  --font-display: 'Barlow Condensed', 'Space Grotesk', sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, 'JetBrains Mono', monospace;

  --container: 1180px;
  --gutter: 2.5rem;
}

/* --- Reset ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--paper);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button { font-family: var(--font); }
::selection { background: var(--yellow); color: var(--ink); }

/* ============================================================
   HIGHLIGHT BLOCK MOTIF — bold uppercase words inside solid
   color rectangles. Used inline AND as standalone tags.
   ============================================================ */
.hl {
  display: inline;
  padding: 0.05em 0.32em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.hl-yellow { background: var(--yellow); color: var(--ink); }
.hl-cyan   { background: var(--cyan);   color: var(--ink); }
.hl-purple { background: var(--purple); color: var(--paper); }

/* ============================================================
   SECTION LABELS
   ============================================================ */
.section-label {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  padding: 0.35em 0.8em;
  margin-bottom: 1.4rem;
  background: var(--yellow);
  color: var(--ink);
  line-height: 1;
  white-space: nowrap;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 6vw, 4.6rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.005em;
  line-height: 0.95;
  margin-bottom: 2.5rem;
}

/* ============================================================
   PRIMARY BUTTON
   ============================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.95em 1.85em;
  border: none;
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
  position: relative;
  transition: transform 0.12s ease, background 0.18s ease, color 0.18s ease;
}
.btn-primary:hover  { background: var(--ink); color: var(--yellow); }
.btn-primary:active { transform: translateY(1px); }

/* ============================================================
   SITE HEADER
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: saturate(140%);
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  font-family: var(--font);
  font-size: 1.35rem;
  font-weight: 300;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--paper);
}
.wordmark-tag {
  background: var(--yellow);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.22em 0.44em;
  line-height: 1;
}
.wordmark-rest { letter-spacing: -0.01em; }

.site-nav { display: flex; align-items: center; gap: 1.5rem; }
.site-nav a {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: color 0.18s;
}
.site-nav a:hover { color: var(--paper); }
.site-nav .nav-cta {
  background: var(--yellow);
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.6em 1.15em;
  white-space: nowrap;
  transition: background 0.18s, color 0.18s;
}
.site-nav .nav-cta:hover { background: var(--cyan); color: var(--ink); }

/* ============================================================
   HERO — purple canvas, deck-scale headline
   ============================================================ */
.hero {
  padding: 2.5rem var(--gutter) 5.5rem;
  max-width: var(--container);
  margin: 0 auto;
  position: relative;
}

.hero-layout {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20rem;
}
.hero-text-col {
  flex: 1;
  min-width: 0;
}

.kicker {
  display: inline-block;
  background: var(--purple);
  color: var(--paper);
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  padding: 0.4em 0.8em;
  margin-bottom: 1.6rem;
  line-height: 1;
  white-space: nowrap;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 9.5vw, 7.6rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.012em;
  line-height: 1.02;
  margin-bottom: 1.75rem;
  color: var(--paper);
}
.hero-title em {
  font-style: normal;
  background: var(--yellow);
  color: var(--ink);
  padding: 0.01em 0.1em 0.04em;
  display: inline-block;
  line-height: 1.02;
}
.hero-title em:first-of-type {
  margin-top: -0.18em;
}

.hero-tagline {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.3vw, 1.45rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  line-height: 1.55;
  margin-bottom: 1.85rem;
  color: rgba(255,255,255,0.92);
}

.hero-desc {
  font-size: 1.02rem;
  color: rgba(255,255,255,0.78);
  line-height: 1.75;
  margin-bottom: 2.6rem;
  max-width: 480px;
}

/* Right column — book cover with a disc centered behind it */
.hero-img-col {
  position: relative;
  flex: 1.15;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 640px;
  transform: translateY(-12rem);
}
.hero-img-col::before {
  content: '';
  position: absolute;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  background: var(--paper-deep);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 0;
}
.hero-book-img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: auto;
  display: block;
  /* Shift the book's golden-yellow toward the brand #F2C200:
     hue-rotate nudges orange-yellow to pure yellow,
     saturate punches up the vividness to match the UI accents. */
  filter:
    drop-shadow(0 22px 28px rgba(0,0,0,0.35))
    hue-rotate(-6deg)
    saturate(1.45)
    brightness(1.06);
}

/* ============================================================
   ABOUT / HOW IT WORKS — paper background, full-color cards
   ============================================================ */
.about {
  background: var(--paper);
  color: var(--ink);
  padding: 6rem var(--gutter);
  position: relative;
}
/* Yellow rule pinning the section break */
.about::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: var(--container);
  max-width: calc(100% - var(--gutter) * 2);
  height: 6px;
  background: var(--yellow);
}

.about-inner { max-width: var(--container); margin: 0 auto; }

.about .section-label { background: var(--ink); color: var(--yellow); }
.about .section-title { color: var(--ink); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.card {
  position: relative;
  padding: 2.2rem 1.85rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 280px;
  transition: transform 0.16s ease;
}
.card:hover { transform: translateY(-4px); }

.card--yellow { background: var(--yellow); color: var(--ink); }
.card--cyan   { background: var(--cyan);   color: var(--ink); }
.card--purple { background: var(--purple); color: var(--paper); }

.card-num {
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 4.5vw, 4.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 0.85;
  display: block;
  margin-bottom: -0.1rem;
}
.card--yellow .card-num,
.card--cyan   .card-num { color: var(--ink); }
.card--purple .card-num { color: var(--paper); }

.card-chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  padding: 0;
  margin-bottom: 0.6rem;
  align-self: flex-start;
  background: transparent !important;
}
.card--yellow .card-chip,
.card--cyan   .card-chip { color: var(--ink); }
.card--purple .card-chip { color: var(--paper); }

.card h3 {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 2.4vw, 2.1rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.005em;
  line-height: 0.95;
  margin-top: auto;
}

.card p {
  font-size: 0.93rem;
  line-height: 1.7;
  opacity: 0.88;
}

.card-img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  margin-bottom: 1rem;
}

/* ============================================================
   BOT SECTION
   ============================================================ */
.bot-section {
  padding: 6.5rem var(--gutter) 8rem;
  max-width: 880px;
  margin: 0 auto;
  text-align: center;
  position: relative;
}

.bot-section-logo {
  width: 88px;
  height: 88px;
  margin: 0 auto 1.5rem;
  filter: drop-shadow(0 14px 28px rgba(0,0,0,0.35));
}

.bot-section .section-label { background: var(--cyan); color: var(--ink); }
.bot-section .section-title { color: var(--paper); margin-bottom: 1.5rem; }

.bot-intro {
  color: rgba(255,255,255,0.82);
  font-size: 1.05rem;
  line-height: 1.75;
  margin: 0 auto 2.75rem;
  max-width: 540px;
}

/* ============================================================
   CHAT WIDGET
   ============================================================ */
.chat {
  background: var(--bg-deep);
  border: 1px solid rgba(255,255,255,0.08);
  text-align: left;
  overflow: hidden;
  box-shadow: 0 30px 70px -30px rgba(0,0,0,0.6);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.95rem 1.25rem;
  background: linear-gradient(0deg, rgba(255,255,255,0.04), rgba(255,255,255,0.04)), var(--purple);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.bot-logo { width: 32px; height: 32px; flex-shrink: 0; }

.chat-name {
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--paper);
  white-space: nowrap;
}

.chat-status {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(255,255,255,0.55);
  position: relative;
  padding-left: 14px;
}
.chat-status::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 7px; height: 7px;
  background: var(--yellow);
  border-radius: 999px;
  box-shadow: 0 0 0 3px rgba(242,194,0,0.16);
}
.chat.connected .chat-status::before {
  background: var(--cyan);
  box-shadow: 0 0 0 3px rgba(41,182,216,0.18);
}
.chat.connected .chat-status { color: rgba(255,255,255,0.75); }

/* --- Mode indicator dot — purple when online -------------------------------- */
.chat.connected.mode-online .chat-status::before {
  background: var(--purple);
  box-shadow: 0 0 0 3px rgba(110,79,160,0.25);
}
.chat.connected.mode-online .chat-status { color: rgba(255,255,255,0.75); }

/* --- Mode picker (two cards shown before setup steps) ---------------------- */
.mode-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 1.5rem;
}

.mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 1.1rem;
  background: rgba(255,255,255,0.04);
  border: 2px solid rgba(255,255,255,0.1);
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s;
  user-select: none;
}
.mode-card:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.22);
}
.mode-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.mode-card:has(input:checked) {
  border-color: var(--cyan);
  background: rgba(41,182,216,0.08);
}

.mode-card-icon {
  font-size: 1.35rem;
  line-height: 1;
}
.mode-card-title {
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--paper);
}
.mode-card:has(input:checked) .mode-card-title { color: var(--cyan); }
.mode-card-desc {
  font-size: 0.76rem;
  color: rgba(255,255,255,0.55);
  line-height: 1.5;
}

/* Disabled state — used on mobile where Local mode can't run */
.mode-card--disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}
.mode-card-mobile-note {
  display: none;
  font-size: 0.71rem;
  color: var(--yellow);
  line-height: 1.45;
  font-style: italic;
  margin-top: 0.2rem;
}
.mode-card--disabled .mode-card-mobile-note { display: block; }

/* --- Online mode steps / privacy notice ------------------------------------ */
.online-privacy-warn {
  padding: 0.9rem 1.05rem;
  background: rgba(255,255,255,0.04);
  border-left: 3px solid var(--yellow);
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.85);
  line-height: 1.6;
}
.online-privacy-note {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
}
.online-privacy-note strong { color: rgba(255,255,255,0.85); }

#local-steps[hidden],
#online-steps[hidden] { display: none; }

/* --- Setup panel --- */
.setup {
  padding: 2.25rem 2rem 2rem;
  display: block;
  background:
    radial-gradient(800px 240px at 50% -10%, rgba(110,79,160,0.22), transparent 70%),
    var(--bg-deep);
}
.chat.connected .setup     { display: none; }
.chat.connected .chat-body { display: flex; }

.setup-title {
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--yellow);
  margin-bottom: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.setup-lead {
  color: rgba(255,255,255,0.82);
  font-size: 0.93rem;
  line-height: 1.7;
  margin-bottom: 1.5rem;
  max-width: 56ch;
}

.setup-steps {
  counter-reset: step;
  list-style: none;
  padding-left: 0;
  margin-bottom: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}
.setup-steps li {
  counter-increment: step;
  position: relative;
  padding: 0.75rem 1rem 0.85rem 3.1rem;
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.85);
  font-size: 0.92rem;
  line-height: 1.65;
}
.setup-steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0.8rem; top: 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--yellow);
  color: var(--ink);
  padding: 0.18em 0.45em;
  line-height: 1.1;
}
.setup-steps strong { color: var(--paper); }

.setup-steps code {
  background: rgba(0,0,0,0.32);
  color: var(--cyan);
  padding: 0.14em 0.5em;
  font-family: var(--font-mono);
  font-size: 0.84em;
}

.setup-steps a {
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
}
.setup-steps a:hover { color: var(--yellow); }

.setup-details { margin-top: 0.55rem; }
.setup-details summary {
  cursor: pointer;
  color: var(--cyan);
  font-size: 0.85rem;
  font-weight: 600;
  list-style: none;
  padding: 0.2rem 0;
  user-select: none;
}
.setup-details summary::-webkit-details-marker { display: none; }
.setup-details summary::before { content: '▸ '; opacity: 0.7; }
details[open] > summary::before { content: '▾ '; }
.setup-details p { margin-top: 0.55rem; }

.setup-note {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.45);
  font-style: italic;
  margin-top: 0.45rem;
}

.setup-status {
  margin-top: 0.85rem;
  font-size: 0.88rem;
  color: var(--yellow);
  line-height: 1.55;
}

/* --- Chat body (revealed on connect) --- */
.chat-body {
  display: none;
  flex-direction: column;
  height: 460px;
  background: var(--bg-deep);
}

/* --- Chat log --- */
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  scrollbar-width: thin;
  scrollbar-color: var(--purple) transparent;
}
.chat-log::-webkit-scrollbar       { width: 5px; }
.chat-log::-webkit-scrollbar-track { background: transparent; }
.chat-log::-webkit-scrollbar-thumb { background: var(--purple); border-radius: 4px; }

.msg      { display: flex; }
.msg.user { justify-content: flex-end; }
.msg.bot  { justify-content: flex-start; }

.msg-bubble {
  max-width: 78%;
  padding: 0.7em 1.05em 0.75em;
  font-size: 0.92rem;
  line-height: 1.55;
  letter-spacing: 0.005em;
  /* Prevent long words / URLs from overflowing on narrow screens */
  overflow-wrap: break-word;
  word-break: break-word;
}
/* Code / pre inside a chat bubble wraps instead of scrolling off-screen */
.msg-bubble code,
.msg-bubble pre {
  white-space: pre-wrap;
  word-break: break-all;
}

/* Asymmetric tail-side corners — recalls a speech bubble */
.msg.user .msg-bubble {
  background: var(--cyan);
  color: var(--ink);
  border-radius: 14px 14px 4px 14px;
}
.msg.bot .msg-bubble {
  background: var(--paper);
  color: var(--ink);
  border-radius: 14px 14px 14px 4px;
}

.msg-bubble strong { font-weight: 700; }

.msg-bubble.error {
  background: rgba(255, 80, 80, 0.12);
  color: #ffb1b1;
  border: 1px solid rgba(255, 80, 80, 0.32);
}

/* Typing indicator (3 dots) */
.typing { display: flex; align-items: center; gap: 5px; padding: 4px 2px; }
.typing span {
  width: 6px; height: 6px;
  background: var(--ink);
  border-radius: 50%;
  animation: bounce 1.1s ease-in-out infinite;
}
.typing span:nth-child(2) { animation-delay: 0.18s; }
.typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

/* --- Suggestion chips --- */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.85rem 1.15rem;
  border-top: 1px solid rgba(255,255,255,0.07);
  background: rgba(0,0,0,0.18);
}
.chip {
  background: transparent;
  color: var(--paper);
  border: 1px solid rgba(255,255,255,0.22);
  padding: 0.55em 1.05em;
  font-family: var(--font);
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s, transform 0.1s;
  line-height: 1;
  min-height: 44px;
}
.chip:hover {
  background: var(--yellow);
  color: var(--ink);
  border-color: var(--yellow);
}
.chip:active { transform: translateY(1px); }

/* --- Quick-reply buttons (fixed set, shown after bot replies) --- */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.55rem 0.95rem 0.3rem;
}
.quick-replies[hidden] { display: none; }
.qr-btn {
  background: transparent;
  color: var(--yellow);
  border: 1px solid var(--yellow);
  padding: 0.55em 0.85em;
  font-family: var(--font);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
  min-height: 44px;
}
.qr-btn:hover  { background: var(--yellow); color: var(--ink); }
.qr-btn:active { opacity: 0.8; }

/* --- Chat input row --- */
.chat-input {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.85rem 0.95rem;
  border-top: 1px solid rgba(255,255,255,0.07);
  background: rgba(0,0,0,0.22);
}

#chat-text {
  flex: 1;
  background: rgba(255,255,255,0.05);
  color: var(--paper);
  border: 1px solid rgba(255,255,255,0.14);
  padding: 0.7em 0.95em;
  font-family: var(--font);
  /* 1rem = 16px — must be ≥16px to prevent iOS Safari auto-zoom on focus */
  font-size: 1rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 120px;
  transition: border-color 0.18s, background 0.18s;
}
#chat-text::placeholder { color: rgba(255,255,255,0.36); }
#chat-text:focus {
  border-color: var(--cyan);
  background: rgba(255,255,255,0.08);
}

#chat-send {
  background: var(--yellow);
  color: var(--ink);
  border: none;
  padding: 0.75em 1.1em;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s, color 0.18s, transform 0.1s;
  line-height: 1;
  /* Minimum 44×44 tap target (Apple HIG / WCAG 2.5.5) */
  min-width: 44px;
  min-height: 44px;
}
#chat-send:hover    { background: var(--cyan); }
#chat-send:active   { transform: translateY(1px); }
#chat-send:disabled { opacity: 0.4; cursor: default; }

/* --- Chat header action buttons (Save chat / New) --------- */
.chat-header-actions {
  display: none;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  margin-right: 0.55rem;
}
.chat.connected .chat-header-actions { display: flex; }
.chat.connected .chat-status { margin-left: 0; }

.chat-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.62);
  font-family: var(--font-mono);
  font-size: 0.61rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.34em 0.65em;
  cursor: pointer;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chat-action-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--paper);
  border-color: rgba(255,255,255,0.4);
}
.chat-action-btn svg { flex-shrink: 0; }

/* --- Attach button (paperclip) ----------------------------- */
.btn-attach {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.52);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-attach:hover {
  background: rgba(255,255,255,0.08);
  color: var(--paper);
  border-color: rgba(255,255,255,0.38);
}
.btn-attach.has-img {
  background: var(--yellow);
  color: var(--ink);
  border-color: var(--yellow);
}

/* --- Image preview strip (above the input row) ------------- */
.img-preview {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.95rem;
  background: rgba(0,0,0,0.22);
  border-top: 1px solid rgba(255,255,255,0.07);
}
.img-preview.has-img { display: flex; }
.img-preview img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 2px;
  display: block;
}
.img-preview-remove {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.45);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  padding: 0.25em 0.4em;
  transition: color 0.15s;
}
.img-preview-remove:hover { color: var(--paper); }

/* --- Thumbnail inside a user message bubble ---------------- */
.msg-img {
  display: block;
  max-width: 200px;
  max-height: 150px;
  object-fit: cover;
  border-radius: 3px;
  margin-bottom: 0.45rem;
}

/* ============================================================
   CONTRIBUTION OPT-IN
   ============================================================ */
.contribute-opt-in {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  padding: 1rem 1.1rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
}

/* Toggle switch */
.contribute-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  cursor: pointer;
  user-select: none;
}
.contribute-toggle-wrap input[type="checkbox"] { display: none; }

.contribute-track {
  flex-shrink: 0;
  width: 34px;
  height: 19px;
  background: rgba(255,255,255,0.18);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
}
.contribute-track::after {
  content: '';
  position: absolute;
  width: 15px;
  height: 15px;
  background: var(--paper);
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
}
#contribute-check:checked + .contribute-track {
  background: var(--cyan);
}
#contribute-check:checked + .contribute-track::after {
  transform: translateX(15px);
}

.contribute-toggle-label {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.88);
  line-height: 1.45;
}

/* Note + "What is shared?" link */
.contribute-note {
  margin-top: 0.6rem;
  font-size: 0.74rem;
  color: rgba(255,255,255,0.48);
  line-height: 1.6;
}
.contribute-what-link {
  background: none;
  border: none;
  color: var(--cyan);
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.contribute-what-link:hover { color: var(--yellow); }

/* Class code row (shown when opted in) */
.class-code-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.class-code-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255,255,255,0.52);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  white-space: nowrap;
}
.class-code-input {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.16);
  color: var(--paper);
  font-family: var(--font-mono);
  /* ≥16px to prevent iOS Safari auto-zoom on focus */
  font-size: 1rem;
  letter-spacing: 0.1em;
  padding: 0.38em 0.65em;
  width: 9.5em;
  outline: none;
  transition: border-color 0.18s;
}
.class-code-input::placeholder { color: rgba(255,255,255,0.25); letter-spacing: 0.05em; }
.class-code-input:focus { border-color: var(--cyan); }
.class-code-hint {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.32);
}

/* Transparency panel */
.contribute-what-panel {
  margin-top: 0.85rem;
  padding: 0.85rem;
  background: rgba(0,0,0,0.28);
}
.contribute-what-intro,
.contribute-what-note {
  font-size: 0.76rem;
  color: rgba(255,255,255,0.55);
  line-height: 1.6;
}
.contribute-what-intro { margin-bottom: 0.55rem; }
.contribute-what-note  { margin-top:  0.55rem; }
.contribute-example {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--cyan);
  background: rgba(0,0,0,0.32);
  padding: 0.65rem 0.85rem;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.8;
}

/* Header "Data" toggle — shows opt-in state when connected */
.contribute-hdr-label {
  cursor: pointer;
  position: relative;
}
.contribute-hdr-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.contribute-hdr-label:has(input:checked) {
  color: var(--cyan);
  border-color: rgba(41,182,216,0.5);
  background: rgba(41,182,216,0.1);
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: 2rem var(--gutter) 2.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--bg);
}

.site-footer .wordmark-tag { font-size: 0.78em; }

.site-footer p {
  color: rgba(255,255,255,0.42);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  flex: 1;
}

.footer-meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.32);
}

/* ============================================================
   AWARD BADGE — self-contained hero element.
   Edit or delete the single <p class="award-badge"> in index.html.
   ============================================================ */
.award-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}
.award-badge-name {
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(255,255,255,0.6);
  white-space: nowrap;
}

/* ============================================================
   PARTNERS SECTION
   ============================================================ */
.partners-section {
  background: var(--bg-deep);
  border-top: 3px solid var(--yellow);
  border-bottom: 1px solid var(--rule);
  padding: 3.5rem var(--gutter);
  text-align: center;
}
.partners-inner {
  max-width: var(--container);
  margin: 0 auto;
}
.partners-section .section-label {
  background: var(--purple);
  color: var(--paper);
}
.partners-grid {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2.25rem 4rem;
  margin-top: 2rem;
}
.partner-item {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: opacity 0.2s;
  text-decoration: none;
  flex-shrink: 0;
}
.partner-item:hover { opacity: 1; }
.partner-item img {
  height: 46px;
  width: auto;
  max-width: 180px;
  display: block;
  filter: brightness(0) invert(1);
}

/* ============================================================
   ABOUT PAGE
   ============================================================ */
/* Nav: highlight the current page link */
.site-nav a[aria-current="page"] {
  color: var(--yellow);
  font-weight: 700;
}

/* Page hero (about.html intro) */
.page-hero {
  padding: 4rem var(--gutter) 5rem;
  max-width: var(--container);
  margin: 0 auto;
}
.page-hero .section-title { max-width: 640px; }

/* Purpose section — sits on .about (paper) background */
.purpose-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  margin-top: 2rem;
}
.purpose-block { display: flex; flex-direction: column; gap: 0.9rem; }
.purpose-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--purple);
}
.purpose-text {
  font-size: 1.06rem;
  line-height: 1.78;
  color: rgba(0,0,0,0.78);
  max-width: 52ch;
}

/* Team section */
.team-section {
  padding: 6rem var(--gutter) 7rem;
}
.team-inner { max-width: var(--container); margin: 0 auto; }
.team-section .section-label { background: var(--cyan); color: var(--ink); }
.team-section .section-title { color: var(--paper); }

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}
.team-card {
  background: var(--bg-deep);
  border: 1px solid var(--rule);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.16s ease;
}
.team-card:hover { transform: translateY(-4px); }
.team-photo-wrap {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg-deep);
}
.team-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
.team-info {
  padding: 1.2rem 1.25rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  border-top: 2px solid var(--yellow);
}
.team-name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.005em;
  line-height: 1;
  color: var(--paper);
}
.team-role {
  font-family: var(--font-mono);
  font-size: 0.69rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--yellow);
  opacity: 0.85;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet — stack hero columns, keep book cover visible (smaller) */
@media (max-width: 960px) {
  .hero-layout {
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
  }
  .hero-text-col {
    width: 100%;
  }
  .hero-img-col { display: none; }
  .hero { padding: 2rem 1.75rem 4rem; }
  .about { padding: 4.5rem 1.75rem; }
  .bot-section { padding: 5rem 1.75rem 6rem; }
  .purpose-body { grid-template-columns: 1fr; gap: 2rem; }
  .team-section { padding: 4.5rem 1.75rem 5.5rem; }
}

/* ============================================================
   MOBILE — icon-only header action buttons (≤500px)
   Keeps the header compact while maintaining tap accessibility.
   ============================================================ */
@media (max-width: 500px) {
  .btn-txt { display: none; }
  .chat-header-actions { gap: 0.3rem; margin-right: 0.35rem; }
  .chat-action-btn {
    padding: 0.3em 0.4em;
    min-height: 40px;
    min-width: 32px;
    justify-content: center;
  }
}

/* ============================================================
   VERY SMALL PHONES — trim secondary nav links (≤380px)
   Keeps "Teacher Login" and CTA; hides content-only links.
   ============================================================ */
@media (max-width: 380px) {
  .site-nav a[href="#about"],
  .site-nav a[href="/about"] { display: none; }
  .site-nav { gap: 0.65rem; }
}

@media (max-width: 640px) {
  .mode-picker { grid-template-columns: 1fr; }

  :root { --gutter: 1.25rem; }
  .site-header { padding: 0.85rem 1.25rem; flex-wrap: wrap; gap: 0.6rem; }
  .site-nav { gap: 0.95rem; }

  .hero { padding: 1.5rem 1.25rem 3rem; }
  .hero-desc { font-size: 0.98rem; }

  .about { padding: 3.5rem 1.25rem; }
  .card { padding: 1.85rem 1.5rem 1.6rem; min-height: 240px; }

  .bot-section { padding: 3.5rem 1.25rem 5rem; }
  .bot-section-logo { width: 72px; height: 72px; }

  .chat-header { padding: 0.85rem 1rem; gap: 0.5rem; }
  .setup { padding: 1.65rem 1.25rem 1.5rem; }
  .setup-steps li { padding: 0.7rem 0.85rem 0.8rem 2.85rem; font-size: 0.88rem; }
  /* When connected, pin chat to fill the full phone screen */
  .chat.connected {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 100dvh;
    z-index: 500;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: none;
    border-radius: 0;
    border: none;
  }
  .chat.connected .chat-header { flex-shrink: 0; }
  .chat.connected .chat-body {
    flex: 1;
    height: auto;
    min-height: 0;
  }
  .chat.connected .chat-input {
    flex-shrink: 0;
    padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
  }

  /* Fallback clamp height when not yet connected */
  .chat:not(.connected) .chat-body { height: clamp(320px, 56svh, 460px); }

  .site-footer {
    padding: 1.5rem 1.25rem;
    flex-direction: column;
    align-items: flex-start;
  }

  .partners-section { padding: 2.75rem 1.25rem; }
  .partners-grid { gap: 1.75rem 2.5rem; }
  .partner-item img { height: 38px; }

  .page-hero { padding: 3rem 1.25rem 3.5rem; }
  .purpose-text { font-size: 1rem; }
  .team-section { padding: 3.5rem 1.25rem 5rem; }
}

@media (max-width: 400px) {
  .hero-title { font-size: 3.1rem; }
  .chat:not(.connected) .chat-body { height: clamp(280px, 52svh, 380px); }
}
