/* Chat page. Tokens only (tokens.css via style.css). See DESIGN.md §5 Chat. */
html, body { height: 100%; }
body.chat { display: flex; flex-direction: column; background: var(--canvas); }
.bar { position: relative; z-index: 2; padding: 10px var(--s-4); padding-top: max(10px, env(safe-area-inset-top)); background: var(--canvas); border-bottom: 1px solid var(--hairline); }
.bar img { width: 40px; height: 40px; border-radius: var(--r-full); object-fit: cover; }
.bar .who { flex: 1; line-height: 1.15; }
.bar .who b { font-family: var(--serif); font-size: var(--t-lead); font-weight: 400; }
.tag-ai { margin-left: var(--s-2); vertical-align: 3px; font-size: var(--t-eyebrow); font-weight: 600; letter-spacing: .1em; color: var(--ash); border: 1px solid var(--hairline); border-radius: var(--r-full); padding: 2px 7px; }
.bar .sub { font-size: var(--t-caption); color: var(--ash); margin-top: 2px; }
.iconbtn { width: 40px; height: 40px; border-radius: var(--r-full); border: 1px solid var(--hairline); background: var(--surface); color: var(--stone); font: 600 var(--t-body)/1 var(--sans); letter-spacing: 1px; cursor: pointer; }
#log { flex: 1; overflow-y: auto; padding: var(--s-5) var(--s-4) var(--s-3); display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 720px; margin: 0 auto; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 20px; font-size: var(--t-body); line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.them { align-self: flex-start; background: var(--surface); border: 1px solid var(--hairline); border-bottom-left-radius: 6px; }
.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; margin-top: var(--s-2); }
.them + .me, .me + .them { margin-top: var(--s-3); }
.note { align-self: center; font-size: var(--t-caption); color: var(--ash); text-align: center; max-width: 86%; margin: var(--s-2) 0; }
.card2 { align-self: stretch; background: var(--crisis-bg); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: var(--s-4) var(--s-5); font-size: var(--t-small); margin: var(--s-2) 0; }
.card2 b { display: block; margin-bottom: var(--s-1); font-weight: 600; }
.typing { align-self: flex-start; background: var(--surface); border: 1px solid var(--hairline); border-radius: 20px; padding: 12px 14px; }
.typing i { display: inline-block; width: 6px; height: 6px; margin: 0 2px; background: var(--mute); border-radius: 50%; animation: km-b 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes km-b { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }
.composer { background: var(--canvas); border-top: 1px solid var(--hairline); padding: var(--s-2) var(--s-3); padding-bottom: max(var(--s-2), env(safe-area-inset-bottom)); }
form.send { display: flex; align-items: flex-end; gap: var(--s-2); max-width: 720px; margin: 0 auto; }
form.send textarea { flex: 1; resize: none; font: var(--t-body)/1.4 var(--sans); padding: 12px 16px; border: 1px solid var(--hairline); border-radius: 24px; max-height: 120px; background: var(--surface); color: var(--ink); }
form.send textarea:focus { outline: none; border-color: var(--stone); }
form.send button { width: 46px; height: 46px; min-height: 0; padding: 0; border-radius: var(--r-full); flex: none; font-size: var(--t-lead); }
.quota { text-align: center; font-size: var(--t-caption); color: var(--ash); padding: var(--s-1) 0 0; }
.sheet { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet .box { background: var(--surface-warm); width: 100%; max-width: 520px; border-radius: 28px 28px 0 0; padding: var(--s-6) var(--s-5); padding-bottom: max(var(--s-5), env(safe-area-inset-bottom)); max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-2); }
@media (min-width: 600px) { .sheet { align-items: center; } .sheet .box { border-radius: 28px; } }
.sheet h2 { font-size: var(--t-h2); margin: 0 0 var(--s-3); }
.sheet p { font-size: var(--t-small); margin: 0 0 var(--s-4); }
.sheet input { width: 100%; font: var(--t-body) var(--sans); padding: 14px 16px; border: 1px solid var(--hairline); border-radius: var(--r-md); margin-bottom: var(--s-3); background: var(--surface); color: var(--ink); }
.sheet input:focus { outline: none; border-color: var(--stone); }
.sheet .row { display: flex; gap: var(--s-3); }
.sheet .row > * { flex: 1; }
.err { color: var(--error); font-size: var(--t-small); min-height: 18px; margin: 0 0 var(--s-2); }
.menu { display: grid; gap: var(--s-2); }
.menu button { display: block; width: 100%; text-align: left; background: var(--surface); color: var(--ink); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 14px 16px; font: 500 var(--t-small) var(--sans); cursor: pointer; }
.menu button.danger { color: var(--error); }
.btn-danger { background: var(--error); color: var(--accent-ink); }
.mem { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: var(--s-3) var(--s-4); margin-bottom: var(--s-2); font-size: var(--t-small); }
.mem .k { font-size: var(--t-eyebrow); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ash); margin-bottom: 2px; }
.mem .acts { margin-top: var(--s-2); display: flex; gap: var(--s-4); font-size: var(--t-caption); }
.mem .acts a { color: var(--ash); cursor: pointer; text-decoration: underline; }
.mem textarea { width: 100%; font: var(--t-small) var(--sans); border: 1px solid var(--hairline); border-radius: var(--r-sm); padding: 6px; }

