/* ============================ AI chat ============================
   The assistant conversation screen: mode picker, hero, message thread and composer.
   Loaded after shell.css. */

/* The screen fills everything below the header; only the thread scrolls. Pinned to the window
   edges rather than sized in vh, which the page's zoom would shrink (same as the Encyclopedia). */
html[data-route="chat"] .shell { position: fixed; inset: 0; min-height: 0; }
html[data-route="chat"] .shell__main { min-height: 0; }
html[data-route="chat"] .shell__main > main { display: flex; min-height: 0; padding: 0; }

.chat {
  position: relative; flex: 1 1 auto; min-height: 0; min-width: 0;
  display: flex; flex-direction: column;
  background: radial-gradient(70% 42% at 50% 0%, var(--primary-soft) 0%, transparent 72%), var(--surface-page);
}

/* ---------- Top row: mode picker, new chat, who ---------- */
.chat__top { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-8) 0; }
@media (max-width: 1200px) { .chat__top { padding: var(--space-4) var(--space-6) 0; } }
@media (max-width: 640px) { .chat__top { padding: var(--space-3) var(--space-4) 0; } }
.chat__spacer { flex: 1 1 auto; }
.chat__new { height: 40px; border-radius: var(--radius-md); }
.chat__new .sicon { color: var(--ink-muted); }

.chatmode { position: relative; }
.chatmode__btn { gap: var(--space-2); padding-left: 10px; }
.chatmode__btn .sicon { color: var(--ink-muted); }
.chatmode__menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 10; min-width: 260px;
  display: grid; gap: 2px; padding: var(--space-1);
  background: var(--surface-card); border: 1px solid var(--border-hairline); border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  transform-origin: top left; animation: pop-in 180ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(0.96); } to { opacity: 1; transform: none; } }
.chatmode__opt {
  display: grid; gap: 1px; text-align: left; padding: 8px 10px;
  border: 0; border-radius: var(--radius-sm); background: none; font: inherit; color: var(--ink); cursor: pointer;
}
.chatmode__opt:hover { background: var(--surface-sunken); }
.chatmode__opt[aria-selected="true"] { background: var(--primary-soft); }
.chatmode__name { font-size: 14px; font-weight: 600; line-height: 20px; }
.chatmode__desc { font-size: 12.5px; line-height: 17px; color: var(--ink-muted); }

.chatwho {
  display: inline-flex; align-items: center; gap: var(--space-2); height: 40px; padding: 0 var(--space-3) 0 5px;
  border: 1px solid var(--border-hairline); border-radius: var(--radius-pill); background: var(--surface-card);
  font-size: 13.5px; font-weight: 600; color: var(--ink);
}
.chatwho .avatar { width: 28px; height: 28px; font-size: 11px; }
.chatwho__name { max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .chatwho { display: none; } }

/* ---------- Side rail: copy, jump, clear ---------- */
.chat__rail { position: absolute; right: var(--space-6); top: 80px; z-index: 5; display: grid; gap: var(--space-2); }
.chat__rail .iconbtn { border-radius: var(--radius-pill); box-shadow: var(--shadow-card); animation: rise-in 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both; transition: transform 140ms ease, background-color 140ms ease; }
.chat__rail .iconbtn:nth-child(2) { animation-delay: 70ms; }
.chat__rail .iconbtn:nth-child(3) { animation-delay: 140ms; }
.chat__rail .iconbtn:hover { transform: translateX(-2px); }
.chat__rail .iconbtn[disabled] { color: var(--ink-faint); cursor: not-allowed; }
@media (max-width: 1100px) {
  .chat__rail { position: static; display: flex; flex-wrap: wrap; padding: var(--space-3) var(--space-6) 0; }
  .chat__rail .iconbtn { width: 36px; height: 36px; }
}
@media (max-width: 640px) { .chat__rail { padding: var(--space-2) var(--space-4) 0; } }

/* ---------- Thread ---------- */
.chat__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--space-6) var(--space-8); scrollbar-width: thin; }
@media (max-width: 1200px) { .chat__body { padding: var(--space-6) var(--space-6); } }
@media (max-width: 640px) { .chat__body { padding: var(--space-4); } }

