/* ============================================================
   LESSPLAN · MR HENEGHAN COMPANION
   A quiet study presence, not a pop-up.
   ============================================================ */
#mrh,
.mrh,
.mrh-scrim,
.mrh-drawer {
  --mrh-ink: #ece3cf;
  --mrh-dim: #c9bfa6;
  --mrh-muted: #978c73;
  --mrh-panel: #1e1a14;
  --mrh-panel-2: #262117;
  --mrh-edge: #463d2b;
  --mrh-gold: #d6b878;
  --mrh-gold-bright: #e2c88f;
  --mrh-good: #8cb99c;
}

.mrh {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  font-family: var(--font-sans, system-ui, sans-serif);
}

.mrh-avatar {
  position: relative;
  width: 70px;
  height: 70px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #262117;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.mrh-avatar:hover,
.mrh-avatar:focus-visible {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55), 0 0 0 2px var(--mrh-gold);
  outline: none;
}
.mrh-avatar-frame {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--mrh-gold);
  background: #d9c7ad;
}
.mrh-avatar-frame img,
.mrh-head-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 32%;
  display: block;
}
.mrh-avatar-frame img {
  animation: mrh-breathe 6.5s ease-in-out infinite;
  transform-origin: 50% 70%;
}
.mrh[data-state="listening"] .mrh-avatar-frame img {
  animation: mrh-listen 3.2s ease-in-out infinite;
}
.mrh[data-state="speaking"] .mrh-avatar-frame img {
  animation: mrh-speak 1.15s ease-in-out infinite;
}
.mrh[data-state="prompting"] .mrh-avatar {
  animation: mrh-prompt 2.8s ease-in-out infinite;
}
.mrh-dot {
  position: absolute;
  right: 0;
  bottom: 1px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--mrh-good);
  border: 2px solid var(--mrh-panel);
  box-shadow: 0 0 0 3px rgba(140, 185, 156, 0.16);
}
.mrh[data-state="listening"] .mrh-dot { background: #86aec9; box-shadow: 0 0 0 3px rgba(134, 174, 201, 0.18); }
.mrh[data-state="speaking"] .mrh-dot { background: var(--mrh-gold-bright); box-shadow: 0 0 0 3px rgba(226, 200, 143, 0.22); }
.mrh[data-state="prompting"] .mrh-dot { background: var(--mrh-gold-bright); animation: mrh-dot-pulse 1.4s ease-in-out infinite; }

.mrh-wave {
  position: absolute;
  right: 78px;
  bottom: 22px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 7px 8px;
  border-radius: 999px;
  background: rgba(18, 16, 11, 0.92);
  border: 1px solid var(--mrh-edge);
  opacity: 0;
  transform: translateX(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.mrh[data-state="speaking"] .mrh-wave { opacity: 1; transform: none; }
.mrh-wave i {
  display: block;
  width: 3px;
  height: 10px;
  border-radius: 2px;
  background: var(--mrh-gold-bright);
  animation: mrh-wave 0.75s ease-in-out infinite;
}
.mrh-wave i:nth-child(2) { animation-delay: 0.12s; height: 14px; }
.mrh-wave i:nth-child(3) { animation-delay: 0.24s; height: 8px; }

.mrh-badge {
  max-width: 270px;
  display: flex;
  align-items: stretch;
  background: #262117;
  border: 1px solid var(--mrh-edge);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
  position: relative;
}
.mrh-badge::after {
  content: "";
  position: absolute;
  right: 27px;
  bottom: -6px;
  width: 11px;
  height: 11px;
  background: #262117;
  border-right: 1px solid var(--mrh-edge);
  border-bottom: 1px solid var(--mrh-edge);
  transform: rotate(45deg);
}
.mrh-badge.on { opacity: 1; transform: none; }
.mrh-badge-main {
  border: 0;
  background: transparent;
  color: var(--mrh-ink);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  text-align: left;
  padding: 11px 4px 11px 14px;
  cursor: pointer;
}
.mrh-badge-main:hover { color: var(--mrh-gold-bright); }
.mrh-badge-close {
  border: 0;
  background: transparent;
  color: var(--mrh-muted);
  font-size: 18px;
  line-height: 1;
  padding: 8px 10px;
  cursor: pointer;
}
.mrh-badge-close:hover { color: var(--mrh-ink); }

.mrh-scrim {
  position: fixed;
  inset: 0;
  z-index: 20001;
  background: rgba(8, 7, 5, 0.56);
  opacity: 0;
  transition: opacity 0.24s ease;
  backdrop-filter: blur(2px);
}
.mrh-scrim.on { opacity: 1; }
.mrh-scrim[hidden] { display: none; }

.mrh-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 20002;
  width: min(460px, 100vw);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--mrh-panel);
  color: var(--mrh-ink);
  border-left: 1px solid var(--mrh-edge);
  box-shadow: -24px 0 70px rgba(0, 0, 0, 0.5);
  transform: translateX(102%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  font-family: var(--font-sans, system-ui, sans-serif);
}
.mrh-drawer.on { transform: none; }
.mrh-drawer[hidden] { display: none; }

.mrh-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--mrh-edge);
}
.mrh-head-img {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid var(--mrh-gold);
}
.mrh-head-copy { flex: 1; min-width: 0; }
.mrh-kicker {
  display: block;
  font-family: var(--font-mono, Consolas, monospace);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mrh-gold);
  margin-bottom: 3px;
}
.mrh-head h2 {
  margin: 0;
  font-family: var(--font-serif, Georgia, serif);
  font-size: 20px;
  line-height: 1.15;
  color: var(--mrh-ink);
}
.mrh-close {
  border: 1px solid var(--mrh-edge);
  background: transparent;
  color: var(--mrh-dim);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.mrh-close:hover { border-color: var(--mrh-gold); color: var(--mrh-gold-bright); }

.mrh-summary {
  margin: 0;
  padding: 13px 18px 0;
  color: var(--mrh-dim);
  font-size: 13.5px;
  line-height: 1.55;
}

.mrh-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 18px 0;
  border-bottom: 1px solid var(--mrh-edge);
}
.mrh-tabs button {
  border: 0;
  background: transparent;
  color: var(--mrh-muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 9px 10px 11px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.mrh-tabs button[aria-selected="true"] {
  color: var(--mrh-gold-bright);
  border-bottom-color: var(--mrh-gold);
}
.mrh-tabs button:hover { color: var(--mrh-ink); }
.mrh-tabs button:focus-visible { outline: 2px solid var(--mrh-gold); outline-offset: 2px; }

.mrh-panels {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 18px 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--mrh-edge) transparent;
}
.mrh-panel[hidden] { display: none; }
.mrh-item {
  border: 1px solid var(--mrh-edge);
  border-radius: 10px;
  background: var(--mrh-panel-2);
  padding: 12px 13px;
  margin-bottom: 10px;
}
.mrh-item h3 {
  margin: 0 0 4px;
  font-family: var(--font-serif, Georgia, serif);
  font-size: 15.5px;
  line-height: 1.3;
  color: var(--mrh-ink);
}
.mrh-item p {
  margin: 0 0 8px;
  color: var(--mrh-dim);
  font-size: 13px;
  line-height: 1.55;
}
.mrh-item-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--mrh-gold-bright);
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px solid rgba(226, 200, 143, 0.4);
  padding-bottom: 1px;
}
.mrh-item-link:hover { color: #fff4db; border-color: currentColor; }
.mrh-answer {
  border: 1px solid rgba(214, 184, 120, 0.5);
  border-radius: 10px;
  background: rgba(214, 184, 120, 0.08);
  padding: 13px;
  margin-bottom: 14px;
}
.mrh-answer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}
.mrh-answer-top .mrh-kicker { margin: 0; }
.mrh-ai-badge {
  border: 1px solid rgba(226, 200, 143, 0.5);
  border-radius: 999px;
  padding: 1px 7px;
  font-family: var(--font-mono, Consolas, monospace);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mrh-gold-bright);
  background: rgba(226, 200, 143, 0.12);
}
.mrh-ai-local {
  color: var(--mrh-dim);
  border-color: var(--mrh-edge);
  background: transparent;
}
.mrh-answer h3 { margin: 0 0 4px; font-family: var(--font-serif, Georgia, serif); font-size: 16px; }
.mrh-answer h4 { margin: 8px 0 3px; font-family: var(--font-serif, Georgia, serif); font-size: 14.5px; color: var(--mrh-ink); }
.mrh-answer p { margin: 0 0 8px; color: var(--mrh-dim); font-size: 13px; line-height: 1.55; }
.mrh-answer p:last-child { margin-bottom: 0; }
.mrh-answer ul,
.mrh-answer ol { margin: 4px 0 9px; padding-left: 18px; }
.mrh-answer li { color: var(--mrh-dim); font-size: 13px; line-height: 1.5; margin: 3px 0; }
.mrh-answer strong { color: var(--mrh-ink); font-weight: 700; }
.mrh-answer-note {
  margin: 9px 0 0 !important;
  color: var(--mrh-muted) !important;
  font-size: 10.5px !important;
  line-height: 1.45 !important;
}
.mrh-answer-loading { border-style: dashed; }
.mrh-typing-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--mrh-dim) !important;
}
.mrh-typing {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.mrh-typing i {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--mrh-gold-bright);
  animation: mrh-typing 1s ease-in-out infinite;
}
.mrh-typing i:nth-child(2) { animation-delay: 0.14s; }
.mrh-typing i:nth-child(3) { animation-delay: 0.28s; }
.mrh-answer-error {
  border-color: rgba(224, 138, 128, 0.55);
  background: rgba(224, 138, 128, 0.08);
}
.mrh-answer-error .mrh-kicker { color: #e8a49c; }
.mrh-retry {
  border: 1px solid rgba(226, 200, 143, 0.6);
  background: transparent;
  color: var(--mrh-gold-bright);
  border-radius: 7px;
  padding: 6px 9px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.mrh-retry:hover { background: rgba(226, 200, 143, 0.12); }

.mrh-ask {
  padding: 12px 18px 10px;
  border-top: 1px solid var(--mrh-edge);
  background: var(--mrh-panel);
}
.mrh-ask-row {
  display: flex;
  gap: 7px;
}
.mrh-ask input {
  flex: 1;
  min-width: 0;
  background: #12100b;
  color: var(--mrh-ink);
  border: 1px solid var(--mrh-edge);
  border-radius: 7px;
  padding: 9px 10px;
  font: inherit;
  font-size: 12.5px;
}
.mrh-ask input:focus-visible { outline: 2px solid var(--mrh-gold); outline-offset: 1px; }
.mrh-ask button {
  border: 1px solid var(--mrh-gold);
  background: var(--mrh-gold);
  color: #171410;
  border-radius: 7px;
  padding: 9px 11px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.mrh-ask button:hover { background: var(--mrh-gold-bright); }
.mrh-ask-note {
  margin: 7px 1px 0;
  color: var(--mrh-muted);
  font-size: 10.5px;
  line-height: 1.45;
}
.mrh-ask-fallback { color: var(--mrh-dim); }

.mrh-foot {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 0 18px 16px;
}
.mrh-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--mrh-gold);
  background: transparent;
  color: var(--mrh-gold-bright);
  border-radius: 7px;
  padding: 8px 11px;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
}
.mrh-action:hover { background: rgba(214, 184, 120, 0.12); }
.mrh-secondary {
  border: 1px solid var(--mrh-edge);
  background: transparent;
  color: var(--mrh-dim);
  border-radius: 7px;
  padding: 8px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.mrh-secondary:hover { border-color: var(--mrh-gold); color: var(--mrh-ink); }
.mrh-secondary[hidden], .mrh-action[hidden] { display: none; }

.mrh-sr {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.mrh-focus {
  outline: 2px solid var(--mrh-gold);
  outline-offset: 6px;
  border-radius: 4px;
  transition: outline-color 0.2s ease;
}

body.mrh-open { overflow: hidden; }

@keyframes mrh-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.018); }
}
@keyframes mrh-listen {
  0%, 100% { transform: rotate(-0.6deg) scale(1.01); }
  50% { transform: rotate(0.6deg) scale(1.02); }
}
@keyframes mrh-speak {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-1.5px) scale(1.018); }
}
@keyframes mrh-prompt {
  0%, 100% { box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45), 0 0 0 0 rgba(214, 184, 120, 0.4); }
  50% { box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55), 0 0 0 8px rgba(214, 184, 120, 0); }
}
@keyframes mrh-dot-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}
@keyframes mrh-wave {
  0%, 100% { transform: scaleY(0.55); }
  50% { transform: scaleY(1); }
}
@keyframes mrh-typing {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}

