/* =========================================================================
   MedPlus AI — application styles
   Dark navy base, mint → electric blue gradient, soft glass panels.
   Mobile-first; three columns from 1100px up.
   ========================================================================= */

:root {
  /* Brand */
  --hp-mint: #16D1B0;
  --hp-blue: #2F6BFF;
  --hp-violet: #7B61FF;
  --hp-rose: #FF5C7A;
  --hp-amber: #FFB547;
  --hp-grad: linear-gradient(135deg, #16D1B0 0%, #2F6BFF 100%);
  --hp-grad-soft: linear-gradient(135deg, rgba(22,209,176,.18) 0%, rgba(47,107,255,.18) 100%);
  --hp-accent-ink: #3FE3C6; /* accent colour used for TEXT; darkened in light mode */

  /* Dark surfaces */
  --hp-bg: #0A1430;
  --hp-bg-2: #0D1A3D;
  --hp-panel: rgba(255,255,255,.045);
  --hp-panel-2: rgba(255,255,255,.07);
  --hp-border: rgba(255,255,255,.10);
  --hp-border-2: rgba(255,255,255,.16);
  --hp-text: #E9EFFF;
  --hp-text-2: rgba(233,239,255,.70);
  --hp-text-3: rgba(233,239,255,.46);
  --hp-shadow: 0 24px 60px rgba(2,8,24,.55);
  --hp-glow: 0 0 0 1px rgba(22,209,176,.22), 0 12px 40px rgba(47,107,255,.22);

  /* Metrics */
  --hp-radius: 18px;
  --hp-radius-sm: 12px;
  --hp-radius-lg: 26px;
  --hp-sidebar: 290px;
  --hp-evidence: 350px;
  --hp-gutter: 16px;
  --hp-font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

:root[data-theme="light"] {
  --hp-bg: #F4F7FF;
  --hp-bg-2: #FFFFFF;
  --hp-panel: rgba(10,20,48,.035);
  --hp-panel-2: rgba(10,20,48,.06);
  --hp-border: rgba(10,20,48,.10);
  --hp-border-2: rgba(10,20,48,.18);
  --hp-text: #0A1430;
  --hp-text-2: rgba(10,20,48,.70);
  --hp-text-3: rgba(10,20,48,.48);
  --hp-shadow: 0 18px 44px rgba(10,20,48,.12);
  --hp-glow: 0 0 0 1px rgba(47,107,255,.16), 0 10px 30px rgba(47,107,255,.14);
}

/* ---------------------------------------------------------------- Reset */
*, *::before, *::after { box-sizing: border-box; }

html, body.hpai-body {
  margin: 0; padding: 0; height: 100%;
  background: var(--hp-bg);
  color: var(--hp-text);
  font-family: var(--hp-font);
  font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body.hpai-body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 480px at 12% -10%, rgba(22,209,176,.16), transparent 60%),
    radial-gradient(760px 420px at 88% 0%, rgba(47,107,255,.18), transparent 60%),
    radial-gradient(620px 420px at 70% 100%, rgba(123,97,255,.12), transparent 65%);
}
:root[data-theme="light"] body.hpai-body::before { opacity: .55; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
a { color: inherit; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--hp-border-2); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid var(--hp-mint); outline-offset: 2px; border-radius: 6px; }

/* ---------------------------------------------------------------- Layout */
.hpai-shell {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  height: 100dvh; max-height: 100dvh;
  overflow: hidden;
}

@media (min-width: 1100px) {
  .hpai-shell { grid-template-columns: var(--hp-sidebar) minmax(0,1fr) var(--hp-evidence); }
  .hpai-only-mobile { display: none !important; }
}

/* ---------------------------------------------------------------- Logo */
.hpai-logo-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 12px;
  background: var(--hp-grad);
  color: #04121d;
  font-weight: 800; font-size: 12px; letter-spacing: -.3px;
  box-shadow: 0 6px 18px rgba(22,209,176,.35);
}
.hpai-logo-mark em { font-style: normal; opacity: .75; }
.hpai-logo-lg { width: 64px; height: 64px; border-radius: 20px; font-size: 18px; margin-bottom: 18px; }

/* Site logo (MedPlus) — keeps the assistant inside the site's identity */
.hpai-logo-img { display: block; width: auto; object-fit: contain; }
.hpai-logo-side { height: 30px; max-width: 120px; flex: 0 0 auto; }
.hpai-logo-lg.hpai-logo-img { height: auto; width: min(260px, 62%); max-width: 260px; margin: 0 auto 20px; border-radius: 0; }
.hpai-logo-modal { height: 40px; max-width: 170px; margin: 0 auto 4px; }
.hpai-gate-logo { height: 52px; max-width: 200px; margin: 0 auto 18px; }
:root[data-theme="light"] .hpai-logo-img { filter: none; }

.hpai-welcome-trust {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0 0 26px;
}
.hpai-welcome-trust span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 550;
  color: var(--hp-text-2); background: var(--hp-panel); border: 1px solid var(--hp-border);
}
.hpai-welcome-trust svg { width: 14px; height: 14px; color: var(--hp-accent-ink); }

.hpai-start-with {
  font-size: 11px; text-transform: uppercase; letter-spacing: .14em; font-weight: 700;
  color: var(--hp-text-3); margin: 0 0 12px; text-align: left;
}