.chat__hero {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: var(--space-2); padding: var(--space-6) 0;
}
.chat__hero > * { animation: rise-in 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.chat__hero > :nth-child(2) { animation-delay: 120ms; }
.chat__hero > :nth-child(3) { animation-delay: 220ms; }
.chat__foot { animation: rise-in 520ms cubic-bezier(0.2, 0.8, 0.2, 1) 300ms both; }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.chat__halo {
  position: relative; display: grid; place-items: center; width: 240px; height: 170px; margin-bottom: var(--space-3);
  background-image: radial-gradient(var(--ink-faint) 1px, transparent 1.6px); background-size: 11px 11px;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 0%, transparent 68%); mask-image: radial-gradient(ellipse at center, #000 0%, transparent 68%);
  opacity: 0.55;
}
.chat__halo::before {
  content: ""; position: absolute; width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle, rgba(215, 37, 57, 0.35) 0%, transparent 68%);
  animation: halo-pulse 5.5s ease-in-out infinite;
}
@keyframes halo-pulse { 0%, 100% { transform: scale(0.9); opacity: 0.6; } 50% { transform: scale(1.25); opacity: 1; } }
.chat__hi { font-size: 22px; line-height: 28px; font-weight: 500; color: var(--ink); }
.chat__hi em { font-style: normal; color: var(--ink-muted); }
.chat__ask { font-size: 32px; line-height: 40px; font-weight: 700; letter-spacing: -0.5px; color: var(--ink); text-wrap: balance; }
.chat__ask span { font-weight: 500; color: var(--ink-muted); }
@media (max-width: 640px) { .chat__hi { font-size: 18px; line-height: 24px; } .chat__ask { font-size: 25px; line-height: 31px; } }

