/* The chat page: a list of chats on the left, one conversation on the right. */
.chat-body { height: 100dvh; overflow: hidden; }
.chat { display: grid; grid-template-columns: 17.5rem minmax(0, 1fr); height: 100dvh; }
.chat svg { width: 1rem; height: 1rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.chat .mark { fill: var(--acc); stroke: none; width: 1.35rem; height: 1.35rem; }
.chat button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.chat [hidden] { display: none !important; }

/* Side */
.chat-side { display: flex; flex-direction: column; min-height: 0; background: var(--bg-1); border-right: 1px solid var(--line); }
.side-top { display: flex; align-items: center; justify-content: space-between; height: 3.5rem; padding: 0 1rem; }
.chat .brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 600; letter-spacing: -.01em; text-decoration: none; }
.side-close, .side-open { display: none; width: 2rem; height: 2rem; align-items: center; justify-content: center; border-radius: 8px; color: var(--mute); }
.side-close:hover, .side-open:hover { background: var(--bg-3); color: var(--text); }
.new-chat { display: flex; align-items: center; gap: .6rem; margin: .25rem .75rem .75rem; height: 2.5rem; padding: 0 .85rem !important; border: 1px solid var(--line-2) !important; border-radius: 10px; font-size: .92rem !important; font-weight: 500 !important; transition: background .2s, border-color .2s; }
.new-chat:hover { background: var(--bg-3); border-color: rgba(255, 122, 26, .5) !important; }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 .5rem; scrollbar-width: thin; scrollbar-color: var(--bg-3) transparent; }
.chat-list p { padding: .5rem .6rem; color: var(--dim); font-size: .85rem; }
.chat-item { position: relative; display: flex; align-items: center; border-radius: 8px; }
.chat-item > button:first-child { flex: 1; min-width: 0; height: 2.25rem; padding: 0 .6rem; text-align: left; font-size: .9rem; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 8px; }
.chat-item:hover { background: rgba(255, 255, 255, .04); }
.chat-item[aria-current="true"] { background: var(--bg-3); }
.chat-item[aria-current="true"] > button:first-child { color: var(--text); }
.chat-item .del-chat { display: none; width: 1.75rem; height: 1.75rem; margin-right: .25rem; align-items: center; justify-content: center; border-radius: 6px; color: var(--dim); }
.chat-item:hover .del-chat, .chat-item:focus-within .del-chat { display: inline-flex; }
.chat-item .del-chat:hover { color: var(--bad); background: rgba(248, 113, 113, .1); }
.side-foot { padding: .75rem; border-top: 1px solid var(--line); }
.local-note { display: flex; gap: .6rem; padding: .7rem .75rem; border: 1px solid rgba(255, 122, 26, .28); border-radius: 10px; background: rgba(255, 122, 26, .05); }
.local-note svg { margin-top: .15rem; color: var(--acc); }
.local-note p { font-size: .78rem; line-height: 1.5; color: var(--mute); }
.local-note strong { color: var(--text); font-weight: 600; }
.side-links { display: flex; flex-wrap: wrap; gap: .25rem 1rem; padding: .75rem .25rem 0; font-size: .8rem; }
.side-links a, .side-links button { color: var(--dim); text-decoration: none; font-size: .8rem; }
.side-links a:hover, .side-links button:hover { color: var(--text); }
.side-shade { display: none; }

