/* Chat page layout. Uses the tokens and components from theme.css. */
html, body.chat-page { height: 100%; }
body.chat-page { display: flex; flex-direction: column; overflow: hidden; }
.chat-bar { gap: var(--s-3); flex-wrap: nowrap; }
.who { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quota { display: grid; gap: 4px; width: 210px; flex: none; } .quota-top { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.quota .meter { height: 4px; } .quota small { font-size: 11px; line-height: 1.2; }

.chat-log { flex: 1; width: 100%; max-width: none; margin: 0; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; padding: var(--s-6) var(--s-4) var(--s-4); }
.chat-log:focus { outline: none; }
.thread { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--s-6); min-height: 100%; }
.msg-skel { display: grid; gap: 10px; } .msg-skel .skel:nth-child(1) { height: 16px; width: 70%; } .msg-skel .skel:nth-child(2) { height: 16px; width: 90%; } .msg-skel .skel:nth-child(3) { height: 16px; width: 45%; }

/* hero shown when the conversation is empty */
.hero { margin: auto; text-align: center; padding: var(--s-8) 0; max-width: 520px; }
.hero h1 { font-size: 26px; margin-bottom: var(--s-2); } .hero p { color: var(--text-2); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: center; margin-top: var(--s-5); }
.chip { all: unset; box-sizing: border-box; cursor: pointer; padding: 7px 13px; border-radius: var(--r-full); font-size: 13px; color: var(--text-2); border: 1px solid var(--border-strong); background: var(--surface); transition: .15s; }
.chip:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); } .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* messages */
.msg { display: flex; flex-direction: column; gap: 6px; min-width: 0; animation: rise .22s var(--ease); }
.msg.me { align-items: flex-end; }
.msg.me .bubble { max-width: 85%; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--r-lg) var(--r-lg) 4px var(--r-lg); padding: 10px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.ai .head { display: flex; align-items: center; gap: var(--s-2); font-size: 12.5px; color: var(--text-3); }
.msg.ai .head .who-ai { color: var(--text-2); font-weight: 500; font-family: var(--font-mono); font-size: 12px; }
.msg.ai .actions { margin-left: auto; opacity: 0; transition: opacity .15s; display: flex; gap: 2px; }
.msg.ai:hover .actions, .msg.ai:focus-within .actions { opacity: 1; }
@media (hover: none) { .msg.ai .actions { opacity: 1; } }
.msg.ai .body { overflow-wrap: anywhere; min-height: 1.55em; }
.msg.err .body { color: var(--danger); background: var(--danger-soft); border: 1px solid var(--danger-line); border-radius: var(--r-md); padding: 10px 14px; }
.err-inline { color: var(--danger); margin-top: .6em; }
.msg .retry { align-self: flex-start; }
.msg.stopped .body::after { content: " (stopped)"; color: var(--text-3); font-size: 12px; }

/* typing indicator */
.typing { display: inline-flex; gap: 5px; align-items: center; padding: 8px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: bounce 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.streaming .body > :last-child::after { content: "▍"; color: var(--accent); margin-left: 1px; animation: blink 1s steps(2) infinite; }
.streaming .body > pre::after, .streaming .body > .code::after { content: none; }
@keyframes blink { 50% { opacity: 0; } }

/* rendered markdown */
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .85em; white-space: pre-wrap; }
.md h3, .md h4, .md h5, .md h6 { margin: 1.1em 0 .4em; line-height: 1.3; } .md h3 { font-size: 17px; } .md h4 { font-size: 15.5px; } .md h5, .md h6 { font-size: 14px; }
.md ul, .md ol { margin: 0 0 .85em; padding-left: 1.4em; } .md li { margin: .2em 0; } .md li::marker { color: var(--text-3); }
.md blockquote { margin: 0 0 .85em; padding: 2px 0 2px 14px; border-left: 3px solid var(--border-strong); color: var(--text-2); white-space: pre-wrap; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.2em 0; }
.md code { font-size: .88em; }
.code { margin: 0 0 .95em; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--term-bg); overflow: hidden; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 2px 12px; background: var(--surface); border-bottom: 1px solid var(--border); font: 11.5px var(--font-mono); color: var(--text-3); }
.code pre { margin: 0; padding: 12px 14px; overflow-x: auto; font: 12.5px/1.6 var(--font-mono); }
.code pre code { background: none; border: 0; padding: 0; word-break: normal; font-size: inherit; }

.jump { position: fixed; left: 50%; transform: translateX(-50%); bottom: 150px; z-index: 15; box-shadow: var(--shadow-pop); border-radius: var(--r-full); }

/* composer dock */
.dock { padding: 0 var(--s-4) max(var(--s-3), env(safe-area-inset-bottom)); background: linear-gradient(180deg, transparent, var(--bg) 24%); }
.dock-inner { max-width: 760px; margin: 0 auto; }
.state-line { min-height: 22px; padding: 0 4px 6px; font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 8px; }
.notice { margin-bottom: var(--s-2); padding: 9px 13px; border-radius: var(--r-md); font-size: 13px; background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); }
.notice.bad { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.think { display: flex; align-items: center; gap: 8px; padding: 0 4px 6px; font-size: 12.5px; }
.think select { width: auto; height: 28px; padding: 0 28px 0 8px; font-size: 12.5px; }
.composer { display: flex; align-items: flex-end; gap: var(--s-2); padding: 8px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-composer); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--accent); box-shadow: var(--ring), var(--shadow-composer); }
.composer textarea { flex: 1; min-height: 38px; max-height: 200px; border: 0; background: transparent; padding: 8px 8px; resize: none; box-shadow: none !important; }
.composer .btn { height: 38px; width: 38px; border-radius: var(--r-md); flex: none; }
.foot { display: flex; justify-content: space-between; padding: 8px 6px 0; font-size: 12px; color: var(--text-3); }
kbd { padding: 1px 5px; border-radius: 4px; background: var(--surface-3); border: 1px solid var(--border); font-size: 11px; }

@media (max-width: 760px) {
  .chat-bar { padding: 0 var(--s-3); gap: var(--s-2); } .who, .quota small, .quota-top, #lvl, #adminLink { display: none; } .quota { width: 56px; }
  .pill { padding: 0 10px; }
  .foot span:first-child { display: none; } .foot { justify-content: flex-end; }
  .msg.me .bubble { max-width: 92%; } .jump { bottom: 130px; }
  .chat-log { padding-top: var(--s-4); }
}