/* The assistant's mark: a brand-red sphere with a slow swirl of light */
.orb {
  position: relative; display: inline-block; width: 96px; height: 96px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  background: radial-gradient(circle at 32% 28%, #ff7f8f 0%, var(--primary) 28%, var(--wine) 64%, #2e0b14 100%);
  box-shadow: 0 18px 40px rgba(215, 37, 57, 0.32), inset -10px -14px 30px rgba(0, 0, 0, 0.38), inset 8px 8px 18px rgba(255, 255, 255, 0.16);
  animation: orb-breathe 5.5s ease-in-out infinite;
  will-change: transform;
}
.orb::before, .orb::after { content: ""; position: absolute; inset: -10%; border-radius: 50%; }
.orb::before {
  background: conic-gradient(from 20deg, transparent 0 36%, rgba(255, 255, 255, 0.45) 48%, transparent 60% 100%);
  filter: blur(7px); animation: orb-swirl 8s linear infinite;
}
.orb::after {
  background:
    conic-gradient(from 210deg, transparent 0 30%, rgba(255, 210, 215, 0.28) 40%, transparent 52% 100%),
    radial-gradient(circle at 72% 78%, rgba(0, 0, 0, 0.45), transparent 48%);
  filter: blur(5px); animation: orb-swirl 13s linear infinite reverse;
}
@keyframes orb-swirl { to { transform: rotate(360deg); } }
@keyframes orb-breathe {
  0%, 100% { transform: translateY(0) scale(1); box-shadow: 0 18px 40px rgba(215, 37, 57, 0.32), inset -10px -14px 30px rgba(0, 0, 0, 0.38), inset 8px 8px 18px rgba(255, 255, 255, 0.16); }
  50% { transform: translateY(-5px) scale(1.04); box-shadow: 0 26px 54px rgba(215, 37, 57, 0.48), inset -10px -14px 30px rgba(0, 0, 0, 0.34), inset 8px 8px 18px rgba(255, 255, 255, 0.22); }
}
.orb--sm { width: 28px; height: 28px; animation: none; box-shadow: 0 4px 10px rgba(215, 37, 57, 0.3), inset -3px -4px 8px rgba(0, 0, 0, 0.35), inset 2px 2px 5px rgba(255, 255, 255, 0.18); }
.orb--sm::before { filter: blur(2px); animation-duration: 6s; }
.orb--sm::after { filter: blur(2px); animation-duration: 9s; }
.chatmode__btn .orb--sm { width: 20px; height: 20px; }

.chat__thread { max-width: 860px; margin: 0 auto; display: grid; gap: var(--space-5); }
.msg { display: flex; gap: var(--space-3); align-items: flex-start; animation: msg-in 320ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.msg--user { transform-origin: bottom right; }
.msg--assistant { transform-origin: top left; }
@keyframes msg-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.msg--user { justify-content: flex-end; }
.msg__avatar { display: inline-flex; flex-shrink: 0; margin-top: 2px; }
.msg__body { min-width: 0; max-width: min(100%, 680px); }
.msg--user .msg__body {
  max-width: min(80%, 620px); padding: 10px 14px; border-radius: 18px 18px 4px 18px;
  background: var(--ink); color: var(--surface-page); white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg__text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 23px; padding-top: 3px; }
.msg__actions { display: flex; gap: var(--space-2); margin-top: var(--space-2); opacity: 0; transition: opacity 120ms ease; }
.msg--assistant:hover .msg__actions, .msg--assistant:focus-within .msg__actions { opacity: 1; }
.msg__act {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px;
  border: 1px solid var(--border-hairline); border-radius: var(--radius-sm); background: var(--surface-card);
  font: inherit; font-size: 12px; font-weight: 600; color: var(--ink-muted); cursor: pointer;
}
.msg__act:hover { background: var(--surface-sunken); color: var(--ink); }
@media (hover: none) { .msg__actions { opacity: 1; } }

.typing { display: inline-flex; gap: 4px; align-items: center; height: 28px; padding: 0 4px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); animation: typing-wave 1.3s cubic-bezier(0.45, 0, 0.55, 1) infinite; }
.typing span:nth-child(2) { animation-delay: 0.18s; }
.typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes typing-wave {
  0%, 55%, 100% { transform: translateY(0) scale(0.85); opacity: 0.35; }
  25% { transform: translateY(-6px) scale(1.1); opacity: 1; }
}

/* ---------- Composer ---------- */
.chat__foot { position: relative; padding: var(--space-2) var(--space-8) var(--space-5); }
.chat__foot::before {
  content: ""; position: absolute; left: 50%; bottom: 10px; width: min(900px, 90%); height: 160px; transform: translateX(-50%);
  background: radial-gradient(50% 70% at 78% 85%, var(--primary-soft) 0%, transparent 70%);
  filter: blur(14px); opacity: 0.9; pointer-events: none;
  animation: glow-drift 7s ease-in-out infinite alternate;
}
@keyframes glow-drift { from { background-position: 0 0; opacity: 0.6; } to { background-position: -220px 0; opacity: 1; } }
@media (max-width: 1200px) { .chat__foot { padding: var(--space-2) var(--space-6) var(--space-5); } }
@media (max-width: 640px) { .chat__foot { padding: var(--space-2) var(--space-4) var(--space-4); } }
.composer {
  max-width: 860px; margin: 0 auto; display: grid; gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-card); border: 1px solid var(--border-hairline); border-radius: 22px;
  box-shadow: var(--shadow-raised);
  position: relative; z-index: 1;
  transition: border-color 160ms ease, box-shadow 220ms ease, transform 220ms ease;
}
.composer:focus-within { transform: translateY(-2px); }
.composer:focus-within { border-color: var(--primary); box-shadow: var(--shadow-raised), 0 0 0 3px var(--primary-soft); }
.composer__input { display: flex; align-items: flex-start; gap: var(--space-2); cursor: text; }
.composer__input > .sicon { color: var(--primary); flex-shrink: 0; margin-top: 8px; }
.composer textarea {
  flex: 1 1 auto; min-width: 0; min-height: 34px; max-height: 180px; padding: 6px 0;
  border: 0; background: none; resize: none; font: inherit; font-size: 15px; line-height: 22px; color: var(--ink);
}
.composer textarea:focus { outline: none; }
.composer textarea::placeholder { color: var(--ink-faint); }
.composer__row { display: flex; align-items: center; gap: var(--space-2); }
.composer__chips { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.composer__chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px;
  border: 1px solid var(--border-hairline); border-radius: var(--radius-pill); background: var(--surface-card);
  font: inherit; font-size: 12.5px; font-weight: 500; color: var(--ink-muted); cursor: pointer; white-space: nowrap;
  transition: transform 140ms ease, background-color 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.composer__chip .sicon { color: var(--primary); }
.composer__chip:hover { background: var(--surface-sunken); color: var(--ink); border-color: var(--border-control); transform: translateY(-1px); box-shadow: var(--shadow-card); }
.composer__chip:active { transform: translateY(0); }
.composer__icon {
  display: inline-grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0;
  border: 1px solid var(--border-hairline); border-radius: 50%; background: var(--surface-card); color: var(--ink-muted); cursor: pointer;
}
.composer__icon { transition: background-color 140ms ease, color 140ms ease, transform 140ms ease; }
.composer__icon:hover { background: var(--surface-sunken); color: var(--ink); transform: translateY(-1px); }
.composer__icon--live { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); animation: live-pulse 1.4s ease-in-out infinite; }
@keyframes live-pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--primary-soft); } 50% { box-shadow: 0 0 0 5px var(--primary-soft); } }
.composer__send {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0;
  border: 0; border-radius: 50%; background: var(--ink); color: var(--surface-page); cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}
