* { box-sizing: border-box; }
:root { color-scheme: light dark; --surface: #f7f7f2; --paper: #fff; --ink: #202923; --muted: #57665e; --line: #d9e1db; --accent: #244f3b; --action: #fff; --user: #e1ede3; --notice: #fff3d7; }
@media (prefers-color-scheme: dark) {
  :root { --surface: #151c19; --paper: #1d2721; --ink: #eaf1eb; --muted: #b2c1b6; --line: #37483d; --accent: #bde2c6; --action: #183b25; --user: #283d2f; --notice: #3b3321; }
}
[hidden] { display: none !important; }
body { margin: auto; max-width: 56rem; height: 100dvh; display: flex; flex-direction: column; background: var(--surface); color: var(--ink); font: 16px/1.55 system-ui, sans-serif; }
header { padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
h1 { margin: 0; font-size: 1rem; font-weight: 650; }
main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 1rem; }
#notice:empty, .chat-status:empty { display: none; }
form:not(.chat-composer), #sessions { margin-block: .7rem; }
label { display: block; margin-bottom: .6rem; }
input, select, textarea, button { min-height: 44px; padding: .5rem .75rem; max-width: 100%; border: 1px solid var(--line); border-radius: .7rem; background: var(--paper); color: var(--ink); font: inherit; }
button { cursor: pointer; }
input:not([type=checkbox]), select, textarea { width: 100%; }
input[type=checkbox] { min-height: auto; accent-color: var(--accent); }
#sessions { flex: none; display: flex; flex-wrap: wrap; gap: .4rem; align-items: end; }
#sessions label { flex: 1 0 100%; min-width: 0; margin: 0; font-size: .8rem; color: var(--muted); }
#sessions button { min-height: 32px; padding: .2rem .55rem; font-size: .78rem; }
#forget { align-self: flex-start; margin-bottom: .5rem; min-height: 32px; padding: .2rem .55rem; font-size: .78rem; }
#conversation { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-history { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: .25rem 0 1rem; }
.chat-turn + .chat-turn { border-top: 1px solid var(--line); margin-top: 1.15rem; padding-top: 1rem; }
.chat-message { margin: .5rem 0 1rem; overflow-wrap: anywhere; }
.chat-message h2 { color: var(--muted); margin: 0 0 .2rem; font-size: .78rem; font-weight: 650; }
.chat-message.user { margin-left: min(12%, 4rem); padding: .65rem .85rem; border-radius: .9rem; background: var(--user); white-space: pre-wrap; }
.chat-message.assistant { padding-inline: .25rem; }
.message-body > :first-child { margin-top: 0; }
.message-body > :last-child { margin-bottom: 0; }
.message-body h2, .message-body h3, .message-body h4 { color: var(--ink); font-size: 1.05rem; margin: 1em 0 .35em; }
.message-body code { background: var(--paper); border: 1px solid var(--line); border-radius: .25rem; padding: 0 .15em; }
.message-body pre, .message-body table { display: block; max-width: 100%; overflow: auto; }
.message-body pre { background: var(--paper); padding: .75rem; border: 1px solid var(--line); border-radius: .55rem; }
.message-body pre code { padding: 0; border: 0; }
.message-body th, .message-body td { padding: .3rem .5rem; border-bottom: 1px solid var(--line); }
.message-body a { color: var(--accent); }
.chat-dock { flex: none; display: grid; gap: .4rem; padding: .5rem 0 max(.4rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.chat-composer { display: flex; gap: .5rem; align-items: end; }
.chat-composer textarea { resize: none; min-height: 44px; }
.chat-composer button, .chrome-handoff-take, [data-chrome-give] { background: var(--accent); color: var(--action); border: 0; flex-shrink: 0; font-weight: 650; }
.chat-refresh { justify-self: start; min-height: 32px; padding: .1rem .5rem; border: 0; background: transparent; color: var(--muted); font-size: .78rem; }
.chat-status { margin: 0; font-size: .85rem; }
.chrome-handoff-card { margin: .75rem 0; padding: .8rem; border: 1px solid var(--line); border-radius: .85rem; background: var(--notice); }
.chrome-handoff-title { font-weight: 650; }
.chrome-handoff-reason, .chrome-handoff-result { margin: .3rem 0 .65rem; }
.chrome-handoff-viewer { margin-top: .65rem; }
[data-chrome-frame], [data-chrome-canvas] { margin-top: .5rem; border-radius: .5rem; cursor: pointer; display: block; }
[data-chrome-text] { display: flex; gap: .45rem; }
[data-chrome-text] button { flex: none; }
.chrome-handoff-diagnostics { color: var(--muted); font-size: .82rem; }
.chrome-handoff-diagnostics summary { cursor: pointer; padding: .25rem 0; }
.chrome-handoff-diagnostics ul { margin-block: .25rem; padding-inline-start: 1.3rem; }
[data-chrome-status] { min-height: 1.4em; margin: .4rem 0; font-size: .85rem; }
.handoff-link { display: inline-block; margin-bottom: .65rem; color: var(--accent); font-size: .85rem; }
#sessions .session-link { align-self: center; color: var(--accent); font-size: .82rem; padding: .2rem .55rem; }