/* Main */
.chat-main { overflow: hidden; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: .75rem; height: 3.5rem; padding: 0 1.25rem; border-bottom: 1px solid var(--line); flex: none; }
.chat-title { margin: 0; max-width: none; line-height: 1.4; text-wrap: nowrap; animation: none; flex: 1; min-width: 0; font-size: .95rem; font-weight: 500; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-btn { display: inline-flex; align-items: center; gap: .5rem; height: 2rem; padding: 0 .75rem !important; border: 1px solid var(--line-2) !important; border-radius: 8px; font-size: .85rem !important; color: var(--mute) !important; transition: color .2s, background .2s; }
.head-btn:hover:not(:disabled) { color: var(--text) !important; background: var(--bg-3); }
.head-btn:disabled { opacity: .4; cursor: default; }
.export { position: relative; }
.export-menu { position: absolute; right: 0; top: calc(100% + .5rem); z-index: 10; width: 19rem; padding: .35rem; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 20px 50px -15px #000; }
.export-menu button { display: block; width: 100%; padding: .6rem .7rem; text-align: left; border-radius: 8px; }
.export-menu button:hover, .export-menu button:focus-visible { background: var(--bg-3); }
.export-menu strong { display: block; font-size: .9rem; font-weight: 500; }
.export-menu span { display: block; margin-top: .1rem; font-size: .8rem; color: var(--mute); line-height: 1.45; }

.wc-thread { flex: 1; min-height: 0; overflow-y: auto; padding: 1.5rem 1.25rem 1rem; scrollbar-width: thin; scrollbar-color: var(--bg-3) transparent; }
.gate { max-width: 34rem; margin: 12vh auto 0; }
.gate h2 { font-size: clamp(1.5rem, 3vw, 1.9rem); font-weight: 600; letter-spacing: -.025em; line-height: 1.2; }
.gate p { margin-top: .75rem; color: var(--mute); max-width: 58ch; }
.gate p a { color: var(--text); text-underline-offset: 3px; }
.gate-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }
.starters { display: grid; gap: .5rem; margin-top: 1.5rem; }
.starters button { padding: .75rem .9rem; text-align: left; font-size: .92rem; color: var(--mute); border: 1px solid var(--line) !important; border-radius: 10px; transition: color .2s, border-color .2s, background .2s; }
.starters button:hover { color: var(--text); border-color: var(--line-2) !important; background: var(--bg-1); }

.messages { max-width: 46rem; margin: 0 auto; padding: 0; list-style: none; display: grid; gap: 1.5rem; }
.msg { min-width: 0; }
.wc-user { justify-self: end; max-width: 85%; padding: .65rem .95rem; background: var(--bg-3); border-radius: 14px 14px 4px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-bot { line-height: 1.65; overflow-wrap: anywhere; }
.msg-bot > * + * { margin-top: .8rem; }
.msg-bot h3 { font-size: 1.05rem; font-weight: 600; margin-top: 1.25rem; }
.msg-bot ul, .msg-bot ol { padding-left: 1.3rem; }
.msg-bot ul { list-style: disc; }
.msg-bot ol { list-style: decimal; }
.msg-bot li::marker { color: var(--dim); }
.msg-bot li + li { margin-top: .25rem; }
.msg-bot a { color: var(--acc-2); text-underline-offset: 3px; }
.msg-bot code { font-size: .86em; padding: .12em .35em; background: var(--bg-3); border-radius: 5px; }
.msg-bot pre { position: relative; padding: .9rem 1rem; background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; font-size: .85rem; line-height: 1.55; }
.msg-bot pre code { padding: 0; background: none; font-size: inherit; }
.msg-bot pre .copy { position: absolute; top: .4rem; right: .4rem; height: 1.6rem; padding: 0 .55rem; font: 500 .72rem var(--sans); color: var(--mute); background: var(--bg-3); border-radius: 6px; opacity: 0; transition: opacity .15s; }
.msg-bot pre:hover .copy, .msg-bot pre .copy:focus-visible { opacity: 1; }
.msg-bot.streaming::after { content: ""; display: inline-block; width: .5rem; height: 1rem; margin-left: .15rem; background: var(--acc); vertical-align: -.15rem; animation: blink 1s steps(2) infinite; }
.msg-error { padding: .75rem .95rem; border: 1px solid rgba(248, 113, 113, .35); border-radius: 10px; background: rgba(248, 113, 113, .06); color: #fca5a5; font-size: .92rem; }
.msg-error a { color: var(--text); }
@keyframes blink { 50% { opacity: 0; } }

.exported { display: flex; gap: 1rem; align-items: flex-start; width: min(46rem, calc(100% - 2.5rem)); margin: 0 auto .75rem; padding: .8rem 1rem; border: 1px solid rgba(74, 222, 128, .3); border-radius: 12px; background: rgba(74, 222, 128, .05); font-size: .88rem; }
.exported div { flex: 1; min-width: 0; }
.exported strong { font-weight: 600; }
.exported p { margin-top: .2rem; color: var(--mute); line-height: 1.55; }
.exported b { color: var(--text); font-weight: 500; }
.exported code { font-size: .82rem; color: var(--text); overflow-wrap: anywhere; }
.exported button { color: var(--mute); }

/* Composer */
.wc-composer { flex: none; padding: 0 1.25rem 1rem; }
.composer-box { max-width: 46rem; margin: 0 auto; padding: .75rem .75rem .6rem .95rem; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 16px; transition: border-color .2s; }
.composer-box:focus-within { border-color: rgba(255, 122, 26, .55); }
.wc-composer textarea { display: block; width: 100%; max-height: 12rem; padding: .15rem 0 .5rem; background: none; border: 0; outline: 0; resize: none; overflow-y: auto; scrollbar-width: none; color: var(--text); font: 400 1rem/1.5 var(--sans); }
.wc-composer textarea::placeholder { color: var(--dim); }
.composer-row { display: flex; align-items: center; gap: .75rem; }
.wc-composer select { height: 1.9rem; max-width: 12rem; padding: 0 1.6rem 0 .6rem; color: var(--mute); font: 500 .82rem var(--sans); background: var(--bg-3) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%239b9ba1' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M4.5 6.5L8 10l3.5-3.5'/%3E%3C/svg%3E") no-repeat right .4rem center / .9rem; border: 0; border-radius: 8px; appearance: none; cursor: pointer; }
.usage { flex: 1; min-width: 0; font-size: .78rem; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.send, .stop { display: inline-flex; width: 2.1rem; height: 2.1rem; align-items: center; justify-content: center; border-radius: 10px; background: var(--acc) !important; color: #140a02 !important; transition: filter .2s, opacity .2s; }
.send svg { stroke-width: 1.8; }
.send:hover:not(:disabled) { filter: brightness(1.1); }
.send:disabled { opacity: .35; cursor: default; }
.stop { background: var(--text) !important; }
.stop svg { fill: currentColor; stroke: none; }
.composer-note { max-width: 46rem; margin: .55rem auto 0; text-align: center; font-size: .76rem; color: var(--dim); }
.composer-note a { color: var(--mute); text-underline-offset: 3px; }

@media (max-width: 52rem) {
  .chat { grid-template-columns: minmax(0, 1fr); }
  .chat-side { position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(19rem, 86vw); transform: translateX(-100%); transition: transform .3s var(--ease); }
  .chat[data-side="open"] .chat-side { transform: none; }
  .chat[data-side="open"] .side-shade { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .6); }
  .side-close, .side-open { display: inline-flex; }
  .chat-head { padding: 0 .75rem; }
  .wc-thread { padding: 1rem .9rem; }
  .wc-composer { padding: 0 .75rem .75rem; }
  .wc-user { max-width: 92%; }
  .gate { margin-top: 6vh; }
  .export-menu { width: min(19rem, 88vw); }
}
@media (prefers-reduced-motion: reduce) {
  .chat-side { transition: none; }
  .msg-bot.streaming::after { animation: none; }
}