.composer__send:not([disabled]) { animation: send-wake 220ms cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes send-wake { from { transform: scale(0.7); } 60% { transform: scale(1.1); } to { transform: scale(1); } }
.composer__send:hover { background: var(--primary); color: #fff; transform: translateY(-1px) scale(1.05); }
.composer__send:active { transform: scale(0.95); }
.composer__send[disabled] { background: var(--surface-sunken); color: var(--ink-faint); cursor: not-allowed; transform: none; }
@media (max-width: 640px) { .composer__chips { display: none; } .composer { border-radius: 18px; } }
.chat__note { max-width: 860px; margin: var(--space-2) auto 0; text-align: center; font-size: 12px; line-height: 17px; color: var(--ink-faint); }

/* ---------- Top row extras ---------- */
.chatlang__label { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.chatmode__menu--compact { min-width: 180px; }
.chat__present { border-radius: var(--radius-md); }
.chat__present[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary-ink); border-color: var(--primary); }
.hpill[disabled] .orb { opacity: 0.6; }
@media (max-width: 640px) { .chatlang__label { display: none; } .chat__new span { display: none; } }

/* ---------- Side panels: history, memory, share ---------- */
.chatpanel {
  position: absolute; top: 72px; right: calc(var(--space-6) + 52px); bottom: var(--space-4); z-index: 20; width: min(360px, calc(100% - 2 * var(--space-4) - 52px));
  display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4);
  background: var(--surface-card); border: 1px solid var(--border-hairline); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover); animation: pop-in 180ms cubic-bezier(0.2, 0.8, 0.2, 1) both; transform-origin: top right;
}
@media (max-width: 1100px) { .chatpanel { top: 124px; right: var(--space-6); width: min(360px, calc(100% - 2 * var(--space-4))); } }
@media (max-width: 640px) { .chatpanel { top: 110px; right: var(--space-4); left: var(--space-4); width: auto; } }
.chatpanel__head { display: flex; align-items: center; gap: var(--space-2); }
.chatpanel__head .h3 { flex: 1 1 auto; }
.chatpanel__hint { margin-top: -4px; }
.chatpanel__tabs { display: flex; gap: 2px; padding: 3px; border-radius: var(--radius-md); background: var(--surface-sunken); }
.chatpanel__tabs button {
  flex: 1 1 auto; padding: 6px 8px; border: 0; border-radius: var(--radius-sm); background: none;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--ink-muted); cursor: pointer; white-space: nowrap;
}
.chatpanel__tabs button[aria-selected="true"] { background: var(--surface-card); color: var(--ink); box-shadow: var(--shadow-card); }
.chatpanel__student { display: grid; gap: 4px; }
.chatpanel__student .control { margin-top: 0; }
.chatpanel__list { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: grid; gap: var(--space-2); align-content: start; scrollbar-width: thin; }
.chatpanel__group { display: grid; gap: 2px; }
.chatpanel__share { display: flex; gap: var(--space-2); }
.chatpanel__share .control { margin-top: 0; flex: 1 1 auto; }
.iconbtn--sm { width: 30px; height: 30px; border-radius: var(--radius-sm); }