/* ---------------------------------------------------------------- Sidebar */
.hpai-sidebar {
  display: flex; flex-direction: column; gap: 14px;
  padding: 16px 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.02));
  border-right: 1px solid var(--hp-border);
  backdrop-filter: blur(18px);
  min-height: 0;
}
@media (max-width: 1099px) {
  .hpai-sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 60;
    width: min(86vw, 320px);
    transform: translateX(-102%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    background: var(--hp-bg-2);
    box-shadow: var(--hp-shadow);
  }
  .hpai-shell.sidebar-open .hpai-sidebar { transform: none; }
  .hpai-shell.sidebar-open .hpai-scrim { opacity: 1; pointer-events: auto; }
}
.hpai-scrim {
  position: fixed; inset: 0; z-index: 55; background: rgba(4,10,26,.6);
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
@media (min-width: 1100px) { .hpai-scrim { display: none; } }

.hpai-sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hpai-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.hpai-brand-text { display: flex; flex-direction: column; min-width: 0; }
.hpai-brand-text strong {
  font-size: 13px; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
  padding-left: 11px; border-left: 1px solid var(--hp-border-2); color: var(--hp-text-2);
}
.hpai-brand-text small { font-size: 11px; color: var(--hp-text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hpai-new-chat { width: 100%; justify-content: center; }
.hpai-new-chat svg { width: 17px; height: 17px; }

.hpai-history-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.hpai-side-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--hp-text-3); margin: 6px 6px 8px; font-weight: 600;
}
.hpai-history { list-style: none; margin: 0; padding: 0 2px; overflow-y: auto; flex: 1; min-height: 0; }
.hpai-history li { position: relative; }
.hpai-history button.hpai-conv {
  display: block; width: 100%; text-align: left;
  padding: 9px 30px 9px 11px; border-radius: var(--hp-radius-sm);
  font-size: 13px; color: var(--hp-text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .18s, color .18s;
}
.hpai-history button.hpai-conv:hover { background: var(--hp-panel); color: var(--hp-text); }
.hpai-history li.is-active button.hpai-conv {
  background: var(--hp-grad-soft); color: var(--hp-text);
  box-shadow: inset 0 0 0 1px var(--hp-border-2);
}
.hpai-conv-del {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center;
  color: var(--hp-text-3); opacity: 0; transition: opacity .15s, color .15s;
}
.hpai-history li:hover .hpai-conv-del, .hpai-history li.is-active .hpai-conv-del { opacity: 1; }
.hpai-conv-del:hover { color: var(--hp-rose); background: rgba(255,92,122,.12); }
.hpai-conv-del svg { width: 14px; height: 14px; }
.hpai-history-empty { font-size: 12.5px; color: var(--hp-text-3); padding: 4px 8px; margin: 0; }

.hpai-sidebar-foot { display: flex; flex-direction: column; gap: 10px; }

/* Usage meter */
.hpai-meter {
  padding: 12px; border-radius: var(--hp-radius);
  background: var(--hp-panel); border: 1px solid var(--hp-border);
}
.hpai-meter-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.hpai-plan-chip {
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px;
  background: var(--hp-grad); color: #04121d;
}
.hpai-meter-count { font-size: 12px; color: var(--hp-text-2); font-variant-numeric: tabular-nums; }
.hpai-meter-bar { height: 6px; border-radius: 99px; background: var(--hp-panel-2); overflow: hidden; }
.hpai-meter-bar span {
  display: block; height: 100%; width: 0%; border-radius: 99px;
  background: var(--hp-grad); transition: width .45s cubic-bezier(.4,0,.2,1);
}
.hpai-meter.is-low .hpai-meter-bar span { background: linear-gradient(135deg,#FFB547,#FF5C7A); }
.hpai-meter.is-out .hpai-meter-bar span { background: var(--hp-rose); }
.hpai-meter-reset { font-size: 11px; color: var(--hp-text-3); margin-top: 7px; }

.hpai-foot-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hpai-ghost-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px; border-radius: var(--hp-radius-sm);
  font-size: 12px; color: var(--hp-text-2); text-decoration: none;
  border: 1px solid var(--hp-border); background: var(--hp-panel);
  transition: background .18s, color .18s;
}
.hpai-ghost-btn:hover { background: var(--hp-panel-2); color: var(--hp-text); }
.hpai-ghost-btn svg { width: 15px; height: 15px; }

/* ---------------------------------------------------------------- Buttons */
.hpai-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; text-decoration: none;
  transition: transform .15s, box-shadow .2s, background .2s, opacity .2s;
}
.hpai-btn:active { transform: translateY(1px); }
.hpai-btn-primary { background: var(--hp-grad); color: #04121d; box-shadow: 0 8px 22px rgba(47,107,255,.32); }
.hpai-btn-primary:hover { box-shadow: 0 12px 28px rgba(47,107,255,.44); }
.hpai-btn-ghost { background: var(--hp-panel); color: var(--hp-text); border: 1px solid var(--hp-border); }
.hpai-btn-ghost:hover { background: var(--hp-panel-2); }
.hpai-btn-upgrade {
  justify-content: center; width: 100%;
  background: linear-gradient(135deg, rgba(123,97,255,.95), rgba(255,92,122,.9));
  color: #fff; box-shadow: 0 8px 22px rgba(123,97,255,.3);
}
.hpai-btn-upgrade svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.hpai-icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 12px; color: var(--hp-text-2);
  transition: background .18s, color .18s;
}
.hpai-icon-btn:hover { background: var(--hp-panel-2); color: var(--hp-text); }
.hpai-link { background: none; color: var(--hp-text-3); font-size: 13px; text-decoration: underline; padding: 6px; }
.hpai-link:hover { color: var(--hp-text); }

/* ---------------------------------------------------------------- Main */
.hpai-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.hpai-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px var(--hp-gutter);
  border-bottom: 1px solid var(--hp-border);
  background: linear-gradient(180deg, rgba(255,255,255,.05), transparent);
  backdrop-filter: blur(12px);
  padding-top: max(10px, env(safe-area-inset-top));
}
.hpai-topbar-title { flex: 1; min-width: 0; }
.hpai-topbar-title h1 {
  margin: 0; font-size: 14.5px; font-weight: 650; letter-spacing: -.1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hpai-topbar-sub { font-size: 11.5px; color: var(--hp-text-3); }
.hpai-evidence-toggle { position: relative; }
@media (min-width: 1100px) { .hpai-evidence-toggle { display: none; } }
.hpai-badge-dot {
  position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px;
  padding: 0 4px; border-radius: 99px; display: none; place-items: center;
  background: var(--hp-mint); color: #04121d; font-size: 10px; font-weight: 700;
}
.hpai-badge-dot.is-on { display: grid; }

/* ---------------------------------------------------------------- Messages */
.hpai-messages {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 22px var(--hp-gutter) 8px;
  scroll-behavior: smooth;
}
.hpai-msg { max-width: 820px; margin: 0 auto 22px; }

.hpai-msg-user {
  display: flex; justify-content: flex-end;
}
.hpai-msg-user .hpai-bubble {
  max-width: 85%;
  padding: 12px 16px; border-radius: 20px 20px 6px 20px;
  background: var(--hp-grad-soft);
  border: 1px solid var(--hp-border-2);
  white-space: pre-wrap; word-break: break-word;
}
.hpai-msg-user .hpai-bubble .hpai-chips { margin-top: 8px; }

.hpai-ai-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }

/* Trust badge */
.hpai-trust {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--hp-panel); border: 1px solid var(--hp-border);
}
.hpai-trust .hpai-trust-ico { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }
.hpai-trust .hpai-trust-ico svg { width: 13px; height: 13px; stroke-width: 2.4; }
.hpai-trust-high .hpai-trust-ico { background: color-mix(in srgb, var(--hp-mint) 18%, transparent); color: var(--hp-accent-ink); }
.hpai-trust-high { box-shadow: inset 0 0 0 1px rgba(22,209,176,.3); }
.hpai-trust-moderate .hpai-trust-ico { background: rgba(255,181,71,.18); color: var(--hp-amber); }
.hpai-trust-low .hpai-trust-ico { background: rgba(255,92,122,.18); color: var(--hp-rose); }
.hpai-trust-sep { opacity: .4; }
.hpai-trust em { font-style: normal; color: var(--hp-text-2); font-weight: 500; }

