/* Composer inspired by Uiverse.io / Cobp. */
.study-chat { --chat-bg:#1b1b1b; --chat-text:#f6f6f6; --chat-muted:#bababa; --chat-border:#464646; position:fixed;right:24px;bottom:24px;z-index:250;width:360px;max-width:calc(100vw - 32px);font-family:inherit;color:var(--chat-text); }
.study-chat [hidden] { display:none!important; }
.study-chat-panel { background:var(--chat-bg);border:1px solid var(--chat-border);border-radius:20px;box-shadow:0 15px 55px #0005;overflow:hidden; }
.study-chat-header {display:grid;grid-template-columns:minmax(0,1fr);align-items:center;padding:14px;border-bottom:1px solid var(--chat-border);gap:10px;}
.study-chat-heading {min-width:0;}
.study-chat-actions {display:flex;align-items:center;justify-content:flex-start;gap:6px;}
.study-chat .study-chat-actions .study-chat-icon {display:inline-flex;align-items:center;justify-content:center;flex:0 0 36px;width:36px;height:36px;min-width:36px;min-height:36px;margin:0;padding:0;line-height:1;border:1px solid var(--chat-border);border-radius:10px;background:transparent;color:var(--chat-text);box-sizing:border-box;}
.study-chat .study-chat-actions .study-chat-icon:hover {background:var(--surface3,#ffffff12);}
.study-chat-actions #studyChatClose {margin-inline-start:auto;}
.study-chat-header strong {font-size:14px;display:block;}
.study-chat-status {font-size:10px;color:var(--chat-muted);display:block;margin-top:4px;}
.study-chat button {font-family:inherit;cursor:pointer;color:inherit;}
.study-chat-icon {background:transparent;border:0;min-width:32px;min-height:32px;border-radius:8px;font-size:18px;}
.study-chat button:focus-visible,.study-chat textarea:focus-visible {outline:2px solid #aaaaaa;outline-offset:2px;}
.study-chat button:disabled {opacity:.45;cursor:wait;}
.study-chat-log {height:230px;max-height:30dvh;overflow-y:auto;padding:14px;display:flex;flex-direction:column;gap:10px;scrollbar-width:thin;}
.study-chat-message {font-size:12px;line-height:1.8;white-space:pre-wrap;overflow-wrap:anywhere;padding:10px 12px;background:#ffffff08;border-radius:12px;flex-shrink:0;}
.study-chat-message.user {background:#6969692e;border:1px solid #90909033;}
.study-chat-message.assistant {white-space:normal;}
.study-chat-message :is(p,h3,h4,h5,h6,ul,ol,blockquote) {margin:0 0 12px;}
.study-chat-message > :last-child {margin-bottom:0;}
.study-chat-message :is(h3,h4,h5,h6) {font-size:1.12em;line-height:1.7;font-weight:700;color:inherit;}
.study-chat-message :is(ul,ol) {padding-inline-start:24px;}
.study-chat-message li {margin-block:5px;}
.study-chat-message blockquote {border-inline-start:3px solid var(--chat-border);padding-inline-start:12px;}
.study-chat-message hr {border:0;border-top:1px solid var(--chat-border);margin-block:16px;}
.study-chat-message code {font-family:monospace;background:#8882;padding:2px 5px;border-radius:4px;}
.study-chat-message-image {display:block;max-width:100%;width:auto;max-height:300px;object-fit:contain;border-radius:10px;margin-bottom:12px;}
.study-chat-attachment-preview {width:64px;height:64px;object-fit:contain;border:1px solid var(--chat-border);border-radius:8px;flex-shrink:0;}
.study-chat-image-expired {font-size:12px;color:var(--chat-muted);border:1px dashed var(--chat-border);padding:12px;border-radius:8px;}
.study-chat-panel {position:relative;box-sizing:border-box;}
.study-chat .study-session-tools {position:absolute;inset:0;inset-inline-end:auto;width:min(290px,100%);z-index:5;box-sizing:border-box;display:flex;flex-direction:column;flex-wrap:nowrap;align-items:stretch;gap:12px;padding:20px 14px 12px;margin:0;background:var(--chat-bg);color:var(--chat-text);border:0;border-inline-end:1px solid var(--chat-border);border-radius:0;box-shadow:0 0 24px #0002;text-align:start;}
.study-chat .study-history-heading {display:flex;align-items:center;justify-content:space-between;gap:12px;font-size:17px;padding-inline:6px;min-height:32px;flex-shrink:0;}
.study-chat .study-session-tools button {margin:0;color:inherit;}
.study-chat #studyHistoryClose {display:grid;place-items:center;width:32px;height:32px;padding:0;border:0;border-radius:8px;background:transparent;color:var(--chat-muted);}
.study-chat #studyHistoryClose:hover {background:var(--surface3,#8882);color:var(--chat-text);}
.study-chat #studyHistoryNew {display:flex;align-items:center;justify-content:flex-start;gap:10px;min-height:44px;padding:10px 12px;border:1px solid var(--chat-border);border-radius:10px;font-size:13px;font-weight:500;background:var(--surface2,#8881);flex-shrink:0;}
.study-chat .study-history-search {display:flex;align-items:center;gap:9px;box-sizing:border-box;min-height:42px;padding-inline:12px;border:1px solid transparent;border-radius:10px;background:var(--surface2,#8881);color:var(--chat-muted);flex-shrink:0;}
.study-chat .study-history-search:focus-within {border-color:var(--chat-muted);}
.study-chat .study-history-search svg {width:17px;height:17px;flex-shrink:0;}
.study-chat #studyHistorySearch {width:100%;min-width:0;box-sizing:border-box;font:inherit;font-size:12px;padding:10px 0;border:0!important;outline:none!important;border-radius:0;box-shadow:none!important;background:transparent;color:var(--chat-text);}
.study-chat #studyHistorySearch::placeholder {color:var(--chat-muted);opacity:.8;}
.study-chat #studyHistoryList {flex:1;overflow-y:auto;min-height:0;scrollbar-width:thin;padding:0 2px 8px;}
.study-chat #studyHistoryList h4 {font-size:11px;font-weight:500;color:var(--chat-muted);margin:18px 10px 7px;line-height:1.6;}
.study-chat #studyHistoryList > p {font-size:12px;color:var(--chat-muted);padding:12px 10px;}
.study-chat-mode-row {display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-block:10px;}
.study-chat-mode {display:flex;flex-shrink:0;gap:3px;padding:3px;border:1px solid var(--chat-border);border-radius:10px;}
.study-chat-mode button {border:0;border-radius:7px;background:transparent;padding:6px 14px;font-size:12px;min-height:32px;}
.study-chat-mode button[aria-pressed="true"] {background:var(--chat-text);color:var(--chat-bg);}
.study-chat #chatStudyCourse {flex:1;min-width:0;max-width:100%;font:inherit;font-size:12px;background:var(--chat-bg);color:var(--chat-text);border:1px solid var(--chat-border);border-radius:9px;padding:8px;}
.study-chat #chatGroundingNote {margin:0 0 8px;font-size:11px;}
.study-chat .study-history-row {display:grid;grid-template-columns:minmax(0,1fr) 32px;align-items:center;gap:2px;border-radius:9px;margin-block:3px;padding-inline-end:5px;min-height:44px;position:relative;}
.study-chat .study-history-row:hover,.study-chat .study-history-row.active {background:var(--surface3,#8882);}
.study-chat .study-history-row .study-history-open {display:block;min-width:0;width:100%;min-height:44px;text-align:start;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;font-size:13px;font-weight:400;background:transparent;border:0;border-radius:8px;padding:10px 12px;line-height:1.6;}
.study-chat .study-history-actions {position:relative;}
.study-chat .study-history-actions > summary {display:grid;place-items:center;list-style:none;width:32px;height:32px;box-sizing:border-box;font:20px/1 sans-serif;border:0;border-radius:7px;color:var(--chat-muted);cursor:pointer;}
.study-chat .study-history-actions > summary::-webkit-details-marker {display:none;}
.study-chat .study-history-actions > summary:hover,.study-chat .study-history-actions[open] > summary {color:var(--chat-text);background:var(--surface2,#8882);}
.study-chat .study-history-actions > summary:focus-visible {outline:1px solid var(--chat-muted);outline-offset:1px;}
.study-chat .study-history-menu {position:absolute;inset-inline-end:0;top:38px;z-index:10;min-width:158px;box-sizing:border-box;padding:5px;border:1px solid var(--chat-border);border-radius:10px;background:var(--chat-bg);box-shadow:0 8px 20px #0004;}
.study-chat .study-history-actions.opens-up .study-history-menu {top:auto;bottom:38px;}
.study-chat .study-history-menu button {display:block;width:100%;text-align:start;background:transparent;border:0;border-radius:6px;font:inherit;font-size:12px;min-height:36px;padding:8px 10px;white-space:nowrap;}
.study-chat .study-history-menu button:hover {background:var(--surface3,#8882);}
.study-chat .study-history-menu .study-history-delete {color:var(--danger,#e99);}
@media(min-width:900px){.study-chat.is-wide.has-history .study-chat-panel {padding-inline-start:290px;}}
.study-chat-message.error {color:#ffb8bb;border:1px solid #b8596060;}
.study-chat-message pre {overflow:auto;text-align:left;direction:ltr;font-size:11px;white-space:pre;background:#0002;padding:8px;border-radius:6px;}
.container_chat_bot {display:flex;flex-direction:column;padding:12px;padding-top:0;}
.container-chat-options {position:relative;display:flex;background:linear-gradient(to bottom right,#7e7e7e,#363636 35%);border-radius:16px;padding:1.5px;overflow:hidden;}
.container-chat-options::after {position:absolute;content:"";top:-10px;left:-10px;background:radial-gradient(ellipse,#ffffff,#ffffff4d,transparent 70%);width:30px;height:30px;filter:blur(1px);pointer-events:none;}
.study-chat .chat {background:#0008;border-radius:15px;width:100%;overflow:hidden;}
.study-chat textarea {box-sizing:border-box;display:block;background:transparent;border:0;width:100%;height:70px;color:var(--chat-text);font-family:inherit;font-size:12px;line-height:1.6;padding:12px;resize:none;}
.study-chat textarea::placeholder {color:var(--chat-muted);}
.study-chat .options {display:flex;justify-content:space-between;align-items:center;padding:7px 10px;}
.study-chat .btns-add {display:flex;align-items:center;gap:5px;color:var(--chat-muted);}
.study-chat .btn-submit {display:flex;padding:8px;background:linear-gradient(to top,#292929,#555,#292929);border:1px solid #666;border-radius:10px;box-shadow:inset 0 6px 2px -4px #ffffff80;}
.study-chat .btn-submit:hover {filter:brightness(1.25);}
.study-chat svg {width:19px;height:19px;display:block;}
.study-chat .tags {padding-top:10px;display:flex;gap:5px;flex-wrap:wrap;}
.study-chat .tags button {font-size:10px;padding:5px 9px;background:var(--chat-bg);border:1px solid var(--chat-border);border-radius:10px;}
.study-chat-note {font-size:9px;line-height:1.6;color:var(--chat-muted);margin:8px 0 0;}
.study-chat-file {display:flex;align-items:center;justify-content:space-between;gap:4px;font-size:10px;padding:5px 10px;overflow-wrap:anywhere;}
.study-chat.is-compact {width:260px;}
.study-chat.is-compact .study-chat-panel {background:transparent;border:0;border-radius:0;box-shadow:none;overflow:visible;}
.study-chat.is-compact .container_chat_bot {padding:0;}
.study-chat.is-compact .container-chat-options {background:linear-gradient(135deg,#888 0%,#363636 25%,#363636 100%);box-shadow:0 1px 1px #ffffff16;}
.study-chat.is-compact .chat {background:#1b1b1b;}
.study-chat.is-compact textarea {height:56px;font-size:11px;padding:11px;}
.study-chat.is-compact .options {direction:ltr;padding:5px 10px 10px;}
.study-chat.is-compact .btns-add {gap:2px;color:#737373;}
.study-chat.is-compact .study-chat-icon {min-width:25px;min-height:28px;padding:3px;transition:color .2s,transform .2s;}
.study-chat.is-compact .study-chat-icon:hover {color:var(--chat-text);transform:translateY(-2px);}
.study-chat.is-compact #studyChatExpand {display:flex;align-items:center;justify-content:center;color:var(--chat-text);border:1px solid var(--chat-border);background:#ffffff08;margin-left:4px;}
.study-chat.is-compact .btn-submit {color:#b8b8b8;padding:7px;border-color:#555;}
.study-chat.is-compact .tags {gap:5px;padding-top:14px;}
.study-chat.is-compact .tags button {background:#1b1b1b;border-color:#363636;padding:4px 8px;font-size:10px;}
.study-chat.is-compact .study-chat-file {background:var(--chat-bg);border:1px solid var(--chat-border);border-radius:10px;margin-bottom:6px;}
html[data-theme="light"] .study-chat.is-compact .chat {background:#f7f7f7;}
html[data-theme="light"] .study-chat.is-compact .tags button {background:#fff;border-color:#d7d7d7;}
@media(prefers-reduced-motion:reduce) {.study-chat.is-compact .study-chat-icon {transition:none;}}
html[data-theme="light"] .study-chat {--chat-bg:#fff;--chat-text:#232323;--chat-muted:#636363;--chat-border:#d7d7d7;}
html[data-theme="light"] .study-chat .chat {background:#f7f7f7;}
html[data-theme="light"] .study-chat .container-chat-options {background:linear-gradient(135deg,#a8a8a8,#dedede);}
html[data-theme="light"] .study-chat .btn-submit {background:linear-gradient(#f1f1f1,#dedede);border-color:#b7b7b7;}
html[data-theme="light"] .study-chat-message.error {color:#a02134;}
@media(max-width:480px) {.study-chat {right:12px;bottom:calc(12px + env(safe-area-inset-bottom));width:calc(100vw - 24px);max-width:none;}.study-chat-log {height:190px;max-height:28dvh;}}
/* Reading mode keeps the same conversation and composer in a spacious panel. */
.study-session-tools {display:flex;flex-wrap:wrap;gap:6px;align-items:center;padding:8px 0;font-size:11px;}
.study-session-tools select {max-width:100%;width:100%;background:var(--chat-bg);color:var(--chat-text);border:1px solid var(--chat-border);border-radius:8px;padding:6px;font:inherit;}
.study-session-tools button {background:var(--chat-bg);border:1px solid var(--chat-border);border-radius:8px;padding:6px 9px;font-size:11px;margin-inline-end:5px;}
.study-chat .study-reference {background:transparent;border:0;border-bottom:1px dotted currentColor;color:var(--text);font-size:inherit;padding:0 3px;}
.study-chat.is-compact .study-session-tools {margin-bottom:8px;padding:8px;background:var(--chat-bg);border:1px solid var(--chat-border);border-radius:12px;}
.study-chat.is-wide {inset:24px;width:auto;max-width:1100px;margin-inline:auto;}
body.has-account-dock .study-chat.is-wide {bottom:24px;z-index:300;}
.study-chat.is-wide .study-chat-panel {height:100%;display:flex;flex-direction:column;}
.study-chat.is-wide .study-chat-header {flex-shrink:0;}
@media(min-width:601px) {.study-chat.is-wide .study-chat-header {grid-template-columns:minmax(0,1fr) auto;}}
.study-chat.is-wide .study-chat-header strong {font-size:17px;}
.study-chat.is-wide .study-chat-log {height:auto;max-height:none;min-height:0;flex:1;padding:22px 28px;gap:16px;overscroll-behavior:contain;}
.study-chat.is-wide .study-chat-message {font-size:16px;line-height:1.95;padding:16px 20px;max-width:860px;width:100%;box-sizing:border-box;margin-inline:auto;}
.study-chat.is-wide .study-chat-message pre {font-size:14px;}
.study-chat.is-wide .container_chat_bot {flex-shrink:0;box-sizing:border-box;width:100%;max-width:860px;margin-inline:auto;padding:12px 20px 16px;max-height:45dvh;overflow-y:auto;}
.study-chat.is-wide textarea {font-size:15px;}
.study-chat.is-wide .study-chat-note,.study-chat.is-wide .study-chat-file {font-size:11px;}
@media(max-width:600px) {
  .study-chat.is-wide {inset:8px 8px calc(8px + env(safe-area-inset-bottom));max-width:none;}
  body.has-account-dock .study-chat.is-wide {bottom:calc(8px + env(safe-area-inset-bottom));}
  .study-chat.is-wide .study-chat-panel {border-radius:14px;}
  .study-chat.is-wide .study-chat-log {padding:12px;gap:12px;}
  .study-chat.is-wide .study-chat-message {font-size:15px;padding:12px;}
  .study-chat.is-wide .container_chat_bot {padding:8px 12px 12px;}
}
@media(max-height:600px) {
  .study-chat.is-wide {top:8px;bottom:8px;}
  body.has-account-dock .study-chat.is-wide {bottom:8px;}
  .study-chat.is-wide textarea {height:48px;}
  .study-chat.is-wide .tags,.study-chat.is-wide .study-chat-note {display:none;}
}
/* Closed chat is a launcher, never a floating text composer over the page. */
.study-chat.is-compact {width:auto;}
.study-chat.is-compact .study-chat-panel {display:none;}
.study-chat .study-chat-launcher {display:flex;align-items:center;justify-content:center;gap:9px;min-height:48px;padding:11px 18px;font-size:14px;font-weight:600;border:1px solid var(--chat-border);border-radius:16px;background:var(--chat-bg);color:var(--chat-text);box-shadow:0 5px 20px #0002;}
.study-chat.is-compact #studyChatExpand {margin:0;padding:11px 18px;background:var(--chat-bg);border:1px solid var(--chat-border);}
@media(max-width:900px){
  body.has-account-dock .study-chat.is-compact {display:none;}
  body.chat-mobile-open {position:fixed;top:var(--chat-page-offset,0);left:0;right:0;width:100%;overflow:hidden;overscroll-behavior:none;}
  body.chat-mobile-open .account-dock {visibility:hidden;pointer-events:none;}
  body .study-chat:not(.is-compact),body.has-account-dock .study-chat:not(.is-compact) {position:fixed;inset:auto;top:var(--chat-viewport-top,0px);left:0;right:0;bottom:auto;width:100%;max-width:none;height:var(--chat-viewport-height,100dvh);margin:0;z-index:400;}
  .study-chat:not(.is-compact) .study-chat-panel {display:flex;flex-direction:column;height:100%;border:0;border-radius:0;box-shadow:none;background:var(--chat-bg);}
  .study-chat:not(.is-compact) .study-chat-header {padding-top:max(12px,env(safe-area-inset-top));flex-shrink:0;}
  .study-chat:not(.is-compact) .study-chat-log {flex:1;min-height:0;height:auto;max-height:none;padding:12px;overscroll-behavior:contain;}
  .study-chat:not(.is-compact) .container_chat_bot {max-height:55%;flex-shrink:0;padding:8px 12px max(12px,env(safe-area-inset-bottom));overflow-y:auto;}
  body .study-chat :is(textarea,input,select) {font-size:16px!important;}
  body .study-chat textarea {height:64px;}
  .study-chat .container_chat_bot > .tags,.study-chat .container_chat_bot > .study-chat-note:last-child {display:none;}
  .study-chat #studyChatResize {display:none;}
  .study-chat .study-chat-message {font-size:16px;}
}