.chatrow { display: flex; align-items: center; gap: 4px; border-radius: var(--radius-md); }
.chatrow:hover, .chatrow.is-current { background: var(--surface-sunken); }
.chatrow__open { flex: 1 1 auto; min-width: 0; display: grid; gap: 1px; padding: 8px 10px; border: 0; background: none; font: inherit; color: var(--ink); text-align: left; cursor: pointer; border-radius: var(--radius-md); }
.chatrow__title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatrow.is-current .chatrow__title { color: var(--primary-ink); }
.chatrow__meta { font-size: 12px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatrow__acts { display: none; gap: 2px; padding-right: 4px; flex-shrink: 0; }
.chatrow:hover .chatrow__acts, .chatrow:focus-within .chatrow__acts { display: flex; }
.chatrow__acts .iconbtn { border-color: transparent; background: none; color: var(--ink-muted); }
.chatrow__acts .iconbtn:hover { background: var(--surface-card); color: var(--ink); }
.chatrow__confirm { display: flex; gap: 4px; padding-right: 6px; flex-shrink: 0; }
.chatrow__rename { flex: 1 1 auto; display: flex; gap: 4px; padding: 4px; }
.chatrow__rename .control { margin-top: 0; padding: 6px 8px; }
@media (hover: none) { .chatrow__acts { display: flex; } }

.memnote { display: flex; align-items: center; gap: var(--space-2); padding: 8px 10px; border: 1px solid var(--border-hairline); border-radius: var(--radius-md); font-size: 13.5px; }
.memnote > .sicon { color: var(--primary); flex-shrink: 0; }
.memnote__text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.memnote .iconbtn { border-color: transparent; color: var(--ink-muted); }

/* ---------- Thread extras ---------- */
.chat__notice { display: inline-flex; align-items: center; gap: 6px; margin: 0 auto var(--space-4); padding: 4px 12px; border-radius: var(--radius-pill); background: var(--surface-sunken); color: var(--ink-muted); font-size: 12.5px; font-weight: 600; position: relative; left: 50%; transform: translateX(-50%); }
.chat__error { max-width: 860px; margin: 0 auto; }
.chat__checkin { margin-top: var(--space-3); font-size: 13.5px; padding: 8px 14px; }
.msg__wrap { min-width: 0; max-width: min(100%, 720px); display: grid; gap: var(--space-2); }
.msg--user .msg__wrap { max-width: min(80%, 620px); justify-items: end; }
.msg--user .msg__body { max-width: 100%; }
.msg--user .msg__actions { justify-content: flex-end; }
.msg--user:hover .msg__actions, .msg--user:focus-within .msg__actions, .msg__actions--open { opacity: 1; }
.msg__edit { width: min(100%, 620px); display: grid; gap: var(--space-2); }
.msg__edit .control { margin-top: 0; }
.msg__files { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.msg__note { font-size: 12.5px; color: var(--ink-faint); }
.msg--error .msg__text { opacity: 0.85; }
.msg__actions { margin-top: 0; flex-wrap: wrap; align-items: center; }
.msg__act[disabled] { opacity: 0.5; cursor: default; }
.msg__act--icon { padding: 3px 6px; }
.msg__act--icon.is-on { color: var(--primary-ink); border-color: var(--primary); background: var(--primary-soft); }
.msg__act--ok { color: var(--success); }
.msg__rate { display: inline-flex; gap: 4px; margin-left: auto; }
.msg__notebox { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.msg__notebox .control { margin-top: 0; flex: 1 1 220px; padding: 6px 10px; }
.msg__suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.msg__suggest .composer__chip { animation: rise-in 300ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.msg__suggest .composer__chip:nth-child(2) { animation-delay: 60ms; }
.msg__suggest .composer__chip:nth-child(3) { animation-delay: 120ms; }

.msg__tools { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.msg__tool { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-muted); }
.msg__tool .sicon { color: var(--success); }
.msg__tool--failed .sicon { color: var(--danger); }
.msg__tool--live { color: var(--ink); animation: tool-pulse 1.4s ease-in-out infinite; }
@keyframes tool-pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
.msg__spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--primary-soft); border-top-color: var(--primary); animation: spin 0.8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Markdown inside a reply */
.msg__md { display: grid; gap: 10px; }
.msg__md > :first-child { margin-top: 0; }
.msg__md h1, .msg__md h2, .msg__md h3, .msg__md h4 { line-height: 1.3; letter-spacing: -0.2px; margin-top: 6px; }
.msg__md h1 { font-size: 20px; } .msg__md h2 { font-size: 17px; } .msg__md h3 { font-size: 15.5px; } .msg__md h4 { font-size: 14.5px; }
.msg__md p { white-space: normal; }
.msg__md ul, .msg__md ol { padding-left: 22px; display: grid; gap: 4px; }
.msg__md li > ul, .msg__md li > ol { margin-top: 4px; }
.msg__md blockquote { margin: 0; padding: 4px 12px; border-left: 3px solid var(--primary); color: var(--ink-muted); }
.msg__md code { font-family: var(--font-mono); font-size: 0.9em; background: var(--surface-sunken); padding: 1px 5px; border-radius: 5px; }
.msg__md pre { position: relative; margin: 0; padding: 12px 14px; padding-right: 64px; border-radius: var(--radius-md); background: var(--surface-sunken); border: 1px solid var(--border-hairline); overflow-x: auto; }
.msg__md pre code { background: none; padding: 0; font-size: 13px; line-height: 20px; }
.msg__codecopy { position: absolute; top: 8px; right: 8px; padding: 2px 8px; border: 1px solid var(--border-hairline); border-radius: 6px; background: var(--surface-card); color: var(--ink-muted); font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer; }
.msg__codecopy:hover { color: var(--ink); }
.msg__md { overflow-x: auto; overflow-y: hidden; }
.msg__md table { border-collapse: collapse; width: max-content; max-width: 100%; font-size: 13.5px; }
.msg__md th, .msg__md td { border: 1px solid var(--border-hairline); padding: 6px 10px; text-align: left; vertical-align: top; }
.msg__md th { background: var(--surface-sunken); font-weight: 600; }
.msg__md a { color: var(--primary-ink); }
.msg__md hr { border: 0; border-top: 1px solid var(--border-hairline); }
.msg__md img { max-width: 100%; border-radius: var(--radius-md); }
.msg__md .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* Cards */
.msg__cards { display: grid; gap: var(--space-2); }
.ccard {
  display: flex; align-items: center; gap: var(--space-3); padding: 10px 12px;
  background: var(--surface-card); border: 1px solid var(--border-hairline); border-radius: var(--radius-md); box-shadow: var(--shadow-card);
  animation: rise-in 320ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.ccard--block { display: grid; gap: 6px; align-items: start; }
.ccard--note { background: var(--primary-soft); border-color: transparent; color: var(--primary-ink); font-size: 13.5px; font-weight: 500; }
.ccard--note .sicon { flex-shrink: 0; }
.ccard__icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--primary-soft); color: var(--primary-ink); flex-shrink: 0; }
.ccard__body { flex: 1 1 auto; min-width: 0; }
.ccard__title { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; line-height: 20px; overflow-wrap: anywhere; }
.ccard__title .sicon { color: var(--primary); flex-shrink: 0; }
.ccard__sub { font-size: 12.5px; line-height: 17px; color: var(--ink-muted); }
.ccard__actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.ccard__done { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--success); }
.ccard__steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 13.5px; }
.ccard__steps li { display: grid; gap: 1px; }
.ccard__steps strong { display: inline-flex; align-items: center; gap: 6px; }
.ccard__pill { font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: var(--radius-pill); background: var(--surface-sunken); color: var(--ink-muted); }
.ccard__line { color: var(--ink); }
.ccard__why { font-size: 12.5px; color: var(--ink-muted); }
.ccard__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ccard__list li { display: grid; gap: 0; }
.ccard__link { padding: 0; border: 0; background: none; font: inherit; font-size: 14px; font-weight: 600; color: var(--primary-ink); text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: transparent; }
.ccard__link:hover { text-decoration-color: currentColor; }
.ccard__link--plain { color: var(--ink); cursor: default; text-decoration: none; }
.ccard__meta { font-size: 12px; color: var(--ink-muted); }
.tablewrap--card { margin: 0; padding: 0; }
.dtable--compact { font-size: 13px; min-width: 0; }
.dtable--compact th, .dtable--compact td { padding: 6px 8px; }
.dtable--compact th:first-child, .dtable--compact td:first-child { padding-left: 0; }