.hpai-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--hp-panel); border: 1px solid var(--hp-border); color: var(--hp-text-2);
}
.hpai-chip-exam { background: rgba(123,97,255,.16); border-color: rgba(123,97,255,.34); color: #C9BFFF; }
:root[data-theme="light"] .hpai-chip-exam { color: #4B36C9; }
.hpai-chip-privacy { background: rgba(22,209,176,.14); border-color: rgba(22,209,176,.3); }

/* Answer body */
.hpai-answer {
  background: var(--hp-panel); border: 1px solid var(--hp-border);
  border-radius: var(--hp-radius-lg); padding: 20px 22px;
  box-shadow: var(--hp-shadow);
  word-break: break-word;
}
.hpai-answer > *:first-child { margin-top: 0; }
.hpai-answer > *:last-child { margin-bottom: 0; }
/* Markdown "#" becomes h2 (document-level), "##" becomes h3 — and "##" is what
   the answer templates use for section headings, so h3 carries the accent. */
.hpai-answer h2 { font-size: 17px; margin: 22px 0 8px; font-weight: 700; letter-spacing: -.2px; }
.hpai-answer h3 {
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .11em;
  color: var(--hp-accent-ink); margin: 22px 0 8px; font-weight: 700;
}
.hpai-answer h4 { font-size: 14.5px; margin: 16px 0 6px; font-weight: 650; }
.hpai-answer p { margin: 0 0 12px; }
.hpai-answer ul, .hpai-answer ol { margin: 0 0 12px; padding-left: 20px; }
.hpai-answer li { margin-bottom: 6px; }
.hpai-answer strong { font-weight: 650; color: var(--hp-text); }
.hpai-answer blockquote {
  margin: 0 0 12px; padding: 10px 14px; border-left: 3px solid var(--hp-violet);
  background: rgba(123,97,255,.08); border-radius: 0 10px 10px 0; color: var(--hp-text-2);
}
.hpai-answer code {
  background: var(--hp-panel-2); padding: 2px 6px; border-radius: 6px;
  font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.hpai-answer pre { background: var(--hp-panel-2); padding: 14px; border-radius: 12px; overflow-x: auto; margin: 0 0 12px; }
.hpai-answer pre code { background: none; padding: 0; }
.hpai-table-wrap { overflow-x: auto; margin: 0 0 14px; -webkit-overflow-scrolling: touch; border-radius: 10px; }
.hpai-answer table { width: 100%; min-width: 420px; border-collapse: collapse; margin: 0; font-size: 13.5px; }
.hpai-answer th, .hpai-answer td { padding: 8px 11px; border: 1px solid var(--hp-border); text-align: left; }
.hpai-answer th { background: var(--hp-panel-2); font-weight: 650; }
.hpai-answer hr { border: 0; border-top: 1px solid var(--hp-border); margin: 18px 0; }

/* Citations */
.hpai-cite {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px;
  padding: 0 4px; margin: 0 1px; vertical-align: 1px;
  border-radius: 6px; font-size: 10.5px; font-weight: 700; line-height: 1;
  background: rgba(47,107,255,.2); color: #9CC0FF;
  border: 1px solid rgba(47,107,255,.35);
  cursor: pointer; transition: background .15s, transform .15s;
}
:root[data-theme="light"] .hpai-cite { color: #1746B8; background: rgba(47,107,255,.12); }
.hpai-cite:hover { background: var(--hp-blue); color: #fff; transform: translateY(-1px); }

/* Issues / unverified notice */
.hpai-issues {
  margin-top: 14px; padding: 12px 14px; border-radius: 14px;
  background: rgba(255,181,71,.10); border: 1px solid rgba(255,181,71,.28);
  font-size: 13px; color: var(--hp-text-2);
}
.hpai-issues strong { color: var(--hp-amber); display: block; margin-bottom: 5px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.hpai-issues ul { margin: 0; padding-left: 18px; }

.hpai-answer-disclaimer { margin-top: 14px; font-size: 11.5px; color: var(--hp-text-3); line-height: 1.5; }

/* Quick actions */
.hpai-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.hpai-action {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 550;
  background: var(--hp-panel); border: 1px solid var(--hp-border); color: var(--hp-text-2);
  transition: background .18s, color .18s, border-color .18s;
}
.hpai-action:hover { background: var(--hp-panel-2); color: var(--hp-text); border-color: var(--hp-border-2); }
.hpai-action svg { width: 14px; height: 14px; }
.hpai-action-exam { border-color: rgba(123,97,255,.4); color: #C9BFFF; }
:root[data-theme="light"] .hpai-action-exam { color: #4B36C9; }
.hpai-action[disabled] { opacity: .45; cursor: default; }

/* Thinking indicator */
.hpai-thinking {
  max-width: 820px; margin: 0 auto 22px;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px; border-radius: var(--hp-radius-lg);
  background: var(--hp-panel); border: 1px solid var(--hp-border);
}
.hpai-ecg { width: 140px; height: 40px; flex: 0 0 auto; }
.hpai-ecg-line {
  fill: none; stroke: var(--hp-accent-ink);
  stroke-width: 2; stroke-linecap: round;
  stroke-dasharray: 90 300; stroke-dashoffset: 390;
  animation: hpai-ecg 1.9s linear infinite;
  filter: drop-shadow(0 0 6px rgba(22,209,176,.6));
}
@keyframes hpai-ecg { to { stroke-dashoffset: 0; } }
.hpai-thinking-text { display: flex; flex-direction: column; gap: 2px; }
.hpai-thinking-text strong { font-size: 13.5px; font-weight: 600; }
.hpai-thinking-text span { font-size: 12px; color: var(--hp-text-3); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .hpai-ecg-line { animation: none; stroke-dasharray: none; stroke-dashoffset: 0; } }

/* Streaming caret */
.hpai-answer.is-streaming > :last-child::after {
  content: ''; display: inline-block; width: 7px; height: 15px;
  margin-left: 3px; vertical-align: -2px; border-radius: 2px;
  background: var(--hp-accent-ink); animation: hpai-blink 1s steps(2) infinite;
}
@keyframes hpai-blink { 50% { opacity: 0; } }

/* ---------------------------------------------------------------- Welcome */
.hpai-welcome { max-width: 760px; margin: 4vh auto 0; text-align: center; position: relative; }
.hpai-welcome-glow {
  position: absolute; left: 50%; top: -60px; width: 420px; height: 240px; transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(22,209,176,.22), transparent 70%);
  filter: blur(14px); pointer-events: none;
}
.hpai-welcome .hpai-logo-mark { margin-left: auto; margin-right: auto; }
.hpai-welcome h2 { font-size: clamp(21px, 4.2vw, 28px); margin: 0 0 10px; letter-spacing: -.4px; font-weight: 700; }
.hpai-welcome > p { color: var(--hp-text-2); max-width: 520px; margin: 0 auto 26px; font-size: 14.5px; }

.hpai-suggestions { display: grid; gap: 10px; grid-template-columns: 1fr; text-align: left; }
@media (min-width: 680px) { .hpai-suggestions { grid-template-columns: 1fr 1fr; } }
.hpai-suggestion {
  text-align: left;
  padding: 14px 16px; border-radius: var(--hp-radius);
  background: var(--hp-panel); border: 1px solid var(--hp-border);
  font-size: 13.5px; color: var(--hp-text-2); line-height: 1.45;
  transition: transform .18s, border-color .18s, background .18s;
}
.hpai-suggestion:hover { transform: translateY(-2px); border-color: var(--hp-border-2); background: var(--hp-panel-2); color: var(--hp-text); }
.hpai-sug-type {
  display: block; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  margin-bottom: 6px; color: var(--hp-accent-ink);
}

/* ---------------------------------------------------------------- Composer */
.hpai-composer-wrap {
  padding: 10px var(--hp-gutter) max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--hp-border);
  background: linear-gradient(180deg, transparent, rgba(10,20,48,.35));
  backdrop-filter: blur(14px);
}
:root[data-theme="light"] .hpai-composer-wrap { background: linear-gradient(180deg, transparent, rgba(255,255,255,.7)); }

.hpai-attachments { max-width: 820px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 8px; }
.hpai-attachments:not(:empty) { margin-bottom: 9px; }
.hpai-attach-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 10px; border-radius: 10px; font-size: 12px;
  background: var(--hp-panel-2); border: 1px solid var(--hp-border);
}
.hpai-attach-chip img { width: 26px; height: 26px; border-radius: 6px; object-fit: cover; }
.hpai-attach-chip button { color: var(--hp-text-3); display: grid; place-items: center; }
.hpai-attach-chip button:hover { color: var(--hp-rose); }
.hpai-attach-chip svg { width: 13px; height: 13px; }

.hpai-composer {
  max-width: 820px; margin: 0 auto;
  display: flex; align-items: flex-end; gap: 6px;
  padding: 7px 7px 7px 8px;
  border-radius: 24px;
  background: var(--hp-panel-2);
  border: 1px solid var(--hp-border-2);
  box-shadow: var(--hp-glow);
  transition: box-shadow .25s, border-color .25s;
}
.hpai-composer:focus-within { border-color: rgba(22,209,176,.5); box-shadow: 0 0 0 1px rgba(22,209,176,.4), 0 16px 40px rgba(47,107,255,.22); }
.hpai-input-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hpai-composer textarea {
  flex: 1; min-width: 0; resize: none; border: 0; background: none;
  padding: 10px 4px; max-height: 168px; font-size: 15px; line-height: 1.5;
}
.hpai-composer textarea:focus { outline: none; }
.hpai-composer textarea::placeholder { color: var(--hp-text-3); }

.hpai-send {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--hp-grad); color: #04121d;
  box-shadow: 0 6px 18px rgba(47,107,255,.35);
  transition: transform .15s, opacity .2s;
}
.hpai-send svg { fill: currentColor; stroke: none; width: 18px; height: 18px; }
.hpai-send:hover { transform: scale(1.06); }
.hpai-send[disabled] { opacity: .4; transform: none; cursor: default; }
.hpai-mic.is-recording { color: var(--hp-rose); background: rgba(255,92,122,.14); }

.hpai-disclaimer {
  max-width: 820px; margin: 9px auto 0; text-align: center;
  font-size: 11px; color: var(--hp-text-3); line-height: 1.45;
}

/* ---------------------------------------------------------------- Evidence */
.hpai-evidence {
  display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--hp-border);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.015));
  backdrop-filter: blur(18px);
}
@media (max-width: 1099px) {
  .hpai-evidence {
    position: fixed; inset: 0 0 0 auto; z-index: 60;
    width: min(92vw, 400px); transform: translateX(102%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    background: var(--hp-bg-2); box-shadow: var(--hp-shadow);
  }
  .hpai-shell.evidence-open .hpai-evidence { transform: none; }
  .hpai-shell.evidence-open .hpai-scrim { opacity: 1; pointer-events: auto; }
}
.hpai-evidence-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: 16px var(--hp-gutter) 12px; border-bottom: 1px solid var(--hp-border);
  padding-top: max(16px, env(safe-area-inset-top));
}
.hpai-evidence-head h2 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: -.1px; }
.hpai-evidence-head span { font-size: 11.5px; color: var(--hp-text-3); }
@media (min-width: 1100px) { #hpai-evidence-close { display: none; } }

.hpai-evidence-body { flex: 1; overflow-y: auto; padding: 12px var(--hp-gutter) 20px; }
.hpai-evidence-empty { text-align: center; color: var(--hp-text-3); padding: 42px 12px; }
.hpai-evidence-empty svg { width: 34px; height: 34px; margin-bottom: 12px; opacity: .55; }
.hpai-evidence-empty p { font-size: 13px; line-height: 1.6; margin: 0; }

.hpai-source {
  display: block; width: 100%; text-align: left;
  padding: 13px 14px; margin-bottom: 10px; border-radius: var(--hp-radius);
  background: var(--hp-panel); border: 1px solid var(--hp-border);
  text-decoration: none; transition: border-color .2s, background .2s, transform .2s;
}
.hpai-source:hover { border-color: var(--hp-border-2); background: var(--hp-panel-2); transform: translateY(-1px); }
.hpai-source.is-highlight {
  border-color: var(--hp-mint);
  box-shadow: 0 0 0 1px rgba(22,209,176,.45), 0 8px 26px rgba(22,209,176,.18);
}
.hpai-source-top { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.hpai-source-n {
  flex: 0 0 auto; width: 21px; height: 21px; border-radius: 7px; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; background: var(--hp-grad); color: #04121d;
}
.hpai-source-type {
  font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 999px;
  background: var(--hp-panel-2); border: 1px solid var(--hp-border); color: var(--hp-text-2);
}
.hpai-type-guideline { background: rgba(22,209,176,.16); border-color: rgba(22,209,176,.34); color: #7FE8D6; }
.hpai-type-research  { background: rgba(47,107,255,.16); border-color: rgba(47,107,255,.34); color: #9CC0FF; }
.hpai-type-textbook  { background: rgba(123,97,255,.16); border-color: rgba(123,97,255,.34); color: #C9BFFF; }
.hpai-type-medplus   { background: rgba(255,181,71,.16); border-color: rgba(255,181,71,.34); color: #FFD79B; }
:root[data-theme="light"] .hpai-type-guideline { color: #0A7A66; }
:root[data-theme="light"] .hpai-type-research { color: #1746B8; }
:root[data-theme="light"] .hpai-type-textbook { color: #4B36C9; }
:root[data-theme="light"] .hpai-type-medplus { color: #9A6512; }
.hpai-source-domain { font-size: 11px; color: var(--hp-text-3); margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42%; }
.hpai-source-title { font-size: 13px; font-weight: 600; margin: 0 0 6px; line-height: 1.4; }
.hpai-source-snippet { font-size: 12px; color: var(--hp-text-2); line-height: 1.55; margin: 0; }
.hpai-source-link { font-size: 11px; color: var(--hp-accent-ink); margin-top: 8px; display: inline-flex; align-items: center; gap: 4px; }
.hpai-source-link svg { width: 12px; height: 12px; }

.hpai-search-suggestions { padding: 0 var(--hp-gutter) 14px; }
.hpai-search-suggestions:empty { display: none; }

/* ---------------------------------------------------------------- Modals */
.hpai-modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 20px;
  background: rgba(4,10,26,.66); backdrop-filter: blur(6px);
  animation: hpai-fade .2s ease;
}
.hpai-modal[hidden] { display: none; }
@keyframes hpai-fade { from { opacity: 0; } }
.hpai-modal-card {
  position: relative; width: 100%; max-width: 440px;
  padding: 28px 26px 22px; border-radius: 26px;
  background: var(--hp-bg-2); border: 1px solid var(--hp-border-2);
  box-shadow: var(--hp-shadow); text-align: center;
  max-height: 90dvh; overflow-y: auto;
  animation: hpai-pop .25s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes hpai-pop { from { transform: translateY(14px) scale(.97); opacity: 0; } }
.hpai-modal-card h3 { margin: 14px 0 8px; font-size: 19px; letter-spacing: -.2px; }
.hpai-modal-sub, .hpai-modal-card > p { color: var(--hp-text-2); font-size: 13.5px; margin: 0 0 16px; }
.hpai-modal-close { position: absolute; top: 12px; right: 12px; font-size: 22px; line-height: 1; }
.hpai-modal-card .hpai-logo-mark { margin: 0 auto; }
.hpai-modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.hpai-modal-card textarea, .hpai-modal-card select {
  width: 100%; padding: 11px 13px; border-radius: 12px; margin-bottom: 10px;
  background: var(--hp-panel); border: 1px solid var(--hp-border); resize: vertical;
}
.hpai-modal-card textarea:focus, .hpai-modal-card select:focus { outline: none; border-color: var(--hp-mint); }
.hpai-field-label { display: block; text-align: left; font-size: 11.5px; color: var(--hp-text-3); margin-bottom: 5px; font-weight: 600; }
.hpai-transcript {
  text-align: left; padding: 12px 14px; border-radius: 14px; margin-bottom: 14px;
  background: var(--hp-panel); border: 1px solid var(--hp-border);
  font-size: 13px; color: var(--hp-text-2); max-height: 150px; overflow-y: auto;
}

.hpai-upgrade-plans { display: grid; gap: 8px; margin: 4px 0 18px; text-align: left; }
.hpai-upgrade-plan {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; border-radius: 14px;
  background: var(--hp-panel); border: 1px solid var(--hp-border); font-size: 13px;
}
.hpai-upgrade-plan strong { font-size: 13.5px; }
.hpai-upgrade-plan span { color: var(--hp-text-3); font-size: 12px; }
.hpai-upgrade-plan.is-current { border-color: var(--hp-mint); }
.hpai-upgrade-plan.is-buyable {
  text-decoration: none; cursor: pointer;
  transition: transform .16s, border-color .2s, background .2s;
}
.hpai-upgrade-plan.is-buyable:hover {
  transform: translateY(-2px); border-color: var(--hp-mint); background: var(--hp-panel-2);
}
.hpai-upgrade-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; white-space: nowrap; }
.hpai-upgrade-go { font-size: 11.5px; font-weight: 700; color: var(--hp-accent-ink); }
.hpai-upgrade-tag { font-size: 11px; color: var(--hp-text-3); }
.hpai-trust-general .hpai-trust-ico { background: rgba(255,181,71,.18); color: var(--hp-amber); }
.hpai-trust-general { box-shadow: inset 0 0 0 1px rgba(255,181,71,.3); }

/* ---------------------------------------------------------------- Toast + recorder */
.hpai-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 120; padding: 12px 20px; border-radius: 999px;
  background: var(--hp-bg-2); border: 1px solid var(--hp-border-2);
  box-shadow: var(--hp-shadow); font-size: 13.5px; max-width: 90vw; text-align: center;
  animation: hpai-pop .25s ease;
}
.hpai-toast[hidden] { display: none; }
.hpai-toast.is-error { border-color: rgba(255,92,122,.5); }

.hpai-recording {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%);
  z-index: 110; display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border-radius: 999px;
  background: var(--hp-bg-2); border: 1px solid var(--hp-border-2); box-shadow: var(--hp-shadow);
}
.hpai-recording[hidden] { display: none; }
.hpai-rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--hp-rose); animation: hpai-pulse 1.1s infinite; }
@keyframes hpai-pulse { 50% { opacity: .25; transform: scale(.8); } }
#hpai-rec-time { font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; min-width: 42px; }

/* ---------------------------------------------------------------- Login gate */
.hpai-gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; position: relative; z-index: 1; }
.hpai-gate-card {
  width: 100%; max-width: 400px; text-align: center;
  padding: 36px 28px; border-radius: 28px;
  background: var(--hp-panel); border: 1px solid var(--hp-border-2);
  box-shadow: var(--hp-shadow); backdrop-filter: blur(18px);
}
.hpai-gate-card .hpai-logo-mark { margin: 0 auto 16px; width: 54px; height: 54px; border-radius: 17px; font-size: 15px; }
.hpai-gate-card h1 { margin: 0 0 4px; font-size: 23px; letter-spacing: -.3px; }
.hpai-gate-tag { margin: 0 0 18px; color: var(--hp-text-3); font-size: 13px; }
.hpai-gate-text { color: var(--hp-text-2); font-size: 14px; margin: 0 0 22px; }
.hpai-gate-card .hpai-btn { width: 100%; justify-content: center; margin-bottom: 10px; }

/* ---------------------------------------------------------------- Free-plan upsell */
.hpai-upsell {
  margin-top: 16px; padding: 16px 18px; border-radius: 18px;
  background: linear-gradient(135deg, rgba(123,97,255,.10), rgba(34,211,238,.08));
  border: 1px solid var(--hp-border-2);
}
.hpai-upsell h4 {
  margin: 0 0 6px; font-size: 14px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.hpai-upsell h4 svg { width: 16px; height: 16px; color: var(--hp-accent-ink); }
.hpai-upsell p { margin: 0 0 13px; font-size: 13px; line-height: 1.65; color: var(--hp-text-2); }
.hpai-upsell .hpai-btn { font-size: 13.5px; padding: 9px 18px; }

.hpai-chip-general {
  background: rgba(255,181,71,.16); border-color: rgba(255,181,71,.36); color: var(--hp-amber);
}
:root[data-theme="light"] .hpai-chip-general { color: #9A6512; }

/* ---------------------------------------------------------------- Coming soon */
.hpai-soon-body { display: grid; place-items: center; min-height: 100dvh; }
.hpai-soon { width: 100%; padding: 24px; position: relative; z-index: 1; }
.hpai-soon-card {
  max-width: 560px; margin: 0 auto; text-align: center;
  padding: 44px 32px 36px; border-radius: 30px;
  background: var(--hp-panel); border: 1px solid var(--hp-border-2);
  box-shadow: var(--hp-shadow); backdrop-filter: blur(18px);
  font-family: 'Tajawal', 'Cairo', var(--hp-font);
}
.hpai-soon-logo { height: auto; width: min(220px, 62%); margin: 0 auto 20px; }
:root[data-theme="light"] .hpai-soon-logo.hpai-logo-chip { padding: 12px 18px; border-radius: 16px; }
.hpai-soon-badge {
  display: inline-block; margin-bottom: 16px; padding: 7px 20px; border-radius: 999px;
  font-size: 13.5px; font-weight: 800; letter-spacing: .04em; color: #06121f;
  background: linear-gradient(135deg, #FFD166, #FF9F45);
  box-shadow: 0 10px 26px rgba(255,159,69,.34);
}
.hpai-soon-card bdi, .hpai-soon-card h1 bdi { unicode-bidi: isolate; }
.hpai-soon-card h1 { margin: 0 0 12px; font-size: clamp(20px, 4.5vw, 27px); line-height: 1.45; font-weight: 800; }
.hpai-soon-card > p { margin: 0 0 22px; font-size: 15px; line-height: 1.85; color: var(--hp-text-2); }
.hpai-soon-list { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 9px; }
.hpai-soon-list li {
  padding: 10px 16px; border-radius: 14px; font-size: 14px; font-weight: 500;
  background: var(--hp-panel-2); border: 1px solid var(--hp-border);
}
.hpai-soon-list li::before { content: '✓'; color: var(--hp-accent-ink); font-weight: 800; margin-left: 9px; }
.hpai-soon-ecg { display: block; width: 100%; height: 40px; margin: 0 0 24px; }
.hpai-soon-ecg path {
  fill: none; stroke: var(--hp-accent-ink); stroke-width: 2; stroke-linecap: round;
  stroke-dasharray: 90 300; stroke-dashoffset: 390; animation: hpai-ecg 2.2s linear infinite;
  filter: drop-shadow(0 0 6px rgba(34,211,238,.55));
}
.hpai-soon-card .hpai-btn { width: 100%; justify-content: center; }

/* ---------------------------------------------------------------- Pricing shortcode */
.hpai-pricing { display: grid; gap: 16px; grid-template-columns: 1fr; font-family: var(--hp-font); }
@media (min-width: 760px) { .hpai-pricing { grid-template-columns: repeat(3, 1fr); } }
.hpai-price-card {
  padding: 24px; border-radius: 24px; text-align: center;
  background: var(--hp-bg-2); color: var(--hp-text); border: 1px solid var(--hp-border-2);
  box-shadow: var(--hp-shadow);
}
.hpai-price-card.is-current { border-color: var(--hp-mint); box-shadow: 0 0 0 1px var(--hp-mint); }
.hpai-price-card h3 { margin: 0 0 6px; font-size: 18px; }
.hpai-price { font-size: 26px; font-weight: 750; margin-bottom: 14px; background: var(--hp-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hpai-price-card ul { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.hpai-price-card li { padding: 7px 0; border-top: 1px solid var(--hp-border); opacity: .85; }
.hpai-price-cta {
  display: inline-block; margin-top: 16px; padding: 12px 28px; border-radius: 999px;
  background: var(--hp-grad); color: #06121f !important; font-weight: 800; font-size: 14.5px;
  text-decoration: none !important; box-shadow: 0 10px 26px rgba(34,211,238,.3);
  transition: transform .18s, box-shadow .25s;
}
.hpai-price-cta:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(34,211,238,.45); }
.hpai-badge-current { display: inline-block; margin-top: 14px; padding: 5px 12px; border-radius: 999px; background: var(--hp-grad); color: #04121d; font-size: 11px; font-weight: 700; }


/* =========================================================================
   Light mode — surfaces, not just inverted colours
   ========================================================================= */
:root[data-theme="light"] body.hpai-body::before {
  opacity: 1;
  background:
    radial-gradient(900px 480px at 10% -12%, rgba(34,211,238,.16), transparent 62%),
    radial-gradient(760px 420px at 92% -4%, rgba(62,100,222,.13), transparent 62%),
    radial-gradient(620px 420px at 70% 108%, rgba(124,92,255,.08), transparent 66%);
}

:root[data-theme="light"] .hpai-sidebar {
  background: linear-gradient(180deg, #FFFFFF 0%, #FBFCFF 100%);
  border-right-color: var(--hp-border);
  box-shadow: 1px 0 0 rgba(11,31,58,.03);
}
:root[data-theme="light"] .hpai-topbar,
:root[data-theme="light"] .hpai-evidence-head { background: rgba(255,255,255,.88); }
:root[data-theme="light"] .hpai-evidence { background: linear-gradient(180deg, #FFFFFF 0%, #FBFCFF 100%); }
:root[data-theme="light"] .hpai-composer-wrap { background: linear-gradient(180deg, rgba(242,246,253,0), #F7FAFF 55%); }

:root[data-theme="light"] .hpai-answer,
:root[data-theme="light"] .hpai-source,
:root[data-theme="light"] .hpai-suggestion,
:root[data-theme="light"] .hpai-meter,
:root[data-theme="light"] .hpai-thinking,
:root[data-theme="light"] .hpai-welcome-trust span,
:root[data-theme="light"] .hpai-action,
:root[data-theme="light"] .hpai-upgrade-plan {
  background: #FFFFFF;
  border-color: var(--hp-border);
}
:root[data-theme="light"] .hpai-answer { box-shadow: 0 10px 30px rgba(11,31,58,.07); }
:root[data-theme="light"] .hpai-source:hover,
:root[data-theme="light"] .hpai-suggestion:hover,
:root[data-theme="light"] .hpai-action:hover { background: #F7FAFF; border-color: var(--hp-border-2); }
:root[data-theme="light"] .hpai-composer { background: #FFFFFF; }
:root[data-theme="light"] .hpai-answer th { background: #F4F7FD; }
:root[data-theme="light"] .hpai-answer code,
:root[data-theme="light"] .hpai-answer pre { background: #F4F7FD; }
:root[data-theme="light"] .hpai-ghost-btn { background: #FFFFFF; }
:root[data-theme="light"] .hpai-ghost-btn:hover { background: #F4F7FD; }
:root[data-theme="light"] .hpai-modal { background: rgba(11,31,58,.38); }
:root[data-theme="light"] .hpai-welcome-glow {
  background: radial-gradient(closest-side, rgba(34,211,238,.26), transparent 70%);
}
:root[data-theme="light"] .hpai-gate-card { background: #FFFFFF; }
:root[data-theme="light"] .hpai-history li.is-active button.hpai-conv { box-shadow: inset 0 0 0 1px var(--hp-border-2); }
:root[data-theme="light"] .hpai-chip-exam { background: rgba(124,92,255,.12); border-color: rgba(124,92,255,.3); }
:root[data-theme="light"] .hpai-answer blockquote { background: rgba(124,92,255,.07); }

/* A white wordmark needs a dark badge on a light background. */
:root[data-theme="light"] .hpai-source.is-highlight {
  background: #ECFBFE;
  border-color: var(--hp-accent-ink);
  box-shadow: 0 0 0 1px var(--hp-accent-ink), 0 8px 24px rgba(12,126,150,.16);
}

:root[data-theme="light"] .hpai-logo-chip {
  background: #0B1F3A; padding: 6px 10px; border-radius: 10px;
  box-shadow: 0 4px 14px rgba(11,31,58,.16);
}
:root[data-theme="light"] .hpai-logo-chip.hpai-logo-lg { padding: 12px 18px; border-radius: 16px; }
.hpai-logo-alt { display: none; }
:root[data-theme="light"] .hpai-logo-alt { display: block; }
:root[data-theme="light"] .hpai-logo-main { display: none; }

/* ---------------------------------------------------------------- Small screens */
@media (max-width: 480px) {
  :root { --hp-gutter: 12px; }
  .hpai-answer { padding: 16px 15px; border-radius: 20px; }
  .hpai-msg { margin-bottom: 18px; }
  .hpai-welcome { margin-top: 2vh; }
  .hpai-ecg { width: 96px; }
  .hpai-trust { font-size: 11.5px; padding: 5px 10px 5px 6px; }
}

/* =========================================================================
 * 1.3.0 — Readable buttons, plan picker, guest note
 * White text on a deeper blue: the old cyan gradient with near-black text
 * was hard to read and looked muddy.
 * ======================================================================= */
:root {
  --hp-btn: linear-gradient(135deg, #0B87B5 0%, #3357D6 100%);
  --hp-btn-hover: linear-gradient(135deg, #0A7AA4 0%, #2B4BC4 100%);
  --hp-btn-shadow: 0 8px 22px rgba(51,87,214,.34);
}
.hpai-btn-primary,
.hpai-send,
.hpai-plan-chip,
.hpai-logo-mark,
.hpai-source-n,
.hpai-badge-current,
.hpai-price-cta {
  background: var(--hp-btn);
  color: #fff !important;
}
.hpai-btn-primary { box-shadow: var(--hp-btn-shadow); font-weight: 700; text-shadow: 0 1px 1px rgba(2,8,24,.22); }
.hpai-btn-primary:hover { background: var(--hp-btn-hover); box-shadow: 0 12px 28px rgba(51,87,214,.46); }
.hpai-new-chat { justify-content: center; }
.hpai-send { box-shadow: var(--hp-btn-shadow); }
.hpai-send:hover { background: var(--hp-btn-hover); }
.hpai-badge-dot { background: #0B87B5; color: #fff; }
.hpai-btn-upgrade[hidden] { display: none; }

/* Guest note */
.hpai-guest-note {
  margin: 0; padding: 10px 12px; border-radius: var(--hp-radius-sm);
  font-size: 12px; line-height: 1.55; color: var(--hp-text-2);
  background: var(--hp-panel); border: 1px dashed var(--hp-border-2);
}
.hpai-guest-note[hidden] { display: none; }
.hpai-guest-note a { color: var(--hp-accent-ink); font-weight: 700; }

/* Plan picker */
.hpai-modal-card.hpai-upgrade-card { max-width: 860px; padding: 30px 26px 20px; }
.hpai-upgrade-card > p#hpai-upgrade-text { max-width: 560px; margin-left: auto; margin-right: auto; }
.hpai-upgrade-plans {
  display: grid; gap: 12px; margin: 8px 0 14px; text-align: left;
  grid-template-columns: 1fr;
}
@media (min-width: 760px) { .hpai-upgrade-plans { grid-template-columns: repeat(3, 1fr); } }
.hpai-pc {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding: 20px 16px 16px; border-radius: 20px;
  background: var(--hp-panel); border: 1px solid var(--hp-border);
}
.hpai-pc.is-popular { border-color: rgba(51,87,214,.55); box-shadow: 0 0 0 1px rgba(51,87,214,.35), 0 14px 34px rgba(51,87,214,.16); }
.hpai-pc.is-deep { border-color: rgba(124,92,255,.5); }
.hpai-pc.is-current { border-color: var(--hp-mint); }
.hpai-pc-flag {
  position: absolute; top: -11px; left: 16px; padding: 4px 11px; border-radius: 999px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .04em; color: #fff;
  background: var(--hp-btn); box-shadow: 0 6px 16px rgba(51,87,214,.35);
}
.hpai-pc-flag.is-deep { background: linear-gradient(135deg, #7C5CFF, #3E64DE); }
.hpai-pc-head strong { display: block; font-size: 17px; letter-spacing: -.2px; }
.hpai-pc-head span { display: block; font-size: 12px; color: var(--hp-text-3); margin-top: 2px; direction: rtl; text-align: left; unicode-bidi: plaintext; }
.hpai-pc-price { font-size: 22px; font-weight: 800; letter-spacing: -.4px; }
.hpai-pc-price small { font-size: 12px; font-weight: 600; color: var(--hp-text-3); letter-spacing: 0; }
.hpai-pc-list { list-style: none; margin: 0; padding: 10px 0 0; border-top: 1px solid var(--hp-border); display: grid; gap: 7px; flex: 1; }
.hpai-pc-list li { position: relative; padding-left: 22px; font-size: 12.5px; line-height: 1.5; color: var(--hp-text-2); }
.hpai-pc-list li b { color: var(--hp-text); }
.hpai-pc-list li::before {
  content: ''; position: absolute; left: 0; top: 2px; width: 15px; height: 15px; border-radius: 50%;
  background: rgba(11,135,181,.16);
}
.hpai-pc-list li::after {
  content: ''; position: absolute; left: 4.5px; top: 6px; width: 6px; height: 3.5px;
  border-left: 2px solid var(--hp-accent-ink); border-bottom: 2px solid var(--hp-accent-ink); transform: rotate(-45deg);
}
.hpai-pc-btn {
  display: flex; align-items: center; justify-content: center; width: 100%; margin-top: 4px;
  padding: 12px 14px; border-radius: 999px; border: 0; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 800; text-decoration: none;
  background: var(--hp-btn); color: #fff; box-shadow: var(--hp-btn-shadow);
  transition: transform .15s, box-shadow .2s, background .2s;
}
.hpai-pc-btn:hover { background: var(--hp-btn-hover); transform: translateY(-1px); }
.hpai-pc.is-deep .hpai-pc-btn:not(.is-current):not(.is-ghost) { background: linear-gradient(135deg, #6D4DF2, #3357D6); }
.hpai-pc-btn.is-ghost { background: transparent; color: var(--hp-text); border: 1px solid var(--hp-border-2); box-shadow: none; }
.hpai-pc-btn.is-ghost:hover { background: var(--hp-panel-2); transform: none; }
.hpai-pc-btn.is-current { background: transparent; color: var(--hp-accent-ink); border: 1px solid var(--hp-mint); box-shadow: none; cursor: default; }
.hpai-upgrade-foot { font-size: 12px !important; line-height: 1.6; color: var(--hp-text-3) !important; margin: 0 0 6px !important; }
.hpai-upgrade-foot a { color: var(--hp-accent-ink); font-weight: 700; }
.hpai-upgrade-links { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
:root[data-theme="light"] .hpai-pc { background: #fff; }
:root[data-theme="light"] .hpai-pc.is-popular { background: linear-gradient(180deg, rgba(51,87,214,.05), #fff 40%); }
@media (max-width: 759px) {
  .hpai-modal { padding: 12px; place-items: end center; }
  .hpai-modal-card.hpai-upgrade-card { padding: 24px 16px 14px; border-radius: 24px 24px 18px 18px; }
  .hpai-pc { padding: 18px 14px 14px; }
}
.hpai-pc-list { align-content: start; }
@media (max-width: 759px) {
  .hpai-pc.is-popular { order: -2; }
  .hpai-pc.is-deep { order: -1; }
}

/* =========================================================================
 * 1.4.0 — MedPlus Night polish
 * Matches medplus.academy (deep navy, royal blue, cyan). White text on every
 * coloured button, a plan pill and a Deep Research switch that explain
 * themselves, and clearer free-plan messaging.
 * ======================================================================= */
:root {
  --hp-btn: linear-gradient(135deg, #2F7CF6 0%, #3E5BDC 100%);
  --hp-btn-hover: linear-gradient(135deg, #2A6FE0 0%, #3450C8 100%);
  --hp-btn-shadow: 0 8px 22px rgba(47,108,240,.35);
  --hp-max: linear-gradient(135deg, #8B5CF6 0%, #4F5BE0 100%);
  --hp-max-ink: #B9A6FF;
}
:root[data-theme="light"] { --hp-max-ink: #5B3FD1; }

/* Buttons: one clear primary, one premium, everything else quiet. */
.hpai-btn-primary, .hpai-send, .hpai-pc-btn { color: #fff !important; text-shadow: none; }
.hpai-btn-upgrade {
  position: relative; overflow: hidden;
  background: var(--hp-max); color: #fff !important; font-weight: 700;
  box-shadow: 0 10px 26px rgba(99,91,240,.38);
}
.hpai-btn-upgrade::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.28), transparent);
  animation: hpai-shine 5.5s ease-in-out infinite;
}
@keyframes hpai-shine { 0%, 70% { left: -60%; } 100% { left: 130%; } }
.hpai-btn-upgrade:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(99,91,240,.48); }
.hpai-btn-max { background: var(--hp-max); color: #fff !important; box-shadow: 0 10px 26px rgba(99,91,240,.38); font-weight: 700; }
.hpai-btn-max:hover { transform: translateY(-1px); }
.hpai-pc.is-deep .hpai-pc-btn:not(.is-current):not(.is-ghost) { background: var(--hp-max); }
.hpai-pc-flag.is-deep { background: var(--hp-max); }

/* The doctor's own message: solid brand blue, white text, in both themes. */
.hpai-msg-user .hpai-bubble {
  background: var(--hp-btn); color: #fff; border: 0;
  box-shadow: 0 10px 24px rgba(47,108,240,.25);
}
.hpai-msg-user .hpai-bubble a { color: #fff; }

/* Answer card */
.hpai-answer h3 { color: var(--hp-accent-ink); }
.hpai-answer-disclaimer { display: none; } /* the footer already shows it */
.hpai-chip-deep {
  background: rgba(139,92,246,.16); border-color: rgba(139,92,246,.4); color: var(--hp-max-ink);
}

/* ---------------------------------------------------------- Plan pill */
.hpai-plan-pill {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  padding: 6px 12px 6px 7px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--hp-border-2); background: var(--hp-panel);
  font: inherit; font-size: 12px; font-weight: 600; color: var(--hp-text-2);
  transition: border-color .18s, background .18s, transform .15s;
}
.hpai-plan-pill:hover { border-color: rgba(47,124,246,.6); color: var(--hp-text); transform: translateY(-1px); }
.hpai-plan-pill-name {
  padding: 3px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 800;
  letter-spacing: .06em; text-transform: uppercase; color: #fff; background: var(--hp-btn);
}
.hpai-plan-pill.is-max .hpai-plan-pill-name { background: var(--hp-max); }
.hpai-plan-pill.is-free .hpai-plan-pill-name { background: rgba(148,163,184,.28); color: var(--hp-text); }
.hpai-plan-pill.is-out { border-color: rgba(255,92,122,.55); }
.hpai-plan-pill.is-out .hpai-plan-pill-left { color: var(--hp-rose); }
.hpai-plan-pill-left:empty { display: none; }
.hpai-plan-pill-left { font-variant-numeric: tabular-nums; }
.hpai-plan-pill.is-free .hpai-plan-pill-left::after { content: ' · Upgrade'; color: var(--hp-accent-ink); font-weight: 700; }
@media (max-width: 420px) { .hpai-plan-pill.is-free .hpai-plan-pill-left::after { content: ''; } }

/* ------------------------------------------------- Deep Research chip */
.hpai-modebar {
  max-width: 820px; margin: 0 auto 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.hpai-deep-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 7px 6px 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(139,92,246,.42); background: rgba(139,92,246,.10);
  font: inherit; font-size: 12.5px; font-weight: 650; color: var(--hp-text);
  transition: background .18s, border-color .18s, box-shadow .2s;
}
.hpai-deep-chip svg { width: 15px; height: 15px; color: var(--hp-max-ink); }
.hpai-deep-chip:hover { background: rgba(139,92,246,.18); border-color: rgba(139,92,246,.7); }
.hpai-deep-state {
  padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: #fff; background: var(--hp-max);
}
.hpai-deep-chip:not(.is-on) .hpai-deep-state::before { content: '🔒 '; font-size: 9px; }
.hpai-deep-chip.is-on { box-shadow: 0 0 0 3px rgba(139,92,246,.18), 0 8px 22px rgba(99,91,240,.25); }
.hpai-deep-chip.is-on .hpai-deep-state { background: linear-gradient(135deg, #22D3EE, #2F7CF6); }
.hpai-mode-hint {
  font-size: 12px; color: var(--hp-text-3); cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px;
}
.hpai-mode-hint:hover { color: var(--hp-text-2); }
@media (max-width: 520px) { .hpai-mode-hint { display: none; } }

/* ------------------------------------------------- Deep Research modal */
.hpai-modal-card.hpai-deep-card { max-width: 620px; text-align: left; padding: 28px 26px 22px; }
.hpai-deep-hero { text-align: center; }
.hpai-deep-ico {
  display: inline-grid; place-items: center; width: 54px; height: 54px; border-radius: 18px;
  background: var(--hp-max); color: #fff; box-shadow: 0 12px 30px rgba(99,91,240,.4);
}
.hpai-deep-ico svg { width: 26px; height: 26px; }
.hpai-deep-hero h3 { margin: 12px 0 4px; font-size: 22px; }
.hpai-deep-ar {
  margin: 0 0 8px !important; font-size: 15px !important; font-weight: 700; color: var(--hp-max-ink) !important;
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif; line-height: 1.7;
}
.hpai-deep-steps { list-style: none; counter-reset: deep; margin: 18px 0 16px; padding: 0; display: grid; gap: 10px; }
.hpai-deep-steps li {
  counter-increment: deep; position: relative; padding: 12px 14px 12px 50px;
  border-radius: 14px; border: 1px solid var(--hp-border); background: var(--hp-panel);
}
.hpai-deep-steps li::before {
  content: counter(deep); position: absolute; left: 14px; top: 13px; width: 24px; height: 24px; border-radius: 8px;
  display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; background: var(--hp-max);
}
.hpai-deep-steps b { display: block; font-size: 14px; margin-bottom: 2px; }
.hpai-deep-steps span { display: block; font-size: 12.5px; line-height: 1.55; color: var(--hp-text-2); }
.hpai-deep-compare { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; margin: 0 0 14px; }
.hpai-deep-compare th, .hpai-deep-compare td { padding: 8px 10px; text-align: center; border-bottom: 1px solid var(--hp-border); }
.hpai-deep-compare td:first-child, .hpai-deep-compare th:first-child { text-align: left; color: var(--hp-text-2); }
.hpai-deep-compare th { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--hp-text-3); }
.hpai-deep-compare .is-max { background: rgba(139,92,246,.10); color: var(--hp-text); }
.hpai-deep-compare th.is-max { color: var(--hp-max-ink); border-radius: 10px 10px 0 0; }
.hpai-deep-compare .is-yes { color: var(--hp-accent-ink); font-weight: 800; }
.hpai-deep-compare .is-no { color: var(--hp-text-3); }
.hpai-deep-best { font-size: 13px; color: var(--hp-text-2); margin: 0 0 16px !important; }
.hpai-deep-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; }
.hpai-deep-actions .hpai-btn { justify-content: center; min-width: 170px; }
.hpai-deep-included { flex-basis: 100%; text-align: center; font-size: 13px; font-weight: 600; color: var(--hp-accent-ink); }
@media (max-width: 520px) {
  .hpai-modal-card.hpai-deep-card { padding: 22px 16px 16px; }
  .hpai-deep-compare { font-size: 11.5px; }
  .hpai-deep-compare th, .hpai-deep-compare td { padding: 7px 5px; }
  .hpai-deep-actions .hpai-btn { width: 100%; }
}

/* ------------------------------------------------- Evidence: free upsell */
.hpai-evidence-upsell {
  margin: 8px 2px; padding: 20px 18px; border-radius: 18px; text-align: left;
  border: 1px solid rgba(47,124,246,.35);
  background: linear-gradient(180deg, rgba(47,124,246,.12), rgba(34,211,238,.04));
}
.hpai-eu-ico {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; margin-bottom: 12px;
  background: var(--hp-btn); color: #fff;
}
.hpai-eu-ico svg { width: 20px; height: 20px; }
.hpai-evidence-upsell strong { display: block; font-size: 15px; margin-bottom: 6px; }
.hpai-evidence-upsell p { margin: 0 0 10px; font-size: 13px; line-height: 1.6; color: var(--hp-text-2); }
.hpai-evidence-upsell ul { margin: 0 0 16px; padding: 0; list-style: none; display: grid; gap: 6px; }
.hpai-evidence-upsell li { font-size: 12.5px; padding-left: 20px; position: relative; color: var(--hp-text); }
.hpai-evidence-upsell li::before { content: '✓'; position: absolute; left: 0; color: var(--hp-accent-ink); font-weight: 800; }
.hpai-evidence-upsell .hpai-btn { width: 100%; justify-content: center; }

/* ------------------------------------------------- Welcome & layout */
.hpai-welcome-trust span { font-weight: 600; }
.hpai-suggestion { transition: transform .18s, border-color .18s, background .18s, box-shadow .2s; }
.hpai-suggestion:hover { border-color: rgba(47,124,246,.5); box-shadow: 0 10px 26px rgba(47,108,240,.16); }
.hpai-topbar { gap: 10px; }
@media (max-width: 1099px) { .hpai-topbar-sub { display: none; } }
@media (min-width: 640px) {
  .hpai-modal-card.hpai-deep-card { max-width: 700px; }
  .hpai-deep-steps { grid-template-columns: repeat(3, 1fr); }
  .hpai-deep-steps li { padding: 46px 14px 14px; }
  .hpai-deep-steps li::before { top: 14px; }
}

/* =========================================================================
 * 1.5.0 — subscription: pill days, renew banner, "My subscription"
 * ======================================================================= */
.hpai-plan-pill.has-sub .hpai-plan-pill-left { color: var(--hp-text); }
.hpai-plan-pill.is-ending { border-color: rgba(255,181,71,.7); }
.hpai-plan-pill.is-ending .hpai-plan-pill-left { color: var(--hp-amber, #FFB547); }

.hpai-sub-link {
  display: flex; align-items: center; gap: 8px; width: 100%; margin: 8px 0 0; padding: 9px 12px;
  border-radius: 12px; border: 1px solid var(--hp-border); background: var(--hp-panel); cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--hp-text-2); text-align: left;
}
.hpai-sub-link svg { width: 16px; height: 16px; flex: 0 0 16px; color: var(--hp-accent-ink); }
.hpai-sub-link:hover { border-color: rgba(47,124,246,.55); color: var(--hp-text); }
.hpai-sub-link.is-ending { border-color: rgba(255,181,71,.6); }
.hpai-sub-link.is-ending svg { color: #FFB547; }

.hpai-renew-bar {
  display: flex; align-items: center; gap: 12px; margin: 10px 16px 0; padding: 10px 12px 10px 14px;
  border-radius: 14px; font-size: 13px; line-height: 1.5; color: var(--hp-text);
  border: 1px solid rgba(255,181,71,.45); background: linear-gradient(90deg, rgba(255,181,71,.14), rgba(255,181,71,.04));
}
.hpai-renew-bar.is-ended { border-color: rgba(255,92,122,.45); background: linear-gradient(90deg, rgba(255,92,122,.13), rgba(255,92,122,.03)); }
.hpai-renew-ico { font-size: 17px; }
.hpai-renew-msg { flex: 1; }
.hpai-renew-btn { flex: 0 0 auto; padding: 8px 14px !important; font-size: 12.5px !important; }
.hpai-renew-x { flex: 0 0 auto; border: 0; background: none; color: var(--hp-text-3); font-size: 20px; cursor: pointer; line-height: 1; }
@media (max-width: 640px) {
  .hpai-renew-bar { flex-wrap: wrap; margin: 8px 10px 0; font-size: 12.5px; }
  .hpai-renew-msg { flex-basis: calc(100% - 60px); }
  .hpai-renew-btn { margin-left: 28px; }
}

.hpai-modal-card.hpai-account-card { max-width: 560px; text-align: left; padding: 24px 22px 20px; }
.hpai-account-loading { padding: 40px 10px; text-align: center; color: var(--hp-text-3); }
.hpai-acc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding-right: 30px; }
.hpai-acc-head strong { display: block; font-size: 16px; }
.hpai-acc-head small { display: block; color: var(--hp-text-3); font-size: 12.5px; }
.hpai-acc-avatar { flex: 0 0 42px; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; background: var(--hp-btn); }
.hpai-acc-plan {
  display: flex; gap: 18px; align-items: center; padding: 18px; border-radius: 18px;
  border: 1px solid rgba(47,124,246,.35); background: linear-gradient(135deg, rgba(47,124,246,.14), rgba(34,211,238,.04));
}
.hpai-acc-plan.is-max { border-color: rgba(139,92,246,.45); background: linear-gradient(135deg, rgba(139,92,246,.18), rgba(79,91,224,.05)); }
.hpai-acc-plan.is-off { filter: saturate(.4); }
.hpai-acc-plan.is-free p { margin: 8px 0 0; color: var(--hp-text-2); font-size: 13px; }
.hpai-acc-ring {
  --p: 50; flex: 0 0 104px; width: 104px; height: 104px; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: radial-gradient(closest-side, var(--hp-bg-2, #0d1b3a) 80%, transparent 81% 100%),
              conic-gradient(#22D3EE calc(var(--p) * 1%), rgba(148,163,184,.18) 0);
}
.hpai-acc-plan.is-max .hpai-acc-ring { background: radial-gradient(closest-side, var(--hp-bg-2, #0d1b3a) 80%, transparent 81% 100%), conic-gradient(#8B5CF6 calc(var(--p) * 1%), rgba(148,163,184,.18) 0); }
:root[data-theme="light"] .hpai-acc-ring { background: radial-gradient(closest-side, #fff 80%, transparent 81% 100%), conic-gradient(#2F7CF6 calc(var(--p) * 1%), rgba(148,163,184,.25) 0); }
.hpai-acc-ring b { font-size: 30px; line-height: 1; }
.hpai-acc-ring span { font-size: 11px; color: var(--hp-text-3); }
.hpai-acc-info { flex: 1; min-width: 0; }
.hpai-acc-tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #fff; background: var(--hp-btn); }
.hpai-acc-plan.is-max .hpai-acc-tag { background: var(--hp-max); }
.hpai-acc-plan.is-free .hpai-acc-tag { background: rgba(148,163,184,.3); color: var(--hp-text); }
.hpai-acc-state { margin-left: 8px; font-size: 12px; font-weight: 700; color: var(--hp-accent-ink); }
.hpai-acc-plan.is-off .hpai-acc-state { color: var(--hp-rose); }
.hpai-acc-info dl { margin: 10px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12.5px; }
.hpai-acc-info dt { color: var(--hp-text-3); }
.hpai-acc-info dd { margin: 0; color: var(--hp-text); font-weight: 600; }
.hpai-acc-note { margin: 12px 2px 14px !important; font-size: 12.5px; color: var(--hp-text-2); }
.hpai-acc-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.hpai-acc-actions .hpai-btn { flex: 1 1 140px; justify-content: center; }
.hpai-acc-h { margin: 20px 0 8px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--hp-text-3); }
.hpai-acc-pay { display: grid; gap: 6px; max-height: 220px; overflow-y: auto; }
.hpai-acc-row {
  display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--hp-border); background: var(--hp-panel); text-decoration: none; color: var(--hp-text); font-size: 13px;
}
.hpai-acc-row:hover { border-color: rgba(47,124,246,.5); }
.hpai-acc-row small { display: block; color: var(--hp-text-3); font-size: 11.5px; }
.hpai-acc-amt { text-align: right; font-weight: 700; }
@media (max-width: 520px) {
  .hpai-acc-plan { flex-direction: column; text-align: center; }
  .hpai-acc-info dl { text-align: left; }
}
