/* AI Training Assistant - one look for every page (homepage + student area).
   Black, gold and cream to match the logo, with a small turquoise "online" accent. */
.th {
  --th-ink: #17130D;
  --th-ink-2: #241E15;
  --th-gold: #C9A055;
  --th-gold-2: #E6C988;
  --th-gold-deep: #9A7232;
  --th-cream: #F6EEDF;
  --th-paper: #FBF6F1;
  --th-line: #E7DAC2;
  --th-muted: #7A6F5E;
  --th-turq: #3FB8AC;
  font-family: 'Inter', system-ui, sans-serif;
}

/* ---------- Launcher button ---------- */
.th-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 450;
  display: flex; align-items: center; gap: 13px;
  padding: 7px 22px 7px 7px; border-radius: 999px; cursor: pointer; text-align: left;
  color: var(--th-cream);
  background:
    linear-gradient(var(--th-ink), var(--th-ink)) padding-box,
    linear-gradient(135deg, var(--th-gold-2), var(--th-gold-deep) 55%, var(--th-gold-2)) border-box;
  border: 1.5px solid transparent;
  box-shadow: 0 12px 30px rgba(23, 19, 13, .32), 0 2px 6px rgba(23, 19, 13, .18);
  transition: transform .2s ease, box-shadow .2s ease;
  animation: th-in .5s ease-out both;
}
.th-fab:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(23, 19, 13, .38), 0 0 0 4px rgba(201, 160, 85, .15); }
.th-fab:focus-visible { outline: 2px solid var(--th-gold-2); outline-offset: 3px; }
.th-fab.th-hide { display: none; }
.th-logo {
  position: relative; display: grid; place-items: center; flex: none;
  width: 50px; height: 50px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2E261B, var(--th-ink) 70%);
  box-shadow: inset 0 0 0 1px rgba(201, 160, 85, .45);
}
.th-logo img { width: 40px; height: 40px; display: block; }
.th-dot {
  position: absolute; right: 1px; bottom: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--th-turq); border: 2px solid var(--th-ink);
  animation: th-pulse 2.6s ease-in-out infinite;
}
.th-fab-tx { display: flex; flex-direction: column; line-height: 1.15; }
.th-fab-tx small {
  font-size: 10.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--th-gold-2);
}
.th-fab-tx b { margin-top: 3px; font: 500 16.5px 'Playfair Display', Georgia, serif; color: var(--th-cream); }
@keyframes th-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(63, 184, 172, .55); } 50% { box-shadow: 0 0 0 6px rgba(63, 184, 172, 0); } }
@keyframes th-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Chat window ---------- */
.th-panel {
  margin: 0; padding: 0;
  position: fixed; right: 22px; bottom: 22px; z-index: 450;
  width: min(390px, calc(100vw - 32px)); height: min(580px, calc(100vh - 100px)); height: min(580px, calc(100dvh - 100px));
  display: none; flex-direction: column; overflow: hidden;
  background: var(--th-paper); border-radius: 18px;
  border: 1px solid rgba(201, 160, 85, .55);
  box-shadow: 0 24px 60px rgba(23, 19, 13, .3);
  animation: th-in .25s ease-out both;
}
.th-panel.th-open { display: flex; }
.th-head {
  position: relative; top: auto; z-index: auto; backdrop-filter: none; flex: none; display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px;
  background: linear-gradient(160deg, var(--th-ink-2), var(--th-ink));
  color: var(--th-cream);
}
.th-head::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--th-gold) 20%, var(--th-gold-2) 50%, var(--th-gold) 80%, transparent);
}
.th-head .th-logo { width: 44px; height: 44px; }
.th-head .th-logo img { width: 35px; height: 35px; }
.th-head-tx { flex: 1; min-width: 0; }
.th-head-tx strong { display: block; font: 600 17.5px 'Playfair Display', Georgia, serif; letter-spacing: .01em; }
.th-head-tx span { display: block; margin-top: 2px; font-size: 12px; color: var(--th-gold-2); }
.th-x {
  flex: none; width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(246, 238, 223, .08); color: var(--th-cream); font-size: 22px; line-height: 1;
}
.th-x:hover { background: rgba(246, 238, 223, .16); }

.th-body { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 12px; }
.th-msg { max-width: 87%; padding: 11px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.55; color: #2B2419; white-space: pre-wrap; }
.th-msg p { margin: 0 0 7px; }
.th-msg p:last-child { margin-bottom: 0; }
.th-bot { align-self: flex-start; background: #fff; border: 1px solid var(--th-line); border-bottom-left-radius: 5px; box-shadow: 0 1px 2px rgba(23, 19, 13, .04); }
.th-me { align-self: flex-end; background: var(--th-ink-2); color: var(--th-cream); border-bottom-right-radius: 5px; }
.th-wait { color: var(--th-muted); font-style: italic; }
.th-err { align-self: center; font-size: 13px; color: #A85C3B; text-align: center; }
.th-cta-btn {
  display: inline-block; margin-top: 10px; padding: 9px 16px; border-radius: 999px;
  background: linear-gradient(135deg, var(--th-gold-2), var(--th-gold)); color: var(--th-ink);
  font-size: 13px; font-weight: 600; text-decoration: none;
}
.th-cta-btn:hover { filter: brightness(1.05); }

.th-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 16px 12px; }
.th-chip {
  padding: 7px 12px; border-radius: 999px; cursor: pointer;
  background: #fff; border: 1px solid var(--th-line); color: #5C4A2C;
  font: 500 12.5px 'Inter', system-ui, sans-serif;
}
.th-chip:hover { border-color: var(--th-gold); color: var(--th-ink); }

.th-form { display: flex; align-items: flex-end; gap: 8px; padding: 12px; border-top: 1px solid var(--th-line); background: #F7F0E4; }
.th-form textarea {
  flex: 1; resize: none; min-height: 42px; max-height: 120px; padding: 10px 12px;
  border: 1px solid var(--th-line); border-radius: 12px; background: #fff;
  font: 14.5px 'Inter', system-ui, sans-serif; color: #2B2419;
}
.th-form textarea:focus { outline: none; border-color: var(--th-gold); box-shadow: 0 0 0 3px rgba(201, 160, 85, .18); }
.th-send {
  flex: none; display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--th-ink); color: var(--th-gold-2);
}
.th-send:hover:not(:disabled) { background: var(--th-ink-2); }
.th-send:disabled { opacity: .4; cursor: default; }
.th-send svg { width: 18px; height: 18px; }
.th-foot { padding: 0 14px 10px; font-size: 11px; line-height: 1.4; color: var(--th-muted); background: #F7F0E4; }

/* Phones: the launcher shrinks to the round logo so it covers as little of
   the page as possible (pages also leave room for it at the bottom). */
@media (max-width: 520px) {
  .th-fab { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); padding: 4px; gap: 0; }
  .th-fab .th-logo { width: 48px; height: 48px; }
  .th-fab .th-logo img { width: 38px; height: 38px; }
  .th-dot { width: 11px; height: 11px; right: 0; bottom: 1px; }
  .th-fab-tx { display: none; }
  .th-head .th-logo { width: 36px; height: 36px; }
  .th-head .th-logo img { width: 29px; height: 29px; }
  .th-head { padding: 10px 12px; gap: 10px; }
  .th-panel { right: 8px; left: 8px; bottom: 8px; width: auto; height: calc(100vh - 76px); height: calc(100dvh - 76px); }
  .th-form textarea { font-size: 16px; } /* 16px stops iPhones zooming in when typing */
}