@media (max-width: 640px) {
  .mrh { right: 14px; bottom: 14px; gap: 8px; }
  .mrh-avatar { width: 58px; height: 58px; }
  .mrh-badge { max-width: calc(100vw - 88px); }
  .mrh-badge-main { font-size: 12.5px; padding: 10px 2px 10px 12px; }
  .mrh-wave { right: 64px; bottom: 17px; }
  .mrh-drawer { width: 100vw; }
  .mrh-head { padding: 14px 14px 10px; }
  .mrh-summary, .mrh-tabs, .mrh-panels, .mrh-ask, .mrh-foot { padding-left: 14px; padding-right: 14px; }
  .mrh-head h2 { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .mrh-avatar-frame img,
  .mrh[data-state="listening"] .mrh-avatar-frame img,
  .mrh[data-state="speaking"] .mrh-avatar-frame img,
  .mrh[data-state="prompting"] .mrh-avatar,
  .mrh[data-state="prompting"] .mrh-dot,
  .mrh-wave i {
    animation: none !important;
  }
  .mrh-typing i { animation: none !important; opacity: 1; }
  .mrh-avatar, .mrh-badge, .mrh-drawer, .mrh-scrim { transition-duration: 0.01ms !important; }
}

@media print {
  .mrh, .mrh-scrim, .mrh-drawer { display: none !important; }
}
