.study-chat {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: 540px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}
.study-chat [hidden] { display: none !important; }
.study-chat button, .study-chat input, .study-chat select, .study-chat textarea { font: inherit; }
.study-chat button, .study-chat input[type=submit], .study-chat summary { cursor: pointer; }
.study-chat :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.study-chat__history { padding: 24px 16px; border-right: 1px solid var(--line); background: var(--paper-soft, #f5f3f5); display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.study-chat__history-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.study-chat__wordmark { font-family: var(--font-display); font-size: 22px; letter-spacing: -.5px; }
.study-chat__new { font-size: 12px; font-weight: 600; color: var(--accent) !important; white-space: nowrap; }
.study-chat__search { display: flex; gap: 5px; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-top: 18px; }
.study-chat__search input[type=search] { width: 100%; min-width: 0; font-size: 12px; background: transparent; border: 0; }
.study-chat__text-button { border: 0; background: transparent; color: var(--accent); font-size: 12px !important; padding: 4px; }
.study-chat__history-list summary { color: var(--ink-soft); font-size: 12px; font-weight: 500; }
.study-chat__history-list summary span { float: right; }
.study-chat__history-list nav { display: grid; gap: 5px; margin-top: 14px; max-height: 510px; overflow: auto; }
.study-chat__history-item { display: grid; gap: 5px; padding: 10px; border-radius: 9px; }
.study-chat__history-item:hover, .study-chat__history-item.is-current { background: var(--accent-soft); }
.study-chat__history-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 500; }
.study-chat__empty { color: var(--ink-soft); font-size: 12px; line-height: 1.7; }
.study-chat__allowance { margin-top: auto; border-top: 1px solid var(--line); padding-top: 18px; }
.study-chat__allowance p, .study-chat__allowance summary { font-size: 12px; color: var(--ink-soft); line-height: 1.7; margin-top: 8px; }
.study-chat__main { min-width: 0; display: flex; flex-direction: column; background: var(--cp-card, #fcfbfd); }
.study-chat__welcome { padding: 36px 32px 12px; }
.study-chat__welcome h1 { font-family: var(--font-display); font-size: 32px; line-height: 1.2; font-weight: 400; letter-spacing: -.6px; margin: 0 0 12px; }
.study-chat__welcome > p { color: var(--ink); font-size: 15px; max-width: 54ch; line-height: 1.65; }
.study-chat__compose-area { padding: 20px 32px 24px; }
.study-chat__selectors { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 20px; }
.study-chat__selectors > div { display: flex; align-items: center; gap: 8px; }
.study-chat__selectors label { font-size: 13px; color: var(--ink); }
.study-chat__selectors select { border: 1px solid var(--line); border-radius: 7px; padding: 7px 28px 7px 10px; font-size: 13px; color: var(--ink); background-color: var(--paper); max-width: 210px; }
.study-chat__starters { display: grid; margin-top: 16px; }
.study-chat__starters button { text-align: left; padding: 12px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--ink); font-size: 13px; line-height: 1.6; }
.study-chat__starters button:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.study-chat__composer { border: 1px solid var(--rule); background: var(--paper); border-radius: 10px; padding: 14px; }
.study-chat__composer:focus-within { border-color: var(--accent); }
.study-chat__composer textarea { display: block; border: 0; background: transparent; width: 100%; resize: none; font-size: 14px; line-height: 1.7; min-height: 75px; outline: none; box-shadow: none; color: var(--ink); }
.study-chat__composer textarea::placeholder { color: var(--ink-faint); }
.study-chat__composer-tools { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.study-chat__attachment { font-size: 12px; position: relative; overflow: hidden; color: var(--ink); white-space: nowrap; cursor: pointer; }
.study-chat__attachment input { position: absolute; width: 100%; inset: 0; opacity: 0; cursor: pointer; }
.study-chat__composer-tools button { border: 0; background: transparent; color: var(--ink); font-size: 12px; padding: 2px; }
.study-chat__file-label { min-width: 0; max-width: 160px; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-mute); }
.study-chat .study-chat__send { margin-left: auto; flex-shrink: 0; background: var(--accent); color: white; border: 0; border-radius: 9px; padding: 9px 17px; font-size: 12px; font-weight: 500; }
.study-chat .study-chat__send:disabled { opacity: .5; cursor: wait; }
.study-chat__notice { font-size: 12px; line-height: 1.6; color: var(--ink-soft); margin-top: 12px; }
.study-chat__status { font-size: 12px; color: var(--accent); margin-top: 8px; }
.study-chat__status:empty { margin: 0; }
.study-chat__header { padding: 22px 28px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 15px; align-items: center; }
.study-chat__header h1 { font-size: 16px; font-weight: 500; margin: 0; overflow-wrap: anywhere; }
.study-chat__actions { position: relative; flex-shrink: 0; }
.study-chat__actions summary { list-style: none; padding: 10px; font-size: 12px; color: var(--ink-mute); }
.study-chat__action-menu { position: absolute; right: 0; top: 100%; z-index: 5; width: 230px; padding: 16px; background: var(--paper); border: 1px solid var(--rule); border-radius: 12px; box-shadow: 0 8px 25px #0001; display: grid; gap: 12px; }
.study-chat__action-menu button, .study-chat__action-menu a, .study-chat__action-menu label, .study-chat__action-menu input { display: block; font-size: 12px; }
.study-chat__action-menu input[type=text] { width: 100%; padding: 6px; border: 1px solid var(--rule); margin: 6px 0; border-radius: 5px; }
.study-chat__action-menu button, .study-chat__action-menu input[type=submit] { background: transparent; border: 0; color: var(--accent); padding: 0; }
.study-chat__danger { color: var(--bad) !important; }
.study-chat__transcript { max-height: 60vh; overflow-y: auto; padding: 15px 28px; scroll-behavior: smooth; }
.study-chat__message { padding: 20px 4px; border-bottom: 1px solid var(--line-soft); overflow-wrap: anywhere; }
.study-chat__message-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.study-chat__message-heading strong { font-size: 12px; font-weight: 600; color: var(--accent); }
.study-chat__message-heading button { border: 0; background: transparent; margin-left: auto; color: var(--ink-soft); font-size: 12px; }
.study-chat__prose { font-size: 14px; line-height: 1.8; color: var(--ink-soft); overflow-x: auto; }
.study-chat__prose p { margin: 0 0 12px; }
.study-chat__prose ul, .study-chat__prose ol { padding-left: 22px; margin-bottom: 14px; }
.study-chat__prose ul { list-style: disc; }
.study-chat__prose ol { list-style: decimal; }
.study-chat__prose h2, .study-chat__prose h3, .study-chat__prose h4 { font-size: 16px; font-weight: 600; margin: 18px 0 10px; }
.study-chat__prose table { border-collapse: collapse; width: 100%; font-size: 12px; margin: 12px 0; }
.study-chat__prose th, .study-chat__prose td { border: 1px solid var(--rule); padding: 8px; text-align: left; }
.study-chat__prose a { color: var(--accent); text-decoration: underline; }
.study-chat__prose pre { white-space: pre-wrap; background: var(--paper); padding: 12px; border-radius: 8px; }
.study-chat__prose blockquote { border-left: 2px solid var(--accent); padding-left: 14px; }
.study-chat__user-text { white-space: pre-wrap; }
.study-chat__message--user .study-chat__prose { background: var(--accent-soft); padding: 12px 16px; border-radius: 12px; }
.study-chat__message--user .study-chat__prose p:last-child { margin-bottom: 0; }
.study-chat__images { display: flex; gap: 8px; margin-top: 10px; }
.study-chat__images img { max-width: min(45%, 230px); max-height: 220px; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; }
.study-chat__writing { color: var(--accent); font-size: 12px; }
.study-chat__failure { color: var(--bad); font-size: 12px; padding: 8px 0; }
.study-chat__share { margin: 10px 32px; font-size: 12px; color: var(--ink-soft); }
.study-chat__share p { margin: 10px 0; line-height: 1.7; }
.study-chat__share input { display: block; width: 100%; padding: 6px; border: 1px solid var(--line); margin: 5px 0; }
.study-chat__share form { display: inline-block; margin: 8px 10px 0 0; }
.study-chat__share button { background: transparent; color: var(--accent); border: 0; padding: 0; }
.study-chat__upgrade { margin: 10px 32px 32px; }
.study-chat__upgrade p { font-size: 14px; line-height: 1.7; color: var(--ink); margin: 0 0 20px; }
.study-chat__sign-in { display: block; font-size: 12px; margin-top: 15px; }
.study-chat--intro { display: block; min-height: 0; }
.study-chat--intro .study-chat__welcome { max-width: 660px; }
.study-chat--shared { display: block; padding: 24px; min-height: 0; }
.study-chat--shared .study-chat__welcome { padding: 15px 0 25px; }
.study-chat-promo { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: center; padding: 48px 0; }
.study-chat-promo h2 { font-family: var(--font-display); font-size: 36px; font-weight: 400; line-height: 1.2; letter-spacing: -.6px; margin: 0 0 16px; }
.study-chat-promo p { font-size: 15px; color: var(--ink); line-height: 1.7; }
.study-chat-promo .cp-btn { margin-top: 22px; }
.study-chat-promo__examples { list-style: none; margin: 0; padding: 0; color: var(--ink); font-size: 14px; line-height: 1.7; }
.study-chat-promo__examples li { padding: 16px 0; border-bottom: 1px solid var(--line); }
.study-chat-promo__examples li:first-child { border-top: 1px solid var(--line); }
.study-chat-feedback { display: flex; align-items: center; justify-content: space-between; gap: 24px; border: 1px solid var(--line); border-radius: 12px; padding: 22px 24px; background: var(--paper); }
.study-chat-feedback h3, .study-chat-dashboard h2 { font-family: var(--font-display); font-size: 24px; font-weight: 400; color: var(--ink); margin: 0 0 6px; }
.study-chat-feedback p, .study-chat-dashboard p { font-size: 14px; line-height: 1.6; color: var(--ink); margin: 0; }
.study-chat-feedback .cp-btn, .study-chat-dashboard .cp-btn { flex-shrink: 0; white-space: nowrap; }
.study-chat-dashboard { min-width: 0; }
.study-chat-dashboard__heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.study-chat-dashboard__heading h2 { margin: 0; }
.study-chat-dashboard__history { font-size: 13px; color: var(--accent); white-space: nowrap; }
.study-chat-dashboard__composer { display: flex; align-items: flex-end; gap: 16px; padding: 16px; border: 1px solid var(--rule); border-radius: 12px; background: var(--cp-card, #fcfbfd); }
.study-chat-dashboard__composer:focus-within { border-color: var(--accent); }
.study-chat-dashboard__composer textarea { display: block; flex: 1; min-width: 0; width: 100%; min-height: 52px; resize: none; border: 0; padding: 0; background: transparent; font: inherit; font-size: 15px; line-height: 1.7; color: var(--ink); box-shadow: none; outline: none; }
.study-chat-dashboard__composer textarea::placeholder { color: var(--ink-soft); }
.study-chat-dashboard__composer .cp-btn { margin: 0; cursor: pointer; }
.study-chat-dashboard__composer .cp-btn:disabled { opacity: .5; cursor: wait; }
.study-chat-dashboard__upgrade { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
@media (max-width: 760px) {
  .study-chat { grid-template-columns: 1fr; min-height: 0; border-radius: 16px; }
  .study-chat__history { border-right: 0; border-bottom: 1px solid var(--line); padding: 16px; gap: 12px; }
  .study-chat__history-list nav { max-height: 145px; }
  .study-chat__allowance { padding-top: 10px; }
  .study-chat__welcome { padding: 26px 16px 8px; }
  .study-chat__compose-area { padding: 16px; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .study-chat__selectors { gap: 10px; }
  .study-chat__selectors > div { display: flex; gap: 8px; flex-basis: 100%; }
  .study-chat__selectors label { min-width: 62px; }
  .study-chat__selectors select { max-width: 100%; min-width: 0; flex: 1; font-size: 16px; }
  .study-chat__starters button { padding: 12px 0; }
  .study-chat__composer textarea { font-size: 16px; }
  .study-chat__header { padding: 17px; }
  .study-chat__transcript { padding: 8px 16px; max-height: 55dvh; }
  .study-chat__upgrade { margin: 10px 16px 24px; }
  .study-chat__share { margin: 10px 18px; }
  .study-chat-promo { grid-template-columns: 1fr; gap: 28px; padding: 40px 0; }
  .study-chat-feedback { flex-direction: column; align-items: flex-start; gap: 16px; padding: 20px; }
  .study-chat-dashboard__composer { gap: 12px; padding: 14px; }
  .study-chat-dashboard__composer textarea { font-size: 16px; }
  .study-chat-dashboard__composer .cp-btn { padding: 10px 16px; }
  .study-chat-dashboard__upgrade { align-items: flex-start; flex-direction: column; gap: 12px; }
}
@media (prefers-reduced-motion: reduce) { .study-chat__transcript { scroll-behavior: auto; } }
