/* =============================================================
   TBUGLEXUSA — application stylesheet
   Homepage design language spread site-wide:
   ink #212331 + coral #EF5861 · Poppins (body) / Roboto Slab (headings)
   ============================================================= */

:root {
  --tbug-ink: #212331;
  --tbug-ink-2: #16171f;
  --tbug-ink-3: #2a2d40;
  --tbug-coral: #EF5861;
  --tbug-coral-2: #dc4750;
  --tbug-paper: #f7f8fa;

  /* Backwards-compatible aliases (kept for any class referencing them) */
  --tbug-navy: var(--tbug-ink);
  --tbug-navy-2: var(--tbug-ink-2);
  --tbug-navy-3: var(--tbug-ink-3);
  --tbug-gold: var(--tbug-coral);
  --tbug-gold-soft: #ffd0ca;
  --tbug-accent: var(--tbug-coral);
  --tbug-accent-2: var(--tbug-coral-2);
  --tbug-bg: var(--tbug-paper);
  --tbug-sidebar: 258px;

  --ink: #212331;
  --ink-2: #16171f;
  --coral: #EF5861;
  --coral-2: #dc4750;
  --paper: #f7f8fa;
}

/* ---------- Accessibility ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: #fff;
  color: #000;
  padding: .6rem 1rem;
  z-index: 2000;
}
.skip-link:focus { left: 0; }

*:focus-visible {
  outline: 3px solid var(--tbug-accent);
  outline-offset: 2px;
}

/* ---------- Shared ---------- */
body { font-family: 'Poppins', 'Segoe UI', system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif; }
h1, h2, h3, h4, h5, h6 { font-family: 'Roboto Slab', Georgia, 'Times New Roman', serif; }

a { text-decoration: none; }
a:hover { text-decoration: underline; }

.card { border: 1px solid rgba(33, 35, 49, .08); box-shadow: 0 1px 2px rgba(33, 35, 49, .04); }
.card-header { background: #fff; font-weight: 600; }

.stat-card { border-radius: .75rem; }
.stat-card .stat-icon {
  width: 44px; height: 44px; border-radius: .7rem;
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
  background: rgba(239, 88, 97, .12); color: var(--tbug-coral);
}
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }

.btn-accent { background: var(--tbug-coral); border-color: var(--tbug-coral); color: #fff; font-weight: 600; }
.btn-accent:hover { background: var(--tbug-coral-2); border-color: var(--tbug-coral-2); color: #fff; }

.btn-ink { background: var(--tbug-ink); border-color: var(--tbug-ink); color: #fff; font-weight: 600; }
.btn-ink:hover { background: var(--tbug-coral); border-color: var(--tbug-coral); color: #fff; }

.btn-coral { background: var(--tbug-coral); border-color: var(--tbug-coral); color: #fff; font-weight: 600; }
.btn-coral:hover { background: var(--tbug-coral-2); border-color: var(--tbug-coral-2); color: #fff; }

.badge-soft { background: rgba(239, 88, 97, .12); color: var(--tbug-coral); }
.badge-soft-success { background: rgba(25, 135, 84, .12); color: #198754; }
.badge-soft-warning { background: rgba(255, 193, 7, .18); color: #997404; }
.badge-soft-danger { background: rgba(220, 53, 69, .12); color: #dc3545; }
.badge-soft-muted { background: rgba(108, 117, 125, .14); color: #6c757d; }

.progress { height: .65rem; }
.progress-bar { background: linear-gradient(90deg, var(--tbug-coral), #ff8f96); }

.table > :not(caption) > * > * { padding: .65rem .75rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #5b6b7f; background: #f8fafc; }

.avatar-circle {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--tbug-ink-3); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600;
}

.breadcrumb { font-size: .85rem; }
.muted-link { color: #6c757d; }

.page-title { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-subtitle { color: #6c757d; font-size: .92rem; }

.empty-state {
  text-align: center; padding: 2.5rem 1rem; color: #6c757d;
}
.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; }

/* =============================================================
   Public website
   ============================================================= */
.site-body { background: #fff; color: #1d2230; }

.site-utility-bar { background: var(--tbug-ink); color: #cdd3e0; padding: .35rem 0; }
.site-utility-bar a { color: #ffc4bf; }
.site-utility-bar a:hover { color: #fff; }

.site-navbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: linear-gradient(90deg, var(--tbug-ink) 0%, var(--tbug-ink-3) 100%);
  padding: .7rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.site-navbar .nav-link { color: #dce3ef; font-weight: 500; font-size: .95rem; padding: .5rem .7rem; }
.site-navbar .nav-link:hover, .site-navbar .nav-link.active { color: #fff; text-decoration: none; }
.site-navbar .navbar-brand strong { color: #fff; letter-spacing: .04em; }
.site-logo-sub { color: #9fb0c4; font-size: .68rem; line-height: 1.1; }
.site-logo-mark {
  width: 40px; height: 40px; border-radius: .55rem;
  background: linear-gradient(135deg, var(--tbug-coral), var(--tbug-coral-2));
  color: #fff; font-weight: 800; font-size: 1.3rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.navbar-toggler { border-color: rgba(255,255,255,.3); }
.navbar-toggler-icon { filter: invert(1); }

.site-hero {
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(239, 88, 97, .30), transparent 60%),
    linear-gradient(160deg, var(--tbug-ink) 0%, var(--tbug-ink-3) 65%, #34384f 100%);
  color: #eef3f9;
}
.site-eyebrow {
  text-transform: uppercase; letter-spacing: .18em; font-size: .76rem;
  color: #ffcfc9; margin-bottom: .6rem;
}
.site-hero-title { font-size: clamp(1.8rem, 4vw, 3rem); font-weight: 800; line-height: 1.12; }
.site-hero-text { color: #cfd8e6; font-size: 1.05rem; max-width: 38rem; }

.site-hero-panel {
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.14);
  border-radius: 1rem; padding: 1.25rem; backdrop-filter: blur(6px);
}
.site-hero-panel dt { color: #bdc6d8; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.site-hero-panel dd { margin: 0 0 .8rem; font-weight: 600; }

.section-alt { background: var(--tbug-bg); }
.section-title { font-weight: 800; font-size: 1.5rem; }

.programme-card { border-radius: .8rem; transition: transform .15s ease, box-shadow .15s ease; height: 100%; }
.programme-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(33,35,49,.10); text-decoration: none; }
.programme-card .prog-level {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--tbug-coral); font-weight: 700;
}

.site-footer { background: var(--tbug-ink-2); color: #b9c2d4; border-top: 4px solid var(--tbug-coral); }
.site-footer a { color: #cfd6e4; display: inline-block; padding: .18rem 0; }
.site-footer a:hover { color: #ffb7ac; }
.site-footer .fw-bold { color: #fff; font-family: 'Roboto Slab', Georgia, serif; letter-spacing: .04em; }
.site-footer .footer-logo { height: 62px; width: auto; }
@media (max-width: 575.98px) { .site-footer .footer-logo { height: 52px; } }

.stat-band { background: var(--tbug-coral); color: #fff; }
.stat-band .stat-num { font-size: 2rem; font-weight: 800; }

/* =============================================================
   Portal shell
   ============================================================= */
.portal-shell { display: flex; min-height: 100vh; background: var(--tbug-bg); }

.portal-sidebar {
  width: var(--tbug-sidebar); flex: 0 0 var(--tbug-sidebar);
  background: linear-gradient(180deg, var(--tbug-ink) 0%, var(--tbug-ink-2) 100%);
  color: #cdd8e6; position: sticky; top: 0; height: 100vh; overflow: hidden;
}
.portal-brand {
  display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.1rem .9rem;
  color: #fff; border-bottom: 1px solid rgba(255,255,255,.08);
}
.portal-brand:hover { text-decoration: none; }
.portal-brand-mark {
  width: 34px; height: 34px; border-radius: .5rem; flex: 0 0 34px;
  background: linear-gradient(135deg, var(--tbug-coral), var(--tbug-coral-2));
  color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.portal-brand-text { font-weight: 700; letter-spacing: .06em; font-size: .95rem; }

.portal-nav { padding: .6rem .6rem 1rem; }
.portal-nav-link {
  display: flex; align-items: center; gap: .7rem; padding: .58rem .75rem;
  color: #b9c7da; border-radius: .55rem; font-size: .92rem; margin-bottom: 2px;
}
.portal-nav-link i { width: 18px; text-align: center; font-size: 1rem; opacity: .85; }
.portal-nav-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.portal-nav-link.active { background: var(--tbug-coral); color: #fff; font-weight: 600; }
.portal-sidebar-foot { padding: .9rem 1.1rem; font-size: .72rem; border-top: 1px solid rgba(255,255,255,.08); }

.portal-offcanvas { background: var(--tbug-ink-2); }
.portal-offcanvas .portal-nav-link { color: #c7d3e3; }
.portal-offcanvas .portal-nav-link.active { color: #fff; }

.portal-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.portal-topbar {
  background: #fff; border-bottom: 1px solid rgba(33,35,49,.09);
  padding: .6rem 1rem; display: flex; align-items: center; gap: .75rem;
  position: sticky; top: 0; z-index: 100;
}
.portal-search { position: relative; max-width: 420px; flex: 1 1 auto; }
.portal-search i { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); color: #8a97a8; }
.portal-search input { padding-left: 2rem; background: var(--tbug-bg); border-radius: 2rem; }

.portal-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--tbug-ink-3);
  color: #fff; font-size: .74rem; display: inline-flex; align-items: center; justify-content: center;
}
.btn-light { background: var(--tbug-bg); }

.notification-menu { width: 320px; max-height: 420px; overflow-y: auto; }
.notification-item { white-space: normal; padding: .55rem .8rem; border-bottom: 1px solid #f0f2f6; }

.portal-content { flex: 1 1 auto; }
.portal-footer { padding: 1rem 1.25rem; border-top: 1px solid rgba(33,35,49,.08); background: #fff; }
.portal-footer a { color: var(--tbug-coral); }

/* ---------- Portal widgets ---------- */
.widget { background: #fff; border: 1px solid rgba(33,35,49,.08); border-radius: .8rem; height: 100%; }
.widget-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1rem; border-bottom: 1px solid rgba(33,35,49,.07);
}
.widget-head h2, .widget-head h3 { font-size: .95rem; font-weight: 700; margin: 0; }
.widget-body { padding: 1rem; }

.quick-link {
  display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem;
  border: 1px solid rgba(33,35,49,.08); border-radius: .65rem; background: #fff; color: inherit;
}
.quick-link:hover { border-color: var(--tbug-coral); color: inherit; text-decoration: none; background: #fdf5f5; }
.quick-link i { font-size: 1.15rem; color: var(--tbug-coral); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 1rem 1.4rem; border-left: 2px solid #e3e8f0; }
.timeline li::before {
  content: ''; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--tbug-coral);
}
.timeline li:last-child { border-left-color: transparent; }

.course-card { border-radius: .8rem; overflow: hidden; }
.course-card .course-band {
  background: linear-gradient(135deg, var(--tbug-ink-3), var(--tbug-coral));
  color: #fff; padding: .9rem 1rem;
}
.course-card .course-code { font-size: .78rem; letter-spacing: .08em; opacity: .85; }

.week-item {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem .9rem; border: 1px solid rgba(33,35,49,.08); border-radius: .6rem;
  background: #fff; margin-bottom: .5rem;
}
.week-item.current { border-color: var(--tbug-coral); background: #fdf6f6; }
.week-item.locked { opacity: .6; }

.step-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; background: #d6dde8; }
.step-dot.done { background: #198754; }
.step-dot.current { background: var(--tbug-coral); box-shadow: 0 0 0 4px rgba(239,88,97,.2); }

.research-tracker { list-style: none; padding: 0; margin: 0; }
.research-tracker li {
  display: flex; align-items: center; gap: .8rem; padding: .55rem 0;
  border-bottom: 1px dashed #e6eaf1; font-size: .93rem;
}
.research-tracker li:last-child { border-bottom: 0; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: .88rem; }
.form-control, .form-select { border-radius: .5rem; }
.form-text { font-size: .8rem; color: #7b8798; }
.required::after { content: ' *'; color: #dc3545; }

.multi-step .step-bar { display: flex; gap: .35rem; margin-bottom: 1.25rem; }
.multi-step .step-bar span { height: 6px; flex: 1; border-radius: 999px; background: #dde3ec; }
.multi-step .step-bar span.done { background: var(--tbug-coral); }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: stretch;
  background: linear-gradient(150deg, var(--tbug-ink) 0%, var(--tbug-ink-3) 100%);
}
.auth-aside {
  flex: 1 1 46%; color: #e7eef7; padding: 3rem; display: flex; flex-direction: column; justify-content: center;
}
.auth-card { flex: 1 1 54%; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card-inner { width: 100%; max-width: 440px; background: #fff; border-radius: 1rem; padding: 2rem; }
.auth-list { list-style: none; padding: 0; }
.auth-list li { padding: .35rem 0; display: flex; gap: .6rem; align-items: flex-start; color: #cbd7e6; }

/* ---------- Reader (textbook / book) ---------- */
.reader-shell { display: flex; gap: 1rem; align-items: flex-start; }
.reader-toc { flex: 0 0 250px; position: sticky; top: 80px; max-height: 75vh; overflow-y: auto; }
.reader-body { flex: 1 1 auto; min-width: 0; }
.reader-body h2 { font-weight: 700; }
.reader-content { line-height: 1.75; font-size: 1.03rem; }
.reader-content p { margin-bottom: 1rem; }

/* ---------- Video ---------- */
.video-frame {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: #120e12; border-radius: .75rem; overflow: hidden;
  display: flex; align-items: center; justify-content: center; color: #7f8fa4;
}
.video-frame video { width: 100%; height: 100%; }
.video-card .video-thumb {
  position: relative; aspect-ratio: 16 / 9; background: linear-gradient(135deg, #2a2d40, #ff8290);
  display: flex; align-items: center; justify-content: center; color: #dfe8f4;
}
.video-card .video-thumb .play-btn {
  width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.92);
  color: var(--tbug-coral); display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
}
.video-duration {
  position: absolute; right: .5rem; bottom: .5rem; background: rgba(0,0,0,.72);
  color: #fff; font-size: .74rem; padding: .1rem .4rem; border-radius: .25rem;
}

/* ---------- Exam / quiz ---------- */
.exam-topbar {
  position: sticky; top: 0; z-index: 90; background: #fff;
  border-bottom: 1px solid rgba(33,35,49,.1); padding: .7rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.exam-timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem; }
.question-card { border: 1px solid rgba(33,35,49,.1); border-radius: .7rem; padding: 1rem; background: #fff; margin-bottom: .85rem; }
.question-card .q-options label {
  display: block; padding: .5rem .7rem; border: 1px solid #e3e8f0; border-radius: .5rem;
  margin-bottom: .4rem; cursor: pointer;
}
.question-card .q-options label:hover { border-color: var(--tbug-coral); background: #fdf6f6; }
.question-card .q-options input { margin-right: .55rem; }

/* ---------- Charts (pure CSS fallback) ---------- */
.bar-chart { display: flex; align-items: flex-end; gap: .5rem; height: 150px; }
.bar-chart .bar { flex: 1; background: linear-gradient(180deg, var(--tbug-coral), #ffa0a6); border-radius: .3rem .3rem 0 0; min-height: 4px; position: relative; }
.bar-chart .bar span {
  position: absolute; top: -1.3rem; left: 0; right: 0; text-align: center; font-size: .7rem; color: #5b6b7f;
}
.bar-labels { display: flex; gap: .5rem; }
.bar-labels span { flex: 1; text-align: center; font-size: .72rem; color: #6c757d; }

/* ---------- Data saver mode ---------- */
body.data-saver .site-hero,
body.data-saver .portal-sidebar { background: var(--tbug-ink) !important; }
body.data-saver * { animation: none !important; transition: none !important; }
body.data-saver img { filter: saturate(.85); }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .portal-sidebar { display: none; }
  .auth-aside { display: none; }
  .auth-card { flex: 1 1 100%; }
}
@media (max-width: 767.98px) {
  .reader-shell { flex-direction: column; }
  .reader-toc { position: static; width: 100%; max-height: 220px; flex: none; }
  .page-title { font-size: 1.15rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Admission letter ---------- */
.letter-sheet { max-width: 860px; margin: 0 auto; }
.letter-brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 54px; height: 54px; border-radius: 12px;
  background: var(--tbug-ink); color: var(--tbug-coral);
  font-size: 1.7rem; font-weight: 700;
}
.letter-details th {
  width: 34%; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .05em; color: #5b6b7f; vertical-align: top; padding: .5rem .75rem .5rem 0;
}
.letter-details td { padding: .5rem 0; vertical-align: top; }
.signature-line { width: 240px; border-bottom: 1.5px solid #1d2a3a; margin-bottom: .4rem; }

@media print {
  .no-print, .site-utility-bar, .site-navbar, .site-footer, .skip-link { display: none !important; }
  .letter-sheet { box-shadow: none !important; border: none !important; }
  body { background: #fff !important; }
}

/* ---------- Messages ---------- */
.message-bubble { border-radius: .9rem; padding: .6rem .9rem; }
.message-bubble-mine { background: var(--tbug-coral); color: #fff; border-top-right-radius: .25rem; }
.message-bubble-mine .text-secondary { color: rgba(255,255,255,.75) !important; }
.message-bubble-other { background: #eef2f7; color: #1d2a3a; border-top-left-radius: .25rem; }

/* ---------- Calendar ---------- */
.calendar-day { min-height: 74px; }

/* ---------- Video player & cards ---------- */
.video-player { width: 100%; aspect-ratio: 16 / 9; background: #120e12; border-radius: .75rem 0 0 0; }
.video-placeholder {
  aspect-ratio: 16 / 9; background: #120e12; color: #7f8fa4;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem;
}
.video-placeholder i { font-size: 2.5rem; }
.video-thumb-link { display: block; position: relative; }
.video-thumb {
  position: relative; aspect-ratio: 16 / 9; background: linear-gradient(135deg, #2a2d40, #ff8290);
  display: flex; align-items: center; justify-content: center; min-height: 120px;
}
.video-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.video-thumb .play-overlay {
  position: relative; width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.92);
  color: var(--tbug-coral); display: flex; align-items: center; justify-content: center; font-size: 1.35rem;
}
.video-thumb-empty .play-overlay { color: #fff; background: rgba(239,88,97,.55); }

.book-cover { width: 100%; height: 100%; object-fit: cover; min-height: 170px; }

/* ---------- Textbook reader ---------- */
.reader-wrap { border-radius: 1rem; overflow: hidden; background: #fff; }
.reader-topbar {
  background: var(--tbug-ink); color: #dfe8f4; padding: .9rem 1.1rem;
  border-bottom: 3px solid var(--tbug-coral);
}
.reader-topbar .text-secondary { color: #a7b0c4 !important; }
.reader-title { min-width: 0; }
.reader-tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .8rem; }
.reader-tab {
  background: transparent; border: 1px solid rgba(255,255,255,.25); border-radius: 999px;
  color: #dfe8f4; font-size: .82rem; padding: .28rem .85rem; cursor: pointer; text-decoration: none;
}
.reader-tab:hover, .reader-tab.active { background: var(--tbug-coral); border-color: var(--tbug-coral); color: #fff; }
.reader-body { min-height: 70vh; }
.reader-content { padding: 2rem 1.4rem; }
.reader-pane { display: none; }
.reader-pane.active { display: block; }
.reader-text { line-height: 1.8; font-size: 1.05rem; }
.reader-text h1, .reader-text h2, .reader-text h3 { margin-top: 1.5rem; margin-bottom: .6rem; font-weight: 700; }
.reader-text p { margin-bottom: 1rem; }
.reader-text img { max-width: 100%; height: auto; border-radius: .5rem; }
.reader-text blockquote {
  border-left: 4px solid var(--tbug-coral); margin: 1rem 0; padding: .6rem 1rem;
  background: #fdf6f6; border-radius: 0 .6rem .6rem 0;
}
.reader-text pre { background: #16171f; color: #e6edf5; padding: 1rem; border-radius: .6rem; overflow-x: auto; }
.reader-nav { gap: .5rem; }
.reader-side { padding: 1.1rem; border-left: 1px solid rgba(33,35,49,.08); background: #f6f9fd; }
@media (max-width: 991.98px) { .reader-side { border-left: none; border-top: 1px solid rgba(33,35,49,.08); } }

.highlight-yellow { background: #fff3a3; }
.highlight-green { background: #b7e6c2; }
.highlight-blue { background: #b8d4f5; }
.highlight-pink { background: #f6c1d4; }
.highlight-colors { display: flex; gap: .45rem; }
.hl-color {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; cursor: pointer;
  box-shadow: 0 0 0 1px rgba(33,35,49,.2);
}
.hl-color.active { box-shadow: 0 0 0 2px var(--tbug-ink); }
.hl-color-yellow { background: #fff3a3; }
.hl-color-green { background: #b7e6c2; }
.hl-color-blue { background: #b8d4f5; }
.hl-color-pink { background: #f6c1d4; }

.text-gold { color: var(--tbug-coral); }

/* ---------- Puter AI study assistant ---------- */
.ai-launcher {
  position: fixed; right: 1.4rem; bottom: 1.4rem; z-index: 1150;
  width: 58px; height: 58px; border-radius: 50%;
  background: linear-gradient(135deg, var(--tbug-coral), var(--tbug-coral-2));
  color: #fff; border: none; box-shadow: 0 12px 30px rgba(239, 88, 97, .5);
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
  transition: transform .2s ease, box-shadow .2s ease;
}
.ai-launcher:hover { transform: translateY(-4px); box-shadow: 0 18px 38px rgba(239, 88, 97, .58); color: #fff; }
.ai-launcher:focus-visible { outline: 3px solid var(--tbug-ink); outline-offset: 2px; }

.ai-panel {
  position: fixed; right: 1.4rem; bottom: 5.2rem; z-index: 1150;
  width: min(94vw, 380px); max-height: min(72vh, 560px);
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid rgba(33, 35, 49, .1); border-radius: 1rem;
  box-shadow: 0 24px 60px rgba(22, 23, 31, .3); overflow: hidden;
}
.ai-panel[hidden] { display: none; }
.ai-panel-head {
  display: flex; align-items: center; gap: .7rem;
  padding: .85rem 1rem; color: #fff;
  background: linear-gradient(90deg, var(--tbug-ink) 0%, var(--tbug-ink-3) 100%);
}
.ai-panel-head .ai-logo {
  width: 34px; height: 34px; border-radius: .6rem; flex: 0 0 34px;
  background: var(--tbug-coral); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
}
.ai-panel-head h2 { font-family: 'Roboto Slab', Georgia, serif; font-size: .95rem; margin: 0; }
.ai-panel-head small { color: rgba(255, 255, 255, .75); font-size: .72rem; }
.ai-body { flex: 1 1 auto; overflow-y: auto; padding: .9rem; background: var(--tbug-paper); }
.ai-msg { margin-bottom: .65rem; max-width: 88%; clear: both; }
.ai-msg .bubble { display: inline-block; padding: .55rem .8rem; border-radius: .8rem; font-size: .9rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.ai-msg.user { float: right; }
.ai-msg.user .bubble { background: var(--tbug-coral); color: #fff; border-top-right-radius: .2rem; }
.ai-msg.ai { float: left; }
.ai-msg.ai .bubble { background: #fff; color: #2b3040; border: 1px solid rgba(33, 35, 49, .08); border-top-left-radius: .2rem; }
.ai-msg.ai .bubble a { color: var(--tbug-coral); }
.ai-typing { color: #8a97a8; font-size: .82rem; padding: .2rem .1rem; }
.ai-hint { font-size: .76rem; color: #8a97a8; background: #f1f3f7; border-radius: .5rem; padding: .45rem .6rem; margin-bottom: .65rem; }
.ai-input-row { display: flex; gap: .5rem; padding: .7rem; border-top: 1px solid rgba(33, 35, 49, .08); background: #fff; }
.ai-input-row input { border-radius: 2rem; }
.ai-input-row button {
  flex: 0 0 auto; border-radius: 2rem; background: var(--tbug-coral); border-color: var(--tbug-coral); color: #fff; font-weight: 600;
}
.ai-input-row button:hover { background: var(--tbug-coral-2); border-color: var(--tbug-coral-2); color: #fff; }
.ai-input-row button:disabled { opacity: .6; }
.ai-cta .btn { color: var(--tbug-ink); border: 1px solid rgba(33, 35, 49, .18); }
.ai-cta .btn:hover { border-color: var(--tbug-coral); color: var(--tbug-coral); }

/* CMS rich-text rendering */
.rich-text h1, .rich-text h2, .rich-text h3, .rich-text h4, .rich-text h5, .rich-text h6 { margin-top: 1.4rem; margin-bottom: .75rem; font-weight: 700; }
.rich-text h2:first-child, .rich-text h3:first-child { margin-top: 0; }
.rich-text p { margin-bottom: 1rem; }
.rich-text ul, .rich-text ol { padding-left: 1.25rem; margin-bottom: 1rem; }
.rich-text li { margin-bottom: .35rem; }
.rich-text table { width: 100%; margin-bottom: 1rem; }
.rich-text .table { border-collapse: collapse; }
.rich-text .table th, .rich-text .table td { padding: .5rem .6rem; border: 1px solid #e2e6ee; vertical-align: top; }
.rich-text .table thead th { background: #f1f3f7; }
.rich-text blockquote { border-left: 4px solid var(--tbug-coral); margin: 1.25rem 0; padding: .5rem 1rem; background: #f6f7fa; }
.rich-text img { max-width: 100%; height: auto; border-radius: .5rem; }
.rich-text a { color: var(--tbug-coral); }
.rich-text .alert p:last-child { margin-bottom: 0; }