.assistant-panel .assistant-header { padding: 16px; align-items: center; gap: 8px; }
.assistant-panel [hidden] { display: none !important; }
.assistant-panel .assistant-header, .assistant-panel .assistant-input, .assistant-panel .chat-index-note { flex-shrink: 0; }
.assistant-panel .assistant-messages { position: relative; gap: 12px; padding: 16px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.assistant-panel .chat-greeting { margin: auto; padding: 20px 4px; color: #5b7c6e; font-size: 16px; text-align: center; }
.assistant-panel .chat-actions { display: flex; gap: 4px; flex-shrink: 0; }
.assistant-panel .chat-actions button { display: grid; place-items: center; width: 34px; height: 34px; padding: 7px; border: 1px solid #e2ece7; border-radius: 9px; background: #fff; color: #3d705c; cursor: pointer; }
.assistant-panel .chat-actions button:hover, .assistant-panel .chat-actions button[aria-pressed="true"], .assistant-panel .chat-actions button[aria-expanded="true"] { background: #edf7f2; border-color: #9ec5b3; }
.assistant-panel .chat-actions svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.assistant-panel .chat-actions button:focus-visible, .assistant-panel .chat-history-item:focus-visible { outline: 2px solid #328563; outline-offset: 2px; }
.assistant-panel .chat-entry { min-width: 0; max-width: 100%; }
.assistant-panel .chat-entry.user { margin-left: 20px; }
.assistant-panel .chat-entry.user .chat-text { background: #3c8067; color: white; border-radius: 12px 12px 4px 12px; }
.assistant-panel .chat-text { margin: 0; padding: 12px; border-radius: 12px 12px 12px 4px; background: #edf7f2; color: #36516e; font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.assistant-panel .chat-entry.error .chat-text { background: #fff3ed; color: #8a4930; }
.assistant-panel .chat-sources { display: grid; gap: 6px; margin-top: 8px; }
.assistant-panel .chat-source { display: block; padding: 2px 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; color: #7b8388; font: inherit; font-size: 11px; line-height: 1.45; text-align: start; text-decoration: none; cursor: pointer; overflow-wrap: anywhere; }
.assistant-panel .chat-source:hover { color: #328563; background: transparent; }
.assistant-panel .chat-source small { display: block; color: inherit; font-size: 10px; }
mark.ai-source-highlight { background: #ccf1d7; color: inherit; padding: 0; border: 0; border-radius: 2px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.assistant-panel .chat-clear { border: 0; border-radius: 6px; padding: 5px; color: #527568; background: transparent; font: inherit; font-size: 12px; cursor: pointer; }
.assistant-panel .chat-clear:focus-visible, .assistant-panel .chat-source:focus-visible { outline: 2px solid #328563; outline-offset: 2px; }
.assistant-panel .assistant-status { line-height: 1.35; font-size: 12px; }
.assistant-panel .assistant-status:empty { display: none; }
.assistant-panel .assistant-input { padding: 12px; border-top: 0; }
.assistant-panel .chat-composer { width: 100%; min-width: 0; padding: 10px; border: 1px solid #d7e5dd; border-radius: 14px; background: #fbfdfc; box-sizing: border-box; }
.assistant-panel .chat-composer:focus-within { border-color: #78ab92; box-shadow: 0 0 0 2px #edf7f2; }
.assistant-panel .assistant-input textarea { display: block; width: 100%; min-width: 0; min-height: 84px; max-height: 220px; padding: 2px; box-sizing: border-box; resize: none; border: 0; outline: 0; background: transparent; color: #18233d; font: inherit; font-size: 16px; line-height: 1.5; overflow-y: auto; }
.assistant-panel .chat-composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 8px; }
.assistant-panel .chat-composer-footer small { font-size: 10px; color: #82958b; }
.assistant-panel .assistant-send { width: 40px; height: 40px; flex: 0 0 40px; cursor: pointer; }
.assistant-panel .assistant-send:disabled { opacity: .4; cursor: default; }
.assistant-panel .chat-index-note { margin: 0; padding: 0 16px 8px; font-size: 11px; line-height: 1.4; color: #7c6951; }
.assistant-panel .chat-index-note:empty { display: none; }
.assistant-panel .chat-retry { border: 0; background: transparent; color: #326a56; text-decoration: underline; font: inherit; cursor: pointer; }
.assistant-panel .chat-thinking { display: flex; align-items: center; align-self: flex-start; gap: 5px; min-height: 26px; padding: 10px 15px; border-radius: 12px; background: #edf7f2; flex-shrink: 0; }
.assistant-panel .chat-thinking span { width: 6px; height: 6px; border-radius: 50%; background: #3c8067; animation: chat-thinking 1.1s ease-in-out infinite; }
.assistant-panel .chat-thinking span:nth-child(2) { animation-delay: .15s; }
.assistant-panel .chat-thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes chat-thinking { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }
@media (prefers-reduced-motion: reduce) { .assistant-panel .chat-thinking span { animation: none; } }
.assistant-panel .chat-history-view { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; overscroll-behavior: contain; }
.assistant-panel .chat-history-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.assistant-panel .chat-history-heading h3 { font-size: 14px; margin: 0; color: #335747; }
.assistant-panel .chat-history-list { display: grid; gap: 8px; }
.assistant-panel .chat-history-list > p { color: #799083; font-size: 14px; }
.assistant-panel .chat-history-item { display: grid; gap: 5px; padding: 12px; border: 1px solid #e2ece7; border-radius: 10px; background: #fafcfb; text-align: start; font: inherit; color: #36516e; cursor: pointer; }
.assistant-panel .chat-history-item:hover { background: #edf7f2; }
.assistant-panel .chat-history-item span { font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.assistant-panel .chat-history-item small, .assistant-panel .chat-stale { display: block; margin-top: 4px; font-size: 11px; color: #819085; }
.assistant-panel .chat-history-more { width: 100%; padding: 10px; margin-top: 12px; border: 1px solid #e2ece7; border-radius: 8px; background: white; color: #326a56; font: inherit; cursor: pointer; }
body.chat-fullscreen-open { overflow: hidden !important; }
.chat-fullscreen { position: fixed; inset: 0; width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; background: #fff; }
.chat-fullscreen[open] { display: flex; }
.chat-fullscreen::backdrop { background: #fff; }
.chat-fullscreen .assistant-panel.chat-expanded { display: flex; width: 100%; height: 100%; min-height: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
.chat-fullscreen .assistant-header { padding: 14px max(20px, calc((100% - 880px) / 2)); }
.chat-fullscreen .assistant-messages, .chat-fullscreen .chat-history-view { flex: 1; width: 100%; max-width: 920px; max-height: none; min-height: 0; box-sizing: border-box; margin: 0 auto; padding: 24px 20px; overflow-y: auto; }
.chat-fullscreen .assistant-input { width: 100%; max-width: 920px; box-sizing: border-box; align-self: center; padding: 12px 20px max(16px, env(safe-area-inset-bottom)); }
.chat-fullscreen .chat-index-note { align-self: center; }
.chat-fullscreen .chat-entry.user { align-self: flex-end; max-width: 85%; }
@media (max-width: 760px) {
  .dashboard.study-open .assistant-panel { height: min(660px, calc(100dvh - 24px)); min-height: 420px; }
  .dashboard.study-open .assistant-panel .assistant-messages { min-height: 0; overflow-y: auto; }
  .chat-fullscreen .assistant-header { padding: 12px; }
  .chat-fullscreen .assistant-input { padding: 10px 12px max(12px, env(safe-area-inset-bottom)); }
  .chat-fullscreen .assistant-messages, .chat-fullscreen .chat-history-view { padding: 16px 12px; }
}