/* round-6: aligned header, ambience, avatars next to Elias (learned from Rizzora; no "online" dot — he's AI) */
.bar { background: color-mix(in srgb, var(--canvas) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.bar-in { display: flex; align-items: center; gap: var(--s-3); max-width: 720px; margin: 0 auto; }
.chat-bg { position: fixed; inset: 0; z-index: 0; background: url("/img/elias-window.jpg") center 30% / cover no-repeat; filter: blur(28px) saturate(.9); opacity: .16; transform: scale(1.1); pointer-events: none; }
#log, .composer { position: relative; z-index: 1; }
.composer { background: color-mix(in srgb, var(--canvas) 90%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.them, .typing { margin-left: 40px; position: relative; }
.them.first::before, .typing::before { content: ""; position: absolute; left: -40px; bottom: 0; width: 30px; height: 30px; border-radius: var(--r-full); background: url("/img/elias-avatar.jpg") center / cover; }
.them.first { margin-top: var(--s-3); }
.them.first ~ .them.first { margin-top: var(--s-3); }

/* round-7: night chat. The photo is visible (not fog), bubbles are warm glass, chrome blends into the night. */
body.chat { background: var(--night-deep); color: var(--on-night); }
.chat-bg { filter: brightness(.72) saturate(1.05); opacity: 1; transform: none; background-position: center 35%; }
.chat-bg::after { content: ""; position: absolute; inset: 0; background: var(--night-veil); }
@media (min-width: 900px) { .chat-bg { background-position: 18% 35%; } }
.bar, .composer { background: var(--glass-strong); border-color: var(--glass-line); }
.bar .who b, .bar .who { color: var(--on-night); }
.bar .sub { color: var(--on-night-mute); }
.tag-ai { color: var(--on-night-mute); border-color: var(--glass-line); }
.iconbtn { background: var(--glass); border-color: var(--glass-line); color: var(--on-night); }
.them, .typing { background: var(--glass); border-color: var(--glass-line); color: var(--on-night); backdrop-filter: blur(14px) saturate(1.1); -webkit-backdrop-filter: blur(14px) saturate(1.1); }
.typing i { background: var(--on-night-mute); }
.note { color: var(--on-night-mute); }
.card2 { background: var(--crisis-bg); color: var(--ink); }
form.send textarea { background: var(--glass); border-color: var(--glass-line); color: var(--on-night); }
form.send textarea::placeholder { color: var(--on-night-mute); }
form.send textarea:focus { border-color: var(--on-night-mute); }
.quota { color: var(--on-night-mute); }
.them.first::before, .typing::before { box-shadow: 0 0 0 1px var(--glass-line); }
.sheet .box { color: var(--ink); }
/* round-8: desktop — show his whole portrait on the right, fade into the night on the left, so the bubbles don't cover his face */
@media (min-width: 900px) {
  .chat-bg { background-size: auto 100%; background-position: right center; background-color: var(--night-deep); }
  .chat-bg::after { background: linear-gradient(90deg, var(--night-deep) 0%, var(--night-deep) 30%, rgba(21, 17, 14, .6) 55%, rgba(21, 17, 14, .2) 100%), linear-gradient(180deg, rgba(21, 17, 14, .5) 0%, rgba(21, 17, 14, 0) 25%, rgba(21, 17, 14, 0) 70%, rgba(21, 17, 14, .7) 100%); }
  #log, form.send, .bar-in { margin-left: max(var(--s-6), calc(50% - 560px)); margin-right: auto; }
}
/* round-9: soften the photo's left edge (it starts at 50% on 1440×900), align the quota line with the composer */
@media (min-width: 900px) {
  .chat-bg::after { background: linear-gradient(90deg, var(--night-deep) 0%, var(--night-deep) 52%, rgba(21, 17, 14, .55) 64%, rgba(21, 17, 14, .15) 82%, rgba(21, 17, 14, 0) 100%), linear-gradient(180deg, rgba(21, 17, 14, .5) 0%, rgba(21, 17, 14, 0) 25%, rgba(21, 17, 14, 0) 70%, rgba(21, 17, 14, .7) 100%); }
  .quota { max-width: 720px; margin-left: max(var(--s-6), calc(50% - 560px)); }
}
