/* Calm, compact chat layout; all colours follow the selected dashboard theme. */
.chat-layout{display:grid;grid-template-columns:200px minmax(0,1fr);height:calc(100dvh - 180px);min-height:400px;max-height:1100px;overflow:hidden;border-radius:14px}
.chat-sidebar{min-height:0;border-right:1px solid var(--line);padding:14px 10px;overflow:auto;scrollbar-width:thin;background:var(--subtle)}
.chat-sidebar>.button{width:100%;margin-bottom:16px}
.chat-history-item{display:flex;flex-direction:column;text-align:left;width:100%;gap:5px;padding:11px 12px;border:0;border-radius:8px;background:transparent;color:var(--text);margin-bottom:4px}
.chat-history-item strong{font-size:12px;font-weight:500;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat-history-item small{font-size:10px;color:var(--muted)}
.chat-history-item:hover{background:var(--surface)}.chat-history-item.active{background:var(--accent-soft);color:var(--accent)}
.chat-main{min-width:0;min-height:0;display:flex;flex-direction:column;overflow:hidden;background:var(--surface)}
.chat-heading{display:flex;justify-content:space-between;align-items:center;padding:16px 24px;border-bottom:1px solid var(--line);gap:12px;flex-shrink:0}
.chat-heading h2{font-size:14px;font-weight:600;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat-heading .button{padding:6px 10px;font-size:11px}
.chat-messages{flex:1;min-height:0;overflow:auto;padding:28px max(24px,calc((100% - 760px)/2));overscroll-behavior:contain;scrollbar-width:thin}
.chat-message{margin:0 0 28px;overflow-wrap:anywhere;font-size:14px}
.chat-message>small{display:block;margin-bottom:9px;font-size:11px;font-weight:600}
.chat-message.user{margin-left:12%;padding:14px 18px;border-radius:14px 14px 4px 14px;background:var(--subtle)}
.chat-markdown p{margin:5px 0;line-height:1.75;min-height:.5em;white-space:pre-wrap}
.chat-markdown pre{overflow:auto;padding:16px;border-radius:10px;max-width:100%;background:var(--code-bg);color:var(--code-text)}
.chat-markdown h3{font-size:16px;margin:18px 0 8px}
.chat-file{display:inline-block;padding:7px 11px;border:1px solid var(--line);border-radius:8px;margin:8px 8px 0 0;font-size:12px}
.chat-form{flex-shrink:0;width:calc(100% - 40px);max-width:800px;align-self:center;margin:0 20px 18px;border:1px solid var(--line);border-radius:12px;padding:12px 14px;background:var(--surface);transition:border-color .15s}
.chat-form:focus-within{border-color:var(--accent)}
#chat-prompt,#chat-prompt:focus,#chat-prompt:focus-visible{display:block;border:0;outline:none;box-shadow:none;background:transparent;resize:vertical;min-height:58px;max-height:180px;width:100%;padding:4px 2px 10px;font-family:inherit;font-size:14px;line-height:1.6;color:var(--text)}
#chat-prompt::placeholder{color:var(--muted);opacity:.85}
.chat-form>.actions{justify-content:space-between;align-items:center;border-top:1px solid var(--line);padding-top:10px;gap:10px}
.chat-form .button{padding:8px 12px;font-size:12px}
.chat-options{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px 16px;margin:3px 0 12px}
.chat-backup-mode{display:flex;flex-direction:column;gap:4px;font-size:10px;color:var(--muted)}
.chat-backup-mode select{font-family:inherit;font-size:11px;padding:5px 7px;max-width:100%;border-radius:6px}
.chat-welcome{font-size:23px;line-height:1.5;letter-spacing:-.5px;text-align:center;max-width:350px;margin:12vh auto 0;color:var(--muted)}
.chat-thinking{font-size:12px;color:var(--muted);padding:6px 0 14px;animation:chat-pulse 1.8s ease-in-out infinite}
.instruction-row{display:flex;align-items:center;gap:8px;margin:8px 0}.instruction-row>:first-child{flex:1;text-align:left}.instruction-row>.instruction-toggle{flex:0 0 auto;margin:0}.instruction-row>.instruction-toggle+.button{flex:1;text-align:left}.instruction-row.disabled>.instruction-toggle+.button{opacity:.55;text-decoration:line-through}
.instruction-editor textarea{font-family:ui-monospace,monospace;min-height:230px}.chat-config details{margin:20px 0}.chat-config summary{cursor:pointer;font-weight:600;margin:16px 0}
#agent-token-result{font-family:monospace}#chat-files{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:8px}.chat-config label.paths-label{display:flex;flex-direction:column;gap:8px;margin:14px 0}
.chat-backup{border:1px solid var(--line);border-radius:10px;padding:16px;margin:18px 0 28px;overflow-wrap:anywhere;background:var(--subtle);font-size:12px}
.chat-backup-heading,.chat-backup-footer{display:flex;justify-content:space-between;gap:10px;align-items:center;flex-wrap:wrap}
.chat-backup-heading strong{font-size:13px}.chat-backup p{margin:8px 0;line-height:1.5}.chat-backup-phase{font-weight:500}
.chat-backup progress{display:block;width:100%;height:6px;margin:14px 0 8px;accent-color:var(--accent);border:0;border-radius:8px;background:var(--line);overflow:hidden}
.chat-backup progress::-webkit-progress-bar{background:var(--line)}.chat-backup progress::-webkit-progress-value{background:var(--accent);border-radius:8px}.chat-backup progress::-moz-progress-bar{background:var(--accent);border-radius:8px}
.chat-backup-footer{margin-top:14px}.chat-backup-footer .button{font-size:11px;padding:5px 8px}
@keyframes chat-pulse{50%{opacity:.55}}
@media(prefers-reduced-motion:reduce){.chat-thinking{animation:none}.chat-form{transition:none}}
@media(max-width:1000px){.chat-layout{grid-template-columns:165px minmax(0,1fr)}.chat-messages{padding:20px}.chat-heading{padding:14px 18px}.chat-effort .muted{display:none}}
@media(max-width:800px){.chat-layout{height:calc(100dvh - 245px);min-height:480px}.chat-form{width:calc(100% - 24px);margin:0 12px 12px}}
@media(max-width:560px){.chat-layout{grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);height:calc(100dvh - 215px);min-height:560px}.chat-sidebar{display:flex;align-items:center;gap:10px;border-right:0;border-bottom:1px solid var(--line);padding:10px;overflow:hidden}.chat-sidebar>.button{width:auto;margin:0;flex-shrink:0}.chat-history{display:flex;overflow:auto;gap:4px;min-width:0;scrollbar-width:thin}.chat-history-item{min-width:130px;max-width:150px;margin:0;padding:7px 10px}.chat-history-item small{display:none}.chat-messages{padding:18px 14px}.chat-message.user{margin-left:5%}.chat-heading{padding:12px 14px}.chat-welcome{font-size:20px;margin-top:7vh}.chat-options{align-items:end;gap:8px}.chat-backup-mode{font-size:9px}.chat-backup-mode select{font-size:10px}.instruction-row{flex-wrap:wrap}}

.chat-image{display:block;max-width:min(100%,400px);max-height:300px;object-fit:contain;border-radius:10px;margin-top:12px}.chat-form textarea{font-family:inherit!important;}

.chat-message.continued{margin-top:-12px}.chat-effort{display:flex;align-items:center;flex-wrap:wrap;gap:10px;margin:8px 0 12px;font-size:12px}.chat-effort label{display:flex;gap:8px;align-items:center;margin:0}.chat-effort output{font-weight:600;min-width:60px}.chat-effort input[type="range"]{width:130px;min-width:90px;padding:0;accent-color:var(--accent);cursor:pointer}.chat-effort .muted{font-size:12px}.chat-effort input:disabled{cursor:default;opacity:.5}

.chat-code{margin:12px 0;border:1px solid var(--line);border-radius:10px;overflow:hidden;background:var(--surface);color:var(--text)}.chat-code-header{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;background:var(--subtle);font-size:12px;gap:12px}.chat-code-header .button{padding:4px 10px;font-size:12px}.chat-code pre{margin:0!important;border-radius:0!important;background:var(--surface)!important;color:var(--text)!important}.chat-code code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre}.chat-code .tok-keyword{color:var(--syntax-keyword)}.chat-code .tok-string,.chat-code .tok-string2{color:var(--syntax-string)}.chat-code .tok-number,.chat-code .tok-bool,.chat-code .tok-null{color:var(--syntax-number)}.chat-code .tok-comment,.chat-code .tok-meta{color:var(--syntax-comment);font-style:italic}.chat-code .tok-typeName,.chat-code .tok-className,.chat-code .tok-tagName{color:var(--syntax-type)}.chat-code .tok-propertyName,.chat-code .tok-attributeName{color:var(--syntax-property)}.chat-code .tok-operator,.chat-code .tok-punctuation{color:var(--syntax-operator)}.chat-code .tok-variableName.tok-definition{color:var(--syntax-function)}.chat-markdown a{color:var(--accent);text-decoration:underline;text-underline-offset:3px}

.chat-options .chat-effort{margin:0;gap:7px}.chat-options .chat-effort label{font-size:11px}.chat-options .chat-effort input[type="range"]{width:100px}.chat-options .chat-effort .muted{display:none}
