.ai-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
}
.ai-toggle:is(:hover, :focus) { background: transparent; }
.ai-toggle svg, .ai-chat svg { width: 17px; height: 17px; flex: none; }
.ai-chat[open] {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: var(--header) 0 0 auto;
  z-index: 40;
  width: min(340px, 100vw);
  height: auto;
  max-height: none;
  max-width: none;
  min-height: 0;
  margin: 0;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  box-shadow: -12px 0 28px #15133612;
}
.ai-chat::backdrop { background: transparent; backdrop-filter: none; }
.ai-chat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px 0 18px;
}
.ai-chat-top h2 { margin: 0; font-size: 15px; font-weight: 650; }
.ai-chat-close { font-size: 23px; line-height: 1; padding: 6px 9px; }
.ai-chat-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px 18px; }
.ai-chat-intro strong { display: block; font-size: 15px; }
.ai-chat-intro p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.ai-chat-prompts { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px; margin-top: 14px; }
.ai-chat-prompts button { border: 1px solid var(--line); border-radius: 7px; font-size: 12px; padding: 6px 10px; }
.ai-chat-log { display: grid; gap: 10px; }
.ai-chat-message { justify-self: end; max-width: 90%; margin: 14px 0 0; padding: 8px 12px; background: var(--selected); border-radius: 13px 13px 3px 13px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.ai-chat-status { margin: 0; color: var(--muted); font-size: 12px; }
.ai-chat-form { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px max(14px, env(safe-area-inset-bottom)); }
.ai-chat-composer { display: flex; align-items: end; gap: 7px; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: var(--surface); }
.ai-chat-composer:focus-within { border-color: var(--accent); }
.ai-chat-composer textarea { height: 52px; min-width: 0; padding: 6px; resize: none; font-size: 14px; }
.ai-chat-send { display: grid; place-items: center; min-width: 34px; height: 34px; padding: 5px; box-shadow: none; }
.ai-chat-send:disabled { opacity: .45; cursor: default; }
@media (min-width: 761px) {
  .toolbar { padding-right: 166px; }
}
@media (min-width: 1160px) {
  body:not(.signed-out).ai-chat-open { grid-template-columns: var(--sidebar) var(--list) minmax(0, 1fr) 320px; }
  .ai-chat[open] { position: relative; inset: auto; grid-column: 4; grid-row: 2; width: 100%; box-shadow: none; }
  .ai-chat-open .reader .toolbar { padding-right: 14px; }
}
@media (max-width: 760px) {
  .ai-chat[open] { inset: 0; width: 100%; height: 100dvh; }
  .ai-chat-composer textarea { font-size: 16px; }
}
@media (max-width: 350px) {
  .headtools { gap: 4px; }
  .brandarea .brand { gap: 7px; }
}

/* Put every toolbar icon on the same square and center line. */
.headtools > :is(.iconbutton, .ai-toggle) {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--ink);
}
.headtools > .ai-toggle:is(:active, [aria-expanded="true"]) {
  background: var(--accent);
  color: white;
}
.headtools > :is(.iconbutton, .ai-toggle) svg {
  display: block;
  width: 19px;
  height: 19px;
}
.headtools .account {
  width: 34px;
  height: 34px;
  font-size: 15px;
  line-height: 1;
}
@media (max-width: 760px) {
  .headtools #settings { display: none; }
  .headtools { top: 0; height: 62px; }
  .headtools .account { width: 38px; height: 38px; font-size: 16px; }
}
