/* Bauta chat. The chat list is a panel of pale plaster, the conversation is plain text on the gesso, what you
   said sits on the wall's green, the composer is the one white field. Everything else comes from styles.css. */

body.chat { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
.chat .top .wrap { width: auto; margin-inline: 0; padding-inline: 28px 22px; }

.app { display: grid; grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); min-height: 0; overflow: clip; }

/* ---------- the chat list */
.side {
  display: flex; flex-direction: column; min-height: 0; margin: 2px 0 14px 14px; padding: 13px 12px 12px;
  border-radius: 14px; color: var(--ink);
  background: var(--grain), linear-gradient(170deg, #ede6d8, var(--ground-lo) 60%, #ddd4c3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), inset 0 -2px 0 rgba(0, 0, 0, .06);
}
.side-head { display: flex; align-items: center; gap: 10px; padding: 0 2px 6px; }
.side-head .key { flex: 1; justify-content: flex-start; }
.side-x { display: none; flex: none; width: 44px; height: 44px; border: 0; border-radius: 10px; background: none; color: var(--mute); font: 400 1.7rem/1 var(--mono); }
.side-x:hover { color: var(--ink); background: rgba(0, 0, 0, .06); }
.chats { flex: 1; min-height: 0; margin: 12px -4px 0; padding: 2px 4px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.chats li { position: relative; display: flex; align-items: center; border-radius: 10px; margin-bottom: 2px; }
.chats li:hover { background: rgba(255, 255, 255, .4); }
.chat-link { flex: 1; min-width: 0; padding: 10px 11px; border: 0; background: none; color: var(--ink); text-align: left; font: 500 var(--fs-1)/1.25 var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-del { position: absolute; right: 3px; top: 50%; translate: 0 -50%; min-width: 34px; height: 34px; padding: 0 9px; border: 0; border-radius: 8px; background: none; color: var(--mute); font: 400 1.25rem/1 var(--mono); opacity: 0; }
.chats li:hover .chat-del, .chats li:focus-within .chat-del, .chat-del[data-sure] { opacity: 1; }
.chats li:hover .chat-link, .chats li:focus-within .chat-link { padding-right: 42px; }
.chats li:has(.chat-del[data-sure]) .chat-link { padding-right: 76px; }
.chat-del:hover { color: var(--ink); background: rgba(0, 0, 0, .07); }
.chat-del[data-sure] { color: var(--bad); font: 700 var(--fs-0)/1 var(--text); }
.chats li.current { background: var(--ground-hi); box-shadow: inset 4px 0 0 var(--gilt), 0 1px 0 rgba(0, 0, 0, .08); }
.chats li.current .chat-link { font-weight: 700; padding-left: 15px; }
.chats li.current .chat-del:hover { background: var(--ground-lo); }
.chats li.current .chat-del[data-sure] { color: var(--bad); }
.side :focus-visible { outline-offset: -3px; }
.side-head .key:focus-visible { outline-offset: 3px; }
.side-none { flex: 1; padding: 14px 11px; color: var(--mute); font-size: var(--fs-1); }
.side-foot { padding: 10px 11px 2px; border-top: 1px solid rgba(0, 0, 0, .1); }
.side-clear { padding: 6px 0; border: 0; background: none; color: var(--mute); font: 600 var(--fs-0)/1.3 var(--text); text-align: left; }
.side-clear:hover { color: var(--ink); }
.side-clear[data-sure] { color: var(--bad); }
.scrim { position: fixed; inset: 0; z-index: 49; background: rgba(22, 22, 25, .55); }

/* ---------- the conversation */
.stage { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: clip; }
.bar { display: none; }
.scroll { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable both-edges; scrollbar-color: var(--line) transparent; }
.thread { display: flex; flex-direction: column; gap: 30px; width: min(100% - 48px, 48rem); margin-inline: auto; padding: 30px 0 38px; }
.msg { position: relative; min-width: 0; }

.msg.user { align-self: flex-end; max-width: min(88%, 36rem); padding: 11px 16px 12px; border-radius: 14px 14px 4px 14px; background: var(--lagoon); color: #f4f1ea; line-height: 1.5; }
.msg.user ::selection { background: var(--gilt-hi); color: var(--ink); }
.said { white-space: pre-wrap; overflow-wrap: anywhere; }
.pics { display: flex; flex-wrap: wrap; gap: 6px; margin: 5px -4px 5px; }
.pics + .said { margin-top: 10px; }
.pics img { width: 104px; height: 104px; object-fit: cover; border-radius: 10px; background: #000; }
.gone { font-size: var(--fs-0); color: #a9a8b0; }
.said + .gone { margin-top: 6px; }

.msg.bot { max-width: 46em; }
.msg.bot > .wait { display: block; margin: 9px 0 4px; }

/* answers are Markdown */
.md { line-height: 1.62; overflow-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md .tbl, .md .code, .md hr { margin: 0 0 .95em; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: 1.5em 0 .5em; font-weight: 800; line-height: 1.18; letter-spacing: -.02em; text-wrap: balance; }
.md h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.03em; }
.md h2 { font-size: 1.35rem; }
.md h3 { font-size: 1.15rem; }
.md h4, .md h5, .md h6 { font-size: 1rem; letter-spacing: 0; }
.md ul { list-style: square; padding-left: 1.25em; }
.md ol { list-style: decimal; padding-left: 1.6em; }
.md li { margin: .28em 0; padding-left: .15em; }
.md li > ul, .md li > ol { margin: .28em 0 0; }
.md li::marker { color: var(--mute); font-variant-numeric: tabular-nums; }
.md li:has(> input[type='checkbox']) { list-style: none; margin-left: -1.25em; }
.md input[type='checkbox'] { margin: 0 .45em 0 0; accent-color: var(--ink); }
.md strong { font-weight: 700; }
.md a { font-weight: 600; overflow-wrap: anywhere; }
.md blockquote { padding: 2px 0 2px 16px; border-left: 3px solid var(--gilt); color: var(--ink-2); }
.md blockquote > :last-child { margin-bottom: 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin-block: 1.4em; }
.md img { border-radius: 10px; max-height: 420px; }
.md :not(pre) > code { font: 500 .88em var(--mono); background: var(--ground-lo); padding: .12em .38em; border-radius: 5px; overflow-wrap: anywhere; }
.md .code { box-shadow: none; }
.md .code-tabs { padding: 8px 8px 0 16px; min-height: 42px; }
.md .code-tabs span { font: 500 var(--fs-0)/1 var(--mono); color: #9c9ba3; margin-bottom: 6px; }
.md .code pre { padding: 16px 18px 18px; white-space: pre; overflow-wrap: normal; }
.md .code pre code { font: inherit; }
.md .tbl { overflow-x: auto; }
.md table { border-collapse: collapse; min-width: 100%; font-size: var(--fs-1); overflow-wrap: normal; }
.md th { text-align: left; font-weight: 700; white-space: nowrap; padding: 8px 18px 8px 0; border-bottom: 2px solid var(--ink); }
.md td { padding: 10px 18px 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.md th:last-child, .md td:last-child { padding-right: 0; }
.md th[align='right'], .md td[align='right'] { text-align: right; }
.md th[align='center'], .md td[align='center'] { text-align: center; }
/* the cursor of an answer that is still being written */
.md.live > p:last-child::after, .md.live > :is(ul, ol):last-child > li:last-child::after, .md.live > :is(h1, h2, h3, h4):last-child::after {
  content: ''; display: inline-block; width: .5em; height: 1em; margin-left: .14em; background: var(--ink); vertical-align: -.14em; animation: blink 1.05s steps(1) infinite;
}

.think { margin-bottom: 12px; }
.think summary { display: inline-flex; align-items: center; gap: .5em; padding: 3px 0; cursor: pointer; list-style: none; font: 600 var(--fs-1)/1.2 var(--text); color: var(--mute); border-radius: 4px; }
.think summary::-webkit-details-marker { display: none; }
.think summary::after { content: '+'; font: 400 1.15em/1 var(--mono); }
.think[open] summary::after { content: '\2212'; }
.think summary:hover { color: var(--ink); }
.think-body { margin-top: 8px; padding-left: 14px; border-left: 3px solid var(--line); color: var(--mute); font-size: var(--fs-1); line-height: 1.52; white-space: pre-wrap; overflow-wrap: anywhere; }

.meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 16px; margin-top: 12px; font: 400 var(--fs-0)/1.4 var(--mono); color: var(--mute); }
.act { margin: -2px 0; padding: 6px 0; border: 0; background: none; color: var(--mute); font: 600 var(--fs-0)/1.4 var(--text); border-radius: 4px; }
.act:hover { color: var(--ink); text-decoration: underline; text-decoration-thickness: .08em; text-underline-offset: .18em; }
.act.done { color: var(--good); }
.fail { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 12px; color: var(--bad); font-weight: 600; font-size: var(--fs-1); line-height: 1.4; }
.fail span { min-width: 0; overflow-wrap: anywhere; }
.md[hidden] + .fail { margin-top: 0; }
.note { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; font-weight: 700; font-size: var(--fs-1); }
.dock > .note { justify-content: center; margin-bottom: 18px; }

/* ---------- the composer */
.dock { position: relative; flex: none; width: min(100% - 48px, 48rem); margin-inline: auto; padding-bottom: max(16px, env(safe-area-inset-bottom)); view-transition-name: dock; }
.latest { position: absolute; left: 50%; bottom: calc(100% + 12px); translate: -50% 0; z-index: 2; }
.composer { background: #fff; border: 2px solid #8b8a84; border-radius: 16px; box-shadow: 0 8px 22px rgba(20, 20, 24, .08); transition: border-color .12s; }
.composer:focus-within { border-color: var(--ink); }
.composer.drop { border-style: dashed; border-color: var(--lagoon); }
.composer textarea { display: block; width: 100%; border: 0; background: none; resize: none; outline: none; color: var(--ink); }
.composer textarea::placeholder { color: #8b8a84; opacity: 1; }
#input { padding: 15px 18px 6px; font: 400 var(--fs-2)/1.5 var(--text); max-height: 40vh; max-height: 40dvh; overflow-y: hidden; }
#input.tall { overflow-y: auto; }
.sys { padding: 13px 18px 0; border-bottom: 1px solid var(--line); }
.sys label { display: block; font: 600 var(--fs-0)/1.2 var(--text); color: var(--mute); }
.sys textarea { padding: 5px 0 11px; font: 400 var(--fs-1)/1.45 var(--text); max-height: 24vh; overflow-y: auto; }
.shots { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 16px 0; }
.shots li { position: relative; }
.shots img { width: 68px; height: 68px; object-fit: cover; border-radius: 10px; background: var(--ground-lo); }
.shots button { position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; display: grid; place-items: center; padding: 0 0 1px; border: 2px solid #fff; border-radius: 50%; background: var(--ink); color: #fff; font: 400 1rem/1 var(--mono); }
.tools { display: flex; align-items: center; gap: 8px; padding: 6px 9px 12px 11px; }
.tools .model { flex: 0 1 auto; min-width: 0; max-width: 17rem; padding: 0 .7em 0 .9em; gap: .35em; }
.tools .model span { min-width: 0; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.tools .model svg { width: .95em; height: .95em; color: var(--mute); }
.tools .icon { flex: none; width: 40px; padding: 0; }
.tools .icon svg { width: 1.3em; height: 1.3em; }
.tool { flex: none; padding: 9px 5px; border: 0; border-radius: 8px; background: none; color: var(--mute); font: 600 var(--fs-1)/1 var(--text); }
.tool:hover, .tool[aria-expanded='true'] { color: var(--ink); }
.tool.set { color: var(--ink); font-weight: 800; }
.send { flex: none; width: 54px; min-height: 44px; padding: 0; margin-left: auto; border-radius: 10px; }
.send svg { width: 1.3em; height: 1.3em; }
.send:disabled { opacity: .38; }

/* ---------- before the first message */
.ask, .quiet { display: none; }
.stage.empty .scroll { display: none; }
.stage.empty .ask { display: block; margin: auto auto 32px; padding-inline: 18px; text-align: center; font: 400 clamp(3rem, 1.8rem + 5vw, 5.6rem)/.95 var(--display); letter-spacing: -.035em; }
.stage.empty .quiet { display: block; width: min(100% - 36px, 44rem); margin: 4px auto auto; padding-bottom: 11vh; text-align: center; text-wrap: balance; font-size: var(--fs-0); line-height: 1.45; color: var(--mute); }
.stage.empty .latest { display: none; }
.stage.empty #input { min-height: 5.2rem; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
::view-transition-group(dock) { animation-duration: .26s; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }

/* ---------- the model picker */
dialog.picker { width: min(100% - 24px, 620px); height: min(100dvh - 24px, 700px); overflow: hidden; }
dialog.picker[open] { display: flex; flex-direction: column; }
.picker-head { display: flex; align-items: center; gap: 12px; padding: 18px 18px 0; }
.picker-head input { flex: 1; min-width: 0; height: 50px; padding: 0 14px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; font: 500 var(--fs-2)/1 var(--text); outline-offset: 2px; -webkit-appearance: none; appearance: none; }
.picker-head input::-webkit-search-cancel-button { -webkit-appearance: none; }
.picker-head .x { margin: 0 -6px 0 0; flex: none; }
.picker-cols, .opt { display: grid; grid-template-columns: minmax(0, 1fr) 4.6em 4.6em; column-gap: 10px; align-items: baseline; }
.picker-cols { margin: 0 18px; padding: 16px 12px 9px; border-bottom: 2px solid var(--ink); font: 600 var(--fs-0)/1.2 var(--text); color: var(--mute); }
.picker .n { text-align: right; white-space: nowrap; }
.picker-list:focus { outline: none; }
.picker-list { flex: 1; min-height: 0; margin: 0; padding: 6px 18px 10px; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: var(--line) transparent; }
.opt { padding: 10px 12px 11px; border-radius: 11px; cursor: pointer; content-visibility: auto; contain-intrinsic-size: auto 62px; scroll-margin: 6px; }
.opt:hover { background: color-mix(in srgb, var(--ground-lo) 55%, transparent); }
.opt.on { background: var(--ground-lo); }
.opt b { font-weight: 700; line-height: 1.25; }
.opt .unc { margin-left: 8px; font: 600 var(--fs-0)/1 var(--text); color: var(--gilt-lo); }
.opt .id { grid-column: 1 / -1; margin-top: 2px; font: 400 var(--fs-0)/1.3 var(--mono); color: var(--mute); overflow-wrap: anywhere; }
.opt .n { font: 400 .9375rem/1.25 var(--mono); }
.opt[aria-selected='true'] b { text-decoration: underline; text-decoration-thickness: .14em; text-underline-offset: .2em; text-decoration-color: var(--gilt); }
.opt.rule { margin-top: 13px; position: relative; }
.opt.rule::before { content: ''; position: absolute; left: 12px; right: 12px; top: -7px; border-top: 1px solid var(--line); }
.picker-list.searching .opt.rule { margin-top: 0; }
.picker-list.searching .opt.rule::before { display: none; }
.picker-none { flex: 1; margin: 0; padding: 22px 30px; color: var(--mute); }
.picker-list[hidden] { display: none; }
.picker .picker-foot { margin: 0 18px; padding: 11px 12px 15px; border-top: 1px solid var(--line); font-size: var(--fs-0); color: var(--mute); }

/* ---------- small screens: the chat list slides in */
@media (max-width: 820px) {
  .chat .top .wrap { padding-inline: 18px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(86vw, 330px); margin: 0; padding: 16px 12px max(12px, env(safe-area-inset-bottom)); border-radius: 0 14px 14px 0; visibility: hidden; transform: translateX(-104%); transition: transform .22s cubic-bezier(.2, .8, .2, 1), visibility 0s .22s; box-shadow: 18px 0 50px rgba(20, 20, 24, .35); }
  .side.open { visibility: visible; transform: none; transition: transform .22s cubic-bezier(.2, .8, .2, 1); }
  .side-x { display: block; }
  .chat-del { opacity: 1; }
  .chat-link { padding-right: 42px; }
  .bar { display: flex; align-items: center; gap: 12px; padding: 2px 14px 10px; }
  .bar-title { flex: 1; min-width: 0; text-align: center; font: 700 var(--fs-1)/1.2 var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .bar .key { flex: none; padding: 0 .8em; }
  .thread { gap: 26px; width: calc(100% - 28px); padding: 18px 0 30px; }
  .dock { width: calc(100% - 28px); }
  .msg.user { max-width: 92%; }
  .pics img { width: 88px; height: 88px; }
  .tools { gap: 7px; padding-left: 9px; }
  .tools .model { max-width: none; }
  .stage.empty .ask { margin-bottom: 26px; }
  .stage.empty .quiet { padding-bottom: 7vh; }
  dialog.picker { height: min(100dvh - 24px, 760px); border-radius: 22px; }
  .picker-head { padding: 14px 14px 0; }
  .picker-cols { margin: 0 14px; padding-inline: 8px; }
  .picker-list { padding-inline: 14px; }
  .opt { padding-inline: 8px; grid-template-columns: minmax(0, 1fr) 4.1em 4.1em; column-gap: 8px; }
  .opt.rule::before { left: 8px; right: 8px; }
  .picker .picker-foot { margin: 0 14px; padding-inline: 8px; }
}
@media (max-width: 480px) {
  .tools { gap: 6px; padding-inline: 8px; }
  .tools .model { padding: 0 .55em 0 .75em; }
  .tools .icon { width: 38px; }
  .tool { padding-inline: 3px; font-size: var(--fs-0); }
  .send { width: 48px; }
}
@media (hover: none) {
  .chat-del { opacity: 1; }
  .chat-link { padding-right: 42px; }
}