/* ---------- Composer extras ---------- */
.composer__files { display: flex; flex-wrap: wrap; gap: 6px; }
.filechip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 8px; border-radius: var(--radius-pill); background: var(--surface-sunken); border: 1px solid var(--border-hairline); font-size: 12.5px; font-weight: 500; color: var(--ink); max-width: 100%; }
.filechip .sicon { color: var(--primary); flex-shrink: 0; }
.filechip__x { display: inline-grid; place-items: center; width: 18px; height: 18px; border: 0; border-radius: 50%; background: none; color: var(--ink-muted); cursor: pointer; padding: 0; }
.filechip__x:hover { background: var(--surface-card); color: var(--ink); }
.filechip--busy { color: var(--ink-muted); }
.composer__send--stop { background: var(--danger); color: #fff; animation: none; }
.composer__send--stop:hover { background: var(--danger); transform: none; }
.composer__icon[disabled] { opacity: 0.5; cursor: default; transform: none; }
.chat__banner { max-width: 860px; margin: 0 auto var(--space-2); padding: 8px 14px; border-radius: var(--radius-md); background: var(--info-band); color: var(--primary-ink); font-size: 13.5px; font-weight: 600; text-align: center; }

/* ---------- Classroom mode: large type for projecting ---------- */
.chat--present { background: var(--surface-page); }
.chat--present .chat__rail, .chat--present .chat__foot, .chat--present .chatpanel, .chat--present .chatwho, .chat--present .chat__new,
.chat--present .msg__actions, .chat--present .msg__suggest, .chat--present .msg__tools { display: none !important; }
.chat--present .chat__thread { max-width: 1100px; gap: var(--space-8); }
.chat--present .msg__text { font-size: 24px; line-height: 36px; }
.chat--present .msg__md h1 { font-size: 34px; } .chat--present .msg__md h2 { font-size: 29px; } .chat--present .msg__md h3 { font-size: 26px; }
.chat--present .msg__md pre code { font-size: 20px; line-height: 30px; }
.chat--present .msg--user .msg__body { font-size: 22px; line-height: 32px; padding: 14px 20px; border-radius: 24px 24px 6px 24px; }
.chat--present .msg--user .msg__wrap { max-width: min(80%, 820px); }
.chat--present .msg__wrap { max-width: min(100%, 980px); }
.chat--present .orb--sm { width: 40px; height: 40px; }
.chat--present .ccard { font-size: 18px; }
.chat--present .chat__hi { font-size: 30px; line-height: 38px; }
.chat--present .chat__ask { font-size: 46px; line-height: 54px; }
.chat--present .chat__body { padding-bottom: 100px; }
.chat__exit { position: absolute; left: 50%; bottom: var(--space-6); transform: translateX(-50%); z-index: 10; box-shadow: var(--shadow-raised); }

/* ---------- Print: the thread only ---------- */
@media print {
  html { zoom: 1; }
  html[data-route="chat"] .shell { position: static; }
  .sidebar, .apphead, .pet, .chat__top, .chat__rail, .chat__foot, .chatpanel, .chat__exit, .msg__actions, .msg__suggest, .msg__tools, .msg__codecopy, .ccard__actions { display: none !important; }
  .shell { display: block; }
  html[data-route="chat"] .shell__main > main { display: block; padding: 0; }
  .chat { display: block; background: #fff; color: #000; }
  .chat__body { overflow: visible; padding: 0; }
  .chat__thread { max-width: none; gap: 14px; }
  .msg { animation: none; break-inside: avoid; }
  .msg--user .msg__body { background: #eee; color: #000; }
  .msg__md pre { background: #f5f5f5; border-color: #ddd; }
  .ccard { box-shadow: none; }
}
