/* css/chat.css: /chat, the app view. Sidebar of saved chats, a thread, and the composer docked at the bottom. */
html, body.page-chat { height: 100%; }
body.page-chat { overflow: hidden; background-image: none; }
.page-chat main { height: 100%; }
.app { display: grid; grid-template-columns: 280px minmax(0, 1fr); height: 100dvh; }

/* sidebar */
.side { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; gap: 12px; padding: 16px 14px; border-right: 1px dashed var(--line); background: var(--bg); min-height: 0; }
.side-top { display: flex; align-items: center; justify-content: space-between; height: 40px; }
.side .brand svg { width: 30px; height: 30px; }
.side .brand .word { font-size: 13px; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); display: grid; place-items: center; color: var(--mute); font-size: 20px; flex: none; }
.icon-btn:hover { color: var(--head); border-color: var(--line-2); }
.icon-btn svg { width: 18px; height: 18px; }
.side-x { display: none; }
.side-new { width: 100%; min-height: 40px; }
.side-new svg { width: 14px; height: 14px; }
.side-q { min-height: 38px; font-size: 14px; }
.side-list { overflow-y: auto; min-height: 0; margin: 0 -6px; padding: 0 6px; overscroll-behavior: contain; }
.side-list h4 { margin: 14px 8px 6px; font: 500 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.side-item { position: relative; display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 10px; border-radius: 9px; text-align: left; color: var(--ink); font-size: 14px; }
.side-item:hover { background: rgba(240, 227, 222, .05); }
.side-item.on { background: rgba(255, 94, 31, .12); color: var(--head); }
.side-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .lk { width: 13px; height: 13px; color: var(--or); flex: none; }
.side-item .del { opacity: 0; width: 24px; height: 24px; border-radius: 6px; color: var(--dim); display: grid; place-items: center; flex: none; }
.side-item:hover .del, .side-item.on .del, .side-item .del:focus-visible { opacity: 1; }
.side-item .del:hover { color: var(--bad); background: var(--bg-2); }
.side-none { padding: 18px 10px; color: var(--dim); font-size: 13.5px; }
.side-foot { display: grid; gap: 12px; }
.acct { padding: 14px; display: grid; gap: 10px; font-size: 13.5px; }
.acct .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.acct .lbl { font: 500 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.acct b { font: 500 20px/1 var(--sans); color: var(--head); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.acct .bar { height: 4px; border-radius: 4px; background: var(--bg-3); overflow: hidden; }
.acct .bar i { display: block; height: 100%; background: var(--or); }
.acct p { color: var(--mute); font-size: 12.5px; line-height: 1.4; }
.acct .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.acct .btns .btn { flex: 1; min-height: 34px; font-size: 13.5px; }
.side-links { display: flex; gap: 4px 14px; flex-wrap: wrap; padding: 0 4px; font-size: 13px; color: var(--dim); }
.side-links a:hover { color: var(--head); }
.side-bg { display: none; }

/* main pane */
.pane { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 18px; border-bottom: 1px dashed var(--line); min-width: 0; }
.top-menu, .top-brand { display: none; }
.top-title { font-size: 15px; font-weight: 500; letter-spacing: 0; color: var(--head); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.top-tags { display: inline-flex; gap: 6px; flex: none; }
.top-r { margin-left: auto; display: flex; gap: 8px; flex: none; }

.thread { overflow-y: auto; min-height: 0; padding: 28px 18px 12px; overscroll-behavior: contain; }
.empty { display: grid; justify-items: center; text-align: center; gap: 12px; padding: 7vh 0 24px; }
.empty img { width: 150px; height: 150px; margin-bottom: 8px; }
.empty h2 { font-size: clamp(26px, 3vw, 38px); line-height: 1.08; letter-spacing: -0.03em; max-width: 620px; text-wrap: balance; }
.empty-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; max-width: 680px; }
.empty-chips .chip { background: var(--bg-1); }
.msgs { width: min(760px, 100%); margin: 0 auto; display: grid; gap: 26px; }
.msg { display: grid; gap: 8px; min-width: 0; }
.msg-u { justify-items: end; }
.msg-u .bubble { max-width: 85%; padding: 12px 16px; border-radius: 16px 16px 4px 16px; background: var(--bg-2); border: 1px solid var(--line); color: var(--head); white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg-u .att { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.msg-u .att img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.msg-u .att span { padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); font-size: 12.5px; color: var(--mute); }
.msg-a .who { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--mute); }
.msg-a .who b { color: var(--head); font-weight: 500; }
.msg-a .who .mi, .msg-a .who .mi-t { width: 18px; height: 18px; }
.think { border-left: 2px solid var(--line-2); padding: 2px 0 2px 12px; color: var(--dim); font-size: 14px; }
.think summary { cursor: pointer; font: 500 12px/1.4 var(--mono); color: var(--mute); list-style: none; }
.think summary::-webkit-details-marker { display: none; }
.think[open] summary { margin-bottom: 6px; }
.think .tx { white-space: pre-wrap; max-height: 260px; overflow: auto; }
.md { color: var(--ink); font-size: 16px; line-height: 1.65; overflow-wrap: anywhere; min-width: 0; }
.md > * + * { margin-top: 12px; }
.md h1, .md h2, .md h3, .md h4 { font-size: 18px; line-height: 1.3; letter-spacing: -0.01em; margin-top: 22px; }
.md h1 { font-size: 22px; } .md h2 { font-size: 20px; }
.md ul, .md ol { padding-left: 22px; display: grid; gap: 4px; }
.md a { color: var(--or-2); text-decoration: underline; text-underline-offset: 3px; }
.md strong { color: var(--head); font-weight: 600; }
.md blockquote { margin: 0; padding: 2px 0 2px 14px; border-left: 2px solid var(--or); color: var(--mute); }
.md code { font-family: var(--mono); font-size: .88em; padding: 1px 6px; border-radius: 6px; background: var(--bg-2); border: 1px solid var(--line); }
.md pre { position: relative; margin: 14px 0; padding: 0; border-radius: 12px; border: 1px solid var(--line); background: #0f0e0e; overflow: hidden; }
.md pre .ph { display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; border-bottom: 1px solid var(--line); font: 500 11.5px/1 var(--mono); color: var(--dim); }
.md pre code { display: block; padding: 14px 16px; border: 0; background: none; font-size: 13.5px; line-height: 1.6; overflow-x: auto; white-space: pre; border-radius: 0; }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.md th { color: var(--head); font-weight: 500; background: var(--bg-1); }
.md hr { border: 0; border-top: 1px dashed var(--line); }
.md img { max-width: 100%; border-radius: 10px; }
.caret::after { content: ''; display: inline-block; width: 8px; height: 1.05em; vertical-align: -2px; margin-left: 2px; background: var(--or); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.msg-a .acts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font: 400 12px/1 var(--mono); color: var(--dim); }
.msg-a .acts button { padding: 6px 8px; border-radius: 7px; color: var(--mute); border: 1px solid transparent; font: 500 12px/1 var(--mono); }
.msg-a .acts button:hover { color: var(--head); border-color: var(--line); }
.msg-a .acts .cost { margin-left: 6px; }
.notice { display: grid; gap: 10px; padding: 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-1); }
.notice.warn { border-color: rgba(255, 94, 31, .5); }
.notice b { color: var(--head); font-weight: 500; }
.notice p { color: var(--mute); font-size: 14.5px; }
.notice .btns { display: flex; gap: 8px; flex-wrap: wrap; }

.dock { padding: 10px 18px calc(12px + env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: 8px; }
.dock .cmp { width: min(760px, 100%); }
.dock .cmp-box { box-shadow: none; background: var(--bg-1); }
.dock .cmp-tab { background: var(--bg-1); }
.dock textarea { min-height: 44px; }
.dock .cmp-send { width: 108px; }
.dock-note { font-size: 12px; color: var(--dim); text-align: center; }
.dock-note a { text-decoration: underline; text-underline-offset: 2px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(320px, 86vw); z-index: 70; transform: translateX(-102%); transition: transform .25s var(--ease); box-shadow: 30px 0 60px -20px rgba(0, 0, 0, .7); }
  .app.side-open .side { transform: none; }
  .app.side-open .side-bg { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(0, 0, 0, .55); }
  .side-x { display: grid; }
  .top-menu, .top-brand { display: grid; }
  .top-brand svg { width: 28px; height: 28px; }
  .top { padding: 0 12px; gap: 10px; height: 56px; }
  .thread { padding: 18px 14px 8px; }
  .dock { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .empty { padding-top: 3vh; }
  .empty img { width: 110px; height: 110px; }
}
@media (max-width: 620px) {
  .dock .cmp-send { width: 100%; padding-top: 11px; padding-bottom: 17px; }
  .dock textarea { min-height: 28px; }
  .dock-note { display: none; }
  .dock .cmp-tab { margin-left: 10px; }
  .msg-u .bubble { max-width: 92%; }
  .top-tags { display: none; }
}
