.synny-learning-chat {
  position: fixed;
  right: 24px;
  bottom: 92px;
  z-index: 2400;
  display: grid;
  grid-template-rows: auto auto minmax(180px, 1fr) auto auto;
  width: min(446px, calc(100vw - 32px));
  height: min(704px, calc(100vh - 120px));
  overflow: hidden;
  color: #172238;
  background: rgba(255, 255, 255, 0.985);
  border: 1px solid #ccd6e7;
  border-radius: 8px;
  box-shadow: 0 24px 64px rgba(25, 36, 59, 0.24);
  transform-origin: right bottom;
  animation: synny-chat-enter 180ms ease-out both;
}

.synny-learning-chat[hidden] { display: none !important; }

.synny-chat-header {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 40px 40px;
  gap: 10px;
  align-items: center;
  min-height: 82px;
  padding: 12px 14px;
  border-bottom: 1px solid #e3e8f1;
  background: linear-gradient(110deg, #f4f1ff 0%, #fff 58%, #ecfaf6 100%);
}

.synny-learning-chat.student .synny-chat-header { background: linear-gradient(110deg, #edfaf6 0%, #fff 58%, #f3f1ff 100%); }
.synny-chat-avatar { width: 58px; height: 58px; object-fit: contain; filter: drop-shadow(0 5px 9px rgba(92, 73, 211, 0.2)); }
.synny-chat-title { min-width: 0; }
.synny-chat-title span { display: block; margin-bottom: 2px; color: #6654e8; font: 700 10px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; text-transform: uppercase; }
.synny-learning-chat.student .synny-chat-title span { color: #07866f; }
.synny-chat-title strong { display: block; overflow: hidden; color: #172238; font-size: 18px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.synny-chat-title small { display: block; margin-top: 2px; overflow: hidden; color: #5e6a80; font-size: 12px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.synny-chat-icon-button { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; color: #445067; background: #fff; border: 1px solid #d6ddeb; border-radius: 7px; cursor: pointer; transition: color 140ms ease, border-color 140ms ease, transform 140ms ease; }
.synny-chat-icon-button:hover { color: #5441d7; border-color: #9e91f6; transform: translateY(-1px); }
.synny-chat-icon-button:focus-visible, .synny-chat-suggestion:focus-visible, .synny-chat-send:focus-visible, .synny-chat-input:focus-visible, .synny-nudge-action:focus-visible { outline: 3px solid rgba(103, 86, 232, 0.24); outline-offset: 2px; }
.synny-chat-context { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: center; padding: 10px 14px; color: #344158; background: #f7f8fc; border-bottom: 1px solid #e3e8f1; }
.synny-chat-context-icon { display: grid; place-items: center; width: 32px; height: 32px; color: #0f8d73; background: #e4f6f1; border-radius: 6px; }
.synny-chat-context strong, .synny-chat-context span { display: block; }
.synny-chat-context strong { overflow: hidden; font-size: 13px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.synny-chat-context span { margin-top: 2px; color: #69758a; font-size: 11px; line-height: 1.3; }
.synny-chat-messages { min-height: 0; padding: 14px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; background: #fff; scrollbar-width: thin; scrollbar-color: #c8c2f5 transparent; }
.synny-chat-message { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 12px; }
.synny-chat-message.user { justify-content: flex-end; }
.synny-chat-message-avatar { flex: 0 0 auto; width: 31px; height: 31px; object-fit: contain; }
.synny-chat-bubble { max-width: calc(100% - 40px); padding: 10px 12px; color: #263248; background: #f3f1ff; border: 1px solid #ddd8fb; border-radius: 7px; font-size: 14px; line-height: 1.52; }
.synny-learning-chat.student .synny-chat-message.assistant .synny-chat-bubble { background: #edf9f6; border-color: #ccebe4; }
.synny-chat-message.user .synny-chat-bubble { color: #fff; background: #6756e8; border-color: #6756e8; }
.synny-chat-bubble p, .synny-chat-bubble .synny-chat-line { margin: 0 0 7px; }
.synny-chat-bubble p:last-child, .synny-chat-bubble .synny-chat-line:last-child { margin-bottom: 0; }
.synny-chat-bubble .synny-chat-heading { display: block; margin: 9px 0 4px; color: #172238; font-size: 14px; }
.synny-chat-bubble .synny-chat-heading:first-child { margin-top: 0; }
.synny-chat-bubble .synny-chat-bullet { position: relative; margin: 0 0 5px; padding-left: 14px; }
.synny-chat-bubble .synny-chat-bullet::before { position: absolute; top: 0; left: 2px; color: #0f9278; content: "\2022"; }
.synny-chat-message.user .synny-chat-heading, .synny-chat-message.user .synny-chat-bullet::before { color: #fff; }
.synny-chat-typing { display: inline-flex; gap: 4px; align-items: center; min-height: 18px; }
.synny-chat-typing i { width: 6px; height: 6px; background: #7768e6; border-radius: 50%; animation: synny-chat-dot 900ms ease-in-out infinite; }
.synny-chat-typing i:nth-child(2) { animation-delay: 120ms; }
.synny-chat-typing i:nth-child(3) { animation-delay: 240ms; }
.synny-chat-suggestions { display: flex; gap: 7px; padding: 10px 14px; overflow-x: auto; border-top: 1px solid #e6eaf2; background: #fbfcfe; scrollbar-width: none; }
.synny-chat-suggestions::-webkit-scrollbar { display: none; }
.synny-chat-suggestion { flex: 0 0 auto; min-height: 38px; padding: 8px 11px; color: #3e4960; background: #fff; border: 1px solid #d7deeb; border-radius: 7px; font: 650 12px/1.25 inherit; cursor: pointer; white-space: nowrap; }
.synny-chat-suggestion:hover { color: #5140d0; background: #f5f2ff; border-color: #a99ef4; }
.synny-learning-chat.student .synny-chat-suggestion:hover { color: #087964; background: #eefaf7; border-color: #80cfbd; }
.synny-chat-compose { display: grid; grid-template-columns: minmax(0, 1fr) 46px; gap: 8px; align-items: end; padding: 10px 12px 12px; border-top: 1px solid #e1e6ef; background: #fff; }
.synny-chat-input { width: 100%; min-height: 46px; max-height: 116px; padding: 11px 12px; color: #172238; background: #fff; border: 1px solid #cfd7e5; border-radius: 7px; font: 14px/1.4 inherit; resize: none; }
.synny-chat-input::placeholder { color: #737f93; }
.synny-chat-send { display: grid; place-items: center; width: 46px; height: 46px; padding: 0; color: #fff; background: #6756e8; border: 1px solid #6756e8; border-radius: 7px; cursor: pointer; transition: transform 140ms ease, background 140ms ease; }
.synny-learning-chat.student .synny-chat-send { background: #0a8d74; border-color: #0a8d74; }
.synny-chat-send:hover:not(:disabled) { background: #5847d6; transform: translateY(-1px); }
.synny-learning-chat.student .synny-chat-send:hover:not(:disabled) { background: #087661; }
.synny-chat-send:disabled { cursor: wait; opacity: 0.5; }
.synny-chat-footer-note { grid-column: 1 / -1; margin-top: -2px; color: #768196; font-size: 10px; line-height: 1.35; }
.synny-chat-svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
body.synny-chat-open .synny-companion-panel { display: none !important; }

.synny-chat-nudge { position: fixed; right: 24px; bottom: 94px; z-index: 2350; width: min(310px, calc(100vw - 32px)); padding: 17px 18px 16px; color: #172238; background: rgba(255,255,255,.985); border: 1px solid #b9dfd6; border-left: 4px solid #0a9277; border-radius: 8px; box-shadow: 0 18px 42px rgba(25,36,59,.19); animation: synny-nudge-enter 260ms ease-out both; }
.synny-chat-nudge::after { position: absolute; right: 24px; bottom: -8px; width: 14px; height: 14px; background: #fff; border-right: 1px solid #b9dfd6; border-bottom: 1px solid #b9dfd6; content: ""; transform: rotate(45deg); }
.synny-chat-nudge > span { display: block; color: #087c67; font: 700 10px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; text-transform: uppercase; }
.synny-chat-nudge > strong { display: block; margin-top: 4px; font-size: 17px; }
.synny-chat-nudge p { margin: 6px 0 12px; color: #59667b; font-size: 13px; line-height: 1.45; }
.synny-nudge-close { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; color: #667287; background: transparent; border: 0; cursor: pointer; }
.synny-nudge-action { min-height: 38px; padding: 8px 14px; color: #fff; background: #0a8d74; border: 1px solid #0a8d74; border-radius: 7px; font-weight: 700; cursor: pointer; }
.synny-nudge-action:hover { background: #087661; }

@keyframes synny-chat-enter { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes synny-nudge-enter { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes synny-chat-dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

@media (max-width: 640px) {
  .synny-learning-chat { right: 8px; bottom: 72px; width: calc(100vw - 16px); height: min(690px, calc(100dvh - 84px)); }
  .synny-chat-header { grid-template-columns: 48px minmax(0, 1fr) 38px 38px; min-height: 72px; padding: 9px 10px; gap: 7px; }
  .synny-chat-avatar { width: 48px; height: 48px; }
  .synny-chat-title strong { font-size: 16px; }
  .synny-chat-title small { max-width: 190px; }
  .synny-chat-messages { padding: 11px; }
  .synny-chat-bubble { font-size: 13px; }
  .synny-chat-nudge { right: 8px; bottom: 76px; width: calc(100vw - 16px); }
}

@media (prefers-reduced-motion: reduce) {
  .synny-learning-chat, .synny-chat-nudge, .synny-chat-typing i { animation: none !important; }
  .synny-chat-icon-button, .synny-chat-send { transform: none !important; }
}
