/* The chat screen, built on the colours and type in site.css. */
body.chat-page { margin: 0; overflow: hidden; font-family: var(--sans); }
.chat .katex { font-size: 1.08em; }
.chat { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--wash); color: var(--ink); font-family: var(--sans); }
.chat svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.chat__top { display: flex; flex: none; align-items: center; gap: 4px; padding: 8px 10px; border-bottom: 4px solid var(--teal); background: var(--indigo); color: #fff; }
.chat__title { display: flex; flex: 1; flex-direction: column; min-width: 0; padding: 0 6px; line-height: 1.3; }
.chat__title strong { overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.chat .meter { display: flex; flex-direction: column; gap: 3px; margin-top: 3px; }
.chat .meter__bar { display: block; width: min(260px, 100%); height: 5px; overflow: hidden; border-radius: 3px; background: rgb(255 255 255 / .25); }
.chat .meter__bar span { display: block; height: 100%; background: #5fd3c6; transition: width .4s ease; }
.chat .meter--low .meter__bar span { background: var(--pop); }
.chat .meter__text { overflow: hidden; font-size: 11.5px; opacity: .88; text-overflow: ellipsis; white-space: nowrap; }
.chat__icon, .chat__menu summary { display: grid; flex: none; place-items: center; width: 42px; height: 42px; border-radius: 8px; color: #fff; cursor: pointer; list-style: none; }
.chat__menu summary::-webkit-details-marker { display: none; }
.chat__icon:hover, .chat__menu summary:hover, .chat__menu[open] summary { background: rgb(255 255 255 / .14); color: #fff; }
.chat__menu { position: relative; }
.chat__menu nav { position: absolute; top: 48px; left: 0; z-index: 5; display: flex; flex-direction: column; width: min(300px, 82vw); max-height: 70dvh; overflow-y: auto; padding: 6px; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper); box-shadow: 0 14px 40px rgb(23 20 46 / .25); }
#content .chat__menu nav a { padding: 10px 12px; overflow: hidden; border-radius: 6px; color: var(--ink); font-size: 14.5px; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; flex: none; }
#content .chat__menu nav a:hover { background: var(--wash); }
#content .chat__menu nav a.chat__new { background: var(--pop); font-weight: 750; }
.chat__menu hr { width: 100%; margin: 6px 0; border: 0; border-top: 1px solid var(--rule); }

.chat__scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.chat__list { display: flex; flex-direction: column; gap: 12px; max-width: 800px; margin: 0 auto; padding: 18px 14px; list-style: none; }
.bubble { align-self: flex-start; max-width: 88%; margin: 0; padding: 11px 15px; border: 1px solid var(--rule); border-radius: 18px 18px 18px 5px; background: var(--paper); animation: bubble-in .18s ease; }
.bubble--student { align-self: flex-end; border-color: var(--indigo); border-radius: 18px 18px 5px 18px; background: var(--indigo); color: #fff; }
.bubble--problem { align-self: stretch; max-width: none; border-width: 1px 1px 1px 5px; border-left-color: var(--teal); border-radius: 10px; }
.suggest { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 22px; }
.suggest h2 { margin: 0 0 2px; font: 650 13px var(--sans); color: var(--ink-2); }
.suggest form { margin: 0; }
.suggest button { padding: 9px 14px; border: 1px solid var(--rule); border-radius: 18px; background: var(--paper); color: var(--ink); font: 500 14px/1.35 var(--sans); text-align: left; cursor: pointer; }
.suggest button:hover { border-color: var(--teal); }
.bubble--prewritten, .bubble--solution { border-color: var(--teal); }
.bubble--code, .bubble--done { border: 2px solid var(--teal); }
.bubble__who { margin: 0 0 3px; color: var(--teal); font-size: 12.5px; font-weight: 750; }
.bubble--student .bubble__who { color: #fff; opacity: .8; }
.bubble__body { overflow-wrap: anywhere; white-space: pre-line; font: 400 15.5px/1.65 var(--sans); }
.bubble__note { margin: 8px 0 0; color: var(--ink-2); font-size: 13.5px; }
.bubble form { margin: 4px 0 0; }
.bubble__report { padding: 2px 0; border: 0; background: none; color: var(--ink-2); font: 500 12px var(--sans); text-decoration: underline; cursor: pointer; }
.bubble__form { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.bubble__form textarea { box-sizing: border-box; width: 100%; padding: 10px; border: 1px solid var(--ink-2); border-radius: 8px; font: 400 16px/1.5 var(--sans); resize: vertical; }
.bubble--typing { display: flex; gap: 5px; padding: 16px; }
.bubble--typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); animation: typing 1s infinite ease-in-out; }
.bubble--typing i:nth-child(2) { animation-delay: .15s; }
.bubble--typing i:nth-child(3) { animation-delay: .3s; }
.maths .katex-display { overflow-x: auto; overflow-y: hidden; }

.chat__welcome { max-width: 560px; margin: 0 auto; padding: 36px 20px; }
#content .chat__welcome h1 { margin: 0 0 10px; font: 750 clamp(23px, 5vw, 30px)/1.2 var(--sans); letter-spacing: -.02em; text-wrap: balance; }
.chat__welcome p { color: var(--ink-2); line-height: 1.55; }
.chat__welcome ul { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 0; padding: 0; list-style: none; }
.chat__welcome li { margin: 0; }
#content .chat__welcome li a { display: block; padding: 12px 16px; border-radius: 8px; background: var(--course); color: #fff; font-weight: 750; text-decoration: none; }
#content .chat__welcome a.button { color: var(--ink); }
.chat__fine { font-size: 13px; }

.chat__dock { flex: none; padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--rule); background: var(--paper); }
.chat__dock > * { max-width: 776px; margin-right: auto; margin-left: auto; }
.chat__flash { margin-top: 0; margin-bottom: 8px; padding: 9px 12px; border-left: 4px solid var(--teal); border-radius: 4px; background: var(--wash); font-size: 14px; line-height: 1.45; }
.chat__flash--error { border-left-color: var(--pop); background: var(--pop-tint); color: var(--ink); }
.chips { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; overflow-x: auto; }
.chips form { flex: none; margin: 0; }
.chips__note { color: var(--ink-2); font-size: 12.5px; }
.chip { min-height: 36px; padding: 0 14px; border: 1.5px solid var(--teal); border-radius: 18px; background: var(--paper); color: var(--teal); font: 700 13.5px var(--sans); white-space: nowrap; cursor: pointer; }
.chip:hover { background: var(--wash); }
.topic { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 14px; font-weight: 650; }
.topic select { flex: 1; min-width: 0; min-height: 38px; padding: 0 8px; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); color: var(--ink); font: 400 15px var(--sans); }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 5px; border: 1.5px solid var(--ink-2); border-radius: 24px; }
.composer:focus-within { border-color: var(--indigo); box-shadow: 0 0 0 3px rgb(47 42 143 / .18); }
.composer textarea { flex: 1; min-width: 0; max-height: 34dvh; padding: 7px 0; border: 0; outline: 0; background: none; color: var(--ink); font: 400 16px/1.5 var(--sans); resize: none; }
.composer__attach { display: grid; flex: none; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--ink-2); cursor: pointer; }
.composer__attach:hover { background: var(--wash); color: var(--indigo); }
.attached { display: flex; align-items: center; gap: 6px; width: fit-content; max-width: 100%; margin-top: 0; margin-bottom: 8px; margin-left: 0; padding: 4px 6px 4px 12px; border: 1px solid var(--teal); border-radius: 14px; font-size: 13px; }
.chat__dock > .attached { margin-right: auto; margin-left: auto; }
.attached[hidden] { display: none; }
.attached span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attached button { border: 0; background: none; color: var(--ink-2); font-size: 18px; line-height: 1; cursor: pointer; }
.bubble__file { margin: 6px 0 0; font-size: 13px; font-weight: 650; opacity: .85; }
.composer__send { display: grid; flex: none; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: var(--pop); color: var(--ink); cursor: pointer; }
.chat button:disabled { opacity: .5; cursor: wait; }
.modes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; margin-bottom: 0; padding: 0; border: 0; }
.modes__choice { position: relative; cursor: pointer; }
.modes__choice input { position: absolute; opacity: 0; }
.modes__choice span { display: inline-block; padding: 5px 12px; border: 1px solid var(--rule); border-radius: 14px; color: var(--ink-2); font-size: 12.5px; font-weight: 650; }
.modes__choice small { margin-left: 3px; font-weight: 450; opacity: .85; }
.modes__choice input:checked + span { border-color: var(--indigo); background: var(--indigo); color: #fff; }
.modes__choice input:focus-visible + span { outline: 3px solid var(--pop); outline-offset: 2px; }

/* In the floating panel the close button (.chat__leave) closes the panel; on its own page it leaves the chat. */
@media (max-width: 420px) { .bubble { max-width: 94%; } }
@keyframes bubble-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes typing { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .bubble, .bubble--typing i { animation: none; } }
/* In chat text a formula flows with the sentence and breaks at its operators, instead of getting its own scroll bar. */
#content .maths :not(.katex-display) > .katex { display: inline; overflow: visible; vertical-align: baseline; }
#content .bubble { overflow-x: auto; }
